This commit is contained in:
USER-20220102CG\noblelift
2023-02-10 17:25:45 +08:00
parent 98e1736c0a
commit 60df5d317e
9 changed files with 143 additions and 44 deletions

View File

@@ -74,6 +74,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
public int error = 0;
public int door = 0;
public int temperature = 0;
public int to_temperature = 0;
public int countdown_house = 0;
public int countdown_min = 0;
public int countdown_sec = 0;
@@ -120,6 +121,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
String device_code;
String message = null;
@Override
public Device getDevice() {
return this.device;
@@ -130,7 +134,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
@Override
public void execute() {
String message = null;
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getItem_heartbeat();
@@ -154,7 +157,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
currentA = this.itemProtocol.getItem_currentA();
currentB = this.itemProtocol.getItem_currentB();
currentC = this.itemProtocol.getItem_currentC();
to_temperature = this.itemProtocol.getItem_to_temperature();
if (mode != last_mode) {
//this.setRequireSucess(false);
}
@@ -187,6 +190,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
if (finish == 1 && !requireSucess) {
message = "烘箱完成反馈LMS...";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "开始烘箱完成反馈lms~");
//烘箱完成反馈LMS
apply_finish();
@@ -358,8 +362,10 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
requireSucess = true;
message = "烘箱完成反馈LMS成功...";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
} else {
message = "烘箱完成反馈LMS失败"+String.valueOf(applyLabelingAndBindingResponse);
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
}
return true;

View File

@@ -118,6 +118,10 @@ public class ItemProtocol {
return this.getOpcFloatValue(item_currentC);
} ;
public int getItem_to_temperature(){
return this.getOpcIntegerValue(item_to_temperature);
} ;
Boolean isonline;
public int getOpcIntegerValue(String protocol) {

View File

@@ -232,7 +232,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min());
jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec());
//温度需要除以10
jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature()/10);
jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
jo.put("door", hongXiangConveyorDeviceDriver.getDoor());
jo.put("finish", hongXiangConveyorDeviceDriver.getFinish());
jo.put("task", hongXiangConveyorDeviceDriver.getTask());

View File

@@ -83,7 +83,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
}
}
Thread.sleep(10000L);
// Thread.sleep(10000L);
log.info("设备执行线程开始...");
while (true) {

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.wql.core.bean.ResultBean;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
@@ -34,7 +35,12 @@ public class DeviceManageServiceImpl implements DeviceManageService {
String opc_plc_id = json.getString("opc_plc_id");
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
//OPC表【acs_opc】
String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
if(ObjectUtil.isEmpty(rb)){
System.out.println(device.getDevice_code());
continue;
}
String opc_code= rb.getString("opc_code");
device.setOpc_server_code(opc_code);
if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
{

View File

@@ -61,7 +61,11 @@ public class DeviceOpcProtocolRunable implements Runnable {
while (true) {
try {
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
Group group = server.addGroup();
// Group group = server.addGroup(this.OpcServer.getOpc_host());
Group group = server.addGroup(this.OpcServer.getOpc_code());
if(ObjectUtil.isEmpty(group)){
log.info("group is null ");
}
List<String> itemsString = new ArrayList();
Iterator it = this.protocols.iterator();
@@ -110,11 +114,18 @@ public class DeviceOpcProtocolRunable implements Runnable {
label97:
while (true) {
long begin = System.currentTimeMillis();
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
Map<Item, ItemState> itemStatus = null;
try {
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
} catch (Exception e){
// System.out.println("数据同步异常:"+itemsMap);
e.printStackTrace();
}
long end = System.currentTimeMillis();
log.trace("{} 开始记时{}", tag, DateUtil.now());
long duration = end - begin;
log.trace("{} 读取耗时:{}", tag, duration);
System.out.println("线程:"+tag + " 读取耗时:"+ duration);
if (duration > 1000L) {
if (!time_out) {
log.warn("{} 读取超时 : {}", tag, duration);
@@ -125,6 +136,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
time_out = false;
}
if(ObjectUtil.isEmpty(itemStatus)) continue label97;
Set<Item> items = itemStatus.keySet();
Iterator var18 = items.iterator();
@@ -151,7 +164,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
ItemState itemState = (ItemState) itemStatus.get(item);
value = OpcUtl.getValue(item, itemState);
his = accessor_value.getValue(item.getId());
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
}
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
@@ -178,7 +191,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
}
} catch (Exception var30) {
String error_message = "设备信息同步异常";
String error_message = "设备信息同步异常,"+var30;
if (!StrUtil.equals(this.message, error_message)) {
log.warn("", var30);
}

View File

@@ -0,0 +1,78 @@
package org.nl.acs.opc;
import org.nl.modules.wql.exception.WDKException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;
public class ObjectUtl {
private ObjectUtl() {
}
public static boolean isEquals(Object a, Object b) {
if (a == null && b == null) {
return true;
} else if (a != null && b != null) {
if (a.getClass().isArray()) {
if (a instanceof boolean[]) {
return Arrays.equals((boolean[]) ((boolean[]) a), (boolean[]) ((boolean[]) b));
} else if (a instanceof byte[]) {
return Arrays.equals((byte[]) ((byte[]) a), (byte[]) ((byte[]) b));
} else if (a instanceof int[]) {
return Arrays.equals((int[]) ((int[]) a), (int[]) ((int[]) b));
} else if (a instanceof long[]) {
return Arrays.equals((long[]) ((long[]) a), (long[]) ((long[]) b));
} else if (a instanceof double[]) {
return Arrays.equals((double[]) ((double[]) a), (double[]) ((double[]) b));
} else if (a instanceof short[]) {
return Arrays.equals((short[]) ((short[]) a), (short[]) ((short[]) b));
} else if (a instanceof char[]) {
return Arrays.equals((char[]) ((char[]) a), (char[]) ((char[]) b));
} else if (a instanceof float[]) {
return Arrays.equals((float[]) ((float[]) a), (float[]) ((float[]) b));
} else if (a instanceof Object[]) {
return Arrays.equals((Object[]) ((Object[]) a), (Object[]) ((Object[]) b));
} else {
throw new WDKException("未实现");
}
} else {
return Objects.equals(a, b);
}
} else {
return false;
}
}
public static boolean isTrue(Boolean boolean_) {
return boolean_ != null && isEquals(boolean_, true);
}
public static boolean isTrue(Boolean targetBoolean, boolean defaultBoolean) {
return targetBoolean == null ? defaultBoolean : targetBoolean;
}
public static boolean isFalse(Boolean boolean_) {
return boolean_ != null && isEquals(boolean_, false);
}
public static boolean isObject(Class<?> clazz) {
if (clazz == null) {
return false;
} else if (clazz.getClass().isArray()) {
return false;
} else {
return Object.class.isAssignableFrom(clazz);
}
}
}

View File

@@ -29,7 +29,7 @@ public class opcServerManageServiceImpl implements OpcServerManageService {
public List<OpcServerManageDto> queryAll() {
//return this.opcServerRepository.queryAll(OpcServerManageDto.class);
//OPC表【acs_opc】
JSONArray arr = WQLObject.getWQLObject("acs_opc").query().getResultJSONArray(0);
JSONArray arr = WQLObject.getWQLObject("acs_opc").query("is_active='1' and is_delete='0'").getResultJSONArray(0);
return arr.toJavaList(OpcServerManageDto.class);
}