完善输送机读值偏移地址
This commit is contained in:
@@ -15,6 +15,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
@MapperScan("com.ruoyi.**.mapper")
|
||||
public class RuoYiApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
|
||||
@@ -576,7 +576,7 @@ public class ApiServiceImpl implements IApiService {
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
// genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(agvQueue.getWmsTaskNo());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
|
||||
@@ -72,5 +72,8 @@ public class DeviceSsj extends BaseEntity
|
||||
@Excel(name = "任务号")
|
||||
private int taskNo;
|
||||
|
||||
@Excel(name = "校验码反馈")
|
||||
private Integer checksum;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -86,15 +86,15 @@ public class PlcRead implements Runnable {
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcOtherSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("40"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(0, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(4, ddsx1));
|
||||
ssjDevice.setKx(ParseUtil.optInt(34, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(36, ddsx1));
|
||||
ssjDevice.setChecksum(ParseUtil.optInt(38, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,15 +104,15 @@ public class PlcRead implements Runnable {
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcInSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("40"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(12, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(0, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(4, ddsx1));
|
||||
ssjDevice.setKx(ParseUtil.optInt(34, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(36, ddsx1));
|
||||
ssjDevice.setChecksum(ParseUtil.optInt(38, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,15 +122,15 @@ public class PlcRead implements Runnable {
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcPickSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("40"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(0, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(4, ddsx1));
|
||||
ssjDevice.setKx(ParseUtil.optInt(34, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(36, ddsx1));
|
||||
ssjDevice.setChecksum(ParseUtil.optInt(38, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,15 +140,15 @@ public class PlcRead implements Runnable {
|
||||
* @param ssjDevice
|
||||
*/
|
||||
private void readPlcOutSsj(DeviceSsj ssjDevice) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("20"));
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(ssjDevice.getPlcDbReadAddress(), Short.parseShort("40"));
|
||||
String ddsx1 = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx1 = SoftBasic.ByteToHexString(read2.Content);
|
||||
ssjDevice.setKx(ParseUtil.optInt(0, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(2, ddsx1));
|
||||
ssjDevice.setRkqq(ParseUtil.optInt(4, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(6, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(10, ddsx1));
|
||||
ssjDevice.setTaskNo(ParseUtil.optDInt(0, ddsx1));
|
||||
ssjDevice.setTrayCode(ParseUtil.optString(4, ddsx1));
|
||||
ssjDevice.setKx(ParseUtil.optInt(34, ddsx1));
|
||||
ssjDevice.setDw(ParseUtil.optInt(36, ddsx1));
|
||||
ssjDevice.setChecksum(ParseUtil.optInt(38, ddsx1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,193 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj;
|
||||
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class PlcWrite {
|
||||
|
||||
/**
|
||||
* plc1输送机ip地址
|
||||
*/
|
||||
private static final String ADDRCONV1 = "192.168.56.20";
|
||||
private static final String ADDRCONV2 = "192.168.56.21";
|
||||
private static final String ADDRCONV3 = "192.168.56.22";
|
||||
|
||||
|
||||
/**
|
||||
* 地址偏移值
|
||||
*/
|
||||
int offset = 78;
|
||||
|
||||
private static final String db5 = "DB5.DB";
|
||||
private static final String db6 = "DB6.DB";
|
||||
/**
|
||||
* 向输送机写值
|
||||
*
|
||||
* @param convNum 输送机编号
|
||||
* @param taskNo 任务号
|
||||
* @param Barcode 条码
|
||||
* @param checksum 校验码
|
||||
*/
|
||||
public static void convWrite(String convNum, Integer taskNo, String Barcode, Integer checksum)
|
||||
{
|
||||
String ipAddress = "";
|
||||
int num = 0;
|
||||
String db = "";
|
||||
try {
|
||||
switch(convNum)
|
||||
{
|
||||
//************************************* plc1 *************************************
|
||||
//---------------------------DB5-------------------------------
|
||||
case "G1003":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 0;
|
||||
db = db5;
|
||||
break;
|
||||
case "G1006":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 1;
|
||||
db = db5;
|
||||
break;
|
||||
case "G1009":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 2;
|
||||
db = db5;
|
||||
break;
|
||||
case "G1012":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 3;
|
||||
db = db5;
|
||||
break;
|
||||
//---------------------------DB6-------------------------------
|
||||
case "G1004":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 0;
|
||||
db = db6;
|
||||
break;
|
||||
case "G1010":
|
||||
ipAddress = ADDRCONV1;
|
||||
num = 1;
|
||||
db = db6;
|
||||
break;
|
||||
|
||||
//************************************* plc2 *************************************
|
||||
//---------------------------DB5-------------------------------
|
||||
case "G2006":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 0;
|
||||
db = db5;
|
||||
break;
|
||||
case "G2012":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 1;
|
||||
db = db5;
|
||||
break;
|
||||
case "G3009":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 2;
|
||||
db = db5;
|
||||
break;
|
||||
case "G3018":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 3;
|
||||
db = db5;
|
||||
break;
|
||||
//---------------------------DB6-------------------------------
|
||||
case "G2001":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 0;
|
||||
db = db6;
|
||||
break;
|
||||
case "G2007":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 1;
|
||||
db = db6;
|
||||
break;
|
||||
case "G3001":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 2;
|
||||
db = db6;
|
||||
break;
|
||||
case "G3010":
|
||||
ipAddress = ADDRCONV2;
|
||||
num = 3;
|
||||
db = db6;
|
||||
break;
|
||||
|
||||
//************************************* plc3 *************************************
|
||||
//---------------------------DB5-------------------------------
|
||||
case "G4009":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 0;
|
||||
db = db5;
|
||||
break;
|
||||
case "G4018":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 1;
|
||||
db = db5;
|
||||
break;
|
||||
case "G5009":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 2;
|
||||
db = db5;
|
||||
break;
|
||||
case "G5018":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 3;
|
||||
db = db5;
|
||||
break;
|
||||
//---------------------------DB6-------------------------------
|
||||
case "G4001":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 0;
|
||||
db = db6;
|
||||
break;
|
||||
case "G4010":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 1;
|
||||
db = db6;
|
||||
break;
|
||||
case "G5001":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 2;
|
||||
db = db6;
|
||||
break;
|
||||
case "G5010":
|
||||
ipAddress = ADDRCONV3;
|
||||
num = 3;
|
||||
db = db6;
|
||||
break;
|
||||
}
|
||||
|
||||
//非电控输送机空判断
|
||||
if (ipAddress.equals("") || ipAddress == null){
|
||||
log.info("无效操作:向" + convNum + "写入值");
|
||||
return;
|
||||
}
|
||||
|
||||
SiemensS7Net plc=new SiemensS7Net(SiemensPLCS.S1500, ipAddress);
|
||||
plc.Write(db + "D" + (40 + 78 * num), taskNo);
|
||||
plc.Write(db + "W" + (46 + 78 * num), Barcode);
|
||||
plc.Write(db + "W" + (76 + 78 * num), checksum);
|
||||
plc.Write(db + "W" + (44 + 78 * num), 1);
|
||||
}catch(Exception e){
|
||||
int num1 = 0;
|
||||
switch (ipAddress){
|
||||
case ADDRCONV1:
|
||||
num1 = 1;
|
||||
break;
|
||||
case ADDRCONV2:
|
||||
num1 = 2;
|
||||
break;
|
||||
case ADDRCONV3:
|
||||
num1 = 3;
|
||||
break;
|
||||
}
|
||||
log.info("输送机plc" + num1 + "写入异常,IP地址:" + ipAddress + "," + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<resultMap type="DeviceSsj" id="DeviceSsjResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="deviceCode " column="device_code " />
|
||||
<result property="name " column="name " />
|
||||
<result property="deviceCode" column="device_code" />
|
||||
<result property="name" column="name" />
|
||||
<result property="type" column="type" />
|
||||
<result property="ipAddress" column="ip_address" />
|
||||
<result property="plcDbReadAddress" column="plc_db_read_address" />
|
||||
|
||||
Reference in New Issue
Block a user