shjung 2 years ago
parent
commit
2cce1d921b

+ 1 - 0
conf/vds-comm-server.pid

@@ -0,0 +1 @@
+24904

+ 40 - 57
src/main/java/com/its/vds/VdsCommServerApplication.java

@@ -25,6 +25,7 @@ import org.springframework.context.ApplicationListener;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.event.ContextClosedEvent;
+import org.springframework.core.io.ClassPathResource;
 import org.springframework.scheduling.annotation.EnableAsync;
 
 import javax.swing.*;
@@ -32,7 +33,9 @@ import java.awt.*;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.io.File;
+import java.io.IOException;
 import java.io.PrintStream;
+import java.net.URL;
 
 @Slf4j
 @EnableAsync
@@ -76,42 +79,6 @@ public class VdsCommServerApplication implements CommandLineRunner, ApplicationL
 
     @Override
     public void run(String... args) throws Exception {
-        SwingUtilities.invokeLater(() -> {
-            String pathOfImage = "C:\\DEV\\ITS\\01.WINDOWS\\22.01.YONGIN\\JAVA\\vds-comm-server\\src\\main\\resources\\static\\image\\application.png";
-            String sysTime = SysUtils.getSysTimeStr();
-            //JFrame.setDefaultLookAndFeelDecorated(true);
-            JFrame frame = new JFrame("VDS 통신 서버 - [" + sysTime + "]");
-            MainUI UI = new MainUI(frame);
-            frame.setIconImage(Toolkit.getDefaultToolkit().getImage(pathOfImage));
-            frame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
-            frame.setContentPane(UI.getRootPanel());
-            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-            frame.addWindowListener(new WindowAdapter() {
-                @Override
-                public void windowClosing(WindowEvent e) {
-                    if (JOptionPane.showConfirmDialog(UI.getRootPanel(), "시스템을 종료 하시겠습니까?", "시스템 종료", 0) == 0) {
-                        System.exit(0);
-                    } else {
-                        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
-                    }
-                }
-            });
-            frame.pack();
-            frame.setBounds(100, 100, 1000, 800);
-            frame.setLocationRelativeTo(null);
-            frame.setVisible(true);
-
-            JTextArea logArea = UI.getTaLog();
-            logArea.setText(null);
-            JTextAreaOutputStream out = new JTextAreaOutputStream(logArea);
-            System.setOut(new PrintStream(out));
-//            try {
-//                PrintStream outStream = new PrintStream(out, true, "euc-kr");
-//                System.setOut(outStream);
-//            } catch (UnsupportedEncodingException e) {
-//                //throw new RuntimeException(e);
-//            }
-        });
 
         ProcessConfig processConfig = (ProcessConfig) AppUtils.getBean(ProcessConfig.class);
 
@@ -141,30 +108,53 @@ public class VdsCommServerApplication implements CommandLineRunner, ApplicationL
         VdsCtlrService ctlrService = (VdsCtlrService)AppUtils.getBean(VdsCtlrService.class);
         ctlrService.loadDb();
         ctlrService.updateCtlrStts(true);
-        MainUI mainUI = MainUI.getInstance();
-        if (mainUI != null) {
-            mainUI.LoadControllerInfo(ctlrService);
-        }
 
         VdsTcpClientCommService vdsCommClientService = (VdsTcpClientCommService)AppUtils.getBean(VdsTcpClientCommService.class);
         vdsCommClientService.run();
 
         CenterTcpServerService centerService = (CenterTcpServerService)AppUtils.getBean(CenterTcpServerService.class);
         centerService.run();
-//
-//        UdpServerCenterComm udpServerCenterComm = (UdpServerCenterComm)AppUtils.getBean(UdpServerCenterComm.class);
-//        udpServerCenterComm.run();
 
         // schedule enable
         processConfig.setStartSchedule(true);
 
-        /*byte val1 = 35;
-        byte val2 = -35;
-        int nval1 = (int)val1;
-        int nval2 = (int)val2;
-        short sval1 = (short)nval1;
-        short sval2 = (short)nval2;
-        log.error("val1: {}, val2: {}, nval1: {}, nval2: {}, sval1: {}, sval2: {}", val1, val2, nval1, nval2, sval1, sval2);*/
+        SwingUtilities.invokeLater(() -> {
+            String sysTime = SysUtils.getSysTimeStr();
+            //JFrame.setDefaultLookAndFeelDecorated(true);
+            JFrame frame = new JFrame("VDS 통신 서버 - [" + sysTime + "]");
+            MainUI UI = new MainUI(frame);
+            try {
+                ClassPathResource file = new ClassPathResource("static/image/application.png");
+                URL imgURL = file.getURL();
+                frame.setIconImage(new ImageIcon(imgURL).getImage());
+            } catch (IOException e) {
+                log.error("Not found application icon image");
+            }
+            frame.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
+            frame.setContentPane(UI.getRootPanel());
+            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+            frame.addWindowListener(new WindowAdapter() {
+                @Override
+                public void windowClosing(WindowEvent e) {
+                    if (JOptionPane.showConfirmDialog(UI.getRootPanel(), "시스템을 종료 하시겠습니까?", "시스템 종료", 0) == 0) {
+                        System.exit(0);
+                    } else {
+                        frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
+                    }
+                }
+            });
+            frame.pack();
+            frame.setBounds(100, 100, 1000, 800);
+            frame.setLocationRelativeTo(null);
+            frame.setVisible(true);
+
+            JTextArea logArea = UI.getTaLog();
+            logArea.setText(null);
+            JTextAreaOutputStream out = new JTextAreaOutputStream(logArea);
+            System.setOut(new PrintStream(out));
+
+            UI.LoadControllerInfo();
+        });
     }
 
     public void terminateApplication() {
@@ -178,13 +168,6 @@ public class VdsCommServerApplication implements CommandLineRunner, ApplicationL
 
         VdsTcpClientCommService vdsCommClientService = (VdsTcpClientCommService)AppUtils.getBean(VdsTcpClientCommService.class);
         vdsCommClientService.shutdown();
-
-//        TcpServerVdsComm tcpServersComm = (TcpServerVdsComm)AppUtils.getBean(TcpServerVdsComm.class);
-//        tcpServersComm.getAcceptGroups().shutdownGracefully();
-//        tcpServersComm.getWorkerGroups().shutdownGracefully();
-
-//        UdpServerCenterComm udpServerCenterComm = (UdpServerCenterComm)AppUtils.getBean(UdpServerCenterComm.class);
-//        udpServerCenterComm.getNioEventLoopGroup().shutdownGracefully();
     }
     @Override
     public void onApplicationEvent(ContextClosedEvent event) {

+ 15 - 18
src/main/java/com/its/vds/ui/MainUI.java

@@ -7,7 +7,6 @@ import com.its.app.utils.SysUtils;
 import com.its.vds.domain.NET;
 import com.its.vds.entity.TbVdsCtlr;
 import com.its.vds.global.AppRepository;
-import com.its.vds.service.VdsCtlrService;
 import com.sun.management.OperatingSystemMXBean;
 import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
@@ -41,13 +40,12 @@ public class MainUI {
 
     private SubUIController subUIController = null;
     private JFrame jFrame = null;
-    private VdsCtlrService vdsCtlrService = null;
     OperatingSystemMXBean osBean = null;
     private Timer timer;
     private Long tick = Long.valueOf(0);
     private TbVdsCtlr selObj = null;
 
-    private CtlrSttsTableModel ctlrSttsTableModel;
+    private CtlrSttsTableModel ctlrSttsTableModel = null;
     private TableCellRenderer cellRenderer = new CtlrSttsTableCellRenderer();
 
     private JPanel rootPanel;
@@ -97,7 +95,6 @@ public class MainUI {
         this.jFrame = jFrame;
         if (_instance == null) {
             _instance = this;
-
             subUIController = new SubUIController(jFrame);
             subUIController.setVisible(false);
         }
@@ -310,6 +307,9 @@ public class MainUI {
      */
     private void initTblListUI(List<TbVdsCtlr> ctlrList) {
 
+        this.ctlrSttsTableModel = new CtlrSttsTableModel(ctlrList);
+        tblCtlrList.setModel(this.ctlrSttsTableModel);
+
         tblCtlrList.getTableHeader().setOpaque(false);
         tblCtlrList.getTableHeader().setBackground(Color.LIGHT_GRAY);
         tblCtlrList.setRowMargin(1);
@@ -318,8 +318,6 @@ public class MainUI {
         //tblCtlrList.setRowSelectionAllowed(true);
         //tblCtlrList.setColumnSelectionAllowed(false);
 
-        ctlrSttsTableModel = new CtlrSttsTableModel(ctlrList);
-        tblCtlrList.setModel(ctlrSttsTableModel);
         tblCtlrList.setBackground(Color.WHITE);
         tblCtlrList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
         //tblCtlrList.setAutoCreateRowSorter(true); // sorting
@@ -371,9 +369,7 @@ public class MainUI {
         lblError.setText(" " + ctlrError + " ");
     }
 
-    public void LoadControllerInfo(VdsCtlrService vdsCtlrService) {
-        this.vdsCtlrService = vdsCtlrService;
-
+    public void LoadControllerInfo() {
         SortedMap<Integer, TbVdsCtlr> ctlrMap = new TreeMap<>();
         for (Map.Entry<String, TbVdsCtlr> e : AppRepository.getInstance().getCtlrMap().entrySet()) {
             TbVdsCtlr obj = e.getValue();
@@ -383,27 +379,28 @@ public class MainUI {
         }
         List<TbVdsCtlr> ctlrList = new ArrayList<TbVdsCtlr>(ctlrMap.values());
         initTblListUI(ctlrList);
-//        for (Map.Entry<Integer, TbVdsCtlr> e : ctlrMap.entrySet()) {
-//            TbVdsCtlr obj = e.getValue();
-//            ctlrSttsTableModel.Add(obj);
-//        }
         updateCommSttsTotal();
     }
 
     public void updateCtlrStts(TbVdsCtlr obj) {
-
-        //CtlrSttsTableModel ctlrSttsTableModel = (CtlrSttsTableModel)tblCtlrList.getModel();
-        for (int ii = 0; ii < ctlrSttsTableModel.getRowCount(); ii++) {
-            if (obj.getVDS_CTLR_ID().equals(ctlrSttsTableModel.getValueAt(ii, 2).toString())) {
+        if (this.ctlrSttsTableModel == null) {
+            return;
+        }
+        for (int ii = 0; ii < this.ctlrSttsTableModel.getRowCount(); ii++) {
+            if (obj.getVDS_CTLR_ID().equals(this.ctlrSttsTableModel.getValueAt(ii, 2).toString())) {
                 int modelRow = tblCtlrList.convertRowIndexToModel(ii);
 //                //int viewColumn = tblCtlrList.getSelectedColumn();
 //                int modelColumn = tblCtlrList.convertColumnIndexToModel(4);
 //                Object cell = tblCtlrList.getValueAt(modelRow, modelColumn);
 //                log.error("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: {}", cell);
-                ctlrSttsTableModel.setValue(obj, ii, modelRow);
+                this.ctlrSttsTableModel.setValue(obj, ii, modelRow);
                 break;
             }
         }
+        CtlrSttsTableModel tableModel = (CtlrSttsTableModel) tblCtlrList.getModel();
+        if (tableModel != null) {
+            tableModel.fireTableDataChanged();
+        }
     }
 
     {

+ 1 - 1
src/main/java/com/its/vds/ui/SubUI.java

@@ -262,7 +262,7 @@ public abstract class SubUI {
         if (txtNameFont != null) txtName.setFont(txtNameFont);
         txtName.setHorizontalAlignment(2);
         txtName.setText("제어기 명칭");
-        panel1.add(txtName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(200, -1), new Dimension(200, -1), new Dimension(200, -1), 0, false));
+        panel1.add(txtName, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(200, -1), null, 0, false));
         final JLabel label2 = new JLabel();
         label2.setText("ㅣ관리번호");
         panel1.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));