|
@ -1,10 +1,7 @@ |
|
|
package org.nl.acs.device_driver.inspect_site.modbus_inspect_site; |
|
|
package org.nl.acs.device_driver.inspect_site.modbus_inspect_site; |
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import lombok.Data; |
|
|
import lombok.Data; |
|
|
|
|
|
import lombok.EqualsAndHashCode; |
|
|
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.device_driver.standard_inspect.ReadUtil; |
|
@ -15,24 +12,18 @@ 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.instruction.service.InstructionService; |
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
import org.nl.acs.opc.Device; |
|
|
|
|
|
import org.nl.acs.opc.WcsConfig; |
|
|
|
|
|
import org.nl.acs.route.service.RouteLineService; |
|
|
import org.nl.acs.route.service.RouteLineService; |
|
|
import org.nl.acs.route.service.dto.RouteLineDto; |
|
|
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.dto.TaskDto; |
|
|
|
|
|
import org.nl.modules.system.util.CodeUtil; |
|
|
|
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.utils.SpringContextHolder; |
|
|
import org.nl.wql.core.bean.WQLObject; |
|
|
|
|
|
import org.openscada.opc.lib.da.Server; |
|
|
import org.openscada.opc.lib.da.Server; |
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.HashMap; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 检测站点驱动 |
|
|
* 检测站点驱动 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@EqualsAndHashCode(callSuper = true) |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Data |
|
|
@Data |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
@ -60,32 +51,30 @@ public class ModbusInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imple |
|
|
|
|
|
|
|
|
String device_code; |
|
|
String device_code; |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Device getDevice() { |
|
|
|
|
|
return this.device; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void execute() { |
|
|
public void execute() { |
|
|
try { |
|
|
try { |
|
|
device_code = this.getDeviceCode(); |
|
|
device_code = this.getDeviceCode(); |
|
|
|
|
|
|
|
|
heartbeat = this.itemProtocol.getHeartbeat(); |
|
|
heartbeat = this.itemProtocol.getHeartbeat(); |
|
|
|
|
|
if ("1".equals(device.getExtraValue().get("inspect_in_stocck"))) { |
|
|
move = this.itemProtocol.getMove(); |
|
|
move = this.itemProtocol.getMove(); |
|
|
|
|
|
} |
|
|
action = this.itemProtocol.getAction(); |
|
|
action = this.itemProtocol.getAction(); |
|
|
|
|
|
|
|
|
if (heartbeat != last_heartbeat) { |
|
|
if (heartbeat != last_heartbeat) { |
|
|
logServer.deviceItemValue(this.device_code, "move", String.valueOf(heartbeat)); |
|
|
logServer.deviceItemValue(this.device_code, "heartbeat", String.valueOf(heartbeat)); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_heartbeat + "->" + heartbeat); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号heartbeat:" + last_heartbeat + "->" + heartbeat); |
|
|
} |
|
|
} |
|
|
|
|
|
if ("1".equals(device.getExtraValue().get("inspect_in_stocck"))) { |
|
|
if (move != last_move) { |
|
|
if (move != last_move) { |
|
|
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); |
|
|
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
if (action != last_action) { |
|
|
if (action != last_action) { |
|
|
logServer.deviceItemValue(this.device_code, "move", String.valueOf(action)); |
|
|
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_action + "->" + action); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} catch (Exception var17) { |
|
|
} catch (Exception var17) { |
|
@ -106,8 +95,13 @@ public class ModbusInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imple |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void writing(int command) { |
|
|
public void writing(int command) { |
|
|
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
String to_command = this.getDevice().getOpc_server_code() + |
|
|
+ "." + ItemProtocol.item_to_command; |
|
|
"." + |
|
|
|
|
|
this.getDevice().getOpc_plc_code() + |
|
|
|
|
|
"." + |
|
|
|
|
|
this.getDevice().getDevice_code() + |
|
|
|
|
|
"." + |
|
|
|
|
|
ItemProtocol.item_to_command; |
|
|
|
|
|
|
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
@ -115,5 +109,6 @@ public class ModbusInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imple |
|
|
itemMap.put(to_command, command); |
|
|
itemMap.put(to_command, command); |
|
|
ReadUtil.write(itemMap, server); |
|
|
ReadUtil.write(itemMap, server); |
|
|
|
|
|
|
|
|
|
|
|
logServer.deviceExecuteLog(device_code, "", "", "to_command 写入 " + command); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|