shjung 2 жил өмнө
parent
commit
0e245a3259

+ 2 - 3
src/main/java/com/its/cctv/CctvCommServerApplication.java

@@ -12,7 +12,6 @@ import com.its.cctv.ui.JTextAreaOutputStream;
 import com.its.cctv.ui.MainUI;
 import com.its.cctv.xnettcp.cctv.CctvTcpClientCommService;
 import com.its.cctv.xnettcp.cctv.process.CctvDataProcess;
-import com.its.cctv.xnettcp.cctvserver.CctvTcpServerService;
 import com.its.cctv.xnettcp.center.CenterTcpServerService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.DisposableBean;
@@ -180,8 +179,8 @@ public class CctvCommServerApplication implements CommandLineRunner, Application
         CctvTcpClientCommService ctlrCommClientService = (CctvTcpClientCommService)AppUtils.getBean(CctvTcpClientCommService.class);
         ctlrCommClientService.run();
 
-        CctvTcpServerService dsrcTcpCommServerService = (CctvTcpServerService)AppUtils.getBean(CctvTcpServerService.class);
-        dsrcTcpCommServerService.run();
+//        CctvTcpServerService dsrcTcpCommServerService = (CctvTcpServerService)AppUtils.getBean(CctvTcpServerService.class);
+//        dsrcTcpCommServerService.run();
 
 //        CenterTcpServerService centerService = (CenterTcpServerService)AppUtils.getBean(CenterTcpServerService.class);
 //        centerService.run();

+ 51 - 0
src/main/java/com/its/cctv/config/DebugConfig.java

@@ -0,0 +1,51 @@
+package com.its.cctv.config;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Configuration;
+
+import javax.annotation.PostConstruct;
+import java.io.FileInputStream;
+import java.util.Properties;
+
+@Slf4j
+@Getter
+@Setter
+@Configuration
+public class DebugConfig {
+
+    private boolean sttsLog;
+
+    @PostConstruct
+    void init() {
+        this.sttsLog = true;
+        load();
+    }
+
+    public void load() {
+        try {
+            String workingDir = System.getProperty("user.dir");
+            FileInputStream in = null;
+
+            try {
+                in = new FileInputStream(workingDir + "/conf/debug.properties");
+            }
+            catch(Exception e) {
+                log.error("{}.load: Exception: {}", this.getClass().getSimpleName(), e.toString());
+                return;
+            }
+
+            Properties props = new Properties();
+            props.load(in);
+            in.close();
+
+            String ptzControl = props.getProperty("stts",  "N").trim().toUpperCase();
+            this.sttsLog = "Y".equals(ptzControl);
+        }
+        catch(Exception e) {
+            log.error("{}.load: Exception: {}", this.getClass().getSimpleName(), e.toString());
+        }
+    }
+
+}

+ 3 - 2
src/main/java/com/its/cctv/ui/CtlrSttsTableModel.java

