rev:netty ndc
This commit is contained in:
3
wcs/nladmin-system/.gitignore
vendored
3
wcs/nladmin-system/.gitignore
vendored
@@ -8,4 +8,5 @@
|
|||||||
/target/*
|
/target/*
|
||||||
/logPath_IS_UNDEFINED/
|
/logPath_IS_UNDEFINED/
|
||||||
/C:*
|
/C:*
|
||||||
/D:*
|
/D:*
|
||||||
|
/E:*
|
||||||
@@ -282,6 +282,12 @@
|
|||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>4.1.59.Final</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--Spring boot Redis-->
|
<!--Spring boot Redis-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package org.nl.acs.agv.server.dto;
|
package org.nl.acs.agv.server.dto;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
public class AgvDto implements Serializable {
|
public class AgvDto implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,4 +76,6 @@ public class AgvDto implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String transportOrder;
|
private String transportOrder;
|
||||||
|
|
||||||
|
public AgvDto() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
|||||||
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
//@Component
|
||||||
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ParamService paramService;
|
private ParamService paramService;
|
||||||
@@ -65,8 +65,8 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
public void autoRun() throws IOException {
|
public void autoRun() throws IOException {
|
||||||
try {
|
try {
|
||||||
String ip = paramService.findByCode(AcsConfig.ONEAGVURL).getValue();
|
String ip = paramService.findByCode(AcsConfig.ONEAGVURL).getValue();
|
||||||
int port = Integer.parseInt(paramService.findByCode(AcsConfig.ONEAGVPORT).getValue());
|
//int port = Integer.parseInt(paramService.findByCode(AcsConfig.ONEAGVPORT).getValue());
|
||||||
|
int port = 10001;
|
||||||
InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
|
InetSocketAddress socketAddress = new InetSocketAddress(ip, port);
|
||||||
|
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
@@ -145,7 +145,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
|||||||
}
|
}
|
||||||
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||||
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||||
agvNdcOneDeviceDriver.processSocket(arr);
|
//agvNdcOneDeviceDriver.processSocket(arr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ObjectUtil.isEmpty(data)) {
|
if (!ObjectUtil.isEmpty(data)) {
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package org.nl.acs.auto.run;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.Unpooled;
|
||||||
|
import io.netty.channel.*;
|
||||||
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||||
|
import org.nl.acs.opc.Device;
|
||||||
|
import org.nl.acs.opc.DeviceAppService;
|
||||||
|
import org.nl.config.ProtocolCodec;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.modules.system.service.ParamService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class OneNDCSocketConnectionAutoRun2 extends AbstractAutoRunnable {
|
||||||
|
@Autowired
|
||||||
|
private ParamService paramService;
|
||||||
|
@Autowired
|
||||||
|
private DeviceAppService deviceAppService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 这些phase值param代表小车Id
|
||||||
|
*/
|
||||||
|
private static final int[] PHASES_CAR_ID = {0x67, 0x70, 0x71, 0x72, 0x73, 0x74};
|
||||||
|
|
||||||
|
private Bootstrap consumer = new Bootstrap();
|
||||||
|
private static EventLoopGroup group = new NioEventLoopGroup();
|
||||||
|
private static Channel channel;
|
||||||
|
|
||||||
|
public OneNDCSocketConnectionAutoRun2() {
|
||||||
|
//this.autoRun();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCode() {
|
||||||
|
return OneNDCSocketConnectionAutoRun2.class.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "单工NDC在线连接";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void autoRun() {
|
||||||
|
try {
|
||||||
|
String ip = "127.0.0.1";//paramService.findByCode(AcsConfig.ONEAGVURL).getValue();
|
||||||
|
int port = 12301;//Integer.parseInt(paramService.findByCode(AcsConfig.ONEAGVPORT).getValue());
|
||||||
|
ChannelFuture boot = consumer.group(group)
|
||||||
|
//.option(ChannelOption.SO_BACKLOG, 1024)
|
||||||
|
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||||
|
.option(ChannelOption.TCP_NODELAY, true)
|
||||||
|
.channel(NioSocketChannel.class)
|
||||||
|
.handler(new ChannelInitializer() {
|
||||||
|
@Override
|
||||||
|
protected void initChannel(Channel ch) {
|
||||||
|
MsgHandler msgHandler = new MsgHandler();
|
||||||
|
// IdleStateHandler idleStateHandler = new IdleStateHandler(0, 5, 0, TimeUnit.SECONDS);
|
||||||
|
ch.pipeline()
|
||||||
|
.addLast(msgHandler);// 添加消息处理器
|
||||||
|
}
|
||||||
|
}).connect(ip, port).sync();
|
||||||
|
channel = boot.channel();
|
||||||
|
channel.closeFuture().sync();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("agv连接出现异常:{}", JSON.toJSONString(e));
|
||||||
|
if (channel != null) {
|
||||||
|
channel.flush();
|
||||||
|
channel.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
if (channel != null) {
|
||||||
|
channel.flush();
|
||||||
|
channel.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void write(byte[] b) {
|
||||||
|
try {
|
||||||
|
log.info("下发agv数据:" + Bytes2HexString(b));
|
||||||
|
channel.writeAndFlush(Unpooled.copiedBuffer(b));
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
log.info("再次下发agv数据:" + Bytes2HexString(b));
|
||||||
|
channel.writeAndFlush(Unpooled.copiedBuffer(b));
|
||||||
|
} catch (Exception e1) {
|
||||||
|
throw new BadRequestException(e1.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MsgHandler extends SimpleChannelInboundHandler<ByteBuf> {
|
||||||
|
@Override
|
||||||
|
@SneakyThrows
|
||||||
|
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) {
|
||||||
|
if (msg.isReadable()) {
|
||||||
|
byte[] data = null;
|
||||||
|
byte[] bytes = ProtocolCodec.readBody(msg);
|
||||||
|
if (bytes.length > 0) {
|
||||||
|
//执行阶段
|
||||||
|
Integer phase = (Byte.toUnsignedInt(bytes[16]) << 8) + Byte.toUnsignedInt(bytes[17]);
|
||||||
|
//agv任务号
|
||||||
|
Integer index = (Byte.toUnsignedInt(bytes[12]) << 8) + Byte.toUnsignedInt(bytes[13]);
|
||||||
|
//任务号
|
||||||
|
Integer ikey = (Byte.toUnsignedInt(bytes[26]) << 8) + Byte.toUnsignedInt(bytes[27]);
|
||||||
|
//站点号
|
||||||
|
Integer param = (Byte.toUnsignedInt(bytes[18]) << 8) + Byte.toUnsignedInt(bytes[19]);
|
||||||
|
//车号
|
||||||
|
byte carId = bytes[20];
|
||||||
|
Device device = null;
|
||||||
|
//Phase值为这些站点号param代表小车号,否则carId代表小车号
|
||||||
|
if (Arrays.stream(PHASES_CAR_ID).anyMatch(v -> v == phase)) {
|
||||||
|
device = deviceAppService.findDeviceByCode(Integer.toString(param));
|
||||||
|
} else {
|
||||||
|
device = deviceAppService.findDeviceByCode(Integer.toString(carId));
|
||||||
|
}
|
||||||
|
if (device != null) {
|
||||||
|
if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) {
|
||||||
|
AgvNdcOneDeviceDriver deviceDriver = (AgvNdcOneDeviceDriver) device.getDeviceDriver();
|
||||||
|
deviceDriver.processSocket(bytes, phase, index, ikey, Byte.toUnsignedInt(carId), param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -5,25 +5,13 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
|
||||||
import org.nl.acs.device.service.DeviceService;
|
|
||||||
import org.nl.acs.device_driver.DeviceDriver;
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
|
||||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
import org.nl.acs.opc.Device;
|
import org.nl.acs.opc.Device;
|
||||||
import org.nl.acs.opc.DeviceAppService;
|
|
||||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
|
||||||
import org.nl.acs.route.service.RouteLineService;
|
|
||||||
import org.nl.acs.task.service.TaskService;
|
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
|
||||||
import org.openscada.opc.lib.da.Server;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -35,18 +23,6 @@ import java.util.*;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
@Autowired
|
|
||||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
|
||||||
@Autowired
|
|
||||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
|
||||||
@Autowired
|
|
||||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
|
||||||
@Autowired
|
|
||||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
|
||||||
@Autowired
|
|
||||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
|
||||||
@Autowired
|
|
||||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
|
||||||
|
|
||||||
//工作模式
|
//工作模式
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
@@ -145,50 +121,15 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean exe_error() {
|
|
||||||
if (this.error == 0) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
log.debug("设备报警");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean exe_business() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
|
|
||||||
instructionService.finish(inst);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
+ "." + param;
|
+ "." + param;
|
||||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
|
||||||
//Server server = ReadUtil.getServer(opcservcerid);
|
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
itemMap.put(to_param, value);
|
itemMap.put(to_param, value);
|
||||||
// itemMap.put(to_param, Integer.parseInt(value));
|
|
||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executing(Server server, Map<String, Object> itemMap) {
|
|
||||||
this.control(itemMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void writing(int command) {
|
|
||||||
|
|
||||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
|
||||||
//Server server = ReadUtil.getServer(opcservcerid);
|
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
|
||||||
this.control(itemMap);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//将扩展表中的字符串数据转换成集合
|
//将扩展表中的字符串数据转换成集合
|
||||||
public List<String> getExtraDeviceCodes(String extraName) {
|
public List<String> getExtraDeviceCodes(String extraName) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import org.nl.acs.history.service.dto.DeviceErrorLogDto;
|
|||||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||||
import org.nl.acs.instruction.service.InstructionService;
|
import org.nl.acs.instruction.service.InstructionService;
|
||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
|
||||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||||
import org.nl.acs.opc.Device;
|
import org.nl.acs.opc.Device;
|
||||||
import org.nl.acs.order.service.dto.EalingOrderDto;
|
import org.nl.acs.order.service.dto.EalingOrderDto;
|
||||||
@@ -138,6 +137,7 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
|
|||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
message = "未联机";
|
message = "未联机";
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Instruction instruction = null;
|
Instruction instruction = null;
|
||||||
List toInstructions;
|
List toInstructions;
|
||||||
|
|
||||||
@@ -148,6 +148,7 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
String applyEmpty = ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("apply_task")) ? "false" : this.getDevice().getExtraValue().get("apply_task").toString();
|
String applyEmpty = ObjectUtil.isEmpty(this.getDevice().getExtraValue().get("apply_task")) ? "false" : this.getDevice().getExtraValue().get("apply_task").toString();
|
||||||
if (StrUtil.equals("true", applyEmpty)) {
|
if (StrUtil.equals("true", applyEmpty)) {
|
||||||
//申请空框任务
|
//申请空框任务
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
|||||||
@@ -405,6 +405,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
|
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
|||||||
@@ -231,6 +231,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void writing(String param, String value) {
|
public void writing(String param, String value) {
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
+ "." + param;
|
+ "." + param;
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.jinterop.dcom.common.JIException;
|
import org.jinterop.dcom.common.JIException;
|
||||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
|
||||||
import org.nl.acs.opc.*;
|
import org.nl.acs.opc.*;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
import org.nl.acs.udw.UnifiedDataAppService;
|
|
||||||
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
import org.nl.modules.lucene.service.LuceneExecuteLogService;
|
||||||
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
import org.nl.modules.lucene.service.dto.LuceneLogDto;
|
||||||
import org.nl.modules.wql.exception.WDKException;
|
import org.nl.modules.wql.exception.WDKException;
|
||||||
@@ -314,7 +310,6 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
*/
|
*/
|
||||||
public void writing(String key, String value) {
|
public void writing(String key, String value) {
|
||||||
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
|
||||||
String opcServerId = this.getDevice().getOpc_server_id();
|
String opcServerId = this.getDevice().getOpc_server_id();
|
||||||
Server server = ReadUtil.getServer(opcServerId);
|
Server server = ReadUtil.getServer(opcServerId);
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
@@ -322,7 +317,6 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
ReadUtil.write(itemMap, server);
|
ReadUtil.write(itemMap, server);
|
||||||
server.disconnect();
|
server.disconnect();
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发单个电气信号:" + key + ",下发电气信号值:" + value));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发单个电气信号:" + key + ",下发电气信号值:" + value));
|
||||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发单个电气信号:" + key + ",下发电气信号值:" + value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -333,7 +327,6 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
*/
|
*/
|
||||||
public void writing(Map<String, Object> map) {
|
public void writing(Map<String, Object> map) {
|
||||||
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
|
||||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||||
map.forEach((key, value) -> {
|
map.forEach((key, value) -> {
|
||||||
if (ObjectUtil.isNotEmpty(value)) {
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
@@ -342,7 +335,6 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
});
|
});
|
||||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
|
||||||
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package org.nl.config;
|
||||||
|
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @author ZZQ
|
||||||
|
* @Date 2024/1/3 17:18
|
||||||
|
*/
|
||||||
|
public class ProtocolCodec {
|
||||||
|
|
||||||
|
public static void readEmp(ByteBuf buf, int size){
|
||||||
|
buf.readBytes(size);
|
||||||
|
}
|
||||||
|
public static byte[] readBody(ByteBuf buf){
|
||||||
|
byte[] body = new byte[buf.readableBytes()];
|
||||||
|
buf.readBytes(body);
|
||||||
|
if ((Byte.toUnsignedInt(body[0])<<8) + Byte.toUnsignedInt(body[1]) == 0X87CD){
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
return new byte[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user