|
@@ -79,15 +79,22 @@ public class MesClient extends JFrame {
|
|
|
public static MesWebView jfxPanel = null;
|
|
public static MesWebView jfxPanel = null;
|
|
|
public static JPanel indexPanelC;
|
|
public static JPanel indexPanelC;
|
|
|
public static MesWebView jfxPanel2 = null;
|
|
public static MesWebView jfxPanel2 = null;
|
|
|
|
|
+ public static JPanel indexPanelD;
|
|
|
public static MesRadio mesRadioHj;
|
|
public static MesRadio mesRadioHj;
|
|
|
|
|
|
|
|
public static JTextField param1;
|
|
public static JTextField param1;
|
|
|
public static JTextField param2;
|
|
public static JTextField param2;
|
|
|
public static JTextField param3;
|
|
public static JTextField param3;
|
|
|
public static JTextField param4;
|
|
public static JTextField param4;
|
|
|
-
|
|
|
|
|
- public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.7");
|
|
|
|
|
- public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.8");
|
|
|
|
|
|
|
+ public static JTextField param5;
|
|
|
|
|
+ public static JTextField param6;
|
|
|
|
|
+ public static JTextField param7;
|
|
|
|
|
+ public static JTextField param8;
|
|
|
|
|
+
|
|
|
|
|
+ public static ModbusTcp plcA;
|
|
|
|
|
+ public static ModbusTcp plcB;
|
|
|
|
|
+ public static String curIpA = "";
|
|
|
|
|
+ public static String curIpB = "";
|
|
|
// public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.27");
|
|
// public static ModbusTcp plcA = new ModbusTcp(1, "192.168.1.27");
|
|
|
// public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.28");
|
|
// public static ModbusTcp plcB = new ModbusTcp(1, "192.168.1.28");
|
|
|
|
|
|
|
@@ -103,7 +110,7 @@ public class MesClient extends JFrame {
|
|
|
public static Short aMax = 0;
|
|
public static Short aMax = 0;
|
|
|
public static Short aFinish = 0;
|
|
public static Short aFinish = 0;
|
|
|
public static List<Map> alist = new ArrayList<>();
|
|
public static List<Map> alist = new ArrayList<>();
|
|
|
- public static Short bSetNum = 41;
|
|
|
|
|
|
|
+ public static Short bSetNum = 42;
|
|
|
// public static Short bSetNum = 27;
|
|
// public static Short bSetNum = 27;
|
|
|
public static Short sortB = 0;
|
|
public static Short sortB = 0;
|
|
|
public static Short bMax = 0;
|
|
public static Short bMax = 0;
|
|
@@ -111,6 +118,9 @@ public class MesClient extends JFrame {
|
|
|
public static Short deviceControl = 0; // 0=本地 1=远程
|
|
public static Short deviceControl = 0; // 0=本地 1=远程
|
|
|
public static Integer tjStatus = 0; // 1=提交失败
|
|
public static Integer tjStatus = 0; // 1=提交失败
|
|
|
|
|
|
|
|
|
|
+ public static List<RivetParamRange> rivetParamRangesA = new ArrayList<>();
|
|
|
|
|
+ public static List<RivetParamRange> rivetParamRangesB = new ArrayList<>();
|
|
|
|
|
+
|
|
|
public static String tjFlagTextErr = "结果上传MES失败,请重试";
|
|
public static String tjFlagTextErr = "结果上传MES失败,请重试";
|
|
|
|
|
|
|
|
public static String curSn = "";
|
|
public static String curSn = "";
|
|
@@ -127,12 +137,13 @@ public class MesClient extends JFrame {
|
|
|
//读文件配置
|
|
//读文件配置
|
|
|
readProperty();
|
|
readProperty();
|
|
|
|
|
|
|
|
|
|
+ JdbcUtils.getConn();
|
|
|
|
|
+ initLocalConfig();
|
|
|
|
|
+
|
|
|
// 显示界面
|
|
// 显示界面
|
|
|
mesClientFrame = new MesClient();
|
|
mesClientFrame = new MesClient();
|
|
|
mesClientFrame.setVisible(false);
|
|
mesClientFrame.setVisible(false);
|
|
|
|
|
|
|
|
- JdbcUtils.getConn();
|
|
|
|
|
-
|
|
|
|
|
welcomeWin = new LoginFarme();
|
|
welcomeWin = new LoginFarme();
|
|
|
welcomeWin.setVisible(true);
|
|
welcomeWin.setVisible(true);
|
|
|
|
|
|
|
@@ -216,6 +227,41 @@ public class MesClient extends JFrame {
|
|
|
System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
|
|
System.out.println(mes_gw + ";" + mes_gw_des + ";" + mes_server_ip + ";" + mes_tcp_port + ";" + mes_heart_beat_cycle);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void initLocalConfig() {
|
|
|
|
|
+ // 本地设备配置优先从 SQLite 加载,便于现场直接在设备管理页调整后持久化。
|
|
|
|
|
+ Map<String, Object> config = JdbcUtils.getConfig();
|
|
|
|
|
+ if (config.size() > 0) {
|
|
|
|
|
+ aSetNum = (Short) config.get("a_set_num");
|
|
|
|
|
+ bSetNum = (Short) config.get("b_set_num");
|
|
|
|
|
+ curIpA = (String) config.get("plc_ip_a");
|
|
|
|
|
+ curIpB = (String) config.get("plc_ip_b");
|
|
|
|
|
+ // ModbusTcp 实例必须等 IP 配置确定后再创建,否则会一直连默认设备。
|
|
|
|
|
+ plcA = new ModbusTcp(1, curIpA);
|
|
|
|
|
+ plcB = new ModbusTcp(1, curIpB);
|
|
|
|
|
+
|
|
|
|
|
+ if (param1 != null) param1.setText(String.valueOf(aSetNum));
|
|
|
|
|
+ if (param3 != null) param3.setText(String.valueOf(bSetNum));
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println("加载本地配置成功:aSetNum=" + aSetNum + ", bSetNum=" + bSetNum + ", plcA=" + curIpA + ", plcB=" + curIpB);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 防御性兜底:正常情况下 JdbcUtils 会先创建默认配置,这里用于数据库异常或空表场景。
|
|
|
|
|
+ aSetNum = 40;
|
|
|
|
|
+ bSetNum = 42;
|
|
|
|
|
+ curIpA = "192.168.1.7";
|
|
|
|
|
+ curIpB = "192.168.1.8";
|
|
|
|
|
+ plcA = new ModbusTcp(1, curIpA);
|
|
|
|
|
+ plcB = new ModbusTcp(1, curIpB);
|
|
|
|
|
+ System.out.println("未找到本地配置,使用默认值");
|
|
|
|
|
+ }
|
|
|
|
|
+ loadRivetParamConfig();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void loadRivetParamConfig() {
|
|
|
|
|
+ // 参数区间缓存到内存中,PLC 轮询线程按颗数切换时不需要频繁查数据库。
|
|
|
|
|
+ rivetParamRangesA = JdbcUtils.getRivetParams("A");
|
|
|
|
|
+ rivetParamRangesB = JdbcUtils.getRivetParams("B");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static void getPlcParam() {
|
|
public static void getPlcParam() {
|
|
|
if(cjTimer!=null) {
|
|
if(cjTimer!=null) {
|
|
|
cjTimer.cancel();
|
|
cjTimer.cancel();
|
|
@@ -416,10 +462,11 @@ public class MesClient extends JFrame {
|
|
|
MesClient.blist = new ArrayList<>();
|
|
MesClient.blist = new ArrayList<>();
|
|
|
MesClient.sortB = 0;
|
|
MesClient.sortB = 0;
|
|
|
MesClient.sortA = 0;
|
|
MesClient.sortA = 0;
|
|
|
- MesClient.param1.setText("");
|
|
|
|
|
|
|
+ MesClient.param1.setText(String.valueOf(aSetNum));
|
|
|
MesClient.param2.setText("");
|
|
MesClient.param2.setText("");
|
|
|
- MesClient.param3.setText("");
|
|
|
|
|
|
|
+ MesClient.param3.setText(String.valueOf(bSetNum));
|
|
|
MesClient.param4.setText("");
|
|
MesClient.param4.setText("");
|
|
|
|
|
+ resetForceStrokeDisplay();
|
|
|
|
|
|
|
|
deviceControl = ModbusUtil.getControlModel(plcA);
|
|
deviceControl = ModbusUtil.getControlModel(plcA);
|
|
|
if(deviceControl == 1){
|
|
if(deviceControl == 1){
|
|
@@ -431,8 +478,8 @@ public class MesClient extends JFrame {
|
|
|
ModbusUtil.setPowerOff(MesClient.plcA); // 远程关机
|
|
ModbusUtil.setPowerOff(MesClient.plcA); // 远程关机
|
|
|
ModbusUtil.setPowerOff(MesClient.plcB); // 远程关机
|
|
ModbusUtil.setPowerOff(MesClient.plcB); // 远程关机
|
|
|
|
|
|
|
|
- ModbusUtil.setTask(MesClient.plcA,MesClient.aSetNum);
|
|
|
|
|
- ModbusUtil.setTask(MesClient.plcB,MesClient.bSetNum);
|
|
|
|
|
|
|
+ ModbusUtil.setTask(MesClient.plcA, MesClient.aSetNum, "A");
|
|
|
|
|
+ ModbusUtil.setTask(MesClient.plcB, MesClient.bSetNum, "B");
|
|
|
|
|
|
|
|
updateMaterailData();
|
|
updateMaterailData();
|
|
|
}
|
|
}
|
|
@@ -441,6 +488,13 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static void resetForceStrokeDisplay() {
|
|
|
|
|
+ if (param5 != null) param5.setText("-");
|
|
|
|
|
+ if (param6 != null) param6.setText("-");
|
|
|
|
|
+ if (param7 != null) param7.setText("-");
|
|
|
|
|
+ if (param8 != null) param8.setText("-");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//获取用户20位
|
|
//获取用户20位
|
|
|
public static void getUser() {
|
|
public static void getUser() {
|
|
|
user20 = user_menu.getText().toString();
|
|
user20 = user_menu.getText().toString();
|
|
@@ -533,6 +587,7 @@ public class MesClient extends JFrame {
|
|
|
connect_request_flag = false;
|
|
connect_request_flag = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static int lastSelectedIndex = 0;
|
|
|
public MesClient() {
|
|
public MesClient() {
|
|
|
setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
|
|
setIconImage(Toolkit.getDefaultToolkit().getImage(MesClient.class.getResource("/bg/logo.png")));
|
|
|
setTitle("MES系统客户端:"+mes_gw + "- " + mes_gw_des);
|
|
setTitle("MES系统客户端:"+mes_gw + "- " + mes_gw_des);
|
|
@@ -763,7 +818,7 @@ public class MesClient extends JFrame {
|
|
|
param1 = new JTextField();
|
|
param1 = new JTextField();
|
|
|
param1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
param1.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
param1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
param1.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
- param1.setText("0");
|
|
|
|
|
|
|
+ param1.setText(String.valueOf(aSetNum));
|
|
|
param1.setEditable(false);
|
|
param1.setEditable(false);
|
|
|
param1.setBounds(288, 241, 83, 34);
|
|
param1.setBounds(288, 241, 83, 34);
|
|
|
indexPanelA.add(param1);
|
|
indexPanelA.add(param1);
|
|
@@ -795,7 +850,7 @@ public class MesClient extends JFrame {
|
|
|
indexPanelA.add(lblNewLabel_1_2);
|
|
indexPanelA.add(lblNewLabel_1_2);
|
|
|
|
|
|
|
|
param3 = new JTextField();
|
|
param3 = new JTextField();
|
|
|
- param3.setText("0");
|
|
|
|
|
|
|
+ param3.setText(String.valueOf(bSetNum));
|
|
|
param3.setHorizontalAlignment(SwingConstants.CENTER);
|
|
param3.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
param3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
param3.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
param3.setEditable(false);
|
|
param3.setEditable(false);
|
|
@@ -817,6 +872,62 @@ public class MesClient extends JFrame {
|
|
|
param4.setBounds(608, 285, 83, 34);
|
|
param4.setBounds(608, 285, 83, 34);
|
|
|
indexPanelA.add(param4);
|
|
indexPanelA.add(param4);
|
|
|
|
|
|
|
|
|
|
+ JLabel lblForceA = new JLabel("\u62c9\u529b");
|
|
|
|
|
+ lblForceA.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ lblForceA.setBounds(204, 329, 50, 34);
|
|
|
|
|
+ indexPanelA.add(lblForceA);
|
|
|
|
|
+
|
|
|
|
|
+ param5 = new JTextField();
|
|
|
|
|
+ param5.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ param5.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ param5.setText("-");
|
|
|
|
|
+ param5.setEditable(false);
|
|
|
|
|
+ param5.setColumns(10);
|
|
|
|
|
+ param5.setBounds(260, 329, 65, 34);
|
|
|
|
|
+ indexPanelA.add(param5);
|
|
|
|
|
+
|
|
|
|
|
+ JLabel lblStrokeA = new JLabel("\u884c\u7a0b");
|
|
|
|
|
+ lblStrokeA.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ lblStrokeA.setBounds(330, 329, 50, 34);
|
|
|
|
|
+ indexPanelA.add(lblStrokeA);
|
|
|
|
|
+
|
|
|
|
|
+ param6 = new JTextField();
|
|
|
|
|
+ param6.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ param6.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ param6.setText("-");
|
|
|
|
|
+ param6.setEditable(false);
|
|
|
|
|
+ param6.setColumns(10);
|
|
|
|
|
+ param6.setBounds(380, 329, 65, 34);
|
|
|
|
|
+ indexPanelA.add(param6);
|
|
|
|
|
+
|
|
|
|
|
+ JLabel lblForceB = new JLabel("\u62c9\u529b");
|
|
|
|
|
+ lblForceB.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ lblForceB.setBounds(525, 329, 50, 34);
|
|
|
|
|
+ indexPanelA.add(lblForceB);
|
|
|
|
|
+
|
|
|
|
|
+ param7 = new JTextField();
|
|
|
|
|
+ param7.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ param7.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ param7.setText("-");
|
|
|
|
|
+ param7.setEditable(false);
|
|
|
|
|
+ param7.setColumns(10);
|
|
|
|
|
+ param7.setBounds(581, 329, 65, 34);
|
|
|
|
|
+ indexPanelA.add(param7);
|
|
|
|
|
+
|
|
|
|
|
+ JLabel lblStrokeB = new JLabel("\u884c\u7a0b");
|
|
|
|
|
+ lblStrokeB.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ lblStrokeB.setBounds(651, 329, 50, 34);
|
|
|
|
|
+ indexPanelA.add(lblStrokeB);
|
|
|
|
|
+
|
|
|
|
|
+ param8 = new JTextField();
|
|
|
|
|
+ param8.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ param8.setFont(new Font("微软雅黑", Font.PLAIN, 18));
|
|
|
|
|
+ param8.setText("-");
|
|
|
|
|
+ param8.setEditable(false);
|
|
|
|
|
+ param8.setColumns(10);
|
|
|
|
|
+ param8.setBounds(701, 329, 65, 34);
|
|
|
|
|
+ indexPanelA.add(param8);
|
|
|
|
|
+
|
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
tabbedPane.addTab("工作面板", new ImageIcon(MesClient.class.getResource("/bg/a_side.png")), indexScrollPaneA, null);
|
|
|
tabbedPane.setEnabledAt(0, true);
|
|
tabbedPane.setEnabledAt(0, true);
|
|
|
|
|
|
|
@@ -835,16 +946,33 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
tabbedPane.addTab("工作记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPane, null);
|
|
tabbedPane.addTab("工作记录", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPane, null);
|
|
|
|
|
|
|
|
|
|
+ indexPanelD = new DeviceManagePanel();
|
|
|
|
|
+ JScrollPane scrollPanelD = new JScrollPane(indexPanelD);
|
|
|
|
|
+ scrollPanelD.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
|
|
|
+ scrollPanelD.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
|
|
|
+ tabbedPane.addTab("设备管理", new ImageIcon(MesClient.class.getResource("/bg/menu_setting.png")), scrollPanelD, null);
|
|
|
|
|
|
|
|
- tabbedPane.addChangeListener(new ChangeListener() {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ tabbedPane.addChangeListener(new ChangeListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
|
|
JTabbedPane tabbedPane = (JTabbedPane) e.getSource();
|
|
|
int selectedIndex = tabbedPane.getSelectedIndex();
|
|
int selectedIndex = tabbedPane.getSelectedIndex();
|
|
|
System.out.println("selectedIndex:"+selectedIndex);
|
|
System.out.println("selectedIndex:"+selectedIndex);
|
|
|
|
|
|
|
|
- if(selectedIndex == 1){
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (selectedIndex == 3) {
|
|
|
|
|
+ // 设备管理能改 PLC 地址和工艺参数,进入前做一次简单管理员口令校验。
|
|
|
|
|
+ String input = JOptionPane.showInputDialog(mesClientFrame, "请输入管理员密码以进入设备管理:", "权限验证", JOptionPane.QUESTION_MESSAGE);
|
|
|
|
|
+ if (input != null && input.equals("503833")) {
|
|
|
|
|
+ lastSelectedIndex = selectedIndex;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (input != null) {
|
|
|
|
|
+ JOptionPane.showMessageDialog(mesClientFrame, "密码错误,请重试", "错误", JOptionPane.ERROR_MESSAGE);
|
|
|
|
|
+ }
|
|
|
|
|
+ tabbedPane.setSelectedIndex(lastSelectedIndex);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ lastSelectedIndex = selectedIndex;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|