@@ -100,8 +100,10 @@ public class CtlrSttsTableModel extends AbstractTableModel {
                 door = "-?-";
                 fan = "-?-";
                 heater = "-?-";
-                temper = "-?-";
+//                temper = "-?-";
                 video = "-?-";
+                temper = String.valueOf(stts.getCBOX_TMPR());
+
                 if ("CDS0".equals(stts.getCBOX_DOOR_STTS_CD())) {
                     door = "닫힘";
                 } else if ("CDS1".equals(stts.getCBOX_DOOR_STTS_CD())) {
@@ -122,7 +124,6 @@ public class CtlrSttsTableModel extends AbstractTableModel {
                 } 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) {

+ 16 - 6
src/main/java/com/its/cctv/ui/MainUI.form

@@ -204,7 +204,7 @@
         <properties/>
         <border type="none"/>
         <children>
-          <grid id="dbb05" binding="pnlLogTitle" layout-manager="GridLayoutManager" row-count="1" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="1" vgap="1">
+          <grid id="dbb05" binding="pnlLogTitle" layout-manager="GridLayoutManager" row-count="1" column-count="7" same-size-horizontally="false" same-size-vertically="false" hgap="1" vgap="1">
             <margin top="0" left="0" bottom="0" right="2"/>
             <constraints>
               <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -230,7 +230,7 @@
               </hspacer>
               <component id="df2a0" class="javax.swing.JButton" binding="btnLogDirOpen">
                 <constraints>
-                  <grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
                 <properties>
                   <font name="Malgun Gothic" size="12" style="0"/>
@@ -240,7 +240,7 @@
               </component>
               <component id="69a98" class="javax.swing.JButton" binding="btnLogPause">
                 <constraints>
-                  <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
                 <properties>
                   <font name="Malgun Gothic" size="12" style="0"/>
@@ -250,24 +250,34 @@
               </component>
               <component id="1e9e7" class="javax.swing.JCheckBox" binding="chkLogPause">
                 <constraints>
-                  <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
                 <properties>
                   <font name="Malgun Gothic" size="12" style="0"/>
                   <horizontalAlignment value="0"/>
                   <horizontalTextPosition value="11"/>
-                  <text value="멈춤"/>
+                  <text value="멈춤   "/>
                 </properties>
               </component>
               <component id="ba97c" class="javax.swing.JButton" binding="btnLogCopy">
                 <constraints>
-                  <grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
                 <properties>
                   <font name="Malgun Gothic" size="12" style="0"/>
                   <text value="복사"/>
                 </properties>
               </component>
+              <component id="6f5c2" class="javax.swing.JCheckBox" binding="chkPtzControl">
+                <constraints>
+                  <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                </constraints>
+                <properties>
+                  <font name="Malgun Gothic" size="12" style="0"/>
+                  <horizontalAlignment value="0"/>
+                  <text value="상태정보   "/>
+                </properties>
+              </component>
             </children>
           </grid>
           <scrollpane id="a6866">

+ 23 - 5
src/main/java/com/its/cctv/ui/MainUI.java

@@ -3,7 +3,9 @@ package com.its.cctv.ui;
 import com.intellij.uiDesigner.core.GridConstraints;
 import com.intellij.uiDesigner.core.GridLayoutManager;
 import com.intellij.uiDesigner.core.Spacer;
+import com.its.app.AppUtils;
 import com.its.app.utils.SysUtils;
+import com.its.cctv.config.DebugConfig;
 import com.its.cctv.domain.NET;
 import com.its.cctv.entity.TbCctvCtlr;
 import com.its.cctv.global.AppRepository;
@@ -72,7 +74,9 @@ public class MainUI {
     private JButton btnDisconnect;
     private JTextField txtName;
     private JTextField txtId;
+    private JCheckBox chkPtzControl;
     private boolean isUpdatable;
+    private DebugConfig debugConfig;
 
     public static MainUI getInstance() {
         return _instance;
@@ -97,6 +101,7 @@ public class MainUI {
     public MainUI(JFrame jFrame) {
         System.setProperty("awt.useSystemAAFontSettings", "false"); // AntiAliasing false
 
+        this.debugConfig = (DebugConfig) AppUtils.getBean(DebugConfig.class);
         this.isUpdatable = false;
         this.jFrame = jFrame;
         if (_instance == null) {
@@ -130,6 +135,7 @@ public class MainUI {
         });
         timer.start();
 
+        chkPtzControl.setSelected(this.debugConfig.isSttsLog());
         chkLogPause.setFocusable(false);
         btnLogPause.setFocusable(false);
         btnLogDirOpen.setFocusable(false);
@@ -154,6 +160,12 @@ public class MainUI {
                 }
             }
         });
+        chkPtzControl.addActionListener(new ActionListener() {
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                debugConfig.setSttsLog(chkPtzControl.isSelected());
+            }
+        });
         chkLogPause.addActionListener(new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent e) {
@@ -604,7 +616,7 @@ public class MainUI {
         pnlLog.setLayout(new GridLayoutManager(2, 1, new Insets(0, 4, 0, 4), -1, -1));
         rootPanel.add(pnlLog, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(-1, 200), new Dimension(-1, 200), new Dimension(-1, 200), 0, false));
         pnlLogTitle = new JPanel();
-        pnlLogTitle.setLayout(new GridLayoutManager(1, 6, new Insets(0, 0, 0, 2), 1, 1));
+        pnlLogTitle.setLayout(new GridLayoutManager(1, 7, new Insets(0, 0, 0, 2), 1, 1));
         pnlLog.add(pnlLogTitle, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
         final JLabel label5 = new JLabel();
         Font label5Font = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, label5.getFont());
@@ -620,25 +632,31 @@ public class MainUI {
         if (btnLogDirOpenFont != null) btnLogDirOpen.setFont(btnLogDirOpenFont);
         btnLogDirOpen.setHorizontalTextPosition(0);
         btnLogDirOpen.setText("로그 폴더");
-        pnlLogTitle.add(btnLogDirOpen, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        pnlLogTitle.add(btnLogDirOpen, new GridConstraints(0, 6, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         btnLogPause = new JButton();
         Font btnLogPauseFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnLogPause.getFont());
         if (btnLogPauseFont != null) btnLogPause.setFont(btnLogPauseFont);
         btnLogPause.setHorizontalTextPosition(0);
         btnLogPause.setText("지우기");
-        pnlLogTitle.add(btnLogPause, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        pnlLogTitle.add(btnLogPause, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         chkLogPause = new JCheckBox();
         Font chkLogPauseFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, chkLogPause.getFont());
         if (chkLogPauseFont != null) chkLogPause.setFont(chkLogPauseFont);
         chkLogPause.setHorizontalAlignment(0);
         chkLogPause.setHorizontalTextPosition(11);
         chkLogPause.setText("멈춤");
-        pnlLogTitle.add(chkLogPause, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        pnlLogTitle.add(chkLogPause, new GridConstraints(0, 3, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         btnLogCopy = new JButton();
         Font btnLogCopyFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, btnLogCopy.getFont());
         if (btnLogCopyFont != null) btnLogCopy.setFont(btnLogCopyFont);
         btnLogCopy.setText("복사");
-        pnlLogTitle.add(btnLogCopy, new GridConstraints(0, 4, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        pnlLogTitle.add(btnLogCopy, new GridConstraints(0, 5, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
+        chkPtzControl = new JCheckBox();
+        Font chkPtzControlFont = this.$$$getFont$$$("Malgun Gothic", Font.PLAIN, 12, chkPtzControl.getFont());
+        if (chkPtzControlFont != null) chkPtzControl.setFont(chkPtzControlFont);
+        chkPtzControl.setHorizontalAlignment(0);
+        chkPtzControl.setText("상태정보  ");
+        pnlLogTitle.add(chkPtzControl, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
         final JScrollPane scrollPane2 = new JScrollPane();
         Font scrollPane2Font = this.$$$getFont$$$("D2Coding", Font.PLAIN, 12, scrollPane2.getFont());
         if (scrollPane2Font != null) scrollPane2.setFont(scrollPane2Font);

+ 2 - 1
src/main/java/com/its/cctv/xnettcp/cctv/CctvTcpClientCommService.java

@@ -45,7 +45,8 @@ public class CctvTcpClientCommService {
          */
         for (Map.Entry<String, TbCctvCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
             TbCctvCtlr obj = e.getValue();
-            if (StringUtils.equals("N", obj.getDEL_YN()) && obj.getCCTV_CTLR_PORT() != commConfig.getCommBindingPort()) {
+            if (StringUtils.equals("N", obj.getDEL_YN())
+                    && StringUtils.equals("Y", obj.getSYOP_CNTL_YN())) { //TODO && obj.getCCTV_CTLR_PORT() != commConfig.getCommBindingPort()) {
                 CctvTcpClient ctlrClient = new CctvTcpClient(obj, this.commConfig, this.cctvDataProcess, this.bootstrapFactory);
                 this.clientTasks.add(ctlrClient);
             }

+ 6 - 2
src/main/java/com/its/cctv/xnettcp/cctv/process/CctvDataProcess.java

@@ -2,6 +2,7 @@ package com.its.cctv.xnettcp.cctv.process;
 
 import com.its.app.AppUtils;
 import com.its.app.utils.SysUtils;
+import com.its.cctv.config.DebugConfig;
 import com.its.cctv.config.ThreadPoolInitializer;
 import com.its.cctv.entity.TbCctvCtlr;
 import com.its.cctv.xnettcp.cctv.protocol.CctvProtocol;
@@ -21,6 +22,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 @Service
 public class CctvDataProcess {
 
+    private final DebugConfig debugConfig;
     private final CctvDataAsyncTask asyncTask;
     public static LinkedBlockingQueue<CctvData> SERVER_DATA_QUEUE = new LinkedBlockingQueue<>(1000);
     private ThreadPoolExecutor taskExecutor = (ThreadPoolExecutor)Executors.newFixedThreadPool(1);
@@ -150,8 +152,10 @@ public class CctvDataProcess {
         int Fan        = SysUtils.getBitValue(stts1, 2);
         int Heater     = SysUtils.getBitValue(stts1, 3);
 
-        log.info("[{}]. RECV: checkStatus. Door:{}, Video:{}, Fan:{}, Heater:{}. {}",
-                obj.getCCTV_CTLR_ID(), DoorOpen, VideoInput, Fan, Heater, stts1);
+        if (this.debugConfig.isSttsLog()) {
+            log.info("[{}]. RECV: checkStatus. Door:{}, Video:{}, Fan:{}, Heater:{}. {}",
+                    obj.getCCTV_CTLR_ID(), DoorOpen, VideoInput, Fan, Heater, stts1);
+        }
 
         String CBOX_DOOR_STTS_CD  = (DoorOpen   == 0) ? "CDS0" : "CDS1";
         String VIDEO_INPUT	      = (VideoInput == 0) ? "VDI0" : "VDI1";

+ 1 - 1
src/main/java/com/its/cctv/xnettcp/cctvserver/CctvTcpServerInitializer.java

@@ -34,7 +34,7 @@ public class CctvTcpServerInitializer extends ChannelInitializer<Channel> {
                 this.commConfig.getCommAllIdleTimeSeconds(),
                 TimeUnit.SECONDS);
 
-        CctvServerIdleStateConnectionHandler connectionHandler = new CctvServerIdleStateConnectionHandler(this.commConfig);
+        CctvServerIdleStateConnectionHandler connectionHandler = new CctvServerIdleStateConnectionHandler();//this.commConfig);
 
         ChannelPipeline pipeline = channel.pipeline();
         pipeline.addLast(new LoggingHandler(LogLevel.INFO));

+ 1 - 2
src/main/java/com/its/cctv/xnettcp/cctvserver/CctvTcpServerService.java

@@ -13,11 +13,10 @@ import io.netty.channel.EventLoopGroup;
 import io.netty.channel.epoll.Epoll;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
 
 @Slf4j
 @RequiredArgsConstructor
-@Service
+//@Service
 public class CctvTcpServerService {
 
     private final RunningConfig config;

+ 5 - 3
src/main/java/com/its/cctv/xnettcp/cctvserver/handler/CctvServerIdleStateConnectionHandler.java

@@ -1,7 +1,6 @@
 package com.its.cctv.xnettcp.cctvserver.handler;
 
 import com.its.app.utils.NettyUtils;
-import com.its.cctv.config.RunningConfig;
 import com.its.cctv.entity.TbCctvCtlr;
 import com.its.cctv.global.AppRepository;
 import com.its.cctv.ui.MainUI;
@@ -25,7 +24,7 @@ import java.util.concurrent.TimeUnit;
 @RequiredArgsConstructor
 public class CctvServerIdleStateConnectionHandler extends ChannelDuplexHandler {
 
-    private final RunningConfig config;
+//    private final RunningConfig config;
 
     @Override
     public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
@@ -90,6 +89,7 @@ public class CctvServerIdleStateConnectionHandler extends ChannelDuplexHandler {
                     obj.getChannel().close();
                 }
                 catch(Exception e) {
+                    log.error("channelActive: exception: {}, {}", ipAddress, ctx.channel().toString());
                 }
             }
 
@@ -143,6 +143,7 @@ public class CctvServerIdleStateConnectionHandler extends ChannelDuplexHandler {
             ctx.channel().close();
         }
         catch(Exception e) {
+            log.error("channelInactive: exception: {}, {}", ipAddress, ctx.channel().toString());
         }
 
         if (obj != null) {
@@ -176,7 +177,7 @@ public class CctvServerIdleStateConnectionHandler extends ChannelDuplexHandler {
             MDC.put("id", obj.getLogKey());
         }
         try {
-            log.error("CctvServerIdleStateConnectionHandler.disconnectChannel: {}, {}", ipAddress, channel.toString());
+            log.error("CctvServerIdleStateConnectionHandler.disconnectChannel: {}, {}", ipAddress, channel);
             if (!channel.isActive()) {
                 log.error("CctvServerIdleStateConnectionHandler.disconnectChannel: {}, channel already closed.", ipAddress);
             }
@@ -188,6 +189,7 @@ public class CctvServerIdleStateConnectionHandler extends ChannelDuplexHandler {
             }
         }
         catch(Exception e) {
+            log.error("disconnectChannel: exception: {}, {}", ipAddress, channel);
         }
 
         if (obj != null) {