代码更新
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
package org.nl.acs.device_driver;
|
package org.nl.acs.device_driver;
|
||||||
|
|
||||||
public interface ScannerDeviceDriver extends DeviceDriver {
|
public interface ScannerDeviceDriver extends DeviceDriver {
|
||||||
void writeBarcode(String var1) throws Exception;
|
void writeBarcode(String var1) ;
|
||||||
|
|
||||||
void cleanBarcode() throws Exception;
|
void cleanBarcode() ;
|
||||||
|
|
||||||
String readBarcode() throws Exception;
|
String readBarcode();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
Boolean requireSucess = false;
|
Boolean requireSucess = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
|
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -183,7 +183,7 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
public synchronized boolean instruction_require(){
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -264,7 +264,13 @@ public class CargoLiftConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
task.setTask_status("1");
|
task.setTask_status("1");
|
||||||
taskserver.update(task);
|
taskserver.update(task);
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
mode = this.itemProtocol.getMode();
|
mode = this.itemProtocol.getMode();
|
||||||
@@ -512,7 +512,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
/**
|
/**
|
||||||
* 请求指令
|
* 请求指令
|
||||||
*/
|
*/
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
public synchronized boolean instruction_require() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -632,7 +632,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
taskdto.setTask_status("1");
|
taskdto.setTask_status("1");
|
||||||
taskserver.update(taskdto);
|
taskserver.update(taskdto);
|
||||||
|
|||||||
@@ -39,34 +39,34 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/** 西门子-输送机驱动-贴标 */
|
||||||
* 西门子-输送机驱动-贴标
|
|
||||||
*/
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
||||||
|
implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||||
@Autowired
|
|
||||||
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
@Autowired DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
||||||
@Autowired
|
@Autowired RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
|
@Autowired TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||||
@Autowired
|
|
||||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
|
||||||
@Autowired
|
@Autowired
|
||||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||||
@Autowired
|
|
||||||
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
@Autowired ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
||||||
@Autowired
|
@Autowired AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
||||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
|
||||||
@Autowired
|
@Autowired
|
||||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
@Autowired
|
|
||||||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
@Autowired NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||||
// 当前指令
|
// 当前指令
|
||||||
Instruction inst = null;
|
Instruction inst = null;
|
||||||
|
|
||||||
@@ -123,15 +123,13 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
String vehicle_code;
|
String vehicle_code;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice() {
|
public Device getDevice() {
|
||||||
return this.device;
|
return this.device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -161,12 +159,18 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||||
}
|
}
|
||||||
if (carrier_direction != last_carrier_direction) {
|
if (carrier_direction != last_carrier_direction) {
|
||||||
logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction));
|
logServer.deviceItemValue(
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction);
|
this.device_code, "carrier_direction", String.valueOf(carrier_direction));
|
||||||
|
logServer.deviceExecuteLog(
|
||||||
|
this.device_code,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction);
|
||||||
}
|
}
|
||||||
if (error != last_error) {
|
if (error != last_error) {
|
||||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
logServer.deviceExecuteLog(
|
||||||
|
this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||||
}
|
}
|
||||||
if (task != last_task) {
|
if (task != last_task) {
|
||||||
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
|
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
|
||||||
@@ -178,17 +182,28 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
// inst_message
|
// inst_message
|
||||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||||
if (inst != null) {
|
if (inst != null) {
|
||||||
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
|
inst_message =
|
||||||
if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
"指令号:"
|
||||||
|
+ inst.getInstruction_code()
|
||||||
|
+ " "
|
||||||
|
+ inst.getStart_point_code()
|
||||||
|
+ "->"
|
||||||
|
+ inst.getNext_point_code()
|
||||||
|
+ " 载具号:"
|
||||||
|
+ inst.getVehicle_code();
|
||||||
|
if (StrUtil.equals(inst.getInstruction_status(), "1")
|
||||||
|
&& StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
||||||
vehicle_code = inst.getVehicle_code();
|
vehicle_code = inst.getVehicle_code();
|
||||||
finish_instruction();
|
finish_instruction();
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
|
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
|
||||||
} else if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
|
} else if (StrUtil.equals(inst.getInstruction_status(), "0")
|
||||||
|
&& StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
|
||||||
inst.setInstruction_status("1");
|
inst.setInstruction_status("1");
|
||||||
instructionService.update(inst);
|
instructionService.update(inst);
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
|
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
|
||||||
} else {
|
} else {
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈失败任务状态不为就绪或者执行中状态,指令号:" + task);
|
logServer.deviceExecuteLog(
|
||||||
|
device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈失败任务状态不为就绪或者执行中状态,指令号:" + task);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task);
|
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task);
|
||||||
@@ -224,7 +239,6 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
Instruction instruction = null;
|
Instruction instruction = null;
|
||||||
List toInstructions;
|
List toInstructions;
|
||||||
|
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 1:
|
case 1:
|
||||||
log.debug("设备运转模式:等待工作");
|
log.debug("设备运转模式:等待工作");
|
||||||
@@ -268,7 +282,6 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
applyAgvTask();
|
applyAgvTask();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_mode = mode;
|
last_mode = mode;
|
||||||
@@ -278,7 +291,6 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
last_task = task;
|
last_task = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean exe_error() {
|
public boolean exe_error() {
|
||||||
if (this.error == 0) {
|
if (this.error == 0) {
|
||||||
return true;
|
return true;
|
||||||
@@ -334,16 +346,20 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void thingToNothing() throws Exception {
|
protected void thingToNothing() throws Exception {
|
||||||
requireSucess = false;
|
requireSucess = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 =
|
||||||
+ "." + param;
|
this.getDevice().getOpc_server_code()
|
||||||
|
+ "."
|
||||||
|
+ this.getDevice().getOpc_plc_code()
|
||||||
|
+ "."
|
||||||
|
+ this.getDevice().getDevice_code()
|
||||||
|
+ "."
|
||||||
|
+ param;
|
||||||
// String opcservcerid = this.getDevice().getOpc_server_id();
|
// String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
// Server server = ReadUtil.getServer(opcservcerid);
|
// Server server = ReadUtil.getServer(opcservcerid);
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
@@ -351,7 +367,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
itemMap.put(to_param, Integer.parseInt(value));
|
itemMap.put(to_param, Integer.parseInt(value));
|
||||||
// itemMap.put(to_param, Integer.parseInt(value));
|
// itemMap.put(to_param, Integer.parseInt(value));
|
||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
logServer.deviceExecuteLog(
|
||||||
|
device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void executing(Server server, Map<String, Object> itemMap) {
|
public void executing(Server server, Map<String, Object> itemMap) {
|
||||||
@@ -364,7 +381,6 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
// Server server = ReadUtil.getServer(opcservcerid);
|
// Server server = ReadUtil.getServer(opcservcerid);
|
||||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -458,23 +474,26 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
Object ob = list.get(i);
|
Object ob = list.get(i);
|
||||||
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
||||||
if (!StrUtil.isEmpty(json.getString("value"))) {
|
if (!StrUtil.isEmpty(json.getString("value"))) {
|
||||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_param =
|
||||||
+ "." + json.getString("code");
|
this.getDevice().getOpc_server_code()
|
||||||
|
+ "."
|
||||||
|
+ this.getDevice().getOpc_plc_code()
|
||||||
|
+ "."
|
||||||
|
+ this.getDevice().getDevice_code()
|
||||||
|
+ "."
|
||||||
|
+ json.getString("code");
|
||||||
itemMap.put(to_param, json.getString("value"));
|
itemMap.put(to_param, json.getString("value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 请求指令 */
|
||||||
/**
|
public synchronized boolean instruction_require() {
|
||||||
* 请求指令
|
|
||||||
*/
|
|
||||||
public synchronized boolean instruction_require() throws Exception {
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
@@ -482,7 +501,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
// 判断是否存在起点相同 任务状态就绪的任务
|
// 判断是否存在起点相同 任务状态就绪的任务
|
||||||
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||||
if (!ObjectUtil.isEmpty(taskdto)) {
|
if (!ObjectUtil.isEmpty(taskdto)) {
|
||||||
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
|
// if
|
||||||
|
// (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
|
||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
// 需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
|
// 需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
|
||||||
@@ -515,7 +535,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
this.writing(list);
|
this.writing(list);
|
||||||
if (task != Integer.parseInt(inst.getInstruction_code())) {
|
if (task != Integer.parseInt(inst.getInstruction_code())) {
|
||||||
this.writing(list);
|
this.writing(list);
|
||||||
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
logServer.deviceExecuteLog(
|
||||||
|
device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||||
}
|
}
|
||||||
message = "下发电气任务号成功";
|
message = "下发电气任务号成功";
|
||||||
requireSucess = true;
|
requireSucess = true;
|
||||||
@@ -535,12 +556,13 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
String route_plan_code = taskdto.getRoute_plan_code();
|
String route_plan_code = taskdto.getRoute_plan_code();
|
||||||
String next_device_code = "";
|
String next_device_code = "";
|
||||||
|
|
||||||
/**
|
/** 开始平均分配 */
|
||||||
* 开始平均分配
|
String this_coevice_code =
|
||||||
*/
|
taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
|
||||||
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
|
|
||||||
if (StrUtil.isEmpty(this_coevice_code)) {
|
if (StrUtil.isEmpty(this_coevice_code)) {
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code);
|
List<RouteLineDto> shortPathsList =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
start_device_code, taskdto.getNext_device_code(), route_plan_code);
|
||||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||||
|
|
||||||
String path = routeLineDto.getPath();
|
String path = routeLineDto.getPath();
|
||||||
@@ -560,7 +582,9 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
next_device_code = this_coevice_code;
|
next_device_code = this_coevice_code;
|
||||||
}
|
}
|
||||||
// 校验路由关系
|
// 校验路由关系
|
||||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
List<RouteLineDto> shortPathsList =
|
||||||
|
routeLineService.getShortPathLines(
|
||||||
|
start_device_code, next_device_code, route_plan_code);
|
||||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||||
throw new RuntimeException("路由不通!");
|
throw new RuntimeException("路由不通!");
|
||||||
}
|
}
|
||||||
@@ -592,7 +616,13 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 创建指令后修改任务状态
|
// 创建指令后修改任务状态
|
||||||
taskdto.setTask_status("1");
|
taskdto.setTask_status("1");
|
||||||
taskserver.update(taskdto);
|
taskserver.update(taskdto);
|
||||||
@@ -656,7 +686,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
// 申请贴标
|
// 申请贴标
|
||||||
public synchronized void applyLabeling() {
|
public synchronized void applyLabeling() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.require_apply_labeling_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -685,16 +716,23 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
}
|
}
|
||||||
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
||||||
new ApplyLabelingAndBindingRequest();
|
new ApplyLabelingAndBindingRequest();
|
||||||
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
|
JSONObject device_json =
|
||||||
|
WQLObject.getWQLObject("acs_storage_cell")
|
||||||
|
.query("storage_code ='" + this.device_code + "'")
|
||||||
|
.uniqueResult(0);
|
||||||
String start_point_code = null;
|
String start_point_code = null;
|
||||||
if (!ObjectUtil.isEmpty(device_json)) {
|
if (!ObjectUtil.isEmpty(device_json)) {
|
||||||
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
|
start_point_code =
|
||||||
|
(String) device_json.get("parent_storage_code") == null
|
||||||
|
? this.device_code
|
||||||
|
: (String) device_json.get("parent_storage_code");
|
||||||
}
|
}
|
||||||
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
||||||
applyLabelingAndBindingRequest.setType("1");
|
applyLabelingAndBindingRequest.setType("1");
|
||||||
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
||||||
applyLabelingAndBindingRequest.setWeight(String.valueOf(weight / 100));
|
applyLabelingAndBindingRequest.setWeight(String.valueOf(weight / 100));
|
||||||
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse =
|
||||||
|
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||||
|
|
||||||
if (applyLabelingAndBindingResponse.getstatus() == 200) {
|
if (applyLabelingAndBindingResponse.getstatus() == 200) {
|
||||||
message = "申请贴标成功";
|
message = "申请贴标成功";
|
||||||
@@ -716,7 +754,8 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
// 申请捆扎
|
// 申请捆扎
|
||||||
public synchronized void applyLaStrangulation() {
|
public synchronized void applyLaStrangulation() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.require_apply_strangulation_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -737,15 +776,22 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
}
|
}
|
||||||
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest =
|
||||||
new ApplyLabelingAndBindingRequest();
|
new ApplyLabelingAndBindingRequest();
|
||||||
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
|
JSONObject device_json =
|
||||||
|
WQLObject.getWQLObject("acs_storage_cell")
|
||||||
|
.query("storage_code ='" + this.device_code + "'")
|
||||||
|
.uniqueResult(0);
|
||||||
String start_point_code = null;
|
String start_point_code = null;
|
||||||
if (!ObjectUtil.isEmpty(device_json)) {
|
if (!ObjectUtil.isEmpty(device_json)) {
|
||||||
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
|
start_point_code =
|
||||||
|
(String) device_json.get("parent_storage_code") == null
|
||||||
|
? this.device_code
|
||||||
|
: (String) device_json.get("parent_storage_code");
|
||||||
}
|
}
|
||||||
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
|
||||||
applyLabelingAndBindingRequest.setType("2");
|
applyLabelingAndBindingRequest.setType("2");
|
||||||
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
|
||||||
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse =
|
||||||
|
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
|
||||||
if (applyLabelingAndBindingResponse.getstatus() == 200) {
|
if (applyLabelingAndBindingResponse.getstatus() == 200) {
|
||||||
if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) {
|
if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) {
|
||||||
Map datas = applyLabelingAndBindingResponse.getData();
|
Map datas = applyLabelingAndBindingResponse.getData();
|
||||||
@@ -786,13 +832,13 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
} else {
|
} else {
|
||||||
message = applyLabelingAndBindingResponse.getMessage();
|
message = applyLabelingAndBindingResponse.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void emptyIn() {
|
public synchronized void emptyIn() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.require_empty_in_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -816,14 +862,14 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
message = "申请空盘入库失败," + jo.get("message").toString();
|
message = "申请空盘入库失败," + jo.get("message").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void applyAgvTask() {
|
public synchronized void applyAgvTask() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -846,14 +892,14 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
message = "申请AGV搬运任务失败," + jo.get("message").toString();
|
message = "申请AGV搬运任务失败," + jo.get("message").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void emptyOut() {
|
public synchronized void emptyOut() {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.require_empty_out_time.getTime()
|
||||||
|
< (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -876,10 +922,7 @@ public class SiemensConveyorLabelingDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
message = "申请空盘出库失败," + jo.get("message").toString();
|
message = "申请空盘出库失败," + jo.get("message").toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void execute() throws Exception {
|
public synchronized void execute(){
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -371,7 +371,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_apply() throws Exception {
|
public boolean instruction_apply() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +433,7 @@ public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean apply_InEmpty() throws Exception {
|
public synchronized boolean apply_InEmpty(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
mode = this.itemProtocol.getMode();
|
mode = this.itemProtocol.getMode();
|
||||||
@@ -614,12 +614,12 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_require(String container_code) throws Exception {
|
public boolean instruction_require(String container_code) {
|
||||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized boolean instruction_apply(String container_code) throws Exception {
|
public synchronized boolean instruction_apply(String container_code) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -725,7 +725,7 @@ public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOp
|
|||||||
* @param container_type
|
* @param container_type
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public synchronized boolean instruction_require(String container_code, String container_type) throws Exception {
|
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
|
|||||||
@@ -132,39 +132,48 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
return barcode;
|
return barcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String barcode() throws Exception {
|
public String barcode() {
|
||||||
ScannerDeviceDriver scanner = this.getScanner();
|
ScannerDeviceDriver scanner = this.getScanner();
|
||||||
return scanner.readBarcode();
|
return scanner.readBarcode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearBarcode() throws Exception {
|
public void clearBarcode() {
|
||||||
ScannerDeviceDriver scanner = this.getScanner();
|
ScannerDeviceDriver scanner = this.getScanner();
|
||||||
scanner.cleanBarcode();
|
scanner.cleanBarcode();
|
||||||
logServer.deviceExecuteLog(this.device_code, "", "", "清理条码");
|
logServer.deviceExecuteLog(this.device_code, "", "", "清理条码");
|
||||||
}
|
}
|
||||||
public synchronized boolean finish_instruction() throws Exception {
|
public synchronized boolean finish_instruction(){
|
||||||
|
try {
|
||||||
instructionService.finish(inst);
|
instructionService.finish(inst);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScannerDeviceDriver getScanner() throws Exception {
|
private ScannerDeviceDriver getScanner() {
|
||||||
String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner);
|
String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner);
|
||||||
if (StrUtil.isEmpty(scanner_code)) {
|
if (StrUtil.isEmpty(scanner_code)) {
|
||||||
throw new Exception("未配置读码器");
|
log.error("未配置读码器");
|
||||||
|
// throw new Exception("未配置读码器");
|
||||||
} else {
|
} else {
|
||||||
Device device = deviceAppservice.findDeviceByCode(scanner_code);
|
Device device = deviceAppservice.findDeviceByCode(scanner_code);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
throw new Exception("无设备:" + scanner_code);
|
// throw new Exception("无设备:" + scanner_code);
|
||||||
|
log.error("无设备:" + scanner_code);
|
||||||
} else {
|
} else {
|
||||||
DeviceDriver deviceDriver = device.getDeviceDriver();
|
DeviceDriver deviceDriver = device.getDeviceDriver();
|
||||||
if (!(deviceDriver instanceof ScannerDeviceDriver)) {
|
if (!(deviceDriver instanceof ScannerDeviceDriver)) {
|
||||||
throw new Exception("扫码器类型不对,不是ScannerDeviceDriver");
|
// throw new Exception("扫码器类型不对,不是ScannerDeviceDriver");
|
||||||
|
log.error("扫码器类型不对,不是ScannerDeviceDriver");
|
||||||
} else {
|
} else {
|
||||||
ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver;
|
ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver;
|
||||||
return driver;
|
return driver;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,7 +183,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws Exception {
|
public void execute(){
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -414,11 +423,11 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
this.control(itemMap);
|
this.control(itemMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean instruction_require(String container_code) throws Exception {
|
public boolean instruction_require(String container_code) {
|
||||||
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
return instruction_require(container_code, WcsConfig.task_container_type_default_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean instruction_apply(String container_code) throws Exception {
|
public synchronized boolean instruction_apply(String container_code) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -480,7 +489,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
* @param container_code
|
* @param container_code
|
||||||
* @param container_type
|
* @param container_type
|
||||||
*/
|
*/
|
||||||
public synchronized boolean instruction_require(String container_code, String container_type) throws Exception {
|
public synchronized boolean instruction_require(String container_code, String container_type) {
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||||
@@ -646,7 +655,13 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
|
|||||||
instdto.setPriority(priority);
|
instdto.setPriority(priority);
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(start_point_code);
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
try {
|
||||||
instructionService.create(instdto);
|
instructionService.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("指令创建失败!",e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//创建指令后修改任务状态
|
//创建指令后修改任务状态
|
||||||
taskdto.setTask_status("1");
|
taskdto.setTask_status("1");
|
||||||
taskserver.update(taskdto);
|
taskserver.update(taskdto);
|
||||||
|
|||||||
@@ -12,12 +12,11 @@ import org.nl.acs.socket.SocketConfig;
|
|||||||
import org.nl.acs.udw.UnifiedDataAccessor;
|
import org.nl.acs.udw.UnifiedDataAccessor;
|
||||||
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
import org.nl.acs.udw.UnifiedDataAccessorFactory;
|
||||||
|
|
||||||
/**
|
/** 标准版扫码器 */
|
||||||
* 标准版扫码器
|
|
||||||
*/
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Data
|
@Data
|
||||||
public class StandardScannerDeviceDriver extends AbstractDeviceDriver implements ScannerDeviceDriver, DeviceDriver, DeviceStageMonitor {
|
public class StandardScannerDeviceDriver extends AbstractDeviceDriver
|
||||||
|
implements ScannerDeviceDriver, DeviceDriver, DeviceStageMonitor {
|
||||||
|
|
||||||
UnifiedDataAccessor accessor_value;
|
UnifiedDataAccessor accessor_value;
|
||||||
|
|
||||||
@@ -31,31 +30,35 @@ public class StandardScannerDeviceDriver extends AbstractDeviceDriver implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String readBarcode() throws Exception {
|
public String readBarcode() {
|
||||||
String ip = this.getIp();
|
String ip = this.getIp();
|
||||||
if (StrUtil.isEmpty(ip)) {
|
if (StrUtil.isEmpty(ip)) {
|
||||||
throw new Exception("ip未配置");
|
// throw new Exception("ip未配置");
|
||||||
|
log.error("ip未配置");
|
||||||
} else {
|
} else {
|
||||||
String result = (String) this.accessor_value.getValue(this.getIp());
|
String result = (String) this.accessor_value.getValue(this.getIp());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeBarcode(String barcode) throws Exception {
|
public void writeBarcode(String barcode) {
|
||||||
String ip = this.getIp();
|
String ip = this.getIp();
|
||||||
if (StrUtil.isEmpty(ip)) {
|
if (StrUtil.isEmpty(ip)) {
|
||||||
throw new Exception("ip未配置");
|
// throw new Exception("ip未配置");
|
||||||
|
log.error("ip未配置");
|
||||||
} else {
|
} else {
|
||||||
this.accessor_value.setValueWithPersistence(this.getIp(), barcode);
|
this.accessor_value.setValueWithPersistence(this.getIp(), barcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanBarcode() throws Exception {
|
public void cleanBarcode() {
|
||||||
String ip = this.getIp();
|
String ip = this.getIp();
|
||||||
if (StrUtil.isEmpty(ip)) {
|
if (StrUtil.isEmpty(ip)) {
|
||||||
throw new Exception("ip未配置");
|
log.error("ip未配置");
|
||||||
|
// throw new Exception("ip未配置");
|
||||||
} else {
|
} else {
|
||||||
this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null);
|
this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null);
|
||||||
}
|
}
|
||||||
@@ -75,8 +78,5 @@ public class StandardScannerDeviceDriver extends AbstractDeviceDriver implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDeviceStatus(JSONObject data) {
|
public void setDeviceStatus(JSONObject data) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import org.nl.acs.ext.wms.data.JsonUtl;
|
import org.nl.acs.ext.wms.data.JsonUtl;
|
||||||
import org.nl.acs.opc.OpcConfig;
|
import org.nl.acs.opc.OpcConfig;
|
||||||
import org.nl.acs.opc.OpcServerService;
|
import org.nl.acs.opc.OpcServerService;
|
||||||
import org.nl.acs.opc.OpcServerServiceImpl;
|
import org.nl.acs.opc.OpcServerServiceImpl;
|
||||||
import org.nl.acs.opc.WcsConfig;
|
|
||||||
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.wql.exception.WDKException;
|
import org.nl.modules.wql.exception.WDKException;
|
||||||
import org.nl.modules.wql.util.SpringContextHolder;
|
import org.nl.modules.wql.util.SpringContextHolder;
|
||||||
|
|
||||||
@@ -46,15 +43,13 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
|||||||
System.out.println(entry.getKey() + ":" + entry.getValue());
|
System.out.println(entry.getKey() + ":" + entry.getValue());
|
||||||
p2[i] = new ItemValue();
|
p2[i] = new ItemValue();
|
||||||
p2[i].setItem_code(entry.getKey());
|
p2[i].setItem_code(entry.getKey());
|
||||||
p2[i].setItem_value((String) entry.getValue());
|
p2[i].setItem_value( entry.getValue());
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.control(p2);
|
return this.control(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean control(ItemValue[] itemValues) {
|
public boolean control(ItemValue[] itemValues) {
|
||||||
if (itemValues != null && itemValues.length != 0) {
|
if (itemValues != null && itemValues.length != 0) {
|
||||||
String this_items = JsonUtl.parseWithoutException(itemValues);
|
String this_items = JsonUtl.parseWithoutException(itemValues);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.nl.acs.device_driver.driver;
|
package org.nl.acs.device_driver.driver;
|
||||||
|
|
||||||
|
import com.esotericsoftware.minlog.Log;
|
||||||
import org.nl.acs.device_driver.DeviceDriver;
|
import org.nl.acs.device_driver.DeviceDriver;
|
||||||
|
|
||||||
public interface ExecutableDeviceDriver extends DeviceDriver {
|
public interface ExecutableDeviceDriver extends DeviceDriver {
|
||||||
@@ -8,10 +9,10 @@ public interface ExecutableDeviceDriver extends DeviceDriver {
|
|||||||
this.execute();
|
this.execute();
|
||||||
} catch (Throwable var6) {
|
} catch (Throwable var6) {
|
||||||
String message = "线程调用异常:" + var6.getMessage();
|
String message = "线程调用异常:" + var6.getMessage();
|
||||||
|
Log.error(message);
|
||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute() throws Exception;
|
void execute();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(String id) throws Exception {
|
public void finish(String id) {
|
||||||
Instruction entity = this.findById(id);
|
Instruction entity = this.findById(id);
|
||||||
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||||
@@ -718,7 +718,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void finish(Instruction dto) throws Exception {
|
public void finish(Instruction dto) {
|
||||||
String now = DateUtil.now();
|
String now = DateUtil.now();
|
||||||
dto.setInstruction_status("2");
|
dto.setInstruction_status("2");
|
||||||
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||||
@@ -773,7 +773,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishAndCreateNextInst(Instruction dto) throws Exception {
|
public void finishAndCreateNextInst(Instruction dto){
|
||||||
dto = foramte(dto);
|
dto = foramte(dto);
|
||||||
String device_code = dto.getNext_device_code();
|
String device_code = dto.getNext_device_code();
|
||||||
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||||
@@ -829,7 +829,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
|||||||
instdto.setPriority(acsTask.getPriority());
|
instdto.setPriority(acsTask.getPriority());
|
||||||
instdto.setInstruction_status("0");
|
instdto.setInstruction_status("0");
|
||||||
instdto.setExecute_device_code(dto.getNext_device_code());
|
instdto.setExecute_device_code(dto.getNext_device_code());
|
||||||
|
try {
|
||||||
this.create(instdto);
|
this.create(instdto);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("完成并创建下一条指令",e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoIn
|
|||||||
try {
|
try {
|
||||||
Server server = (Server) this.servers.get(code);
|
Server server = (Server) this.servers.get(code);
|
||||||
server.disconnect();
|
server.disconnect();
|
||||||
} catch (Exception var3) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("清理server异常,",e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.servers.remove(code);
|
this.servers.remove(code);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class OpcUtl {
|
|||||||
|
|
||||||
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
public static void writeValue(Group group, WriteRequest... requests) throws WDKException {
|
||||||
try {
|
try {
|
||||||
Map e = group.write(requests);
|
Map<Item, Integer> e = group.write(requests);
|
||||||
boolean is_success = true;
|
boolean is_success = true;
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
Iterator arg4 = e.keySet().iterator();
|
Iterator arg4 = e.keySet().iterator();
|
||||||
@@ -59,6 +59,7 @@ public class OpcUtl {
|
|||||||
// group.write(requests);
|
// group.write(requests);
|
||||||
}
|
}
|
||||||
} catch (JIException arg7) {
|
} catch (JIException arg7) {
|
||||||
|
log.info("下发信号失败:"+arg7.getMessage());
|
||||||
throw new WDKException(arg7);
|
throw new WDKException(arg7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user