|
@@ -8,8 +8,11 @@ import com.jeesite.common.lang.StringUtils;
|
|
|
import com.jeesite.modules.mes.entity.MesLine;
|
|
import com.jeesite.modules.mes.entity.MesLine;
|
|
|
import com.jeesite.modules.mes.entity.MesProduct;
|
|
import com.jeesite.modules.mes.entity.MesProduct;
|
|
|
import com.jeesite.modules.mes.entity.MesProductFsw;
|
|
import com.jeesite.modules.mes.entity.MesProductFsw;
|
|
|
|
|
+import com.jeesite.modules.mes.resp.BindMaterialResp;
|
|
|
|
|
+import com.jeesite.modules.mes.resp.ParamsResp;
|
|
|
import com.jeesite.modules.mes.service.MesLineService;
|
|
import com.jeesite.modules.mes.service.MesLineService;
|
|
|
import com.jeesite.modules.mes.service.MesProductFswService;
|
|
import com.jeesite.modules.mes.service.MesProductFswService;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesProductRecordService;
|
|
|
import com.jeesite.modules.mes.service.MesProductService;
|
|
import com.jeesite.modules.mes.service.MesProductService;
|
|
|
import com.jeesite.modules.mes.web.MesProductRecordController;
|
|
import com.jeesite.modules.mes.web.MesProductRecordController;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@@ -20,6 +23,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -30,12 +35,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
* 3600 数据采集触发(1=请求采集,MES读完后置0)
|
|
* 3600 数据采集触发(1=请求采集,MES读完后置0)
|
|
|
* 3610 质量校验结果(1=合格,2=不合格)
|
|
* 3610 质量校验结果(1=合格,2=不合格)
|
|
|
* 3620~3649 工件码(30个字,ASCII拼接)
|
|
* 3620~3649 工件码(30个字,ASCII拼接)
|
|
|
- * 3740 进给速度
|
|
|
|
|
- * 3780 进给倍率
|
|
|
|
|
- * 3820 主轴转速
|
|
|
|
|
- * 3860 主轴倍率
|
|
|
|
|
- * 4040 指定焊接点压力
|
|
|
|
|
- * 4590 指定焊接点偏移量
|
|
|
|
|
|
|
+ * 3740 进给速度 → feedSpeed
|
|
|
|
|
+ * 3780 进给倍率 → feedRate
|
|
|
|
|
+ * 3820 主轴转速 → spindleSpeed
|
|
|
|
|
+ * 3860 主轴倍率 → spindleRate
|
|
|
|
|
+ * 4040 指定焊接点压力 → pressure
|
|
|
|
|
+ * 4590 指定焊接点偏移量 → pyl
|
|
|
|
|
+ * 4742 B轴角度 → jd
|
|
|
*
|
|
*
|
|
|
* 配置(application.yml):
|
|
* 配置(application.yml):
|
|
|
* mes.fsw.modbus.enabled 是否启用(默认 false)
|
|
* mes.fsw.modbus.enabled 是否启用(默认 false)
|
|
@@ -59,17 +65,22 @@ public class FswModbusScheduling {
|
|
|
private static final int ADDR_SN_START = 3620;
|
|
private static final int ADDR_SN_START = 3620;
|
|
|
private static final int SN_REGISTER_COUNT = 60;
|
|
private static final int SN_REGISTER_COUNT = 60;
|
|
|
|
|
|
|
|
- private static final int ADDR_FEED_RATE = 3740;
|
|
|
|
|
- private static final int ADDR_FEED_OVERRIDE = 3780;
|
|
|
|
|
|
|
+ private static final int ADDR_FEED_SPEED = 3740;
|
|
|
|
|
+ private static final int ADDR_FEED_RATE = 3780;
|
|
|
private static final int ADDR_SPINDLE_SPEED = 3820;
|
|
private static final int ADDR_SPINDLE_SPEED = 3820;
|
|
|
- private static final int ADDR_SPINDLE_OVERRIDE = 3860;
|
|
|
|
|
|
|
+ private static final int ADDR_SPINDLE_RATE = 3860;
|
|
|
private static final int ADDR_WELD_PRESSURE = 4040;
|
|
private static final int ADDR_WELD_PRESSURE = 4040;
|
|
|
private static final int ADDR_WELD_OFFSET = 4590;
|
|
private static final int ADDR_WELD_OFFSET = 4590;
|
|
|
|
|
+ private static final int ADDR_B_AXIS_ANGLE = 4742;
|
|
|
|
|
|
|
|
private static final String DEFAULT_HOST = "10.0.20.141";
|
|
private static final String DEFAULT_HOST = "10.0.20.141";
|
|
|
private static final int DEFAULT_PORT = 502;
|
|
private static final int DEFAULT_PORT = 502;
|
|
|
private static final int DEFAULT_UNIT_ID = 1;
|
|
private static final int DEFAULT_UNIT_ID = 1;
|
|
|
|
|
|
|
|
|
|
+ /** 过程参数落库固定产线 / 工位 */
|
|
|
|
|
+ private static final String FIXED_LINE_SN = "XT";
|
|
|
|
|
+ private static final String FIXED_OPRNO = "OP230B";
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MesProductRecordController mesProductRecordController;
|
|
private MesProductRecordController mesProductRecordController;
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -78,6 +89,8 @@ public class FswModbusScheduling {
|
|
|
private MesLineService mesLineService;
|
|
private MesLineService mesLineService;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MesProductFswService mesProductFswService;
|
|
private MesProductFswService mesProductFswService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesProductRecordService mesProductRecordService;
|
|
|
|
|
|
|
|
private final AtomicBoolean running = new AtomicBoolean(false);
|
|
private final AtomicBoolean running = new AtomicBoolean(false);
|
|
|
private volatile ModbusTcp modbusTcp;
|
|
private volatile ModbusTcp modbusTcp;
|
|
@@ -150,17 +163,18 @@ public class FswModbusScheduling {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String sn = readWorkpieceCode(plc);
|
|
String sn = readWorkpieceCode(plc);
|
|
|
|
|
+ float feedSpeed = plc.readFloat32(ADDR_FEED_SPEED, EByteBuffFormat.BA_DC);
|
|
|
float feedRate = plc.readFloat32(ADDR_FEED_RATE, EByteBuffFormat.BA_DC);
|
|
float feedRate = plc.readFloat32(ADDR_FEED_RATE, EByteBuffFormat.BA_DC);
|
|
|
- float feedOverride = plc.readFloat32(ADDR_FEED_OVERRIDE, EByteBuffFormat.BA_DC);
|
|
|
|
|
float spindleSpeed = plc.readFloat32(ADDR_SPINDLE_SPEED, EByteBuffFormat.BA_DC);
|
|
float spindleSpeed = plc.readFloat32(ADDR_SPINDLE_SPEED, EByteBuffFormat.BA_DC);
|
|
|
- float spindleOverride = plc.readFloat32(ADDR_SPINDLE_OVERRIDE, EByteBuffFormat.BA_DC);
|
|
|
|
|
|
|
+ float spindleRate = plc.readFloat32(ADDR_SPINDLE_RATE, EByteBuffFormat.BA_DC);
|
|
|
float weldPressure = plc.readFloat32(ADDR_WELD_PRESSURE, EByteBuffFormat.BA_DC);
|
|
float weldPressure = plc.readFloat32(ADDR_WELD_PRESSURE, EByteBuffFormat.BA_DC);
|
|
|
float weldOffset = plc.readFloat32(ADDR_WELD_OFFSET, EByteBuffFormat.BA_DC);
|
|
float weldOffset = plc.readFloat32(ADDR_WELD_OFFSET, EByteBuffFormat.BA_DC);
|
|
|
|
|
+ float bAxisAngle = plc.readFloat32(ADDR_B_AXIS_ANGLE, EByteBuffFormat.BA_DC);
|
|
|
|
|
|
|
|
- logger.info("FSW过程采集 sn={} 进给速度={} 进给倍率={} 主轴转速={} 主轴倍率={} 焊接压力={} 焊接偏移={}",
|
|
|
|
|
- sn, feedRate, feedOverride, spindleSpeed, spindleOverride, weldPressure, weldOffset);
|
|
|
|
|
|
|
+ logger.info("FSW过程采集 sn={} 进给速度={} 进给倍率={} 主轴转速={} 主轴倍率={} 焊接压力={} 偏移量={} B轴角度={}",
|
|
|
|
|
+ sn, feedSpeed, feedRate, spindleSpeed, spindleRate, weldPressure, weldOffset, bAxisAngle);
|
|
|
|
|
|
|
|
- saveProcessData(sn, feedRate, feedOverride, spindleSpeed, spindleOverride, weldPressure, weldOffset);
|
|
|
|
|
|
|
+ saveProcessData(sn, feedSpeed, feedRate, spindleSpeed, spindleRate, weldPressure, weldOffset, bAxisAngle);
|
|
|
plc.writeInt16(ADDR_COLLECT_FLAG, (short) 0);
|
|
plc.writeInt16(ADDR_COLLECT_FLAG, (short) 0);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -211,27 +225,31 @@ public class FswModbusScheduling {
|
|
|
return line.getSn();
|
|
return line.getSn();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void saveProcessData(String sn, float feedRate, float feedOverride,
|
|
|
|
|
- float spindleSpeed, float spindleOverride, float weldPressure, float weldOffset) {
|
|
|
|
|
|
|
+ private void saveProcessData(String sn, float feedSpeed, float feedRate,
|
|
|
|
|
+ float spindleSpeed, float spindleRate, float weldPressure, float weldOffset, float bAxisAngle) {
|
|
|
if (StringUtils.isBlank(sn)) {
|
|
if (StringUtils.isBlank(sn)) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
try {
|
|
try {
|
|
|
- String oprno = Global.getConfig("mes.fsw.modbus.oprno");
|
|
|
|
|
- String lineSn = Global.getConfig("mes.fsw.modbus.lineSn");
|
|
|
|
|
- if (StringUtils.isBlank(lineSn)) {
|
|
|
|
|
- lineSn = resolveLineSn(sn);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 进给/主轴倍率、焊接偏移暂无附加字段落库,拼入对应字段便于追溯
|
|
|
|
|
MesProductFsw entity = new MesProductFsw();
|
|
MesProductFsw entity = new MesProductFsw();
|
|
|
entity.setSn(sn);
|
|
entity.setSn(sn);
|
|
|
- entity.setOprno(oprno);
|
|
|
|
|
- entity.setLineSn(lineSn);
|
|
|
|
|
- entity.setFeedRate(fmt(feedRate) + "/" + fmt(feedOverride));
|
|
|
|
|
- entity.setSpindleSpeed(fmt(spindleSpeed) + "/" + fmt(spindleOverride));
|
|
|
|
|
- entity.setPressure(fmt(weldPressure) + "/" + fmt(weldOffset));
|
|
|
|
|
|
|
+ entity.setOprno(FIXED_OPRNO);
|
|
|
|
|
+ entity.setLineSn(FIXED_LINE_SN);
|
|
|
|
|
+ entity.setFeedSpeed(fmt(feedSpeed));
|
|
|
|
|
+ entity.setFeedRate(fmt(feedRate));
|
|
|
|
|
+ entity.setSpindleSpeed(fmt(spindleSpeed));
|
|
|
|
|
+ entity.setSpindleRate(fmt(spindleRate));
|
|
|
|
|
+ entity.setPressure(fmt(weldPressure));
|
|
|
|
|
+ entity.setPyl(fmt(weldOffset));
|
|
|
|
|
+ entity.setJd(fmt(bAxisAngle));
|
|
|
mesProductFswService.save(entity);
|
|
mesProductFswService.save(entity);
|
|
|
|
|
+
|
|
|
|
|
+ // 保存完成后提交工位总结果为 OK
|
|
|
|
|
+ List<ParamsResp> params = new ArrayList<>();
|
|
|
|
|
+ List<BindMaterialResp> bmlists = new ArrayList<>();
|
|
|
|
|
+ mesProductRecordService.updateRecordResult(sn, FIXED_OPRNO, "100000", "", "OK",
|
|
|
|
|
+ "", params, FIXED_LINE_SN, true, bmlists, null);
|
|
|
|
|
+ logger.info("FSW过程参数已保存并更新工位结果 OK sn={} oprno={}", sn, FIXED_OPRNO);
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("FSW过程参数保存失败 sn={}:{}", sn, e.getMessage());
|
|
logger.error("FSW过程参数保存失败 sn={}:{}", sn, e.getMessage());
|
|
|
}
|
|
}
|