package com.zy.core.thread.impl;
|
|
import HslCommunication.Core.Types.OperateResult;
|
import HslCommunication.Core.Types.OperateResultExOne;
|
import HslCommunication.Profinet.Siemens.SiemensPLCS;
|
import HslCommunication.Profinet.Siemens.SiemensS7Net;
|
import com.alibaba.fastjson.JSON;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.core.common.DateUtils;
|
import com.core.common.SpringUtils;
|
import com.core.exception.CoolException;
|
import com.zy.asrs.entity.BasLift;
|
import com.zy.asrs.entity.DeviceDataLog;
|
import com.zy.asrs.service.BasLiftService;
|
import com.zy.asrs.service.DeviceDataLogService;
|
import com.zy.asrs.utils.Utils;
|
import com.zy.common.ExecuteSupport;
|
import com.zy.common.model.NavigateNode;
|
import com.zy.common.service.CommonService;
|
import com.zy.common.utils.LiftUtils;
|
import com.zy.common.utils.NavigatePositionConvert;
|
import com.zy.common.utils.RedisUtil;
|
import com.zy.core.News;
|
import com.zy.core.action.ForkLiftAction;
|
import com.zy.core.action.LiftAction;
|
import com.zy.core.cache.OutputQueue;
|
import com.zy.core.enums.ForkLiftTaskModeType;
|
import com.zy.core.enums.LiftCommandModeType;
|
import com.zy.core.enums.LiftProtocolStatusType;
|
import com.zy.core.enums.RedisKeyType;
|
import com.zy.core.model.CommandResponse;
|
import com.zy.core.model.LiftSlave;
|
import com.zy.core.model.command.LiftCommand;
|
import com.zy.core.model.protocol.LiftProtocol;
|
import com.zy.core.model.protocol.LiftStaProtocol;
|
import com.zy.core.thread.LiftThread;
|
import lombok.Data;
|
import lombok.extern.slf4j.Slf4j;
|
import java.text.MessageFormat;
|
import java.util.*;
|
|
@Slf4j
|
@SuppressWarnings("all")
|
public class NyLiftThread implements LiftThread {
|
|
private SiemensS7Net siemensS7Net;
|
private LiftSlave slave;
|
private LiftProtocol liftProtocol;
|
private RedisUtil redisUtil;
|
private List<LiftStaProtocol> liftStaProtocols = new ArrayList<>();
|
|
public static final HashMap<Integer, Integer> liftLevMap = new HashMap<Integer, Integer>() {{
|
put(1, 101);
|
put(2, 102);
|
put(3, 103);
|
put(4, 104);
|
put(5, 105);
|
put(6, 106);
|
put(7, 107);
|
put(8, 108);
|
put(9, 109);
|
}};
|
|
public static final HashMap<Integer, List<String>> liftNodeMap = new HashMap<Integer, List<String>>() {{
|
put(1, new ArrayList<String>(){{add("0200201");add("0200101");}});
|
put(2, new ArrayList<String>(){{add("0200202");add("0200102");}});
|
put(3, new ArrayList<String>(){{add("0200203");add("0200103");}});
|
put(4, new ArrayList<String>(){{add("0200204");add("0200104");}});
|
put(5, new ArrayList<String>(){{add("0200205");add("0200105");}});
|
put(6, new ArrayList<String>(){{add("0200206");add("0200106");}});
|
put(7, new ArrayList<String>(){{add("0200207");add("0200107");}});
|
put(8, new ArrayList<String>(){{add("0200208");add("0200108");}});
|
put(9, new ArrayList<String>(){{add("0200209");add("0200109");}});
|
}};
|
|
public NyLiftThread(LiftSlave slave, RedisUtil redisUtil) {
|
this.slave = slave;
|
this.redisUtil = redisUtil;
|
//初始化站点
|
for (LiftSlave.Sta sta : this.slave.getSta()) {
|
LiftStaProtocol liftStaProtocol = new LiftStaProtocol();
|
liftStaProtocol.setStaNo(sta.getStaNo());//站点号
|
liftStaProtocol.setLev(sta.getLev());//站点楼层
|
String locNo = Utils.getLocNo(this.slave.getStaRow(), this.slave.getStaBay(), sta.getLev());
|
liftStaProtocol.setLocNo(locNo);//站点库位号
|
liftStaProtocol.setLiftNo(sta.getLiftNo());//提升机号
|
liftStaProtocols.add(liftStaProtocol);
|
}
|
}
|
|
@Override
|
public void run() {
|
News.info("{}号提升机线程启动", slave.getId());
|
this.connect();
|
while (true) {
|
try {
|
read();
|
Thread.sleep(500);
|
execute();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
}
|
|
private void execute() {
|
LiftAction liftAction = SpringUtils.getBean(LiftAction.class);
|
if (liftAction == null) {
|
return;
|
}
|
|
Object object = redisUtil.get(RedisKeyType.LIFT_FLAG.key + slave.getId());
|
if (object == null) {
|
return;
|
}
|
|
Integer taskNo = Integer.valueOf(String.valueOf(object));
|
if (taskNo != 0) {
|
//存在任务需要执行
|
boolean result = liftAction.executeWork(slave.getId(), taskNo);
|
}
|
}
|
|
@Override
|
public List<LiftStaProtocol> getLiftStaProtocols() {
|
return this.liftStaProtocols;
|
}
|
|
private void read() {
|
try {
|
readStatus();
|
|
//提升机处于运行状态,将标记置为true
|
if (liftProtocol.getRun()) {
|
liftProtocol.setPakMk(true);
|
}
|
} catch (Exception e) {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
}
|
}
|
|
private void readStatus() {
|
try {
|
//获取提升机数据
|
OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB82.4.0", (short) 10);
|
if (result1.IsSuccess) {
|
if (null == liftProtocol) {
|
liftProtocol = new LiftProtocol();
|
liftProtocol.setLiftNo(slave.getId());
|
liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
|
|
InnerLiftExtend innerLiftExtend = new InnerLiftExtend();
|
liftProtocol.setExtend(innerLiftExtend);
|
}
|
|
//----------读取提升机状态-----------
|
//读取4.0-4.7数据
|
boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result1.Content, 0, 1);
|
//读取5.0-5.7数据
|
boolean[] status2 = siemensS7Net.getByteTransform().TransBool(result1.Content, 1, 1);
|
//模式
|
liftProtocol.setModel(status1[0]);
|
//忙闲
|
liftProtocol.setRun(!status1[1]);
|
//前超限
|
liftProtocol.setFrontOverrun(status1[4]);
|
//后超限
|
liftProtocol.setBackOverrun(status1[5]);
|
//左超限
|
liftProtocol.setLeftOverrun(status1[6]);
|
//右超限
|
liftProtocol.setRightOverrun(status1[7]);
|
//超高
|
liftProtocol.setOverHeight(status2[0]);
|
//超重
|
liftProtocol.setOverWeight(status2[1]);
|
//有托盘
|
liftProtocol.setHasTray(status2[5]);
|
//有小车
|
liftProtocol.setHasCar(status2[6]);
|
//设备故障
|
liftProtocol.setErrorCode(status2[7]?"1":"0");
|
//目的地址
|
liftProtocol.setDistAddress(siemensS7Net.getByteTransform().TransInt16(result1.Content, 4));
|
//已完成任务号
|
liftProtocol.setCompleteTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 6)));
|
//当前楼层
|
short lev = siemensS7Net.getByteTransform().TransInt16(result1.Content, 8);
|
liftProtocol.setLev((int) lev);
|
|
//************补充扩展字段*************
|
InnerLiftExtend liftExtend = (InnerLiftExtend) liftProtocol.getExtend();
|
//任务号
|
liftExtend.setLiftTaskNo(String.valueOf(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2)));
|
liftProtocol.setExtend(liftExtend);
|
|
boolean ready = true;
|
if (!liftProtocol.getModel() || liftProtocol.getRun()) {
|
ready = false;
|
}
|
liftProtocol.setReady(ready);//就绪状态
|
|
|
}else {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】{1}读取提升机状态信息失败", DateUtils.convert(new Date()), slave.getId()));
|
throw new CoolException(MessageFormat.format( "读取提升机状态信息失败 ===>> [id:{0}] [ip:{1}] [port:{2}]", slave.getId(), slave.getIp(), slave.getPort()));
|
}
|
Thread.sleep(200);
|
|
//获取提升机站点数据
|
OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB82.14.0", (short) (10 * liftStaProtocols.size()));
|
if (result1.IsSuccess) {
|
for (int i = 0; i < this.liftStaProtocols.size(); i++) {
|
LiftStaProtocol liftStaProtocol = liftStaProtocols.get(i);
|
int i1 = 0 + (i * 10);
|
int i2 = 1 + (i * 10);
|
//读取x4.0-x4.7数据
|
boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result2.Content, i1, 1);
|
//读取x5.0-x5.7数据
|
boolean[] status2 = siemensS7Net.getByteTransform().TransBool(result2.Content, i2, 1);
|
//模式
|
liftStaProtocol.setModel(status1[0]);
|
//忙闲
|
liftStaProtocol.setBusy(!status1[1]);
|
//有托盘
|
liftStaProtocol.setHasTray(status1[2]);
|
//前超限
|
liftStaProtocol.setFrontOverrun(status1[4]);
|
//后超限
|
liftStaProtocol.setBackOverrun(status1[5]);
|
//左超限
|
liftStaProtocol.setLeftOverrun(status1[6]);
|
//右超限
|
liftStaProtocol.setRightOverrun(status1[7]);
|
//超高
|
liftStaProtocol.setOverHeight(status2[0]);
|
//超重
|
liftStaProtocol.setOverWeight(status2[1]);
|
//有小车
|
liftStaProtocol.setHasCar(status2[6]);
|
//设备故障
|
liftStaProtocol.setDeviceError(status2[7]);
|
//任务号
|
liftStaProtocol.setTaskNo(siemensS7Net.getByteTransform().TransInt16(result2.Content, 2));
|
//已完成任务号
|
liftStaProtocol.setCompleteTaskNo(siemensS7Net.getByteTransform().TransInt16(result2.Content, 6));
|
}
|
}
|
|
if (System.currentTimeMillis() - liftProtocol.getDeviceDataLog() > 1000 * 5) {
|
//采集时间超过5s,保存一次数据记录
|
//保存数据记录
|
DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class);
|
DeviceDataLog deviceDataLog = new DeviceDataLog();
|
deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result1.Content));
|
deviceDataLog.setWcsData(JSON.toJSONString(liftProtocol));
|
deviceDataLog.setType("lift");
|
deviceDataLog.setDeviceNo(slave.getId());
|
deviceDataLog.setCreateTime(new Date());
|
deviceDataLogService.insert(deviceDataLog);
|
|
//更新采集时间
|
liftProtocol.setDeviceDataLog(System.currentTimeMillis());
|
}
|
|
//将提升机状态保存至数据库
|
BasLiftService basLiftService = SpringUtils.getBean(BasLiftService.class);
|
BasLift basLift = basLiftService.selectOne(new EntityWrapper<BasLift>()
|
.eq("lift_no", slave.getId()));
|
if (basLift == null) {
|
basLift = new BasLift();
|
//提升机号
|
basLift.setLiftNo(liftProtocol.getLiftNo());
|
basLift.setStatus(1);
|
basLiftService.insert(basLift);
|
}
|
//任务号
|
basLift.setWrkNo(liftProtocol.getTaskNo());
|
//修改时间
|
basLift.setUpdateTime(new Date());
|
//设备状态
|
basLift.setDeviceStatus(JSON.toJSONString(liftProtocol));
|
if (basLiftService.updateById(basLift)) {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), liftProtocol.getLiftNo()));
|
}
|
|
} catch (Exception e) {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
}
|
}
|
|
@Override
|
public LiftProtocol getStatus() {
|
return getStatus(true);
|
}
|
|
@Override
|
public LiftProtocol getStatus(boolean clone) {
|
if (this.liftProtocol == null) {
|
return null;
|
}
|
return clone ? this.liftProtocol.clone() : this.liftProtocol;
|
}
|
|
@Override
|
public CommandResponse move(LiftCommand command) {
|
return write(command);
|
}
|
|
@Override
|
public CommandResponse palletInOut(LiftCommand command) {
|
return write(command);
|
}
|
|
private CommandResponse write(LiftCommand command) {
|
CommandResponse response = new CommandResponse(false);
|
if (null == command) {
|
News.error("提升机写入命令为空");
|
response.setMessage("提升机写入命令为空");
|
return response;
|
}
|
|
List<Short> shorts = JSON.parseArray(command.getBody(), Short.class);
|
short[] array = new short[shorts.size()];//获取命令报文
|
for (int i = 0; i < shorts.size(); i++) {
|
array[i] = shorts.get(i);
|
}
|
|
if (command.getTaskNo() != null) {
|
array[3] = command.getTaskNo().shortValue();
|
}
|
|
OperateResult result = siemensS7Net.Write("DB83.0", array);
|
if (result != null && result.IsSuccess) {
|
liftProtocol.setSendTime(System.currentTimeMillis());//指令下发时间
|
News.info("提升机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
|
response.setMessage(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
|
response.setResult(true);
|
return response;
|
} else {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
News.error("写入提升机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
|
response.setMessage(MessageFormat.format("【{0}】写入提升机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}],次数:{}", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
return response;
|
}
|
}
|
|
@Override
|
public CommandResponse lock(LiftCommand command) {
|
return new CommandResponse(true);
|
}
|
|
@Override
|
public CommandResponse unlock(LiftCommand command) {
|
return new CommandResponse(true);
|
}
|
|
@Override
|
public CommandResponse reset(LiftCommand command) {
|
return new CommandResponse(false);
|
}
|
|
@Override
|
public boolean isIdle() {
|
// 判断提升机是否自动、就绪、空闲
|
if (this.liftProtocol.getModel()
|
&& this.liftProtocol.getTaskNo() == 0
|
&& !this.liftProtocol.getRun()
|
&& this.liftProtocol.getReady()
|
&& this.liftProtocol.getPakMk()
|
&& this.liftProtocol.getErrorCode().equals("0")
|
&& (this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.IDLE)
|
|| this.liftProtocol.getProtocolStatusType().equals(LiftProtocolStatusType.WAITING))
|
) {
|
return true;
|
}
|
return false;
|
}
|
|
@Override
|
public boolean isDeviceIdle() {
|
return isDeviceIdle(null);
|
}
|
|
@Override
|
public boolean isDeviceIdle(ExecuteSupport support) {
|
if (null != support) {
|
Boolean judgement = support.judgement();
|
if (judgement != null && !judgement) {
|
return true;
|
}
|
}
|
|
// 判断提升机是否自动、就绪、空闲
|
if (this.liftProtocol.getModel()
|
&& !this.liftProtocol.getRun()
|
&& this.liftProtocol.getReady()
|
&& this.liftProtocol.getErrorCode().equals("0")
|
) {
|
return true;
|
}
|
return false;
|
}
|
|
@Override
|
public synchronized boolean setProtocolStatus(LiftProtocolStatusType status) {
|
this.liftProtocol.setProtocolStatus(status);
|
return true;
|
}
|
|
@Override
|
public synchronized boolean setSyncTaskNo(Integer taskNo) {
|
this.liftProtocol.setTaskNo(taskNo);
|
return true;
|
}
|
|
@Override
|
public boolean isLock(ExecuteSupport support) {
|
if (support != null) {
|
return support.judgement();
|
}
|
return true;
|
}
|
|
@Override
|
public int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type) {
|
int deviceTaskNo = taskNo;
|
try {
|
CommonService commonService = SpringUtils.getBean(CommonService.class);
|
deviceTaskNo = commonService.getWorkNo(8);
|
} catch (Exception e) {
|
return taskNo;
|
}
|
return deviceTaskNo;
|
}
|
|
@Override
|
public String getLiftLocNo(int lev) {
|
return Utils.getLocNo(slave.getRow(), slave.getBay(), lev);
|
}
|
|
@Override
|
public String getLiftStandByLocNo(int lev, boolean in) {
|
if (in) {
|
return Utils.getLocNo(slave.getStandByInRow(), slave.getStandByInBay(), lev);
|
}
|
return Utils.getLocNo(slave.getStandByOutRow(), slave.getStandByOutBay(), lev);
|
}
|
|
@Override
|
public List<NavigateNode> getLiftStaNodes(int lev) {
|
List<NavigateNode> targetNodes = new ArrayList<>();
|
List<String> list = liftNodeMap.get(lev);
|
NavigateNode targetNode = NavigatePositionConvert.locNoToNode(list.get(0));//目标节点
|
NavigateNode targetLastNode = NavigatePositionConvert.locNoToNode(list.get(1));//目标节点前一站
|
targetNodes.add(targetNode);
|
targetNodes.add(targetLastNode);
|
return targetNodes;
|
}
|
|
@Override
|
public Integer getLevToStaNo(int lev) {
|
return liftLevMap.get(lev);
|
}
|
|
@Override
|
public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
|
/**
|
* 任务类型
|
1=移托盘;升降机将源站台托盘移到目标站台
|
2=换层,升降机移到目标层,等待
|
3=入库托盘,升降机将源站台托盘移到目标层数;
|
4=出库托盘,升降机将源站台托盘移到目标站台
|
*/
|
short taskMode = 2;
|
|
Integer sourceData = liftLevMap.get(sourceLev);
|
Integer targetData = liftLevMap.get(targetLev);
|
|
// 开始任务
|
short[] array = new short[4];
|
//任务类型
|
array[0] = taskMode;
|
//源站台编号
|
array[1] = sourceData.shortValue();
|
//目标站台编号
|
array[2] = targetData.shortValue();
|
//任务号
|
array[3] = taskNo.shortValue();
|
|
LiftCommand command = new LiftCommand();
|
command.setLiftNo(slave.getId());
|
command.setBody(JSON.toJSONString(array));
|
command.setMode(mode.id);
|
command.setOriginLev(sourceLev);
|
command.setTargetLev(targetLev);
|
|
ArrayList<LiftCommand> list = new ArrayList<>();
|
list.add(command);
|
return list;
|
}
|
|
@Override
|
public List<LiftCommand> getMoveWithShuttleCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
|
/**
|
* 任务类型
|
1=移托盘;升降机将源站台托盘移到目标站台
|
2=换层,升降机移到目标层,等待
|
3=入库托盘,升降机将源站台托盘移到目标层数;
|
4=出库托盘,升降机将源站台托盘移到目标站台
|
5=车和托盘升降
|
*/
|
short taskMode = 5;
|
|
Integer sourceData = liftLevMap.get(sourceLev);
|
Integer targetData = liftLevMap.get(targetLev);
|
|
// 开始任务
|
short[] array = new short[4];
|
//任务类型
|
array[0] = taskMode;
|
//源站台编号
|
array[1] = sourceData.shortValue();
|
//目标站台编号
|
array[2] = targetData.shortValue();
|
//任务号
|
array[3] = taskNo.shortValue();
|
|
LiftCommand command = new LiftCommand();
|
command.setLiftNo(slave.getId());
|
command.setBody(JSON.toJSONString(array));
|
command.setMode(mode.id);
|
command.setOriginLev(sourceLev);
|
command.setTargetLev(targetLev);
|
|
ArrayList<LiftCommand> list = new ArrayList<>();
|
list.add(command);
|
return list;
|
}
|
|
@Override
|
public List<LiftCommand> getPalletInCommand(Integer taskNo, Integer sourceLev, Integer targetLev) {
|
/**
|
* 任务类型
|
1=移托盘;升降机将源站台托盘移到目标站台
|
2=换层,升降机移到目标层,等待
|
3=入库托盘,升降机将源站台托盘移到目标层数;
|
4=出库托盘,升降机将源站台托盘移到目标站台
|
*/
|
short taskMode = 3;
|
|
// 开始任务
|
short[] array = new short[4];
|
//任务类型
|
array[0] = taskMode;
|
//源站台编号
|
array[1] = sourceLev.shortValue();
|
//目标站台编号
|
array[2] = targetLev.shortValue();
|
//任务号
|
array[3] = taskNo.shortValue();
|
|
LiftCommand command = new LiftCommand();
|
command.setLiftNo(slave.getId());
|
command.setBody(JSON.toJSONString(array));
|
command.setMode(LiftCommandModeType.PALLET_IN.id);
|
command.setOriginLev(sourceLev);
|
command.setTargetLev(targetLev);
|
|
ArrayList<LiftCommand> list = new ArrayList<>();
|
list.add(command);
|
return list;
|
}
|
|
@Override
|
public List<LiftCommand> getPalletOutCommand(Integer taskNo, Integer sourceLev, Integer targetLev) {
|
/**
|
* 任务类型
|
1=移托盘;升降机将源站台托盘移到目标站台
|
2=换层,升降机移到目标层,等待
|
3=入库托盘,升降机将源站台托盘移到目标层数;
|
4=出库托盘,升降机将源站台托盘移到目标站台
|
*/
|
short taskMode = 4;
|
|
// 开始任务
|
short[] array = new short[4];
|
//任务类型
|
array[0] = taskMode;
|
//源站台编号
|
array[1] = sourceLev.shortValue();
|
//目标站台编号
|
array[2] = targetLev.shortValue();
|
//任务号
|
array[3] = taskNo.shortValue();
|
|
LiftCommand command = new LiftCommand();
|
command.setLiftNo(slave.getId());
|
command.setBody(JSON.toJSONString(array));
|
command.setMode(LiftCommandModeType.PALLET_OUT.id);
|
command.setOriginLev(sourceLev);
|
command.setTargetLev(targetLev);
|
|
ArrayList<LiftCommand> list = new ArrayList<>();
|
list.add(command);
|
return list;
|
}
|
|
@Override
|
public List<LiftCommand> getLockCommand(Integer taskNo, Boolean lock) {
|
return null;
|
}
|
|
@Override
|
public List<LiftCommand> getShuttleSignalCommand(Integer taskNo, Boolean signal) {
|
return null;
|
}
|
|
@Override
|
public boolean connect() {
|
boolean result = false;
|
//-------------------------提升机连接方法------------------------//
|
siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
|
OperateResult connect = siemensS7Net.ConnectServer();
|
if(connect.IsSuccess){
|
result = true;
|
OutputQueue.LIFT.offer(MessageFormat.format( "【{0}】提升机plc连接成功 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
log.info("提升机plc连接成功 ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort());
|
} else {
|
OutputQueue.LIFT.offer(MessageFormat.format("【{0}】提升机plc连接失败!!! ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
|
log.error("提升机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}] ", slave.getId(), slave.getIp(), slave.getPort());
|
}
|
siemensS7Net.ConnectClose();
|
//-------------------------提升机连接方法------------------------//
|
return result;
|
}
|
|
@Override
|
public void close() {
|
siemensS7Net.ConnectClose();
|
}
|
|
/**
|
* 扩展字段
|
*/
|
@Data
|
private class InnerLiftExtend {
|
|
/**
|
* 提升机内部工作号
|
*/
|
private String liftTaskNo;
|
|
}
|
|
}
|