Browse Source

驱动读写优化,单字段读取异常不影响驱动运行

master
psh 1 year ago
parent
commit
ca99141253
  1. 21
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java

21
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/ssx_site/ItemProtocol.java

@ -54,9 +54,11 @@ public class ItemProtocol {
public int getTask() { public int getTask() {
return this.getOpcIntegerValue(item_task); return this.getOpcIntegerValue(item_task);
} }
public double getWeight() { public double getWeight() {
return this.getOpcFloatValue(item_weight); return this.getOpcFloatValue(item_weight);
} }
public String getSubTray() { public String getSubTray() {
return this.getOpcStringValue(item_sub_tray); return this.getOpcStringValue(item_sub_tray);
} }
@ -106,6 +108,7 @@ public class ItemProtocol {
Boolean isonline; Boolean isonline;
public int getOpcIntegerValue(String protocol) { public int getOpcIntegerValue(String protocol) {
try {
Integer value = this.driver.getIntegeregerValue(protocol); Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) { if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
@ -114,19 +117,26 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return 0; } catch (Exception e) {
} }
return 0;
}
public String getOpcStringValue(String protocol) { public String getOpcStringValue(String protocol) {
try {
String value = this.driver.getStringValue(protocol); String value = this.driver.getStringValue(protocol);
if (value != null) { if (value != null) {
return value; return value;
} }
} catch (Exception e) {
}
return ""; return "";
} }
public float getOpcFloatValue(String protocol) { public float getOpcFloatValue(String protocol) {
try {
Float value = this.driver.getDoubleValue(protocol); Float value = this.driver.getDoubleValue(protocol);
if (value == null) { if (value == null) {
setIsonline(false); setIsonline(false);
@ -134,9 +144,11 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return 0L; } catch (Exception e) {
} }
return 0L;
}
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
@ -148,6 +160,11 @@ public class ItemProtocol {
list.add(new ItemDto(item_sub_tray, "子托盘条码", "DB600.D4")); list.add(new ItemDto(item_sub_tray, "子托盘条码", "DB600.D4"));
list.add(new ItemDto(item_mother_tray, "母托盘条码", "DB600.D4")); list.add(new ItemDto(item_mother_tray, "母托盘条码", "DB600.D4"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B5")); list.add(new ItemDto(item_error, "报警信号", "DB600.B5"));
list.add(new ItemDto(item_error_code, "超限/称重报警信号", "DB600.B6"));
list.add(new ItemDto(item_device_type, "称重信号", "DB600.B7"));
list.add(new ItemDto(item_frame_type, "检测框架信号", "DB600.B8"));
list.add(new ItemDto(item_mother_type, "母托信号", "DB600.B9"));
list.add(new ItemDto(item_sub_type, "子托信号", "DB600.B10"));
return list; return list;
} }

Loading…
Cancel
Save