堆垛机信号读取
This commit is contained in:
@@ -28,10 +28,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.SendData;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.ruoyi.schedule.plcRead.ssj.domain;
|
||||
package com.ruoyi.common.domain;
|
||||
|
||||
/**
|
||||
* 发送数据的实体类
|
||||
@@ -24,7 +24,7 @@ public class MsgDdj extends BaseEntity
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long id;
|
||||
private Integer id;
|
||||
|
||||
/** 堆垛机名称 */
|
||||
@Excel(name = "堆垛机名称")
|
||||
@@ -36,67 +36,69 @@ public class MsgDdj extends BaseEntity
|
||||
|
||||
/** 阶段标志 */
|
||||
@Excel(name = "阶段标志")
|
||||
private Long jdbz;
|
||||
private Integer jdbz;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private Long sbzt;
|
||||
private Integer sbzt;
|
||||
|
||||
/** 操作方式 */
|
||||
@Excel(name = "操作方式")
|
||||
private Long czfs;
|
||||
private Integer czfs;
|
||||
|
||||
/** 允许下发 */
|
||||
@Excel(name = "允许下发")
|
||||
private Long yxxf;
|
||||
private Integer yxxf;
|
||||
|
||||
/** 原排 */
|
||||
@Excel(name = "原排")
|
||||
private Long yp;
|
||||
private Integer yph;
|
||||
|
||||
/** 原列 */
|
||||
@Excel(name = "原列")
|
||||
private Long yl;
|
||||
private Integer ylh;
|
||||
|
||||
/** 原层 */
|
||||
@Excel(name = "原层")
|
||||
private Long yc;
|
||||
private Integer ych;
|
||||
|
||||
/** 目标排 */
|
||||
@Excel(name = "目标排")
|
||||
private Long mbp;
|
||||
private Integer mbph;
|
||||
|
||||
/** 目标列 */
|
||||
@Excel(name = "目标列")
|
||||
private Long mbl;
|
||||
private Integer mblh;
|
||||
|
||||
/** 目标层 */
|
||||
@Excel(name = "目标层")
|
||||
private Long mbc;
|
||||
private Integer mbch;
|
||||
|
||||
/** 心跳信号 */
|
||||
@Excel(name = "心跳信号")
|
||||
private Long xtxh;
|
||||
private Integer xtxh;
|
||||
|
||||
/** 当前巷道 */
|
||||
@Excel(name = "当前巷道")
|
||||
private Long dqxd;
|
||||
private Integer dqxd;
|
||||
|
||||
/** 货叉状态 */
|
||||
@Excel(name = "货叉状态")
|
||||
private Long hczt;
|
||||
private Integer hczt;
|
||||
|
||||
/** 备用字段1 */
|
||||
@Excel(name = "备用字段1")
|
||||
private Long spare1;
|
||||
private Integer spare1;
|
||||
|
||||
/** 备用字段2 */
|
||||
@Excel(name = "备用字段2")
|
||||
private Long spare2;
|
||||
private Integer spare2;
|
||||
|
||||
/** 备用字段3 */
|
||||
@Excel(name = "备用字段3")
|
||||
private Long spare3;
|
||||
private Integer spare3;
|
||||
|
||||
private String plcDbReadAddress;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface IMydoJobService
|
||||
|
||||
MydoJob selectMydoJobByTaskNo(Long rwh);
|
||||
|
||||
boolean ddjTaskFinish(Long rwh, Long id);
|
||||
boolean ddjTaskFinish(Long rwh, Integer id);
|
||||
|
||||
boolean InvalidMydoJob(Long rwh, Long id);
|
||||
boolean InvalidMydoJob(Long rwh, Integer id);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class MydoJobServiceImpl implements IMydoJobService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ddjTaskFinish(Long rwh, Long id) {
|
||||
public boolean ddjTaskFinish(Long rwh, Integer id) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_rwh", rwh);
|
||||
map.put("v_ddj_id", id);
|
||||
@@ -115,7 +115,7 @@ public class MydoJobServiceImpl implements IMydoJobService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean InvalidMydoJob(Long rwh, Long id) {
|
||||
public boolean InvalidMydoJob(Long rwh, Integer id) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("v_rwh", rwh);
|
||||
map.put("v_ddj_id", id);
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.ruoyi.queue.ddj.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
@@ -7,10 +11,14 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 堆垛机执行队列对象 ddj_device_execution_queue
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-09-22
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@ToString
|
||||
public class DdjDeviceExecutionQueue extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -28,35 +36,35 @@ public class DdjDeviceExecutionQueue extends BaseEntity
|
||||
|
||||
/** 设备id */
|
||||
@Excel(name = "设备id")
|
||||
private Long devId;
|
||||
private Integer devId;
|
||||
|
||||
/** 任务状态 */
|
||||
@Excel(name = "任务状态")
|
||||
private Long rwzt;
|
||||
private Integer rwzt;
|
||||
|
||||
/** 原排 */
|
||||
@Excel(name = "原排")
|
||||
private Long yph;
|
||||
private Integer yph;
|
||||
|
||||
/** 原列 */
|
||||
@Excel(name = "原列")
|
||||
private Long ylh;
|
||||
private Integer ylh;
|
||||
|
||||
/** 原层 */
|
||||
@Excel(name = "原层")
|
||||
private Long ych;
|
||||
private Integer ych;
|
||||
|
||||
/** 目标排 */
|
||||
@Excel(name = "目标排")
|
||||
private Long mbph;
|
||||
private Integer mbph;
|
||||
|
||||
/** 目标列 */
|
||||
@Excel(name = "目标列")
|
||||
private Long mblh;
|
||||
private Integer mblh;
|
||||
|
||||
/** 目标层 */
|
||||
@Excel(name = "目标层")
|
||||
private Long mbch;
|
||||
private Integer mbch;
|
||||
|
||||
/** 堆垛机下发 */
|
||||
@Excel(name = "堆垛机下发")
|
||||
@@ -64,7 +72,7 @@ public class DdjDeviceExecutionQueue extends BaseEntity
|
||||
|
||||
/** 任务类型 */
|
||||
@Excel(name = "任务类型")
|
||||
private Long rwlx;
|
||||
private Integer rwlx;
|
||||
|
||||
/** 生成时间 */
|
||||
@Excel(name = "生成时间")
|
||||
@@ -80,7 +88,7 @@ public class DdjDeviceExecutionQueue extends BaseEntity
|
||||
|
||||
/** 命令方式 */
|
||||
@Excel(name = "命令方式")
|
||||
private Long mlfs;
|
||||
private Integer mlfs;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
@@ -94,229 +102,5 @@ public class DdjDeviceExecutionQueue extends BaseEntity
|
||||
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||
private String spare3;
|
||||
|
||||
public void setUuid(String uuid)
|
||||
{
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUuid()
|
||||
{
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setRwh(Long rwh)
|
||||
{
|
||||
this.rwh = rwh;
|
||||
}
|
||||
|
||||
public Long getRwh()
|
||||
{
|
||||
return rwh;
|
||||
}
|
||||
|
||||
public void setDevName(String devName)
|
||||
{
|
||||
this.devName = devName;
|
||||
}
|
||||
|
||||
public String getDevName()
|
||||
{
|
||||
return devName;
|
||||
}
|
||||
|
||||
public void setDevId(Long devId)
|
||||
{
|
||||
this.devId = devId;
|
||||
}
|
||||
|
||||
public Long getDevId()
|
||||
{
|
||||
return devId;
|
||||
}
|
||||
|
||||
public void setRwzt(Long rwzt)
|
||||
{
|
||||
this.rwzt = rwzt;
|
||||
}
|
||||
|
||||
public Long getRwzt()
|
||||
{
|
||||
return rwzt;
|
||||
}
|
||||
|
||||
public void setYph(Long yph)
|
||||
{
|
||||
this.yph = yph;
|
||||
}
|
||||
|
||||
public Long getYph()
|
||||
{
|
||||
return yph;
|
||||
}
|
||||
|
||||
public void setYlh(Long ylh)
|
||||
{
|
||||
this.ylh = ylh;
|
||||
}
|
||||
|
||||
public Long getYlh()
|
||||
{
|
||||
return ylh;
|
||||
}
|
||||
|
||||
public void setYch(Long ych)
|
||||
{
|
||||
this.ych = ych;
|
||||
}
|
||||
|
||||
public Long getYch()
|
||||
{
|
||||
return ych;
|
||||
}
|
||||
|
||||
public void setMbph(Long mbph)
|
||||
{
|
||||
this.mbph = mbph;
|
||||
}
|
||||
|
||||
public Long getMbph()
|
||||
{
|
||||
return mbph;
|
||||
}
|
||||
|
||||
public void setMblh(Long mblh)
|
||||
{
|
||||
this.mblh = mblh;
|
||||
}
|
||||
|
||||
public Long getMblh()
|
||||
{
|
||||
return mblh;
|
||||
}
|
||||
|
||||
public void setMbch(Long mbch)
|
||||
{
|
||||
this.mbch = mbch;
|
||||
}
|
||||
|
||||
public Long getMbch()
|
||||
{
|
||||
return mbch;
|
||||
}
|
||||
|
||||
public void setDdjxf(String ddjxf)
|
||||
{
|
||||
this.ddjxf = ddjxf;
|
||||
}
|
||||
|
||||
public String getDdjxf()
|
||||
{
|
||||
return ddjxf;
|
||||
}
|
||||
|
||||
public void setRwlx(Long rwlx)
|
||||
{
|
||||
this.rwlx = rwlx;
|
||||
}
|
||||
|
||||
public Long getRwlx()
|
||||
{
|
||||
return rwlx;
|
||||
}
|
||||
|
||||
public void setScsj(String scsj)
|
||||
{
|
||||
this.scsj = scsj;
|
||||
}
|
||||
|
||||
public String getScsj()
|
||||
{
|
||||
return scsj;
|
||||
}
|
||||
|
||||
public void setXfsj(String xfsj)
|
||||
{
|
||||
this.xfsj = xfsj;
|
||||
}
|
||||
|
||||
public String getXfsj()
|
||||
{
|
||||
return xfsj;
|
||||
}
|
||||
|
||||
public void setJssj(String jssj)
|
||||
{
|
||||
this.jssj = jssj;
|
||||
}
|
||||
|
||||
public String getJssj()
|
||||
{
|
||||
return jssj;
|
||||
}
|
||||
|
||||
public void setMlfs(Long mlfs)
|
||||
{
|
||||
this.mlfs = mlfs;
|
||||
}
|
||||
|
||||
public Long getMlfs()
|
||||
{
|
||||
return mlfs;
|
||||
}
|
||||
|
||||
public void setSpare1(String spare1)
|
||||
{
|
||||
this.spare1 = spare1;
|
||||
}
|
||||
|
||||
public String getSpare1()
|
||||
{
|
||||
return spare1;
|
||||
}
|
||||
|
||||
public void setSpare2(String spare2)
|
||||
{
|
||||
this.spare2 = spare2;
|
||||
}
|
||||
|
||||
public String getSpare2()
|
||||
{
|
||||
return spare2;
|
||||
}
|
||||
|
||||
public void setSpare3(String spare3)
|
||||
{
|
||||
this.spare3 = spare3;
|
||||
}
|
||||
|
||||
public String getSpare3()
|
||||
{
|
||||
return spare3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("uuid", getUuid())
|
||||
.append("rwh", getRwh())
|
||||
.append("devName", getDevName())
|
||||
.append("devId", getDevId())
|
||||
.append("rwzt", getRwzt())
|
||||
.append("yph", getYph())
|
||||
.append("ylh", getYlh())
|
||||
.append("ych", getYch())
|
||||
.append("mbph", getMbph())
|
||||
.append("mblh", getMblh())
|
||||
.append("mbch", getMbch())
|
||||
.append("ddjxf", getDdjxf())
|
||||
.append("rwlx", getRwlx())
|
||||
.append("scsj", getScsj())
|
||||
.append("xfsj", getXfsj())
|
||||
.append("jssj", getJssj())
|
||||
.append("mlfs", getMlfs())
|
||||
.append("spare1", getSpare1())
|
||||
.append("spare2", getSpare2())
|
||||
.append("spare3", getSpare3())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package com.ruoyi.schedule;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.CustomThread;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.common.domain.CustomThread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.Ddj1Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.ddj.Ddj2Thread;
|
||||
import com.ruoyi.schedule.scheduleTask.ssj.floor1.Floor1SsjInOutThread;
|
||||
@@ -25,7 +26,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
@Slf4j
|
||||
public class ScheduleThread {
|
||||
|
||||
public CustomThread<PlcRead> customThread;
|
||||
public CustomThread<PlcSsjRead> customSsjThread;
|
||||
public CustomThread<PlcDdjRead> customDdjThread;
|
||||
@Autowired
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
|
||||
@@ -88,19 +90,25 @@ public class ScheduleThread {
|
||||
list.put(deviceSsj.getDeviceCode(), deviceSsj);
|
||||
}
|
||||
|
||||
ConcurrentHashMap<String, MsgDdj> list2 = new ConcurrentHashMap<>();
|
||||
|
||||
//plc读取线程
|
||||
PlcRead plcRead = new PlcRead(list,list2, ssjPlcConnectInfo);
|
||||
Thread plcReadThread = new Thread(plcRead);
|
||||
customThread = new CustomThread<PlcRead>(plcReadThread, plcRead);
|
||||
//plc输送机读取线程
|
||||
PlcSsjRead plcSsjRead = new PlcSsjRead(list, ssjPlcConnectInfo);
|
||||
Thread plcSsjReadThread = new Thread(plcSsjRead);
|
||||
customSsjThread = new CustomThread<PlcSsjRead>(plcSsjReadThread, plcSsjRead);
|
||||
//plc堆垛机读取现场
|
||||
ConcurrentHashMap<String, MsgDdj> list2 = new ConcurrentHashMap<>();
|
||||
PlcDdjRead plcDdjRead = new PlcDdjRead(list2, ssjPlcConnectInfo);
|
||||
Thread plcDdjReadThread = new Thread(plcDdjRead);
|
||||
customDdjThread = new CustomThread<PlcDdjRead>(plcDdjReadThread, plcDdjRead);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始线程
|
||||
*/
|
||||
public void startAllThread() {
|
||||
customThread.getThread().start();
|
||||
customSsjThread.getThread().start();
|
||||
customDdjThread.getThread().start();
|
||||
isRun = true;
|
||||
}
|
||||
|
||||
@@ -131,7 +139,8 @@ public class ScheduleThread {
|
||||
* 停止线程
|
||||
*/
|
||||
public void stopAllThread() {
|
||||
customThread.runnable.isRun = false;
|
||||
customDdjThread.runnable.isRun = false;
|
||||
customSsjThread.runnable.isRun = false;
|
||||
plcReadInit();
|
||||
isRun = false;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.ruoyi.schedule.plcRead.ddj;
|
||||
|
||||
public class IsoTcpClientDDJ1 extends Thread {
|
||||
|
||||
|
||||
/// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
|
||||
public static int WritetoDDJ(String address, byte[] tsak) {
|
||||
/*int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, tsak), address);
|
||||
}
|
||||
return a;*/
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.ruoyi.schedule.plcRead.ddj;
|
||||
|
||||
import HslCommunication.BasicFramework.SoftBasic;
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Core.Types.OperateResultExOne;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.ruoyi.common.domain.HslRead;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public class PlcDdjRead extends Thread {
|
||||
public static ConcurrentHashMap<String, MsgDdj> deviceDdjMap;
|
||||
public volatile boolean isRun = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
public static IReadWriteNet readWriteNet = null;
|
||||
private String ip;
|
||||
private int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcDdjRead(ConcurrentHashMap<String, MsgDdj> deviceDdjMap, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceDdjMap = deviceDdjMap;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
|
||||
public static int WriteToSSJ(String address, byte[] data) {
|
||||
int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, data), address);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
for (String key : deviceDdjMap.keySet()) {
|
||||
MsgDdj msgDdj = deviceDdjMap.get(key);
|
||||
if (msgDdj != null) {
|
||||
readPlcDdj(msgDdj);
|
||||
}
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
} else {
|
||||
reConnect();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>쳣<EFBFBD><ECB3A3><EFBFBD>˳<EFBFBD>ѭ<EFBFBD><D1AD>
|
||||
Thread.currentThread().interrupt(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣 " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void readPlcDdj(MsgDdj msgDdj) {
|
||||
OperateResultExOne<byte[]> read2 = readWriteNet.Read(msgDdj.getPlcDbReadAddress(), Convert.toShort("38"));
|
||||
String ddsx = "0";
|
||||
if (read2.IsSuccess) {
|
||||
ddsx = SoftBasic.ByteToHexString(read2.Content);
|
||||
msgDdj.setCzfs(ParseUtil.optInt(0, ddsx));
|
||||
msgDdj.setSbzt(ParseUtil.optInt(2, ddsx));
|
||||
msgDdj.setRwh(Convert.toLong(ParseUtil.optDInt(4, ddsx)));
|
||||
msgDdj.setHczt(ParseUtil.optInt(8, ddsx));
|
||||
msgDdj.setJdbz(ParseUtil.optInt(10, ddsx));
|
||||
msgDdj.setYph(ParseUtil.optInt(12, ddsx));
|
||||
msgDdj.setYlh(ParseUtil.optInt(14, ddsx));
|
||||
msgDdj.setYch(ParseUtil.optInt(16, ddsx));
|
||||
msgDdj.setMbph(ParseUtil.optInt(18, ddsx));
|
||||
msgDdj.setMblh(ParseUtil.optInt(20, ddsx));
|
||||
msgDdj.setMbch(ParseUtil.optInt(22, ddsx));
|
||||
msgDdj.setYxxf(ParseUtil.optInt(24, ddsx));
|
||||
msgDdj.setXtxh(ParseUtil.optInt(26, ddsx));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConnectServer() {
|
||||
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1500);
|
||||
try {
|
||||
siemensS7Net.setIpAddress(this.ip);
|
||||
siemensS7Net.setPort(this.port);
|
||||
siemensS7Net.setRack((byte) 0);
|
||||
siemensS7Net.setSlot((byte) 1);
|
||||
|
||||
OperateResult connect = siemensS7Net.ConnectServer();
|
||||
if (connect.IsSuccess) {
|
||||
setIsConnect(true);
|
||||
readWriteNet = siemensS7Net;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD> " + ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setIsConnect(boolean bflag) {
|
||||
if (!success) {
|
||||
success = bflag;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsConnect() {
|
||||
if (success) {
|
||||
return success;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reConnect() {
|
||||
closeServer();
|
||||
ConnectServer();
|
||||
log.info("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SSJ-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
if (readWriteNet != null) {
|
||||
readWriteNet.ConnectClose();
|
||||
}
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
/// <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
|
||||
public static int WritetoDDJ(String address, byte[] tsak) {
|
||||
/*int a = 0;
|
||||
if (readWriteNet != null) {
|
||||
a = HslRead.WriteResultRender(readWriteNet.Write(address, tsak), address);
|
||||
}
|
||||
return a;*/
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -8,19 +8,17 @@ import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.HslRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.domain.PlcConnectInfo;
|
||||
import com.ruoyi.common.domain.HslRead;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.schedule.plcRead.util.ParseUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.Offset;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public class PlcRead implements Runnable {
|
||||
public class PlcSsjRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceSsj> deviceSsjMap;
|
||||
public static ConcurrentHashMap<String, MsgDdj> deviceDdjMap;
|
||||
public volatile boolean isRun = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
@@ -29,9 +27,8 @@ public class PlcRead implements Runnable {
|
||||
private int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcRead(ConcurrentHashMap<String, DeviceSsj> deviceMap1,ConcurrentHashMap<String, MsgDdj> deviceMap2, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceSsjMap = deviceMap1;
|
||||
this.deviceDdjMap = deviceMap2;
|
||||
public PlcSsjRead(ConcurrentHashMap<String, DeviceSsj> deviceSsjMap, PlcConnectInfo plcConnectInfo) {
|
||||
this.deviceSsjMap = deviceSsjMap;
|
||||
this.ip = plcConnectInfo.getIp();
|
||||
this.port = plcConnectInfo.getPort();
|
||||
}
|
||||
@@ -14,8 +14,8 @@ import com.ruoyi.job.service.IMydoJobService;
|
||||
import com.ruoyi.queue.ddj.domain.DdjDeviceExecutionQueue;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueFinishService;
|
||||
import com.ruoyi.queue.ddj.service.IDdjDeviceExecutionQueueService;
|
||||
import com.ruoyi.schedule.plcRead.ddj.IsoTcpClientDDJ1;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ddj.PlcDdjRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -48,7 +48,8 @@ public class Ddj1Thread implements Runnable {
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
ddjDeviceExecutionQueueService = SpringUtils.getBean(IDdjDeviceExecutionQueueService.class);
|
||||
ddjDeviceExecutionQueueFinishService = SpringUtils.getBean(IDdjDeviceExecutionQueueFinishService.class);
|
||||
log.info("初始化服务 {},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService,mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,8 +61,8 @@ public class Ddj1Thread implements Runnable {
|
||||
if ("ddj".equals(type)) {
|
||||
for (String ddjCode : ddjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceDdjMap.containsKey(ddjCode)) {
|
||||
ddjTask(PlcRead.deviceDdjMap.get(ddjCode));
|
||||
if (PlcDdjRead.deviceDdjMap.containsKey(ddjCode)) {
|
||||
ddjTask(PlcDdjRead.deviceDdjMap.get(ddjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ddjCode);
|
||||
}
|
||||
@@ -213,7 +214,7 @@ public class Ddj1Thread implements Runnable {
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void InvalidMydoJob(Long rwh, Long id) {
|
||||
private void InvalidMydoJob(Long rwh, Integer id) {
|
||||
mydoJobService.InvalidMydoJob(rwh, id);
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ public class Ddj1Thread implements Runnable {
|
||||
* @param rwh 作业单号
|
||||
* @param id 作业单id
|
||||
*/
|
||||
private void ddjTaskFinish(Long rwh, Long id) {
|
||||
private void ddjTaskFinish(Long rwh, Integer id) {
|
||||
mydoJobService.ddjTaskFinish(rwh, id);
|
||||
}
|
||||
|
||||
@@ -233,7 +234,7 @@ public class Ddj1Thread implements Runnable {
|
||||
*
|
||||
* @param queue 堆垛机执行的队列
|
||||
*/
|
||||
private int issuedDDJTask(Long devId, DdjDeviceExecutionQueue queue) {
|
||||
private int issuedDDJTask(Integer devId, DdjDeviceExecutionQueue queue) {
|
||||
int taskNo = Convert.toInt(queue.getRwh());
|
||||
int yph = Convert.toInt(queue.getYph());
|
||||
int ylh = Convert.toInt(queue.getYlh());
|
||||
@@ -246,9 +247,9 @@ public class Ddj1Thread implements Runnable {
|
||||
int jym = Tools.getJYM(taskNo, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc);
|
||||
byte[] sendData = Tools.sendDataToDevice(taskNo, null, yph, ylh, ych, mbph, mblh, mbch, mlfs, xfwc, jym);
|
||||
if (devId==1){
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
return PlcDdjRead.WritetoDDJ("DB61.0", sendData);
|
||||
}else {
|
||||
return IsoTcpClientDDJ1.WritetoDDJ("DB61.0", sendData);
|
||||
return PlcDdjRead.WritetoDDJ("DB61.0", sendData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,8 +58,8 @@ public class Ddj2Thread implements Runnable {
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,8 +58,8 @@ public class Floor1SsjInOutThread implements Runnable {
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -51,8 +51,8 @@ public class Floor1SsjRoadWayThread implements Runnable {
|
||||
//退料入库 其它入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
@@ -65,8 +65,8 @@ public class Floor1SsjRoadWayThread implements Runnable {
|
||||
case "out":
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
outDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
outDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.ruoyi.job.domain.MydoJob;
|
||||
import com.ruoyi.queue.agv.domain.AgvQueue;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,8 +58,8 @@ public class Floor2SsjInOutThread implements Runnable {
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.queue.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcSsjRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -45,8 +45,8 @@ public class Floor2SsjRoadWayThread implements Runnable {
|
||||
//生产线入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceSsjMap.get(ssjCode));
|
||||
if (PlcSsjRead.deviceSsjMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcSsjRead.deviceSsjMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user