Browse Source

更新

master
gengby 2 years ago
parent
commit
38ffbc693d
  1. 79
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java
  2. 289
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java
  3. 93
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_palletizing_station/HailiangOldPalletizingStationDriver.java
  4. 4
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_palletizing_station/ItemProtocol.java
  5. 236
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_device/HailiangOldSpecialDeviceDriver.java
  6. 127
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_empty_station/HailiangOldSpecialEmptyStationDeviceDriver.java
  7. 92
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_full_station/HailiangOldSpecialFullStationDeviceDriver.java
  8. 118
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_pick_station/HailiangOldSpecialPickStationDeviceDriver.java
  9. 133
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_pour_station/HailiangOldSpecialPourStationDeviceDriver.java
  10. 181
      acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_stacking_manipulator/HailiangOldStackingManipulatorDriver.java
  11. 194
      acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

79
acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java

@ -20,6 +20,13 @@ import org.nl.acs.device.service.dto.*;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.ScannerDeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_palletizing_station.HailiangOldPalletizingStationDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_special_device.HailiangOldSpecialDeviceDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_special_empty_station.HailiangOldSpecialEmptyStationDeviceDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_special_full_station.HailiangOldSpecialFullStationDeviceDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_special_pick_station.HailiangOldSpecialPickStationDeviceDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_special_pour_station.HailiangOldSpecialPourStationDeviceDriver;
import org.nl.acs.device_driver.hailiang_old.hailiang_old_stacking_manipulator.HailiangOldStackingManipulatorDriver;
import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver;
import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver;
@ -134,7 +141,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
public DeviceDto findByCode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_device");
JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0);
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class);
return obj;
}
@ -183,7 +190,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
dto.setUpdate_by(currentUsername);
WQLObject wo = WQLObject.getWQLObject("acs_device");
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.update(json);
}
@ -228,7 +235,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
Iterator<Device> iterator = allDevice.iterator();
while (iterator.hasNext()) {
Device device = iterator.next();
if (StrUtil.equals(device.getDevice_code(),device_code)) {
if (StrUtil.equals(device.getDevice_code(), device_code)) {
iterator.remove();
}
}
@ -240,7 +247,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
if (deviceByCode != null) {
DeviceDriverDefination deviceDriverDefination = deviceByCode.getDeviceDriverDefination();
String name = "";
if (ObjectUtil.isNotEmpty(deviceDriverDefination)){
if (ObjectUtil.isNotEmpty(deviceDriverDefination)) {
name = deviceByCode.getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
}
if (StrUtil.equals("storage", name)) {
@ -864,6 +871,13 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
//检测站点
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
HailiangOldPalletizingStationDriver hailiangOldPalletizingStationDriver;
HailiangOldSpecialDeviceDriver hailiangOldSpecialDeviceDriver;
HailiangOldSpecialEmptyStationDeviceDriver hailiangOldSpecialEmptyStationDeviceDriver;
HailiangOldSpecialFullStationDeviceDriver hailiangOldSpecialFullStationDeviceDriver;
HailiangOldSpecialPickStationDeviceDriver hailiangOldSpecialPickStationDeviceDriver;
HailiangOldSpecialPourStationDeviceDriver hailiangOldSpecialPourStationDeviceDriver;
HailiangOldStackingManipulatorDriver hailiangOldStackingManipulatorDriver;
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
@ -924,6 +938,27 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
standardInspectSiteDeviceDriver.setBatch(batch);
device.setMaterial_type(material_type);
device.setBatch(batch);
} else if (device.getDeviceDriver() instanceof HailiangOldPalletizingStationDriver) {
hailiangOldPalletizingStationDriver = (HailiangOldPalletizingStationDriver) device.getDeviceDriver();
hailiangOldPalletizingStationDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldSpecialEmptyStationDeviceDriver) {
hailiangOldSpecialEmptyStationDeviceDriver = (HailiangOldSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialEmptyStationDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldSpecialFullStationDeviceDriver) {
hailiangOldSpecialFullStationDeviceDriver = (HailiangOldSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialFullStationDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldSpecialPickStationDeviceDriver) {
hailiangOldSpecialPickStationDeviceDriver = (HailiangOldSpecialPickStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPickStationDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldSpecialPourStationDeviceDriver) {
hailiangOldSpecialPourStationDeviceDriver = (HailiangOldSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPourStationDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldStackingManipulatorDriver) {
hailiangOldStackingManipulatorDriver = (HailiangOldStackingManipulatorDriver) device.getDeviceDriver();
hailiangOldStackingManipulatorDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof HailiangOldSpecialDeviceDriver) {
hailiangOldSpecialDeviceDriver = (HailiangOldSpecialDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialDeviceDriver.setDeviceStatus(form);
}
}
@ -1176,14 +1211,14 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONArray rs = WQLObject.getWQLObject("acs_device_extra").query("filed_type='02' and device_id = '" + device_id + "'", "order_seq").getResultJSONArray(0);
JSONArray r_arry = new JSONArray();
//先获取模板
if(ObjectUtil.isNotEmpty(opcDeviceDriverDefination)){
if (ObjectUtil.isNotEmpty(opcDeviceDriverDefination)) {
List<ItemDto> readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos();
List<JSONObject> readableItemJsons = new ArrayList<>();
for (int i = 0; i < readableItemDtos.size(); i++) {
ItemDto itemDto = readableItemDtos.get(i);
JSONObject readableItemJson = new JSONObject();
readableItemJson.put("code",itemDto.getCode());
readableItemJson.put("name",itemDto.getName());
readableItemJson.put("code", itemDto.getCode());
readableItemJson.put("name", itemDto.getName());
// readableItemJson.put("db",itemDto.getDb());
readableItemJsons.add(readableItemJson);
}
@ -1194,7 +1229,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String code = split[split.length - 1];
robj.put("code", code);
robj.put("name", rs.getJSONObject(i).getString("remark"));
if (readableItemJsons.contains(robj)){
if (readableItemJsons.contains(robj)) {
robj.put("code", rs.getJSONObject(i).getString("extra_code"));
robj.put("db", rs.getJSONObject(i).getString("extra_name"));
r_arry.add(robj);
@ -1208,16 +1243,16 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
code = split[split.length - 1];
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", code);
jsonObject.put("name",rJson.getString("name"));
jsonObject.put("name", rJson.getString("name"));
rarry.add(jsonObject);
}
for (int i = 0; i < readableItemDtos.size(); i++) {
ItemDto itemDto = readableItemDtos.get(i);
JSONObject readableItemJson = new JSONObject();
readableItemJson.put("code",itemDto.getCode());
readableItemJson.put("name",itemDto.getName());
if (!rarry.contains(readableItemJson)){
readableItemJson.put("db",itemDto.getDb());
readableItemJson.put("code", itemDto.getCode());
readableItemJson.put("name", itemDto.getName());
if (!rarry.contains(readableItemJson)) {
readableItemJson.put("db", itemDto.getDb());
r_arry.add(readableItemJson);
}
}
@ -1228,8 +1263,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
for (int i = 0; i < writeableItemDtos.size(); i++) {
ItemDto itemDto = writeableItemDtos.get(i);
JSONObject writeableItemJson = new JSONObject();
writeableItemJson.put("code",itemDto.getCode());
writeableItemJson.put("name",itemDto.getName());
writeableItemJson.put("code", itemDto.getCode());
writeableItemJson.put("name", itemDto.getName());
//writeableItemJson.put("db",itemDto.getDb());
writeableItemJsons.add(writeableItemJson);
}
@ -1240,7 +1275,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
JSONObject robj = new JSONObject();
robj.put("code", code);
robj.put("name", ws.getJSONObject(i).getString("remark"));
if (writeableItemJsons.contains(robj)){
if (writeableItemJsons.contains(robj)) {
robj.put("code", ws.getJSONObject(i).getString("extra_code"));
robj.put("db", ws.getJSONObject(i).getString("extra_name"));
w_arry.add(robj);
@ -1253,17 +1288,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String[] split = code.split("\\.");
code = split[split.length - 1];
JSONObject jsonObject = new JSONObject();
jsonObject.put("code",code);
jsonObject.put("name",wJson.getString("name"));
jsonObject.put("code", code);
jsonObject.put("name", wJson.getString("name"));
warry.add(jsonObject);
}
for (int i = 0; i < writeableItemDtos.size(); i++) {
ItemDto itemDto = writeableItemDtos.get(i);
JSONObject writeableItemJson = new JSONObject();
writeableItemJson.put("code",itemDto.getCode());
writeableItemJson.put("name",itemDto.getName());
if (!warry.contains(writeableItemJson)){
writeableItemJson.put("db",itemDto.getDb());
writeableItemJson.put("code", itemDto.getCode());
writeableItemJson.put("name", itemDto.getName());
if (!warry.contains(writeableItemJson)) {
writeableItemJson.put("db", itemDto.getDb());
w_arry.add(writeableItemJson);
}
}

289
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java

@ -1,15 +1,8 @@
package org.nl.acs.device_driver.driver;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.OpcConfig;
import org.nl.modules.udw.UnifiedDataAccessor;
import org.nl.modules.udw.UnifiedDataAccessorFactory;
import org.nl.utils.SpringContextHolder;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class AbstractOpcDeviceDriver<T> extends AbstractDeviceDriver implements OpcDeviceDriver {
@ -24,287 +17,5 @@ public class AbstractOpcDeviceDriver<T> extends AbstractDeviceDriver implements
return this.opcUdw;
}
//不需要写入日志的点位名称
String notWriteLog = "heartbeat,device_running_time";
//信号值与上次值不一致时的日志
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
if (lastNumber != nowNumber) {
logServer.deviceItemValue(device_code, name, String.valueOf(nowNumber));
logServer.deviceExecuteLog(device_code, "", "", "信号'" + name + "':" + lastNumber + "->" + nowNumber);
}
}
//判断信号是否异常
public synchronized void signalIsException(T sonDriver) {
Class<?> sonDriverClass = sonDriver.getClass();
try {
//获取对应驱动的itemprotocol对象
Method methodItemProtocol = sonDriverClass.getMethod("getItemProtocol");
Object itemProtocol = methodItemProtocol.invoke(sonDriver);
//获取对应驱动的设备编码
String deviceCode = (String) sonDriverClass.getMethod("getDeviceCode").invoke(sonDriver);
//获取itemProtocol对象中的所有属性
Field[] fields = itemProtocol.getClass().getDeclaredFields();
//遍历所有属性 主要是获取对应的点位信息
for (Field field : fields) {
//获取属性名字 itemProtocol中定义点位的变量严格按照规范
//即定义读取的变量名称时,需要在前缀加上item_,定义写入的变量时需要在前缀加上item_to_,
//定义读取或写入的点位名称(即变量名称对应的值)时去掉item_即可
String fieldName = field.getName();
//判断点位名称是否含有item_,如果含有说明是需要读取或写入的点位
if (fieldName.contains("item_")) {
//判断点位是否是读取的点位,因为主要是获取kep上可读取的点位值,不需要写入的,
//主要是用来记录与上次点位不一致时写入日志,或作一些其他事情
if (!fieldName.contains("to_")) {
//通过itemProtocol对象中定义的变量名称,获取对应的点位名称,
//主要是为了通过点位名称获取对应的点位值
String fieldValue = (String) field.get(fieldName);
Method methodGet = null;
try {
//通过反射获取点位值的方法 规定方法名为get+点位名称,其中点位名称首字母大写
methodGet = itemProtocol.getClass().getMethod("get" + initialUpperCase(fieldValue));
} catch (Exception e) {
}
//定义点位值
int itemValue = 0;
//判断是否有获取获取该点位值的方法,若果有就通过反射执行该方法,并将获取到的值赋给点位值
if (ObjectUtil.isNotEmpty(methodGet)) {
itemValue = (int) methodGet.invoke(itemProtocol);
}
//通过反射将点位值赋值给驱动中定义的点位变量
Method methodSet = null;
try {
methodSet = sonDriverClass.getMethod("set" + initialUpperCase(fieldValue), int.class);
} catch (Exception e) {
}
if (ObjectUtil.isNotEmpty(methodSet)) {
try {
methodSet.invoke(sonDriver, itemValue);
} catch (Exception e) {
}
}
//判断本次点位值和上次是否一致 如果不一致则写入日志记录
// notWriteLog是值不一致时,不需要写入日志的点位名称
if (!fieldValue.contains(notWriteLog)) {
//通过反射获取点位上一次的值的方法
Method methodGetLast = null;
try {
methodGetLast = sonDriverClass.getMethod("getLast_" + fieldValue);
} catch (Exception e) {
}
//定义上次点位值
int last_Number = 0;
//判断是否有获取获取该上次点位值的方法,若果有就通过反射执行该方法,并将获取到的值赋给上次点位值
if (ObjectUtil.isNotEmpty(methodGetLast)) {
last_Number = (int) methodGetLast.invoke(sonDriver);
}
//通过反射获取本次与上次点位值不一样写入日志的方法writeLogInfo
//需要传入设备编码,点位名称,上一次点位值,本次点位值
Method writeLogInfo = null;
try {
writeLogInfo = sonDriverClass.getMethod("writeLogInfo", String.class, String.class, int.class, int.class);
} catch (Exception e) {
}
if (ObjectUtil.isNotEmpty(writeLogInfo)) {
writeLogInfo.invoke(sonDriver, deviceCode, fieldValue, last_Number, itemValue);
}
}
}
}
}
//method1 是在获取点位值并写入日志后 需要执行的业务逻辑方法
//如果需要在获取点位值并写入日志后执行业务逻辑,在驱动对应的method1方法中书写就行
Method method1 = null;
try {
method1 = sonDriverClass.getMethod("method1");
} catch (Exception e) {
}
if (ObjectUtil.isNotEmpty(method1)) {
method1.invoke(sonDriver);
}
//获取设置设备是否在线方法
Method methodIsonline = null;
try {
methodIsonline = sonDriverClass.getMethod("setIsonline", Boolean.class);
} catch (Exception e) {
}
//获取设置设备是否故障方法
Method methodIserror = null;
try {
methodIserror = sonDriverClass.getMethod("setIserror", Boolean.class);
} catch (Exception e) {
}
//获取设置异常消息的方法 貌似没用
Method methodMessage = null;
try {
methodMessage = sonDriverClass.getMethod("setMessage", String.class);
} catch (Exception e) {
}
//获取mode值方法 是否联机
Method methodMode = null;
try {
methodMode = sonDriverClass.getMethod("getMode");
} catch (Exception e) {
}
//获取设备是否故障方法
Method methodError = null;
try {
methodError = sonDriverClass.getMethod("getError");
} catch (Exception e) {
}
//获取设备是否在线方法
Method methodOnline = null;
try {
methodOnline = itemProtocol.getClass().getMethod("getIsonline");
} catch (Exception e) {
}
//定义是否联机点位值
int mode = 0;
//定义故障点位值
int error = 0;
//定义在线点位值
Boolean isonline = true;
//先判断该驱动是否有该点位值,如果有->
//执行获取mode值的方法,并将获取的mode值付给联机点位值
if (ObjectUtil.isNotEmpty(methodMode)) {
mode = (int) methodMode.invoke(sonDriver);
} else {
mode = 1;
}
//执行获取error值的方法,并将error值付给故障点位值
if (ObjectUtil.isNotEmpty(methodError)) {
error = (int) methodError.invoke(sonDriver);
}
//执行获取isonline值的方法,并将isonline值付给在线点位值
//该值是在其驱动对象对应的itemProtocol中获取的
if (ObjectUtil.isNotEmpty(methodOnline)) {
isonline = (Boolean) methodOnline.invoke(itemProtocol);
}
//设备不在线时执行逻辑
if (!isonline) {
try {
methodIsonline.invoke(sonDriver, false);
methodIserror.invoke(sonDriver, true);
methodMessage.invoke(sonDriver, "信号量同步异常");
} catch (Exception e) {
}
} else if (mode == 0) { //设备未联机执行逻辑 如果该设备没有mode值 上面有赋值mode=1 不会执行该方法
try {
methodIsonline.invoke(sonDriver, false);
methodIserror.invoke(sonDriver, true);
methodMessage.invoke(sonDriver, "未联机");
} catch (Exception e) {
}
} else if (error != 0) { //设备异常执行逻辑
try {
methodIsonline.invoke(sonDriver, false);
methodIserror.invoke(sonDriver, true);
methodMessage.invoke(sonDriver, "有报警");
} catch (Exception e) {
}
} else {
//设备正常时执行的业务逻辑
try {
methodIsonline.invoke(sonDriver, true);
methodIserror.invoke(sonDriver, false);
} catch (Exception e) {
}
//判断是否符合生成任务的条件,如果需要生成任务在该驱动的isSatisfyCreateTask方法中做一些逻辑判断
//断条件是否满足,如果满足就返回需要执行的任务方法名,如果不满足就返回null
Method methodIsSatisfyCreateTask = null;
try {
methodIsSatisfyCreateTask = sonDriverClass.getMethod("isSatisfyCreateTask");
} catch (Exception e) {
}
//通过反射获取isSatisfyCreateTask返回的需要生成任务的方法名
String methodName = null;
if (ObjectUtil.isNotEmpty(methodIsSatisfyCreateTask)) {
Object o = methodIsSatisfyCreateTask.invoke(sonDriver);
if (ObjectUtil.isNotEmpty(o)) {
methodName = (String) o;
}
}
//判断方法名是否为空,如果为空则不需要生成任务 不做任何操作
//不为空则执行生成任务的方法
if (StrUtil.isNotEmpty(methodName)) {
Method methodTask = null;
try {
methodTask = sonDriverClass.getMethod(methodName);
} catch (Exception e) {
}
if (ObjectUtil.isNotEmpty(methodTask)) {
methodTask.invoke(sonDriver);
}
//sonDriverClass.getMethod(methodName).invoke(sonDriver);
}
//method2 也是做做一些业务处理的方法 设备正常执行时 比如说任务完成时,需要做的一些业务逻辑等
Method method2 = null;
try {
method2 = sonDriverClass.getMethod("method2");
} catch (Exception e) {
}
if (ObjectUtil.isNotEmpty(method2)) {
method2.invoke(sonDriver);
}
}
//赋值last_属性 将当前读取到的值赋值给需要记录的上一次值
//首先获取驱动中的所有属性
Field[] declaredFields = sonDriverClass.getDeclaredFields();
//遍历所有属性
for (Field declaredField : declaredFields) {
//获取属性名称
String fieldName = declaredField.getName();
//获取属性类型
Class<?> fieldType = declaredField.getType();
//判断属性类型是否位int或Integer 因为需要将当前值赋值给记录上一次值的变量的都是整型
if (fieldType == int.class || fieldType == Integer.class) {
//判断属性名是否包含last_,因为只有设备需要记录上一次的点位值才含有last_
if (fieldName.contains("last_")) {
//获取执行赋值的方法
Method method = null;
try {
method = sonDriverClass.getMethod("set" + initialUpperCase(fieldName), int.class);
} catch (Exception e) {
}
//将属性名从last_后截取,因为要读取当前的属性值
int index = fieldName.indexOf("last_");
String subName = fieldName.substring(index + 5);
//获取执行获取当前点位值的方法
Method methodSub = null;
try {
methodSub = sonDriverClass.getMethod("get" + initialUpperCase(subName));
} catch (Exception e) {
}
//执行获取当前点位值的方法,并将获取的值付给当前点位值
int nowItemValue = 0;
if (ObjectUtil.isNotEmpty(methodSub)) {
nowItemValue = (int) methodSub.invoke(sonDriver);
}
//执行将当前点位值赋值给记录上次值的变量
if (ObjectUtil.isNotEmpty(method)) {
method.invoke(sonDriver, nowItemValue);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
//首字母转大写
public String initialUpperCase(String str) {
return str.substring(0, 1).toUpperCase() + str.substring(1, str.length());
}
}

93
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_palletizing_station/HailiangOldPalletizingStationDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.hailiang_old.hailiang_old_palletizing_station;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -14,6 +15,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.order.service.ProduceshiftorderService;
@ -33,7 +36,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -53,7 +56,8 @@ public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
Boolean isonline = true;
int hasGoods = 0;
@ -104,10 +108,57 @@ public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
number = this.itemProtocol.getNumber();
error = this.itemProtocol.getError();
boxtype = this.itemProtocol.getBoxtype();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
}
if (number != last_number) {
logServer.deviceItemValue(this.device_code, "number", String.valueOf(number));
logServer.deviceExecuteLog(this.device_code, "", "", "信号number:" + last_number + "->" + number);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (boxtype != last_boxtype) {
logServer.deviceItemValue(this.device_code, "boxtype", String.valueOf(boxtype));
logServer.deviceExecuteLog(this.device_code, "", "", "信号boxtype:" + last_boxtype + "->" + boxtype);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
}
}
protected void executing(Instruction instruction) {
@ -122,22 +173,6 @@ public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver
ReadUtil.write(itemMap, server);
}
public void writing(int command, int target, int task) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
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);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
@ -149,23 +184,19 @@ public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver
ReadUtil.write(itemMap, server);
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
public String isSatisfyCreateTask() {
return null;
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
return jo;
}
public void method1() {
@Override
public void setDeviceStatus(JSONObject data) {
}
public void method2() {
public String toString() {
return "";
}
}

4
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_palletizing_station/ItemProtocol.java

@ -108,5 +108,9 @@ public class ItemProtocol {
return list;
}
@Override
public String toString() {
return "ItemProtocol{}";
}
}

236
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_device/HailiangOldSpecialDeviceDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.hailiang_old.hailiang_old_special_device;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -14,6 +15,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.order.service.ProduceshiftorderService;
@ -33,7 +36,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -53,7 +56,8 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
int heartbeat = 0;
int mode = 0;
int line_status = 0;
@ -134,46 +138,131 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl
public Device getDevice() {
return this.device;
}
@Override
public synchronized void execute() throws Exception {
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
heartbeat = this.itemProtocol.getHeartbeat();
mode = this.itemProtocol.getMode();
line_status = this.itemProtocol.getLineStatus();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
is_open = this.itemProtocol.getIsOpen();
running = this.itemProtocol.getRunning();
finish = this.itemProtocol.getFinish();
all_ready = this.itemProtocol.getAllReady();
order_compel_finish = this.itemProtocol.getOrder_compel_finish();
order = this.itemProtocol.getOrder();
now_order_prod_num = this.itemProtocol.getNow_order_prod_num();
full_number = this.itemProtocol.getFull_number();
now_one_box_num = this.itemProtocol.getNow_one_box_num();
storage_stock_num = this.itemProtocol.getStorage_stock_num();
line_stock_num = this.itemProtocol.getLine_stock_num();
open_ready_time = this.itemProtocol.getOpen_ready_time();
device_running_time = this.itemProtocol.getDevice_running_time();
await_time = this.itemProtocol.getAwait_time();
order_prod_allnum = this.itemProtocol.getOrder_prod_allnum();
empty_is_lack = this.itemProtocol.getEmpty_is_lack();
device_is_running = this.itemProtocol.getDevice_is_running();
empty_is_finish = this.itemProtocol.getEmpty_is_finish();
full_ready_req_agv = this.itemProtocol.getFull_ready_req_agv();
full_out = this.itemProtocol.getFull_out();
device_prepare = this.itemProtocol.getDevice_prepare();
device_ready = this.itemProtocol.getDevice_ready();
line_ready = this.itemProtocol.getLine_ready();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
}
if (finish != last_finish) {
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish);
}
if (order_compel_finish != last_order_compel_finish) {
logServer.deviceItemValue(this.device_code, "order_compel_finish", String.valueOf(order_compel_finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_compel_finish:" + last_order_compel_finish + "->" + order_compel_finish);
}
if (order != last_order) {
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order);
}
if (now_order_prod_num != last_now_order_prod_num) {
logServer.deviceItemValue(this.device_code, "now_order_prod_num", String.valueOf(now_order_prod_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_order_prod_num:" + last_now_order_prod_num + "->" + now_order_prod_num);
}
if (full_number != last_full_number) {
logServer.deviceItemValue(this.device_code, "full_number", String.valueOf(full_number));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_number:" + last_full_number + "->" + full_number);
}
if (now_one_box_num != last_now_one_box_num) {
logServer.deviceItemValue(this.device_code, "now_one_box_num", String.valueOf(now_one_box_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_one_box_num:" + last_now_one_box_num + "->" + now_one_box_num);
}
if (storage_stock_num != last_storage_stock_num) {
logServer.deviceItemValue(this.device_code, "storage_stock_num", String.valueOf(storage_stock_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_stock_num:" + last_storage_stock_num + "->" + storage_stock_num);
}
if (line_stock_num != last_line_stock_num) {
logServer.deviceItemValue(this.device_code, "line_stock_num", String.valueOf(line_stock_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号line_stock_num:" + last_line_stock_num + "->" + line_stock_num);
}
if (order_prod_allnum != last_order_prod_allnum) {
logServer.deviceItemValue(this.device_code, "order_prod_allnum", String.valueOf(order_prod_allnum));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_prod_allnum:" + last_order_prod_allnum + "->" + order_prod_allnum);
}
if (empty_is_lack != last_empty_is_lack) {
logServer.deviceItemValue(this.device_code, "empty_is_lack", String.valueOf(empty_is_lack));
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_is_lack:" + last_empty_is_lack + "->" + empty_is_lack);
}
if (empty_is_finish != last_empty_is_finish) {
logServer.deviceItemValue(this.device_code, "empty_is_finish", String.valueOf(empty_is_finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_is_finish:" + last_empty_is_finish + "->" + empty_is_finish);
}
if (full_ready_req_agv != last_full_ready_req_agv) {
logServer.deviceItemValue(this.device_code, "full_ready_req_agv", String.valueOf(full_ready_req_agv));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_ready_req_agv:" + last_full_ready_req_agv + "->" + full_ready_req_agv);
}
if (full_out != last_full_out) {
logServer.deviceItemValue(this.device_code, "full_out", String.valueOf(full_out));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_out:" + last_full_out + "->" + full_out);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(int command, int target, int task) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
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);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
}
}
public void writing(String param, String value) {
@ -186,88 +275,13 @@ public class HailiangOldSpecialDeviceDriver extends AbstractOpcDeviceDriver impl
ReadUtil.write(itemMap, server);
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
public String isSatisfyCreateTask(){
@Override
public JSONObject getDeviceStatusName() {
return null;
}
public void method1(){
if (mode == 1 && last_mode == 0 && order > 0){
System.out.println("我进入方法一了");
}
// synchronized (this){
// int realError = 0;
// long now_feedTime = System.currentTimeMillis();
// if (now_feedTime - last_feedDeviceStatusTime >= 5000){
// heartbeat = this.itemProtocol.getHeartbeat();
// if (heartbeat == last_heartbeat){
// status_type = 01;
// } else {
// status_type = 02;
// if (error == 1 || error == 51) {
// status_type = 05;
// realError = error;
// }else if (mode == 1 && order > 0) {
// status_type = 03;
// realError = 0;
// } else if (mode == 0 && order > 0) {
// realError = 0;
// status_type = 04;
// }
// }
// if (status_type != last_status_type) {
// JSONObject map = new JSONObject();
// map.put("device_code", device_code);
// map.put("status_type", "0" + status_type);
// map.put("start_time", DateUtil.now());
// map.put("error_code",realError);
// acsToWmsService.feedDeviceStatusType(map);
// last_status_type = status_type;
// }
// last_feedDeviceStatusTime = now_feedTime;
// last_heartbeat = heartbeat;
// }
// }
}
@Override
public void setDeviceStatus(JSONObject data) {
public void method2(){
if (mode == 0 && last_mode == 1 && order > 0){
System.out.println("我进入方法2了");
}
// if ( mode == 1 && finish != last_finish && finish == 1 && order > 0){
// ProduceshiftorderDto dto = new ProduceshiftorderDto();
// dto.setOrder_code(order + "");
// dto.setOrder_status("2");
// ProduceshiftorderDto deviceInfo = produceshiftorderService.findOrderByDeviceCode(this.device_code);
// if(deviceInfo != null){
// if (StrUtil.isNotEmpty(deviceInfo.getExt_order_id())) {
// String ext_order_id = deviceInfo.getExt_order_id();
// JSONObject param = new JSONObject();
// param.put("ext_order_id",ext_order_id);
// acsToWmsService.feedbackOrderStatus(param);
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的外部标识:"+ext_order_id);
// }else {
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单的没有外部标识");
// }
// }else {
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,对应的工单信息为空");
// }
// produceshiftorderService.updateByOrderCode(dto);
// this.writing("to_confirm_finished","1");
// this.writing("to_order", "0");
// this.writing("to_clear","1");
// this.writing("to_pause","1");
// } else {
// logServer.deviceLogToacs(this.device_code,"","",device_code+":,finish>"+ finish +",last_finish>"+last_finish + "mode:" + mode + "order:" + order);
// }
}
}

127
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_empty_station/HailiangOldSpecialEmptyStationDeviceDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.hailiang_old.hailiang_old_special_empty_station;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -15,6 +16,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.route.service.RouteLineService;
@ -34,7 +37,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldSpecialEmptyStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldSpecialEmptyStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -54,7 +57,8 @@ public class HailiangOldSpecialEmptyStationDeviceDriver extends AbstractOpcDevic
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
String container;
int agvphase = 0;
@ -144,49 +148,72 @@ public class HailiangOldSpecialEmptyStationDeviceDriver extends AbstractOpcDevic
public void execute() throws Exception {
String message = null;
try {
this.signalIsException(this);
device_code = this.getDeviceCode();
mode = this.getItemProtocol().getMode();
status = this.getItemProtocol().getStatus();
move = this.getItemProtocol().getMove();
finish = this.getItemProtocol().getFinish();
allready = this.getItemProtocol().getAllReady();
order = this.getItemProtocol().getOrder();
error = this.getItemProtocol().getError();
task = this.getItemProtocol().getTask();
running = this.getItemProtocol().getRunning();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
}
if (finish != last_finish) {
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish);
}
if (allready != last_all_ready) {
logServer.deviceItemValue(this.device_code, "allready", String.valueOf(allready));
logServer.deviceExecuteLog(this.device_code, "", "", "信号allready:" + last_all_ready + "->" + allready);
}
if (order != last_order) {
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(int command, int target, int task) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
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);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
}
public void writing(int type, int command) {
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
}
}
public void writing(String key, String value) {
@ -199,21 +226,13 @@ public class HailiangOldSpecialEmptyStationDeviceDriver extends AbstractOpcDevic
ReadUtil.write(itemMap, server);
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
public String isSatisfyCreateTask(){
@Override
public JSONObject getDeviceStatusName() {
return null;
}
public void method1(){}
public void method2(){}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

92
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_full_station/HailiangOldSpecialFullStationDeviceDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.hailiang_old.hailiang_old_special_full_station;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -15,6 +16,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.order.service.ProduceshiftorderService;
@ -34,7 +37,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldSpecialFullStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldSpecialFullStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -54,6 +57,8 @@ public class HailiangOldSpecialFullStationDeviceDriver extends AbstractOpcDevice
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
String container;
String container_type_desc;
@ -151,17 +156,78 @@ public class HailiangOldSpecialFullStationDeviceDriver extends AbstractOpcDevice
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
mode = this.getItemProtocol().getMode();
move = this.getItemProtocol().getMove();
status = this.getItemProtocol().getStatus();
finish = this.getItemProtocol().getFinish();
all_ready = this.getItemProtocol().getAll_Ready();
order = this.getItemProtocol().getOrder();
error = this.getItemProtocol().getError();
task = this.getItemProtocol().getTask();
full_number = this.getItemProtocol().getFull_number();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (move != last_move) {
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
}
if (finish != last_finish) {
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish);
}
if (all_ready != last_all_ready) {
logServer.deviceItemValue(this.device_code, "all_ready", String.valueOf(all_ready));
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_ready:" + last_all_ready + "->" + all_ready);
}
if (order != last_order) {
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
}
if (full_number != last_full_number) {
logServer.deviceItemValue(this.device_code, "full_number", String.valueOf(full_number));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_number:" + last_full_number + "->" + full_number);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
}
}
public boolean exe_business() {
return true;
}
@ -188,20 +254,14 @@ public class HailiangOldSpecialFullStationDeviceDriver extends AbstractOpcDevice
itemMap.put(to_command, value);
ReadUtil.write(itemMap, server);
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
public String isSatisfyCreateTask(){
@Override
public JSONObject getDeviceStatusName() {
return null;
}
public void method1(){}
public void method2(){}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

118
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_pick_station/HailiangOldSpecialPickStationDeviceDriver.java

@ -18,6 +18,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.WcsConfig;
@ -42,7 +44,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldSpecialPickStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldSpecialPickStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -60,6 +62,9 @@ public class HailiangOldSpecialPickStationDeviceDriver extends AbstractOpcDevice
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
String container;
String container_type_desc;
String last_container_type_desc;
@ -150,52 +155,69 @@ public class HailiangOldSpecialPickStationDeviceDriver extends AbstractOpcDevice
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
mode = this.getItemProtocol().getMode();
status = this.getItemProtocol().getStatus();
error = this.getItemProtocol().getError();
task = this.getItemProtocol().getTask();
finish = this.getItemProtocol().getFinish();
order = this.getItemProtocol().getOrder();
full_number = this.getItemProtocol().getFull_number();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
}
if (finish != last_finish) {
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish);
}
if (order != last_order) {
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order);
}
if (full_number != last_full_number) {
logServer.deviceItemValue(this.device_code, "full_number", String.valueOf(full_number));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_number:" + last_full_number + "->" + full_number);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
}
}
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
public void writing(int command) {}
public void writing(int command, int target, int task) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
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);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
}
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;
@ -206,19 +228,13 @@ public class HailiangOldSpecialPickStationDeviceDriver extends AbstractOpcDevice
ReadUtil.write(itemMap, server);
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
public String isSatisfyCreateTask(){
@Override
public JSONObject getDeviceStatusName() {
return null;
}
public void method1(){}
public void method2(){}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

133
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_special_pour_station/HailiangOldSpecialPourStationDeviceDriver.java

@ -1,5 +1,6 @@
package org.nl.acs.device_driver.hailiang_old.hailiang_old_special_pour_station;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -15,6 +16,8 @@ import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.route.service.RouteLineService;
@ -33,7 +36,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -53,7 +56,8 @@ public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDevice
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
String container;
String container_type_desc;
@ -103,8 +107,8 @@ public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDevice
private int instruction_finished_time_out;
private Date instruction_apply_time = new Date();
int agvphase=0;
int index =0;
int agvphase = 0;
int index = 0;
int branchProtocol = 0;
//备注
@ -143,27 +147,81 @@ public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDevice
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
mode = this.getItemProtocol().getMode();
error = this.getItemProtocol().getError();
task = this.getItemProtocol().getTask();
status = this.getItemProtocol().getStatus();
running = this.getItemProtocol().getRunning();
finish = this.getItemProtocol().getFinish();
all_ready = this.getItemProtocol().getAll_Ready();
storage_stock_num = this.getItemProtocol().getStorage_stock_num();
line_stock_num = this.getItemProtocol().getLine_stock_num();
order = this.getItemProtocol().getOrder();
full_number = this.getItemProtocol().getFull_number();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
}
if (finish != last_finish) {
logServer.deviceItemValue(this.device_code, "finish", String.valueOf(finish));
logServer.deviceExecuteLog(this.device_code, "", "", "信号finish:" + last_finish + "->" + finish);
}
if (all_ready != last_all_ready) {
logServer.deviceItemValue(this.device_code, "all_ready", String.valueOf(all_ready));
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_ready:" + last_all_ready + "->" + all_ready);
}
if (storage_stock_num != last_storage_stock_num) {
logServer.deviceItemValue(this.device_code, "storage_stock_num", String.valueOf(storage_stock_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号storage_stock_num:" + last_storage_stock_num + "->" + storage_stock_num);
}
if (line_stock_num != last_line_stock_num) {
logServer.deviceItemValue(this.device_code, "line_stock_num", String.valueOf(line_stock_num));
logServer.deviceExecuteLog(this.device_code, "", "", "信号line_stock_num:" + last_line_stock_num + "->" + line_stock_num);
}
if (order != last_order) {
logServer.deviceItemValue(this.device_code, "order", String.valueOf(order));
logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order);
}
if (full_number != last_full_number) {
logServer.deviceItemValue(this.device_code, "full_number", String.valueOf(full_number));
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_number:" + last_full_number + "->" + full_number);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
public boolean exe_business() {
return true;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
}
@ -177,36 +235,13 @@ public class HailiangOldSpecialPourStationDeviceDriver extends AbstractOpcDevice
ReadUtil.write(itemMap, server);
}
public void writing(int command, int target, int task) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
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);
itemMap.put(to_target, target);
itemMap.put(to_task, task);
ReadUtil.write(itemMap, server);
@Override
public JSONObject getDeviceStatusName() {
return null;
}
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
// if (name.equals("mode")) {
// this.setRequireSucess(false);
// }
}
}
@Override
public void setDeviceStatus(JSONObject data) {
public String isSatisfyCreateTask(){
return null;
}
public void method1(){}
public void method2(){}
}

181
acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang_old/hailiang_old_stacking_manipulator/HailiangOldStackingManipulatorDriver.java

@ -14,7 +14,8 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
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.order.service.ProduceshiftorderService;
@ -32,7 +33,7 @@ import java.util.*;
@Slf4j
@Data
@RequiredArgsConstructor
public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver {
public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@ -52,7 +53,8 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class);
@Autowired
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
//心跳
int heartbeat = 0;
int last_heartbeat = 0;
@ -89,7 +91,6 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
Boolean stackingRequireSuccess = false;
//当前设备状态 01代表 关机, 02代表 开机, 03代表 生产中, 04代表 待机, 05代表 异常
int status_type = 0;
//上次设备状态
@ -124,39 +125,85 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
String message = null;
try {
device_code = this.getDeviceCode();
this.signalIsException(this);
mode = this.getItemProtocol().getMode();
status = this.getItemProtocol().getStatus();
action = this.getItemProtocol().getAction();
error = this.getItemProtocol().getError();
getStation = this.getItemProtocol().getGetStation();
putStation = this.getItemProtocol().getPutStation();
encoder_qty = this.getItemProtocol().getEncoder_qty();
boxtype = this.getItemProtocol().getBoxtype();
if (mode != last_mode) {
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
}
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
}
if (action != last_action) {
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
}
if (getStation != last_getStation) {
logServer.deviceItemValue(this.device_code, "getStation", String.valueOf(getStation));
logServer.deviceExecuteLog(this.device_code, "", "", "信号getStation:" + last_getStation + "->" + getStation);
}
if (putStation != last_putStation) {
logServer.deviceItemValue(this.device_code, "putStation", String.valueOf(putStation));
logServer.deviceExecuteLog(this.device_code, "", "", "信号putStation:" + last_putStation + "->" + putStation);
}
if (encoder_qty != last_encoder_qty) {
logServer.deviceItemValue(this.device_code, "encoder_qty", String.valueOf(encoder_qty));
logServer.deviceExecuteLog(this.device_code, "", "", "信号encoder_qty:" + last_encoder_qty + "->" + encoder_qty);
}
if (boxtype != last_boxtype) {
logServer.deviceItemValue(this.device_code, "boxtype", String.valueOf(boxtype));
logServer.deviceExecuteLog(this.device_code, "", "", "信号boxtype:" + last_boxtype + "->" + boxtype);
}
} catch (Exception var17) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
return;
}
}
//判断是否生成任务 如果生成任务返回执行该任务的方法名,如果不需要生成任务则返回null
public String isSatisfyCreateTask() {
return null;
}
public void method1() {
}
public void method2() {
switch (action) {
case 1:
if (!vehicleInfoRequireSuccess){
getVehicleInfo();
}
break;
case 2:
if (!singlePlacementRequireSuccess){
singlePlacementCompleted();
}
break;
case 3:
if (!stackingRequireSuccess){
stackingCompleted();
}
break;
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
//有报警
} else if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
this.setIsonline(true);
this.setIserror(false);
switch (action) {
case 1:
if (!vehicleInfoRequireSuccess) {
getVehicleInfo();
}
break;
case 2:
if (!singlePlacementRequireSuccess) {
singlePlacementCompleted();
}
break;
case 3:
if (!stackingRequireSuccess) {
stackingCompleted();
}
break;
}
}
}
@ -187,17 +234,17 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
String boxtype = resp.getString("boxtype");
if (code == 200) {
//根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置
int getIndex = putDeviceCodeList.indexOf(getStation);
int getIndex = getDeviceCodeList.indexOf(getStation);
int putIndex = putDeviceCodeList.indexOf(putStation);
//将的到的索引 + 1 写入kep中
this.writing("to_feedback", "1");
this.writing("to_getStation", String.valueOf(getIndex + 1));
this.writing("to_putStation", String.valueOf(putIndex + 1));
this.writing("to_boxtype", boxtype);
this.writing("to_feedback", "1");
//获取托盘信息成功后 设为true 防止多次请求 等单次防止完成时设为false
this.setVehicleInfoRequireSuccess(true);
} else {
log.warn("获取托盘信息失败!设备号:{},原因{}", device_code,message);
log.warn("获取托盘信息失败!设备号:{},原因{}", device_code, message);
}
}
return true;
@ -229,11 +276,11 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
int code = Integer.parseInt(resp.getString("code"));
String message = resp.getString("message");
JSONObject data = resp.getJSONObject("data");
if (code == 200){
this.writing("to_feedback","2");
if (code == 200) {
this.writing("to_feedback", "2");
this.setSinglePlacementRequireSuccess(true);
} else {
log.warn("单次放置完成反馈失败!设备号:{},原因{}", device_code,message);
log.warn("单次放置完成反馈失败!设备号:{},原因{}", device_code, message);
}
}
return true;
@ -260,39 +307,29 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
int code = Integer.parseInt(resp.getString("code"));
String message = resp.getString("message");
JSONObject data = resp.getJSONObject("data");
if (code == 200){
this.writing("to_feedback","3");
if (code == 200) {
this.writing("to_feedback", "3");
this.setStackingRequireSuccess(true);
} else {
log.warn("码垛完成反馈失败!设备号:{},原因{}", device_code,message);
log.warn("码垛完成反馈失败!设备号:{},原因{}", device_code, message);
}
}
return true;
}
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName){
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
String[] devices = extraValue.substring(1, extraValue.length() - 1).split(",");
List<String> devicesList = Arrays.asList(devices);
String devices1 = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devices1.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
protected void executing(Instruction instruction) {
this.executing(1, instruction, "");
}
public void executing(int command, Instruction instruction, String appendMessage) {
}
public void executing(Server server, Map<String, Object> itemMap) {
ReadUtil.write(itemMap, server);
}
//写入kep点位值
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
@ -304,20 +341,14 @@ public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDrive
ReadUtil.write(itemMap, server);
}
//判断当前点位值和上一次值是否一致 不一致写入日志并且复位请求成功标志
public void writeLogInfo(String device_code, String name, int lastNumber, int nowNumber) {
super.writeLogInfo(device_code, name, lastNumber, nowNumber);
if (lastNumber != nowNumber) {
if (name.equals("action")) {
if (action == 1){
this.setVehicleInfoRequireSuccess(false);
} else if (action == 2){
this.setSinglePlacementRequireSuccess(false);
} else if (action == 3){
this.setStackingRequireSuccess(false);
}
}
}
@Override
public JSONObject getDeviceStatusName() {
return null;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
public String toString() {

194
acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -26,12 +26,15 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Random;
@Service
@RequiredArgsConstructor
@Slf4j
public class AcsToWmsServiceImpl implements AcsToWmsService {
int a = 0;
@Autowired
AcsConfigService acsConfigService;
@ -50,8 +53,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Value("${acsTowms.token}")
public String token;
private String log_file_type="log_file_type";
private String log_type="ACS请求WMS";
private String log_file_type = "log_file_type";
private String log_type = "ACS请求WMS";
@Override
public String applyTaskToWms(String device_code, String container_code, int height, int weight) {
@ -96,7 +99,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
// logServer.log("", "applyTaskToWms", type, jo.toString(), result2.body(), String.valueOf(result2.getStatus()), url, container_code);
log.info("applyTaskToWms-----输出参数{}", result2.body());
return result2.body();
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -136,7 +139,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("applyTaskManipulatorToWms-----输出参数{}", result2.body());
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -177,7 +180,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("applyOuttoKiln-----输出参数{}", result2.body());
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -218,14 +221,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("lnshApplyTaskToWms-----输出参数{}", result2.body());
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
}
@Override
public HttpResponse applyBarcode(JSONObject json) {
try {
@ -261,7 +263,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("lnshApplyTaskToWms-----输出参数{}", result2.body());
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -302,7 +304,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("lnshApplyTaskToWms-----输出参数{}", result2.body());
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -310,38 +312,59 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONObject getVehicle(JSONObject json) {
JSONObject map = new JSONObject();
map.put("code",200);
map.put("message","成功");
map.put("getStation","X001");
map.put("putStation","L001");
map.put("encoder_qty","1");
map.put("boxtype","1");
return map;
// try {
// MDC.put(log_file_type, log_type);
// String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
// AddressDto addressDto = addressService.findByCode("getVehicle");
// String methods_url = addressDto.getMethods_url();
// String url = wmsurl + methods_url;
// log.info("getVehicle----获取托盘信息请求参数{}", json.toString());
// HttpResponse result = null;
// try {
// result = HttpRequest.post(url)
// .header("Authorization", token)
// .body(String.valueOf(json))
// .execute();
// System.out.println(result);
// } catch (Exception e) {
// System.out.println(e.getMessage());
// }
// log.info("getVehicle----获取托盘信息返回参数{}", result.body());
// JSONObject jo = JSONObject.parseObject(result.body());
// return jo;
// } finally {
// MDC.remove(log_file_type);
// String getStation = json.getString("getStation");
// JSONObject map = new JSONObject();
// Random r = new Random();
// int i = 1;
// if (a == 20){
// i = 2;
// }
// String a = "";
// if (i == 1) {
// a = "L001";
// } else if (i == 2){
// a = "L002";
// } else if (i == 3){
// a = "L003";
// } else if (i == 4){
// a = "L004";
// }else if (i == 5){
// a = "L005";
// }else if (i == 6){
// a = "L006";
// }else {
// a = "L002";
// }
// map.put("code",200);
// map.put("message","成功");
// map.put("getStation",getStation);
// map.put("putStation",a);
// map.put("encoder_qty","1");
// map.put("boxtype","1");
// return map;
try {
MDC.put(log_file_type, log_type);
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("getVehicle");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
log.info("getVehicle----获取托盘信息请求参数{}", json.toString());
HttpResponse result = null;
try {
result = HttpRequest.post(url)
.header("Authorization", token)
.body(String.valueOf(json))
.execute();
System.out.println(result);
} catch (Exception e) {
System.out.println(e.getMessage());
}
log.info("getVehicle----获取托盘信息返回参数{}", result.body());
JSONObject jo = JSONObject.parseObject(result.body());
return jo;
} finally {
MDC.remove(log_file_type);
}
}
@Override
@ -367,7 +390,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("getVehicleTokiln----返回参数{}", result.body());
JSONObject jo = JSONObject.parseObject(result.body());
return jo;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -396,7 +419,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("getVehicleTokiln----返回参数{}", result.body());
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -425,7 +448,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
log.info("outKiln----返回参数{}", result.body());
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -454,7 +477,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
log.info("enterOrder----返回参数{}", result.body());
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -465,7 +488,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
} finally {
} finally {
MDC.remove(log_file_type);
}
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
@ -474,7 +497,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String url = wmsurl + methods_url;
JSONObject json = new JSONObject();
json.put("device_code",device_code);
json.put("device_code", device_code);
log.info("getVehicleCode----请求参数{}", json.toString());
HttpResponse result = null;
@ -496,7 +519,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
} finally {
} finally {
MDC.remove(log_file_type);
}
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
@ -505,7 +528,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
String url = wmsurl + methods_url;
JSONObject json = new JSONObject();
json.put("vehicle_code",vehicle_code);
json.put("vehicle_code", vehicle_code);
log.info("getVehiclePoint----请求参数{}", json.toString());
HttpResponse result = null;
@ -528,7 +551,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
try {
MDC.put(log_file_type, log_type);
} finally {
} finally {
MDC.remove(log_file_type);
}
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
@ -603,7 +626,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
resultJson.put("data", new JSONArray());
log.info("feedbackPointStatusToWms----输出参数{}", resultJson.toString());
return resultJson;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -611,26 +634,26 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONArray getDeviceStatusToWms() {
try {
MDC.put(log_file_type,log_type);
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("getDeviceStatusToWms");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
String result = "";
try {
result = HttpRequest.get(url)
.execute().body();
System.out.println(result);
log.info("getTaskStatusToWms----返回参数{}", result);
} catch (Exception e) {
System.out.println(e.getMessage());
}
JSONArray jsonArray = JSONArray.parseArray(result);
return jsonArray;
}finally {
MDC.remove(log_file_type);
}
try {
MDC.put(log_file_type, log_type);
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("getDeviceStatusToWms");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
String result = "";
try {
result = HttpRequest.get(url)
.execute().body();
System.out.println(result);
log.info("getTaskStatusToWms----返回参数{}", result);
} catch (Exception e) {
System.out.println(e.getMessage());
}
JSONArray jsonArray = JSONArray.parseArray(result);
return jsonArray;
} finally {
MDC.remove(log_file_type);
}
}
@ -662,7 +685,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -698,7 +721,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -739,7 +762,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -771,7 +794,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result2;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -806,7 +829,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -845,7 +868,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -874,7 +897,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -905,7 +928,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
System.out.println(msg);
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -933,7 +956,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
return result;
} finally {
} finally {
MDC.remove(log_file_type);
}
@ -942,9 +965,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONObject singlePlacementCompleted(JSONObject param) {
JSONObject map = new JSONObject();
map.put("code",200);
map.put("message","成功");
map.put("data",null);
map.put("code", 200);
map.put("message", "成功");
map.put("data", null);
return map;
// try {
// MDC.put(log_file_type, log_type);
@ -972,10 +995,11 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
public JSONObject stackingCompleted(JSONObject param) {
a = 20;
JSONObject map = new JSONObject();
map.put("code",200);
map.put("message","成功");
map.put("data",null);
map.put("code", 200);
map.put("message", "成功");
map.put("data", null);
return map;
// try {
// MDC.put(log_file_type, log_type);

Loading…
Cancel
Save