|
|
@@ -2,19 +2,12 @@ package com.mes.component;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
-import com.github.s7connector.api.DaveArea;
|
|
|
-import com.github.s7connector.api.S7Connector;
|
|
|
-import com.github.s7connector.api.S7Serializer;
|
|
|
-import com.github.s7connector.api.factory.S7ConnectorFactory;
|
|
|
-import com.github.s7connector.api.factory.S7SerializerFactory;
|
|
|
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
|
|
|
import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
|
|
|
import com.mes.ui.CacheData;
|
|
|
import com.mes.ui.DataUtil;
|
|
|
import com.mes.ui.MesClient;
|
|
|
-import com.mes.util.DateLocalUtils;
|
|
|
import com.mes.util.JdbcUtils;
|
|
|
-import com.mes.util.S7Util;
|
|
|
import com.mes.util.TCPClient;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
@@ -22,8 +15,6 @@ import org.slf4j.LoggerFactory;
|
|
|
import javax.swing.*;
|
|
|
import java.awt.*;
|
|
|
import java.awt.event.*;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
import java.util.Timer;
|
|
|
import java.util.TimerTask;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
@@ -75,13 +66,9 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
|
|
|
public String plcIp1 = "192.168.90.85"; // plc5 西侧
|
|
|
public String plcIp2 = "192.168.90.86"; // plc6 东侧
|
|
|
- public String deviceIp = ""; //摩擦焊ip
|
|
|
|
|
|
- public Integer errflag = 0; // 1=报警 0=正常
|
|
|
public Integer errflag2 = 0;
|
|
|
|
|
|
- public S7Connector s7Connector;
|
|
|
-
|
|
|
public S7PLC s7PLC = null;
|
|
|
|
|
|
public Integer workWidth = 470;
|
|
|
@@ -104,13 +91,11 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
|
|
|
public Integer isScan = 1; // 1=西侧 2=东测
|
|
|
|
|
|
- public static List<String> hjparams = new ArrayList<>();
|
|
|
public int transferSn = 0;
|
|
|
public int transferFloor = 0;
|
|
|
public JLabel oprnoLabel;
|
|
|
public JLabel oprnoLabel2;
|
|
|
public String fswDeviceName = ""; // 设备名:1号机/2号机
|
|
|
- public Boolean fswOnline = true;
|
|
|
|
|
|
public JButton signalBtn; // 信号监控按钮
|
|
|
|
|
|
@@ -141,11 +126,9 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
|
|
|
if(MesClient.mes_line_pos.equals("east")){ // 东侧
|
|
|
s7PLC = new S7PLC(EPlcType.S1500, plcIp2);
|
|
|
- deviceIp = "80.25.10.42";
|
|
|
isScan = 2;
|
|
|
}else{
|
|
|
s7PLC = new S7PLC(EPlcType.S1500, plcIp1);
|
|
|
- deviceIp = "80.24.10.42";
|
|
|
isScan = 1;
|
|
|
}
|
|
|
|
|
|
@@ -153,7 +136,6 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
// pos: A=西侧1号机 B=东侧1号机(默认DB7000);C=西侧2号机 D=东侧2号机(DB7004,新增设备)
|
|
|
if(pos.equals("C") || pos.equals("D")){
|
|
|
plcDb = "DB7004";
|
|
|
- deviceIp = ""; // TODO 封板正面FSW2设备IP待现场确认后修改,未确认前参数采集不可用
|
|
|
fswDeviceName = pos.equals("C") ? "西侧2号机" : "东侧2号机";
|
|
|
}else{
|
|
|
fswDeviceName = MesClient.mes_line_pos.equals("east") ? "东侧1号机" : "西侧1号机";
|
|
|
@@ -351,7 +333,7 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
|
|
|
|
|
|
// resetScanA();
|
|
|
- monitorDeviceStatus(); //获取摩擦焊参
|
|
|
+ monitorDeviceStatus(); //设备报警监控
|
|
|
|
|
|
|
|
|
|
|
|
@@ -424,31 +406,6 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
public void run() {
|
|
|
if(MesClient.isLogin == 1 && isLocal == 0){
|
|
|
try{
|
|
|
- initS7();
|
|
|
- monitorDevice();
|
|
|
- boolean ret = S7Util.getFswAlarm(s7Connector);
|
|
|
- if(ret){
|
|
|
- errflag = 0;
|
|
|
- }
|
|
|
- if(!ret && errflag == 0 ){
|
|
|
- errflag = 1;
|
|
|
- DataUtil.deviceAlarm(oprno+pos,productSn.getText(),oprno+pos+"随动夹具报警",MesClient.user_menu.getText());
|
|
|
- }
|
|
|
- fswOnline = true;
|
|
|
- }catch (Exception e){
|
|
|
- log.info(e.getMessage());
|
|
|
- fswOnline = false;
|
|
|
- }
|
|
|
-
|
|
|
- if(fswOnline){
|
|
|
- oprnoLabel.setForeground(Color.BLACK);
|
|
|
- oprnoLabel2.setForeground(Color.BLACK);
|
|
|
- }else{
|
|
|
- oprnoLabel.setForeground(Color.RED);
|
|
|
- oprnoLabel2.setForeground(Color.RED);
|
|
|
- }
|
|
|
-
|
|
|
- try{
|
|
|
int ret = getAlarm();
|
|
|
if(ret == 0){
|
|
|
errflag2 = 0;
|
|
|
@@ -633,13 +590,6 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
productSnFeeding.setText(sn);
|
|
|
lastSn = sn;
|
|
|
|
|
|
- //判断刀具寿命
|
|
|
-// Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
|
|
|
-// if(hjjs > 1230){
|
|
|
-// setMenuStatus("搅拌头达到使用寿命,请换搅拌头",-1);
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
// 查询工件质量
|
|
|
JSONObject retObj = DataUtil.checkQuality(sn,oprno+pos,MesClient.user_menu.getText());
|
|
|
if(retObj.get("result")!=null&&retObj.get("result").toString().equalsIgnoreCase("true")) {
|
|
|
@@ -850,66 +800,6 @@ public class WorkJPanelOP60 extends JPanel {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- public void initS7(){
|
|
|
- try {
|
|
|
- if(s7Connector == null) {
|
|
|
- //PLC地址
|
|
|
- String ipAddress = deviceIp;
|
|
|
- //默认端口
|
|
|
- int port = 102;
|
|
|
- int rack=0;
|
|
|
- int slot=3;
|
|
|
- int timeout=5000;
|
|
|
- s7Connector=
|
|
|
- S7ConnectorFactory
|
|
|
- .buildTCPConnector()
|
|
|
- .withHost(ipAddress)
|
|
|
- .withPort(port) //optional
|
|
|
-// .withRack(rack) //optional
|
|
|
-// .withSlot(slot) //optional
|
|
|
- .withTimeout(timeout) //连接超时时间
|
|
|
- .build();
|
|
|
- S7Serializer s7Serializer2L = S7SerializerFactory.buildSerializer(s7Connector);
|
|
|
- }
|
|
|
- } catch (Exception e) { // 如果连接失败保存失败再次尝试连接一次
|
|
|
- s7Connector = null;
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void monitorDevice(){
|
|
|
- //工件加工状态开始上传摩擦焊参数
|
|
|
- if(tjFlag == 2){
|
|
|
- try{
|
|
|
- String zzzs = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 0));
|
|
|
- String jgsd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 4));
|
|
|
- String zzzb = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 8));
|
|
|
- String ylz = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 12));
|
|
|
- Integer hjjs = S7Util.formatS7Int(s7Connector.read(DaveArea.DB, 9051, 2, 26));
|
|
|
- String hjcd = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 28));
|
|
|
- String hjms = S7Util.formatS7Val(s7Connector.read(DaveArea.DB, 9051, 4, 32));
|
|
|
- String record_time = DateLocalUtils.getCurrentTime();
|
|
|
-// log.info(oprno+pos+"摩擦焊参数采集 -> 时间: {}, 转速: {}, 速度: {}, Z轴: {}, 压力: {}, 计数: {}, 长度: {}, 耗时: {}", record_time, zzzs, jgsd, zzzb, ylz, hjjs, hjcd, hjms);
|
|
|
- hjparams.add(zzzs+"|"+jgsd+"|"+zzzb+"|"+ylz+"|"+hjjs+"|"+hjcd+"|"+hjms+"|"+record_time);
|
|
|
- if (hjparams.size() == 60 && productSn.getText() != null && !productSn.getText().trim().isEmpty() ) {
|
|
|
- JdbcUtils.insertParamData(oprno+pos,MesClient.mes_line_sn,productSn.getText(), JSON.toJSONString(hjparams));
|
|
|
- hjparams = new ArrayList<>();
|
|
|
- }else{
|
|
|
-// log.info("未执行插入");
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- s7Connector = null;
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(hjparams.size() > 0){
|
|
|
- JdbcUtils.insertParamData(oprno+pos,MesClient.mes_line_sn,productSn.getText(), JSON.toJSONString(hjparams));
|
|
|
- hjparams = new ArrayList<>();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public int getAlarm(){
|
|
|
boolean ret0 = readBoolean(plcDb+".6.0");
|
|
|
if(ret0){
|