This commit is contained in:
2023-10-08 17:46:27 +08:00
3 changed files with 72 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@@ -157,17 +158,47 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
this.control(itemMap);
}
public void writing(String key, String value) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + key;
public void writing(List list) {
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, value);
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"));
}
}
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
try{
this.checkcontrol(itemMap);
} catch (Exception e1){
e1.printStackTrace();
}
}
}
public void writing(String key, String param) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(param));
// itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param);
}
@Override

View File

@@ -1194,7 +1194,17 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
paperTubeConveyorDeviceDriver.writing("to_material", material_code);
try{
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_material");
map.put("value", material_code);
list.add(map);
paperTubeConveyorDeviceDriver.writing(list);
} catch (Exception e){
e.printStackTrace();
}
} else if (StrUtil.equals(type, "2")) {
if (paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)) {
resp.put("status", 400);
@@ -1221,9 +1231,28 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
log.info("paperTubeAction--------------:输出参数" + resp.toString());
return resp;
}
paperTubeConveyorDeviceDriver.writing("to_out_qty", qty);
paperTubeConveyorDeviceDriver.writing("to_target", device.getAddress());
paperTubeConveyorDeviceDriver.writing("to_command", "2");
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_out_qty");
map.put("value", qty);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_target");
map2.put("value", device.getAddress());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", 2);
list.add(map3);
try{
// paperTubeConveyorDeviceDriver.writing("to_out_qty", qty);
// paperTubeConveyorDeviceDriver.writing("to_target", device.getAddress());
// paperTubeConveyorDeviceDriver.writing("to_command", "2");
paperTubeConveyorDeviceDriver.writing(list);
} catch (Exception e){
e.printStackTrace();
}
}
}

View File

@@ -190,7 +190,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
Object his = accessor_value.getValue(itemId);
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
valueAllNotNull = true;
valueAllNotNull = false;
}
if (!UnifiedDataAppService.isEquals(value, his)) {
@@ -224,7 +224,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
log.warn("{} 所有内容都为空, all_null:{} ,暂定{}s", tag, all_null,5000 + random);
}
ThreadUtl.sleep((long) (5000 + random));
ThreadUtl.sleep((long) ((new Random()).nextInt(3) +1) * 1000);
break start;
} else if (this.all_null < 6) {
if (log.isWarnEnabled()) {
log.warn(tag + "重新创建server");