add:新增rgv驱动
This commit is contained in:
@@ -63,7 +63,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
INDOOR_MANIPULATOR(24,"indoor_manipulator","内包间-行架机械手","station"),
|
||||
|
||||
PLUGGING_UNPLUGGING_MACHINE(25,"plugging_unplugging_machine","插拔轴机","station");
|
||||
PLUGGING_UNPLUGGING_MACHINE(25,"plugging_unplugging_machine","插拔轴机","station"),
|
||||
|
||||
RGV(28,"rgv","rgv","conveyor");
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -99,6 +99,9 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
String material2 = null;
|
||||
String last_material2 = null;
|
||||
|
||||
int qty = 0;
|
||||
int last_qty = 0;
|
||||
|
||||
|
||||
//下发命令
|
||||
int to_command = 0;
|
||||
@@ -135,6 +138,7 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
task = this.itemProtocol.getTask();
|
||||
material1 = this.itemProtocol.getMaterial1();
|
||||
material2 = this.itemProtocol.getMaterial2();
|
||||
qty = this.itemProtocol.getQty();
|
||||
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
|
||||
@@ -186,6 +190,11 @@ public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||
}
|
||||
|
||||
if (qty != last_qty) {
|
||||
logServer.deviceItemValue(this.device_code, "qty", String.valueOf(qty));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号qty:" + last_qty + "->" + qty);
|
||||
}
|
||||
|
||||
if (move != 0 && task > 1) {
|
||||
update_instruction_status();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ public class ItemProtocol {
|
||||
public static String item_material1 = "material1";
|
||||
//物料2
|
||||
public static String item_material2 = "material2";
|
||||
//数量
|
||||
public static String item_qty = "qty";
|
||||
|
||||
//下发命令
|
||||
public static String item_to_command = "to_command";
|
||||
@@ -48,6 +50,10 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getQty() {
|
||||
return this.getOpcIntegerValue(item_qty);
|
||||
}
|
||||
|
||||
public int getCarrier_direction() {
|
||||
return this.getOpcIntegerValue(item_carrier_direction);
|
||||
}
|
||||
@@ -108,12 +114,13 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_task, "任务号", "DB101.W6"));
|
||||
list.add(new ItemDto(item_material1, "物料1", "DB101.W7"));
|
||||
list.add(new ItemDto(item_material2, "物料2", "DB101.W8"));
|
||||
list.add(new ItemDto(item_qty, "数量", "DB101.W114"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4"));
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB201.W4"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,11 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
bushingSucess();
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
if (task1 > 0 && !requireSucess) {
|
||||
pullingSucess();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -159,6 +164,31 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
last_task2 = task2;
|
||||
}
|
||||
|
||||
private synchronized void pullingSucess() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = instructionService.findByCode(String.valueOf(task1));
|
||||
String task_code1 = inst1.getTask_code();
|
||||
applyManipulatorActionRequest.setTask_code1(task_code1);
|
||||
applyManipulatorActionRequest.setType("8");
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse.getstatus()==200) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 6);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "拔轴完成成功";
|
||||
}else{
|
||||
message = applyManipulatorActionResponse.getMessage();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 99);
|
||||
requireSucess = true;
|
||||
message = "拔轴失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴,返回参数:" + applyManipulatorActionResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void bushingSucess() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
@@ -175,6 +205,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
if (applyManipulatorActionResponse.getstatus()==200) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 5);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "套轴完成成功";
|
||||
@@ -182,6 +213,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
message = applyManipulatorActionResponse.getMessage();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 99);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
message = "套轴失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
|
||||
@@ -203,6 +235,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
if (applyManipulatorActionResponse.getstatus()==200) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 4);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
|
||||
message = "套轴申请成功";
|
||||
@@ -210,6 +243,7 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
message = applyManipulatorActionResponse.getMessage();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 99);
|
||||
this.writing(map);
|
||||
requireSucess = true;
|
||||
message = "申请失败";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyManipulatorActionResponse);
|
||||
@@ -225,22 +259,32 @@ public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriv
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(List list) {
|
||||
/**
|
||||
* 抽取统一下发电气信号前缀
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
//String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
//Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object ob = list.get(i);
|
||||
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
|
||||
if (!StrUtil.isEmpty(json.getString("value"))) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + json.getString("code");
|
||||
itemMap.put(to_param, json.getString("value"));
|
||||
/**
|
||||
* 多个信号一起下发电气
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.nl.acs.device_driver.basedriver.rgv;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode";
|
||||
public static String item_move1 = "move1";
|
||||
public static String item_move2 = "move2";
|
||||
public static String item_error = "error";
|
||||
public static String item_task = "task";
|
||||
public static String item_qty1 = "qty1";
|
||||
public static String item_qty2 = "qty2";
|
||||
public static String item_to_command = "to_command";
|
||||
|
||||
|
||||
private RgvDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(RgvDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove1() {
|
||||
return this.getOpcIntegerValue(item_move1);
|
||||
}
|
||||
|
||||
public int getMove2() {
|
||||
return this.getOpcIntegerValue(item_move2);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getQty1() {
|
||||
return this.getOpcIntegerValue(item_qty1);
|
||||
}
|
||||
|
||||
public int getQty2() {
|
||||
return this.getOpcIntegerValue(item_qty2);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB102.W0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB102.W2"));
|
||||
list.add(new ItemDto(item_move1, "光电开关信号1", "DB102.W4"));
|
||||
list.add(new ItemDto(item_move1, "光电开关信号2", "DB102.W6"));
|
||||
list.add(new ItemDto(item_qty1, "工位1重量", "DB102.REAL8"));
|
||||
list.add(new ItemDto(item_qty2, "工位2重量", "DB102.REAL12"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB102.W16"));
|
||||
list.add(new ItemDto(item_task, "任务号(行架任务号)", "DB102.D18"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "作业命令", "DB202.W0"));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.nl.acs.device_driver.basedriver.rgv;
|
||||
|
||||
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.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RgvDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "rgv";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new RgvDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return RgvDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package org.nl.acs.device_driver.basedriver.rgv;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class RgvDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
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
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
|
||||
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
int move1 = 0;
|
||||
int last_move1 = 0;
|
||||
int move2 = 0;
|
||||
int last_move2 = 0;
|
||||
int qty1 = 0;
|
||||
int last_qty1 = 0;
|
||||
int qty2 = 0;
|
||||
int last_qty2 = 0;
|
||||
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
Boolean isonline = true;
|
||||
|
||||
Boolean iserror = false;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
//1-执行任务;2-取货完成;3-放货完成;
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
String message = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
move1 = this.itemProtocol.getMove1();
|
||||
move2 = this.itemProtocol.getMove2();
|
||||
qty1 = this.itemProtocol.getQty1();
|
||||
qty2 = this.itemProtocol.getQty2();
|
||||
task = this.itemProtocol.getTask();
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.requireSucess = false;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记");
|
||||
}
|
||||
if (move1 != last_move1) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move1:" + last_move1 + "->" + move1);
|
||||
}
|
||||
if (move2 != last_move2) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move2:" + last_move2 + "->" + move2);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
}
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
return;
|
||||
case 2:
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
if (task > 0 && !requireSucess && (qty1 > 0 || qty2 > 0)) {
|
||||
feedbackQty();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_move1 = move1;
|
||||
last_move2 = move2;
|
||||
last_task = task;
|
||||
last_qty1 = qty1;
|
||||
last_qty2 = qty2;
|
||||
}
|
||||
|
||||
private void feedbackQty() {
|
||||
ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest();
|
||||
ApplyManipulatorActionResponse applyManipulatorActionResponse;
|
||||
Instruction inst1 = checkInst();
|
||||
String task_code = inst1.getTask_code();
|
||||
applyManipulatorActionRequest.setType("2");
|
||||
if (qty1 > 0) {
|
||||
applyManipulatorActionRequest.setQty(String.valueOf(qty1));
|
||||
}
|
||||
if (qty2 > 0) {
|
||||
applyManipulatorActionRequest.setQty(String.valueOf(qty2));
|
||||
}
|
||||
applyManipulatorActionRequest.setTask_code1(task_code);
|
||||
applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest);
|
||||
if (applyManipulatorActionResponse.getstatus() == 200) {
|
||||
requireSucess = true;
|
||||
message = "反馈LMS成功...";
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 4);
|
||||
this.writing(map);
|
||||
} else {
|
||||
requireSucess = false;
|
||||
message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "反馈重量请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse));
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_command", 99);
|
||||
this.writing(map);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 抽取统一下发电气信号前缀
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个信号一起下发电气
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
if (this.task > 0) {
|
||||
if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
|
||||
return this.inst;
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String mode = "";
|
||||
String action = "";
|
||||
String move1 = "";
|
||||
String move2 = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = "未联机";
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = "单机";
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = "联机";
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
|
||||
if (this.getMove1() == 0 && this.getMove2() == 0) {
|
||||
move1 = "无货";
|
||||
move2 = "无货";
|
||||
jo.put("hasGoods", false);
|
||||
} else if (this.getMove1() == 1 || this.getMove2() == 1) {
|
||||
jo.put("hasGoods", true);
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move1", move1);
|
||||
jo.put("move2", move2);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("isError", this.getIserror());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public void writing(String param, String value) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ public class ApplyManipulatorActionRequest extends BaseRequest {
|
||||
* 5-反馈二次放货点
|
||||
* 6-套轴申请
|
||||
* 7-套轴完成
|
||||
* 8-拔轴完成
|
||||
*/
|
||||
private String type;
|
||||
|
||||
@@ -35,5 +36,10 @@ public class ApplyManipulatorActionRequest extends BaseRequest {
|
||||
* 取货完成1 放货完成2
|
||||
*/
|
||||
private String action;
|
||||
/**
|
||||
* 重量
|
||||
*/
|
||||
private String qty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -112,10 +112,22 @@ public interface AcsToWmsService {
|
||||
// 输送线有货变成无货时向lms请求
|
||||
HttpResponse shipDeviceUpdate(JSONObject param);
|
||||
|
||||
//task变化时向LMS请求
|
||||
HttpResponse taskDeviceUpdate(JSONObject param);
|
||||
|
||||
void sendDeviceStatus(JSONObject param);
|
||||
|
||||
/**
|
||||
* 向lms申请反馈
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param);
|
||||
|
||||
/**
|
||||
* 向LMS反馈缓存库取/放货完成
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
ApplyManipulatorActionResponse actionFinishRequest(ApplyManipulatorActionRequest param);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper;
|
||||
import org.nl.acs.device_driver.basedriver.paper_tube_device2.PaperTubeConveyor2DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.rgv.RgvDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver;
|
||||
@@ -252,6 +253,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
IndoorManipulatorDeviceDriver indoorManipulatorDeviceDriver;
|
||||
//套管工位
|
||||
CasingStationConveyorDeviceDriver casingStationConveyorDeviceDriver;
|
||||
//RGV
|
||||
RgvDeviceDriver rgvDeviceDriver;
|
||||
|
||||
if (datas.size() == 0) {
|
||||
throw new BadRequestException("缺少输入参数!");
|
||||
@@ -315,6 +318,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("task", casingStationConveyorDeviceDriver.getTask());
|
||||
jo.put("material1", casingStationConveyorDeviceDriver.getMaterial1());
|
||||
jo.put("material2", casingStationConveyorDeviceDriver.getMaterial2());
|
||||
jo.put("qty", casingStationConveyorDeviceDriver.getQty());
|
||||
|
||||
|
||||
} else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) {
|
||||
@@ -326,7 +330,19 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial()) ? "" : paperTubeConveyorDeviceDriver.getMaterial());
|
||||
jo.put("out_finish", paperTubeConveyorDeviceDriver.getOut_finish());
|
||||
|
||||
} else if (device.getDeviceDriver() instanceof DeviceStatusDeviceDriver) {
|
||||
} else if (device.getDeviceDriver() instanceof RgvDeviceDriver) {
|
||||
rgvDeviceDriver = (RgvDeviceDriver) device.getDeviceDriver();
|
||||
jo.put("device_code", parent_device_code);
|
||||
jo.put("qty1", rgvDeviceDriver.getQty1());
|
||||
jo.put("qty2", rgvDeviceDriver.getQty2());
|
||||
jo.put("mode", rgvDeviceDriver.getMode());
|
||||
jo.put("move1", rgvDeviceDriver.getMove1());
|
||||
jo.put("move2", rgvDeviceDriver.getMove2());
|
||||
jo.put("task", rgvDeviceDriver.getTask());
|
||||
jo.put("error", rgvDeviceDriver.getError());
|
||||
|
||||
|
||||
}else if (device.getDeviceDriver() instanceof DeviceStatusDeviceDriver) {
|
||||
deviceStatusDeviceDriver = (DeviceStatusDeviceDriver) device.getDeviceDriver();
|
||||
jo.put("device_code", deviceStatusDeviceDriver.getDevice().getDevice_code());
|
||||
jo.put("device_name", deviceStatusDeviceDriver.getDevice().getDevice_name());
|
||||
|
||||
Reference in New Issue
Block a user