三时纪smart200自动门驱动更新

This commit is contained in:
loujf
2022-11-21 14:57:33 +08:00
parent ccbd60dafa
commit 2aef517493
7 changed files with 701 additions and 2 deletions

View File

@@ -21,7 +21,9 @@ import org.nl.acs.device_driver.magic3.Magic3DeviceDriver;
import org.nl.acs.device_driver.ndxy_special_two.NdxySpecialTwoDeviceDriver;
import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver;
import org.nl.acs.device_driver.standard_autodoor_smart200.StandardAutodoorSmartDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site_smart200.StandardInspectSiteSmartDeviceDriver;
import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver;
import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver;
@@ -828,6 +830,7 @@ public class AgvServiceImpl implements AgvService {
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver;
YzjaSpecialDeviceDriver yzjaSpecialDeviceDriver;
StandardInspectSiteSmartDeviceDriver standardInspectSiteSmartDeviceDriver;
//请求进入
if ("onEntry".equals(type)) {
@@ -954,6 +957,27 @@ public class AgvServiceImpl implements AgvService {
}
}
}
if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteSmartDeviceDriver) {
standardInspectSiteSmartDeviceDriver = (StandardInspectSiteSmartDeviceDriver) addressdevice.getDeviceDriver();
//取货完成
if ("Load".equals(action)) {
if (standardInspectSiteSmartDeviceDriver.getMode() != 0 && standardInspectSiteSmartDeviceDriver.getMove() == 0) {
inst.setExecute_device_code(processingVehicle);
inst.setExecute_status("2");
standardInspectSiteSmartDeviceDriver.writing(2);
is_feedback = true;
}
//放货完成
} else if ("Unload".equals(action)) {
if (standardInspectSiteSmartDeviceDriver.getMode() != 0 && standardInspectSiteSmartDeviceDriver.getMove() > 0) {
inst.setExecute_device_code(address);
inst.setExecute_status("4");
standardInspectSiteSmartDeviceDriver.writing(3);
is_feedback = true;
}
}
}
if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver();
@@ -1365,6 +1389,7 @@ public class AgvServiceImpl implements AgvService {
break;
default:
StandardAutodoorDeviceDriver autodoor;
StandardAutodoorSmartDeviceDriver standardAutodoorSmartDeviceDriver;
LampThreecolorDeviceDriver lampThreecolorDeviceDriver;
Device doordevice = deviceAppService.findDeviceByCode(device);
if (ObjectUtil.isEmpty(doordevice)) {
@@ -1381,6 +1406,17 @@ public class AgvServiceImpl implements AgvService {
log.info("下发关门请求");
}
}
if (doordevice.getDeviceDriver() instanceof StandardAutodoorSmartDeviceDriver) {
standardAutodoorSmartDeviceDriver = (StandardAutodoorSmartDeviceDriver) doordevice.getDeviceDriver();
if (StrUtil.equals("open", param)) {
standardAutodoorSmartDeviceDriver.OpenOrClose("1");
log.info("下发开门请求");
} else if (StrUtil.equals("close", param)) {
standardAutodoorSmartDeviceDriver.OpenOrClose("2");
log.info("下发关门请求");
}
}
if (doordevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) {
lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) doordevice.getDeviceDriver();
if (StrUtil.equals("open", param)) {

View File

@@ -90,7 +90,9 @@ public enum DriverTypeEnum {
YZJA_SPECIAL(40, "yzja_special", "扬州晶澳专用", "conveyor"),
INSPECT_SITE_SMART(41, "standard_inspect_site_smart", "检测站点_smaet200", "conveyor");
INSPECT_SITE_SMART(41, "standard_inspect_site_smart", "检测站点_smart200", "conveyor"),
AUTODOORSMART(42, "standard_autodoor_smart", "标准版-自动门-samrt200", "autodoor");
//驱动索引
private int index;

View File

@@ -0,0 +1,72 @@
package org.nl.acs.device_driver.standard_autodoor_smart200;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_action = "action";
public static String item_error = "error";
public static String item_to_command = "to_command";
private StandardAutodoorSmartDeviceDriver driver;
public ItemProtocol(StandardAutodoorSmartDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegerValue(protocol);
if (value == null) {
log.error("读取错误!");
} else {
return value;
}
return 0;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "VW0"));
list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true)));
list.add(new ItemDto(item_action, "动作信号", "VW4"));
list.add(new ItemDto(item_error, "报警信号", "VW6"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "VW52", Boolean.valueOf(true)));
return list;
}
}

View File

@@ -0,0 +1,71 @@
package org.nl.acs.device_driver.standard_autodoor_smart200;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
/**
* 自动门samrt200驱动定义
*/
@Service
public class StandardAutodoorSmartDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_autodoor_smart";
}
@Override
public String getDriverName() {
return "标准版-自动门-smart";
}
@Override
public String getDriverDescription() {
return "标准版-自动门-smart";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardAutodoorSmartDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardAutodoorSmartDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return getReadableItemDtos2();
}
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "VW0"));
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "VW2", true));
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "VW4"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "VW6"));
return list;
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -0,0 +1,164 @@
package org.nl.acs.device_driver.standard_autodoor_smart200;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
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.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.Device;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.utils.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 自动门驱动smart200
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardAutodoorSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver {
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");
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
//放货准备锁
String putReadyLock = null;
//有货标记
protected boolean has_goods_tag = false;
String devicecode;
int mode = 0;
int action = 0;
int error = 0;
Boolean iserror = false;
int move = 0;
int task = 0;
int last_action = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
boolean hasVehicle = false;
boolean isReady = false;
protected int instruction_num = 0;
protected int instruction_num_truth = 0;
protected boolean hasGoods = false;
boolean isFold = false;
private String assemble_check_tag;
private Boolean sampleMode0;
private Boolean sampleMode3;
private Integer sampleError;
private Boolean sampleOnline;
protected String displayMessage = null;
public int display_message_time_out = 30000;
public Date display_message_time;
protected String current_stage_instruction_message;
protected String last_stage_instruction_message;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
boolean requireSucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
String device_code = this.getDevice().getDevice_code();
mode = this.itemProtocol.getMode();
action = this.itemProtocol.getAction();
error = this.itemProtocol.getError();
if (mode != last_mode) {
this.execute_log.log("设备:" + device_code + ",last_mode -> mode:" + last_mode + "->" + mode);
}
if (action != last_action) {
this.execute_log.log("设备:" + device_code + ",last_action -> action:" + last_action + "->" + action);
}
if (error != last_error) {
//this.execute_log.setContainer("");
this.execute_log.log("设备:" + device_code + ",last_error -> error:" + last_error + "->" + error);
}
last_action = action;
last_mode = mode;
last_error = error;
//message = StringFormatUtl.format("设备报警:{}", new Object[]{});
// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString();
}
public synchronized String getStatus() {
JSONObject jo = new JSONObject();
if (action == 1 && mode == 2) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "OPEN");
} else if (action == 2 && mode == 2) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "CLOSE");
} else {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "ERROR");
}
return jo.toString();
}
public void writeing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
log.info("下发PLC信号{},{}", to_command, command);
System.out.println("设备:" + devicecode + ",下发PLC信号" + to_command + ",value:" + command);
}
public synchronized void OpenOrClose(String type) {
//开门
if ("1".equals(type)) {
writeing(1);
} else {
writeing(2);
}
}
}