|
@@ -103,6 +103,10 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
public static JLabel fxlabel;
|
|
public static JLabel fxlabel;
|
|
|
|
|
|
|
|
|
|
+ public static JLabel fxlabel2;
|
|
|
|
|
+
|
|
|
|
|
+ public static Integer fxlabel2Flag = 0;
|
|
|
|
|
+
|
|
|
// public static String plcUrl = "192.168.88.89"; // 180AF
|
|
// public static String plcUrl = "192.168.88.89"; // 180AF
|
|
|
|
|
|
|
|
public static String plcUrl = "192.168.88.99"; // 180BE 280AB
|
|
public static String plcUrl = "192.168.88.99"; // 180BE 280AB
|
|
@@ -149,6 +153,11 @@ public class MesClient extends JFrame {
|
|
|
// 显示组件
|
|
// 显示组件
|
|
|
public static JLabel spindleSpeedLabel;
|
|
public static JLabel spindleSpeedLabel;
|
|
|
public static JLabel feedRateLabel;
|
|
public static JLabel feedRateLabel;
|
|
|
|
|
+ public static JLabel torqueLabel;
|
|
|
|
|
+
|
|
|
|
|
+ public static Integer curPoint = 0;
|
|
|
|
|
+ public static List<String> curPointX = new ArrayList<>();
|
|
|
|
|
+ public static List<String> curPointY = new ArrayList<>();
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
if (LockUtil.getInstance().isAppActive() == true){
|
|
@@ -191,6 +200,8 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
monitorDevice();
|
|
monitorDevice();
|
|
|
|
|
|
|
|
|
|
+ fswCheckPoint();
|
|
|
|
|
+
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
@@ -311,12 +322,14 @@ public class MesClient extends JFrame {
|
|
|
// 读取转速和进给
|
|
// 读取转速和进给
|
|
|
actSpindleSpeed = S7Util.readActSpindleSpeed(s7PLC);
|
|
actSpindleSpeed = S7Util.readActSpindleSpeed(s7PLC);
|
|
|
feedRate = S7Util.readFeedRate(s7PLC);
|
|
feedRate = S7Util.readFeedRate(s7PLC);
|
|
|
|
|
+ final double torque = S7Util.readTorque(s7PLC);
|
|
|
// 更新UI
|
|
// 更新UI
|
|
|
final double spindle = actSpindleSpeed;
|
|
final double spindle = actSpindleSpeed;
|
|
|
final double feed = feedRate;
|
|
final double feed = feedRate;
|
|
|
SwingUtilities.invokeLater(() -> {
|
|
SwingUtilities.invokeLater(() -> {
|
|
|
spindleSpeedLabel.setText(String.format("转速: %.1f rpm", spindle));
|
|
spindleSpeedLabel.setText(String.format("转速: %.1f rpm", spindle));
|
|
|
feedRateLabel.setText(String.format("进给: %.1f mm/min", feed));
|
|
feedRateLabel.setText(String.format("进给: %.1f mm/min", feed));
|
|
|
|
|
+ torqueLabel.setText(String.format("扭矩: %.1f ", torque));
|
|
|
});
|
|
});
|
|
|
// 存储数据
|
|
// 存储数据
|
|
|
final String currentSn = product_sn.getText();
|
|
final String currentSn = product_sn.getText();
|
|
@@ -370,6 +383,78 @@ public class MesClient extends JFrame {
|
|
|
}, 1000, 30*1000); // 首次延迟1秒,之后每30秒执行
|
|
}, 1000, 30*1000); // 首次延迟1秒,之后每30秒执行
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static java.util.Timer fswCheckPointTimer;
|
|
|
|
|
+
|
|
|
|
|
+ public static void fswCheckPoint() {
|
|
|
|
|
+ if(fswCheckPointTimer != null) {
|
|
|
|
|
+ fswCheckPointTimer.cancel();
|
|
|
|
|
+ }
|
|
|
|
|
+ fswCheckPointTimer = new java.util.Timer();
|
|
|
|
|
+ fswCheckPointTimer.schedule(new TimerTask() {
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ try{
|
|
|
|
|
+ if(work_status == 1 && fxlabel2Flag == 1){ // 获取点位
|
|
|
|
|
+ boolean ret = S7Util.getParamFlag();
|
|
|
|
|
+ if(ret){
|
|
|
|
|
+ curPoint += 1;
|
|
|
|
|
+ curPointX.add(String.valueOf(S7Util.readXPosition()));
|
|
|
|
|
+ curPointY.add(String.valueOf(S7Util.readYPosition()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(curPoint == 4){
|
|
|
|
|
+ String pointx1 = "";
|
|
|
|
|
+ String pointx2 = "";
|
|
|
|
|
+ String pointx3 = "";
|
|
|
|
|
+ String pointx4 = "";
|
|
|
|
|
+ String pointy1 = "";
|
|
|
|
|
+ String pointy2 = "";
|
|
|
|
|
+ String pointy3 = "";
|
|
|
|
|
+ String pointy4 = "";
|
|
|
|
|
+ int i = 0;
|
|
|
|
|
+ for(String str : curPointX){
|
|
|
|
|
+ if(i == 0){
|
|
|
|
|
+ pointx1 = str;
|
|
|
|
|
+ }else if(i == 1){
|
|
|
|
|
+ pointx2 = str;
|
|
|
|
|
+ }else if(i == 2){
|
|
|
|
|
+ pointx3 = str;
|
|
|
|
|
+ }else if(i == 3){
|
|
|
|
|
+ pointx4 = str;
|
|
|
|
|
+ }
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int j = 0;
|
|
|
|
|
+ for(String str : curPointX){
|
|
|
|
|
+ if(i == 0){
|
|
|
|
|
+ pointy1 = str;
|
|
|
|
|
+ }else if(i == 1){
|
|
|
|
|
+ pointy2 = str;
|
|
|
|
|
+ }else if(i == 2){
|
|
|
|
|
+ pointy3 = str;
|
|
|
|
|
+ }else if(i == 3){
|
|
|
|
|
+ pointy4 = str;
|
|
|
|
|
+ }
|
|
|
|
|
+ j++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject retObj = DataUtil.saveFswPoint(product_sn.getText(),pointx1+"_"+pointy1,pointx2+"_"+pointy2,pointx3+"_"+pointy3,pointx4+"_"+pointy4);
|
|
|
|
|
+ if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
|
|
+ MesClient.curPointX.clear();
|
|
|
|
|
+ MesClient.curPointY.clear();
|
|
|
|
|
+ MesClient.curPoint = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }catch (Exception e){
|
|
|
|
|
+ log.info("异常: " + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 1000, 500); // 首次延迟1秒,之后每30秒执行
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//设置tcp连接状态显示
|
|
//设置tcp连接状态显示
|
|
|
public static void setTcpStatus() {
|
|
public static void setTcpStatus() {
|
|
|
if(tcp_connect_flag) {
|
|
if(tcp_connect_flag) {
|
|
@@ -404,8 +489,12 @@ public class MesClient extends JFrame {
|
|
|
MesClient.status_menu.setText("请扫工件码");
|
|
MesClient.status_menu.setText("请扫工件码");
|
|
|
S7Util.sendStartSignal(true);
|
|
S7Util.sendStartSignal(true);
|
|
|
|
|
|
|
|
|
|
+ MesClient.curPointX.clear();
|
|
|
|
|
+ MesClient.curPointY.clear();
|
|
|
|
|
+ MesClient.curPoint = 0;
|
|
|
|
|
+
|
|
|
updateMaterailData();
|
|
updateMaterailData();
|
|
|
- shiftUserCheck();
|
|
|
|
|
|
|
+// shiftUserCheck();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static int userLoginHours;//用户登录所处小时
|
|
public static int userLoginHours;//用户登录所处小时
|
|
@@ -615,6 +704,25 @@ public class MesClient extends JFrame {
|
|
|
});
|
|
});
|
|
|
settingMenu.add(mes_block_menu);
|
|
settingMenu.add(mes_block_menu);
|
|
|
|
|
|
|
|
|
|
+ JMenuItem resetTcpMenu_2 = new JMenuItem("程序点检");
|
|
|
|
|
+ resetTcpMenu_2.setIcon(new ImageIcon(MesClient.class.getResource("/bg/reset_logo.png")));
|
|
|
|
|
+ resetTcpMenu_2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
|
|
+ resetTcpMenu_2.addMouseListener(new MouseAdapter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void mousePressed(MouseEvent e) {
|
|
|
|
|
+ super.mouseClicked(e);
|
|
|
|
|
+// resetScanA();
|
|
|
|
|
+ boolean ret = fxlabel2Flag == 1?false:true;
|
|
|
|
|
+ if(fxlabel2Flag == 1){
|
|
|
|
|
+ fxlabel2Flag = 0;
|
|
|
|
|
+ }else{
|
|
|
|
|
+ fxlabel2Flag = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ fxlabel2.setVisible(ret);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ settingMenu.add(resetTcpMenu_2);
|
|
|
|
|
+
|
|
|
contentPane = new JPanel();
|
|
contentPane = new JPanel();
|
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
|
setContentPane(contentPane);
|
|
setContentPane(contentPane);
|
|
@@ -718,6 +826,14 @@ public class MesClient extends JFrame {
|
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
indexScrollPaneA = new JScrollPane(indexPanelA);
|
|
|
indexPanelA.setLayout(null);
|
|
indexPanelA.setLayout(null);
|
|
|
|
|
|
|
|
|
|
+ fxlabel2 = new JLabel("程序点检中");
|
|
|
|
|
+ fxlabel2.setFont(new Font("微软雅黑", Font.PLAIN, 24));
|
|
|
|
|
+ fxlabel2.setBounds(81, 0, 810, 70);
|
|
|
|
|
+ fxlabel2.setForeground(Color.RED);
|
|
|
|
|
+ fxlabel2.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
|
|
+ fxlabel2.setVisible(false);
|
|
|
|
|
+ indexPanelA.add(fxlabel2);
|
|
|
|
|
+
|
|
|
product_sn = new JTextField();
|
|
product_sn = new JTextField();
|
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
product_sn.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
product_sn.setEditable(false);
|
|
product_sn.setEditable(false);
|
|
@@ -821,18 +937,23 @@ public class MesClient extends JFrame {
|
|
|
|
|
|
|
|
// 转速显示
|
|
// 转速显示
|
|
|
spindleSpeedLabel = new JLabel("转速: 0 rpm");
|
|
spindleSpeedLabel = new JLabel("转速: 0 rpm");
|
|
|
- spindleSpeedLabel.setBounds(81, 240, 400, 40);
|
|
|
|
|
|
|
+ spindleSpeedLabel.setBounds(81, 200, 400, 40);
|
|
|
spindleSpeedLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
spindleSpeedLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
indexPanelA.add(spindleSpeedLabel);
|
|
indexPanelA.add(spindleSpeedLabel);
|
|
|
|
|
|
|
|
// 进给显示
|
|
// 进给显示
|
|
|
feedRateLabel = new JLabel("进给: 0 mm/min");
|
|
feedRateLabel = new JLabel("进给: 0 mm/min");
|
|
|
- feedRateLabel.setBounds(500, 240, 400, 40);
|
|
|
|
|
|
|
+ feedRateLabel.setBounds(320, 200, 400, 40);
|
|
|
feedRateLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
feedRateLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
indexPanelA.add(feedRateLabel);
|
|
indexPanelA.add(feedRateLabel);
|
|
|
|
|
|
|
|
- tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
|
|
|
|
+ // 扭矩显示
|
|
|
|
|
+ torqueLabel = new JLabel("扭矩: 0");
|
|
|
|
|
+ torqueLabel.setBounds(600, 200, 400, 40);
|
|
|
|
|
+ torqueLabel.setFont(new Font("微软雅黑", Font.PLAIN, 20));
|
|
|
|
|
+ indexPanelA.add(torqueLabel);
|
|
|
|
|
|
|
|
|
|
+ tabbedPane.addTab("开班点检", new ImageIcon(MesClient.class.getResource("/bg/menu_data_preprocess.png")), searchScrollPaneDj, null);
|
|
|
|
|
|
|
|
indexPanelB = new JPanel();
|
|
indexPanelB = new JPanel();
|
|
|
searchScrollPane = new JScrollPane(indexPanelB);
|
|
searchScrollPane = new JScrollPane(indexPanelB);
|
|
@@ -1092,7 +1213,7 @@ public class MesClient extends JFrame {
|
|
|
// int port = 102;
|
|
// int port = 102;
|
|
|
int rack=0;
|
|
int rack=0;
|
|
|
int slot=3;
|
|
int slot=3;
|
|
|
- int timeout=5000;
|
|
|
|
|
|
|
+ int timeout=1000;
|
|
|
s7Connector=
|
|
s7Connector=
|
|
|
S7ConnectorFactory
|
|
S7ConnectorFactory
|
|
|
.buildTCPConnector()
|
|
.buildTCPConnector()
|