This commit is contained in:
psh
2023-09-04 15:25:06 +08:00
parent a1a20de73c
commit c9b0f495dd
4 changed files with 81 additions and 149 deletions

View File

@@ -11,21 +11,18 @@ import java.util.List;
@Data
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_ioaction = "ioaction";
public static String item_error = "error";
public static String item_task = "task";
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
public static String item_weight = "weight";
public static String item_product_code = "product_code";
public static String item_batch_code = "batch_code";
public static String item_product_specifications = "product_specifications";
public static String item_time = "time";
public static String item_year = "year";
public static String item_month = "month";
public static String item_day = "day";
public static String item_hour = "hour";
public static String item_minute = "minute";
public static String item_second = "second";
private StandardInspectSiteSmartDeviceDriver driver;
@@ -33,30 +30,6 @@ public class ItemProtocol {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getIoaction() {
return this.getOpcIntegerValue(item_ioaction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
public String getWeight() {
return this.getOpcStringValue(item_weight);
}
@@ -73,22 +46,31 @@ public class ItemProtocol {
return this.getOpcStringValue(item_product_specifications);
}
public String getTime() {
return this.getOpcStringValue(item_time);
public String getYear() {
return this.getOpcStringValue(item_year);
}
public String getMonth() {
return this.getOpcStringValue(item_month);
}
public String getDay() {
return this.getOpcStringValue(item_day);
}
public String getHour() {
return this.getOpcStringValue(item_hour);
}
public String getMinute() {
return this.getOpcStringValue(item_minute);
}
public String getSecond() {
return this.getOpcStringValue(item_second);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getToTarget() {
return this.getOpcIntegerValue(item_to_target);
}
public int getToTask() {
return this.getOpcIntegerValue(item_to_task);
}
//是否有货
public int hasGoods(int move) {
@@ -123,25 +105,23 @@ public class ItemProtocol {
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_move, "光电开关信号", "VW4"));
list.add(new ItemDto(item_action, "动作信号", "VW8"));
list.add(new ItemDto(item_error, "报警信号", "VW12"));
list.add(new ItemDto(item_task, "任务号", "VD14"));
list.add(new ItemDto(item_product_code, "产品名称", "VW18"));
list.add(new ItemDto(item_batch_code, "批次号", "VW20", Boolean.valueOf(true)));
list.add(new ItemDto(item_product_specifications, "产品规格", "VW40"));
list.add(new ItemDto(item_weight, "重量", "VW50"));
list.add(new ItemDto(item_time, "时间", "VW60"));
list.add(new ItemDto(item_product_code, "产品名称", "VB3251 "));
list.add(new ItemDto(item_batch_code, "批次号", "VB3264"));
list.add(new ItemDto(item_product_specifications, "产品规格", "VB3277"));
list.add(new ItemDto(item_weight, "重量", "VD380"));
list.add(new ItemDto(item_year, "", "VB1056"));
list.add(new ItemDto(item_month, "", "VB1057"));
list.add(new ItemDto(item_day, "", "VB1058"));
list.add(new ItemDto(item_hour, "", "VB1059"));
list.add(new ItemDto(item_minute, "", "VB1060"));
list.add(new ItemDto(item_second, "", "VB1061"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "VW52", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "目标站", "VW54"));
list.add(new ItemDto(item_to_task, "任务号", "VD58"));
return list;
}

View File

@@ -43,15 +43,15 @@ import java.util.Map;
@RequiredArgsConstructor
public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
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
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
String container;
String container_type_desc;
@@ -160,9 +160,22 @@ public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDrive
private String last_product_specifications;
// 时间
private String year;
private String last_year;
private String month;
private String last_month;
private String day;
private String last_day;
private String hour;
private String last_hour;
private String minute;
private String last_minute;
private String second;
private String last_second;
private String time;
private String last_time;
@Override
public Device getDevice() {
return this.device;
@@ -174,16 +187,18 @@ public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDrive
String message = null;
try {
String device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
error = this.itemProtocol.getError();
move = this.itemProtocol.getMove();
task = this.itemProtocol.getTask();
hasGoods = this.itemProtocol.getMove();
weight = this.itemProtocol.getWeight();
product_code = this.itemProtocol.getProductCode();
batch_code = this.itemProtocol.getBatchCode();
product_specifications = this.itemProtocol.getProductSpecifications();
time = this.itemProtocol.getTime();
year = this.itemProtocol.getYear();
month = this.itemProtocol.getMonth();
day = this.itemProtocol.getDay();
hour = this.itemProtocol.getHour();
minute = this.itemProtocol.getMinute();
second = this.itemProtocol.getSecond();
time= new StringBuilder().append(year).append(month).append(day)
.append(hour).append(minute).append(second).toString();
if (mode != last_mode) {
if (mode == 5) {
@@ -342,17 +357,6 @@ public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDrive
break;
}
switch (flag) {
//取货完成
case 1:
writing(2);
return;
//放货完成
case 2:
writing(3);
return;
}
}
last_mode = mode;
@@ -363,8 +367,15 @@ public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDrive
last_product_code = product_code;
last_product_specifications = product_specifications;
last_batch_code = batch_code;
last_year = year;
last_month = month;
last_day = day;
last_hour = hour;
last_minute = minute;
last_second = second;
last_time = time;
}
@@ -397,70 +408,11 @@ public class StandardInspectSiteSmartDeviceDriver extends AbstractOpcDeviceDrive
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
if (appendMessage == null) {
appendMessage = "";
}
if (instruction != null) {
instruction_num = Integer.parseInt(instruction.getInstruction_code());
}
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, 1);
itemMap.put(to_task, instruction_num);
ReadUtil.write(itemMap, server);
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(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);
}
public void writing(int type, int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + ItemProtocol.item_to_task;
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
if (type == 1) {
itemMap.put(to_command, command);
} else if (type == 2) {
itemMap.put(to_target, command);
} else if (type == 3) {
itemMap.put(to_task, command);
}
ReadUtil.write(itemMap, server);
}
public boolean instruction_require(String container_code) {
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
}