汪菘
3 years ago
21 changed files with 676 additions and 525 deletions
@ -0,0 +1,71 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_feeding; |
|||
|
|||
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; |
|||
|
|||
/** |
|||
* 海亮上料线体 |
|||
*/ |
|||
@Service |
|||
public class HaiLiangFeedingDefination implements OpcDeviceDriverDefination { |
|||
@Override |
|||
public String getDriverCode() { |
|||
return "hailiang_feeding"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "海亮包装项目-上料线体"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "海亮包装项目-上料线体"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return (new HaiLiangFeedingDeviceDriver()).setDevice(device).setDriverDefination(this); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return HaiLiangFeedingDeviceDriver.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, "心跳", "DB600.B0")); |
|||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); |
|||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); |
|||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<ItemDto> getWriteableItemDtos() { |
|||
return ItemProtocol.getWriteableItemDtos(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_feeding; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
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.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; |
|||
|
|||
/** |
|||
* 海亮-上料线体 |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class HaiLiangFeedingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { |
|||
|
|||
@Override |
|||
public Device getDevice() { |
|||
return this.device; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void execute() { |
|||
|
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk; |
|||
|
|||
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; |
|||
|
|||
/** |
|||
* 海亮裹膜机 |
|||
*/ |
|||
@Service |
|||
public class HaiLiangFeedingTrunkDefination implements OpcDeviceDriverDefination { |
|||
@Override |
|||
public String getDriverCode() { |
|||
return "hailiang_feeding_trunk"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "海亮包装项目-上料总线体"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "海亮包装项目-上料总线体"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return (new HaiLiangFeedingTrunkDeviceDriver()).setDevice(device).setDriverDefination(this); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return HaiLiangFeedingTrunkDeviceDriver.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, "心跳", "DB600.B0")); |
|||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); |
|||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); |
|||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<ItemDto> getWriteableItemDtos() { |
|||
return ItemProtocol.getWriteableItemDtos(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,31 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk; |
|||
|
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
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.opc.Device; |
|||
|
|||
/** |
|||
* 海亮-上料总线体 |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class HaiLiangFeedingTrunkDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { |
|||
protected ItemProtocol itemProtocol = new ItemProtocol(this); |
|||
|
|||
@Override |
|||
public Device getDevice() { |
|||
return this.device; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void execute() { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk; |
|||
|
|||
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 HaiLiangFeedingTrunkDeviceDriver driver; |
|||
|
|||
public ItemProtocol(HaiLiangFeedingTrunkDeviceDriver 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.getIntegeregerValue(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, "心跳", "DB51.B0")); |
|||
list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); |
|||
list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); |
|||
list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); |
|||
return list; |
|||
} |
|||
|
|||
public static List<ItemDto> getWriteableItemDtos() { |
|||
ArrayList list = new ArrayList(); |
|||
list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); |
|||
return list; |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,67 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_lettering; |
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto; |
|||
import org.nl.acs.device_driver.hailiang.hailiang_labeling.HaiLiangLabelingDeviceDriver; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
@Slf4j |
|||
public class ItemProtocol { |
|||
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 HaiLiangLabelingDeviceDriver driver; |
|||
|
|||
public ItemProtocol(HaiLiangLabelingDeviceDriver driver) { |
|||
this.driver = driver; |
|||
} |
|||
|
|||
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.getIntegeregerValue(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_mode, "工作状态", "V100.1", Boolean.valueOf(true))); |
|||
list.add(new ItemDto(item_action, "动作信号", "V100.0")); |
|||
list.add(new ItemDto(item_error, "报警信号", "VB101")); |
|||
return list; |
|||
} |
|||
|
|||
public static List<ItemDto> getWriteableItemDtos() { |
|||
ArrayList list = new ArrayList(); |
|||
list.add(new ItemDto(item_to_command, "作业命令", "V102.0", Boolean.valueOf(true))); |
|||
return list; |
|||
} |
|||
|
|||
} |
|||
|
@ -1,155 +0,0 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_packing; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
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.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; |
|||
|
|||
/** |
|||
* 海亮-包装机驱动 |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class HaiLiangPackingDeviceDriver 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; |
|||
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) { |
|||
} |
|||
if (action != last_action) { |
|||
} |
|||
if (error != last_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) { |
|||
jo.put("name", this.getDevice().getDevice_code()); |
|||
jo.put("status", "OPEN"); |
|||
|
|||
} else if (action == 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 writing(int command) { |
|||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|||
+ "." + org.nl.acs.device_driver.standard_inspect_site.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) { |
|||
|
|||
writing(Integer.parseInt(type)); |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,31 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_risking; |
|||
|
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
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.opc.Device; |
|||
|
|||
/** |
|||
* 海亮-裹膜线体 |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class HaiLiangRiskingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { |
|||
protected ItemProtocol itemProtocol = new ItemProtocol(this); |
|||
|
|||
@Override |
|||
public Device getDevice() { |
|||
return this.device; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void execute() { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_risking; |
|||
|
|||
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 HaiLiangRiskingDeviceDriver driver; |
|||
|
|||
public ItemProtocol(HaiLiangRiskingDeviceDriver 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.getIntegeregerValue(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, "心跳", "DB51.B0")); |
|||
list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); |
|||
list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); |
|||
list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); |
|||
return list; |
|||
} |
|||
|
|||
public static List<ItemDto> getWriteableItemDtos() { |
|||
ArrayList list = new ArrayList(); |
|||
list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); |
|||
return list; |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,71 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_strapping; |
|||
|
|||
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; |
|||
|
|||
/** |
|||
* 海亮包装项目-捆扎线体 |
|||
*/ |
|||
@Service |
|||
public class HaiLiangStrappingDefination implements OpcDeviceDriverDefination { |
|||
@Override |
|||
public String getDriverCode() { |
|||
return "hailiang_strapping"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverName() { |
|||
return "海亮包装项目-捆扎线体"; |
|||
} |
|||
|
|||
@Override |
|||
public String getDriverDescription() { |
|||
return "海亮包装项目-捆扎线体"; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceDriver getDriverInstance(Device device) { |
|||
return (new HaiLiangStrappingDeviceDriver()).setDevice(device).setDriverDefination(this); |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public Class<? extends DeviceDriver> getDeviceDriverType() { |
|||
return HaiLiangStrappingDeviceDriver.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, "心跳", "DB600.B0")); |
|||
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); |
|||
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); |
|||
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); |
|||
return list; |
|||
} |
|||
|
|||
@Override |
|||
public List<ItemDto> getWriteableItemDtos() { |
|||
return ItemProtocol.getWriteableItemDtos(); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_strapping; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.Data; |
|||
import lombok.RequiredArgsConstructor; |
|||
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.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; |
|||
|
|||
/** |
|||
* 海亮-捆扎线体 |
|||
*/ |
|||
@Slf4j |
|||
@Data |
|||
@RequiredArgsConstructor |
|||
public class HaiLiangStrappingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { |
|||
protected ItemProtocol itemProtocol = new ItemProtocol(this); |
|||
|
|||
@Override |
|||
public Device getDevice() { |
|||
return this.device; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void execute() { |
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,72 @@ |
|||
package org.nl.acs.device_driver.hailiang.hailiang_strapping; |
|||
|
|||
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 HaiLiangStrappingDeviceDriver driver; |
|||
|
|||
public ItemProtocol(HaiLiangStrappingDeviceDriver 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.getIntegeregerValue(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, "心跳", "DB51.B0")); |
|||
list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); |
|||
list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); |
|||
list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); |
|||
return list; |
|||
} |
|||
|
|||
public static List<ItemDto> getWriteableItemDtos() { |
|||
ArrayList list = new ArrayList(); |
|||
list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); |
|||
return list; |
|||
} |
|||
|
|||
} |
|||
|
Loading…
Reference in new issue