123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- package com.its.cctv.ui;
- import com.its.cctv.entity.TbCctvCtlr;
- import com.its.cctv.entity.TbCctvCtlrStts;
- import lombok.extern.slf4j.Slf4j;
- import javax.swing.table.AbstractTableModel;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- @Slf4j
- public class CtlrSttsTableModel extends AbstractTableModel {
- private static final long serialVersionUID = 1331132425472559704L;
- private List<TbCctvCtlr> ctlrList = Collections.synchronizedList(new ArrayList<TbCctvCtlr>());
- private final String[] columnNames = {
- "#",
- "번호",
- "CCTV ID",
- "명칭",
- "IP",
- "PORT",
- "연결상태",
- "도어",
- "팬",
- "히터",
- "온도",
- "영상",
- "P / T / Z / F",
- "연결 시각",
- "연결종료 시각"
- };
- public static final String[] netStateStr = {
- "Close", "Login", "Connect",
- };
- public CtlrSttsTableModel(List<TbCctvCtlr> ctlrList) {
- this.ctlrList = ctlrList;
- int indexCount = 1;
- for (TbCctvCtlr obj : ctlrList) {
- obj.setIndex(indexCount++);
- }
- }
- @Override
- public int getColumnCount() {
- return columnNames.length;
- }
- @Override
- public int getRowCount() {
- int size = 0;
- synchronized (this.ctlrList) {
- size = this.ctlrList.size();
- }
- return size;
- }
- @Override
- public String getColumnName(int columnIndex) {
- if (columnIndex < columnNames.length) {
- return columnNames[columnIndex];
- }
- return super.getColumnName(columnIndex);
- }
- @Override
- public Class<?> getColumnClass(int columnIndex) {
- if (ctlrList.isEmpty()) {
- return Object.class;
- }
- return getValueAt(0, columnIndex).getClass();
- }
- public TbCctvCtlr getControllerInfo(int row) {
- TbCctvCtlr info = this.ctlrList.get(row);
- return info;
- }
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
- Object returnValue = null;
- synchronized (this.ctlrList) {
- TbCctvCtlr info = this.ctlrList.get(rowIndex);
- if (info == null) {
- return "";
- }
- int netState = info.getNetState();
- TbCctvCtlrStts stts = info.getStts();
- String door = "-";
- String fan = "-";
- String heater = "-";
- String temper = "-";
- String video = "-";
- String sttsText = "----/----/----/----";
- if ("CMS0".equals(stts.getCMNC_STTS_CD())) {
- door = "-?-";
- fan = "-?-";
- heater = "-?-";
- temper = "-?-";
- video = "-?-";
- if ("CDS0".equals(stts.getCBOX_DOOR_STTS_CD())) {
- door = "닫힘";
- } else if ("CDS1".equals(stts.getCBOX_DOOR_STTS_CD())) {
- door = "열림";
- }
- if ("PAS0".equals(stts.getFAN_STTS_CD())) {
- fan = "중지";
- } else if ("PAS1".equals(stts.getFAN_STTS_CD())) {
- fan = "가동";
- }
- if ("HTS0".equals(stts.getHETR_STTS_CD())) {
- heater = "중지";
- } else if ("HTS1".equals(stts.getHETR_STTS_CD())) {
- heater = "가동";
- }
- if ("VDI0".equals(stts.getVIDEO_INPUT())) {
- video = "정상";
- } else if ("VDI1".equals(stts.getVIDEO_INPUT())) {
- video = "이상";
- }
- temper = String.valueOf(stts.getCBOX_TMPR());
- sttsText = String.format("%4d/%4d/%4d/%4d", stts.getPAN(), stts.getTILT(), stts.getZOOM(), stts.getFOCUS());
- }
- switch (columnIndex) {
- case 0:
- returnValue = info.getIndex();
- break;
- case 1:
- returnValue = info.getCCTV_CTLR_NMBR();
- break;
- case 2:
- returnValue = info.getCCTV_CTLR_ID();
- break;
- case 3:
- returnValue = info.getCCTV_NM();
- break;
- case 4:
- returnValue = info.getCCTV_CTLR_IP();
- break;
- case 5:
- returnValue = String.valueOf(info.getCCTV_CTLR_PORT());
- break;
- case 6:
- returnValue = netStateStr[netState];
- break;
- case 7: returnValue = door; break;
- case 8: returnValue = fan; break;
- case 9: returnValue = heater; break;
- case 10: returnValue = temper; break;
- case 11: returnValue = video; break;
- case 12: returnValue = sttsText; break;
- case 13:
- returnValue = info.getConnectTm();
- break;
- case 14:
- returnValue = info.getDisConnectTm();
- break;
- }
- }
- return returnValue;
- }
- @Override
- public void setValueAt(Object value, int rowIndex, int columnIndex) {
- synchronized (this.ctlrList) {
- TbCctvCtlr obj = ctlrList.get(rowIndex);
- if (columnIndex == 0) {
- obj.setIndex((int) value);
- }
- }
- }
- public void setValueAt(TbCctvCtlr obj, int rowIdx, int colIdx) {
- synchronized (this.ctlrList) {
- }
- fireTableCellUpdated(rowIdx, colIdx);
- fireTableDataChanged();
- }
- public void Add(TbCctvCtlr info) {
- int index = 0;
- synchronized (this.ctlrList) {
- index = this.ctlrList.size();
- this.ctlrList.add(info);
- }
- fireTableRowsInserted(index, index);
- }
- public void setValue(TbCctvCtlr obj, int viewRow, int modelRow) {
- fireTableDataChanged();
- }
- }
|