提升机代码 和 四向车
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.device.srgv.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 输送机对象 device_ssj
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceSrgv extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 设备唯一编码 */
|
||||
@Excel(name = "设备唯一编码")
|
||||
private String deviceCode ;
|
||||
|
||||
/** 设备名称 */
|
||||
@Excel(name = "设备名称")
|
||||
private String name ;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
private String type;
|
||||
|
||||
/** 设备IP */
|
||||
@Excel(name = "设备IP")
|
||||
private String ipAddress;
|
||||
|
||||
/** PLC读取地址 */
|
||||
@Excel(name = "PLC读取地址")
|
||||
private String plcDbReadAddress;
|
||||
|
||||
/** 0-F 1-T */
|
||||
@Excel(name = "0-F 1-T")
|
||||
private String isActive;
|
||||
|
||||
/** PLC写入地址 */
|
||||
@Excel(name = "PLC写入地址")
|
||||
private String plcDbWriteAddress;
|
||||
|
||||
/** 入库请求 */
|
||||
@Excel(name = "入库请求")
|
||||
private int rkqq;
|
||||
|
||||
/** 空闲 */
|
||||
@Excel(name = "空闲")
|
||||
private int kx;
|
||||
|
||||
/** 到位 */
|
||||
@Excel(name = "到位")
|
||||
private int dw;
|
||||
|
||||
/** 条码 */
|
||||
@Excel(name = "条码")
|
||||
private String trayCode;
|
||||
|
||||
/** 任务号 */
|
||||
@Excel(name = "任务号")
|
||||
private int taskNo;
|
||||
|
||||
@Excel(name = "异常")
|
||||
private int exception;
|
||||
|
||||
@Excel(name = "托盘尺寸")
|
||||
private int traySize;
|
||||
|
||||
@Excel(name="允许放货")
|
||||
private int allowPut;
|
||||
|
||||
@Excel(name="输送线模式 1-入库 2-出库")
|
||||
private int model;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.ruoyi.device.tsj.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 输送机对象 device_ssj
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-07-04
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceTsj extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** 设备唯一编码 */
|
||||
@Excel(name = "设备唯一编码")
|
||||
private String deviceCode ;
|
||||
|
||||
/** 设备名称 */
|
||||
@Excel(name = "设备名称")
|
||||
private String name ;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
private String type;
|
||||
|
||||
/** 设备IP */
|
||||
@Excel(name = "设备IP")
|
||||
private String ipAddress;
|
||||
|
||||
/** PLC读取地址 */
|
||||
@Excel(name = "PLC读取地址")
|
||||
private String plcDbReadAddress;
|
||||
|
||||
/** 0-F 1-T */
|
||||
@Excel(name = "0-F 1-T")
|
||||
private String isActive;
|
||||
|
||||
/** PLC写入地址 */
|
||||
@Excel(name = "PLC写入地址")
|
||||
private String plcDbWriteAddress;
|
||||
|
||||
/** 入库请求 */
|
||||
@Excel(name = "入库请求")
|
||||
private int rkqq;
|
||||
|
||||
/** 空闲 */
|
||||
@Excel(name = "空闲")
|
||||
private int kx;
|
||||
|
||||
/** 到位 */
|
||||
@Excel(name = "到位")
|
||||
private int dw;
|
||||
|
||||
/** 条码 */
|
||||
@Excel(name = "条码")
|
||||
private String trayCode;
|
||||
|
||||
/** 任务号 */
|
||||
@Excel(name = "任务号")
|
||||
private int taskNo;
|
||||
|
||||
@Excel(name = "异常")
|
||||
private int exception;
|
||||
|
||||
@Excel(name = "托盘尺寸")
|
||||
private int traySize;
|
||||
|
||||
@Excel(name="允许放货")
|
||||
private int allowPut;
|
||||
|
||||
@Excel(name="输送线模式 1-入库 2-出库")
|
||||
private int model;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ruoyi.schedule.plcRead.tsj;
|
||||
|
||||
import HslCommunication.Core.Net.IReadWriteNet;
|
||||
import HslCommunication.Core.Types.OperateResult;
|
||||
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
||||
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
||||
import com.ruoyi.common.domain.HslRead;
|
||||
import com.ruoyi.common.domain.PlcConnectInfo;
|
||||
import com.ruoyi.common.domain.SendData;
|
||||
import com.ruoyi.device.tsj.domain.DeviceTsj;
|
||||
import com.ruoyi.schedule.plcRead.util.Tools;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Slf4j
|
||||
public class PlcTsjRead implements Runnable {
|
||||
|
||||
public static ConcurrentHashMap<String, DeviceTsj> deviceTsjMap;
|
||||
public volatile boolean isRun = true;
|
||||
|
||||
public SiemensS7Net siemensS7Net = null;
|
||||
public static IReadWriteNet readWriteNet = null;
|
||||
private final String ip;
|
||||
private final int port;
|
||||
private boolean success = false;
|
||||
|
||||
public PlcTsjRead(ConcurrentHashMap<String, DeviceTsj> deviceTsjMap, PlcConnectInfo plcConnectInfo) {
|
||||
PlcTsjRead.deviceTsjMap = deviceTsjMap;
|
||||
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()) {
|
||||
int step = 20;
|
||||
int baseOffset = 0;
|
||||
for (String tsjCode : deviceTsjMap.keySet()) {
|
||||
DeviceTsj tsjDevice = deviceTsjMap.get(tsjCode);
|
||||
|
||||
}
|
||||
Thread.sleep(1000);
|
||||
} else {
|
||||
reConnect();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 + "连接失败 " + 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("重新连接 SSJ-PLC");
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
if (readWriteNet != null) {
|
||||
readWriteNet.ConnectClose();
|
||||
}
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
public static int writeToSsj(String address, String taskNo, int qx, int completed) {
|
||||
int jym = Tools.getJYM(Integer.parseInt(taskNo), qx, completed);
|
||||
SendData taskNoSendData = new SendData(Tools.INT, taskNo);
|
||||
SendData qxSendData = new SendData(Tools.INT, qx);
|
||||
SendData completedSendData = new SendData(Tools.INT, completed);
|
||||
SendData jymSendData = new SendData(Tools.INT, jym);
|
||||
byte[] bytes = Tools.sendData(taskNoSendData, qxSendData, completedSendData, jymSendData);
|
||||
return PlcTsjRead.WriteToSSJ(address, bytes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user