驱动读写优化,单字段读取异常不影响驱动运行
This commit is contained in:
@@ -19,11 +19,11 @@ public class ItemProtocol {
|
|||||||
public static String item_weight = "weight";
|
public static String item_weight = "weight";
|
||||||
public static String item_sub_tray = "sub_tray";
|
public static String item_sub_tray = "sub_tray";
|
||||||
public static String item_mother_tray = "mother_tray";
|
public static String item_mother_tray = "mother_tray";
|
||||||
public static String item_error_code="error_code";
|
public static String item_error_code = "error_code";
|
||||||
public static String item_device_type="device_type";
|
public static String item_device_type = "device_type";
|
||||||
public static String item_frame_type="frame_type";
|
public static String item_frame_type = "frame_type";
|
||||||
public static String item_mother_type="mother_type";
|
public static String item_mother_type = "mother_type";
|
||||||
public static String item_sub_type="sub_type";
|
public static String item_sub_type = "sub_type";
|
||||||
public static String item_to_command = "to_command";
|
public static String item_to_command = "to_command";
|
||||||
public static String item_to_target = "to_target";
|
public static String item_to_target = "to_target";
|
||||||
public static String item_to_task = "to_task";
|
public static String item_to_task = "to_task";
|
||||||
@@ -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,36 +108,46 @@ public class ItemProtocol {
|
|||||||
Boolean isonline;
|
Boolean isonline;
|
||||||
|
|
||||||
public int getOpcIntegerValue(String protocol) {
|
public int getOpcIntegerValue(String protocol) {
|
||||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
try {
|
||||||
if (value == null) {
|
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
if (value == null) {
|
||||||
setIsonline(false);
|
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||||
} else {
|
setIsonline(false);
|
||||||
setIsonline(true);
|
} else {
|
||||||
return value;
|
setIsonline(true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpcStringValue(String protocol) {
|
public String getOpcStringValue(String protocol) {
|
||||||
String value = this.driver.getStringValue(protocol);
|
try {
|
||||||
if (value != null) {
|
String value = this.driver.getStringValue(protocol);
|
||||||
return value;
|
if (value != null) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getOpcFloatValue(String protocol) {
|
public float getOpcFloatValue(String protocol) {
|
||||||
Float value = this.driver.getDoubleValue(protocol);
|
try {
|
||||||
if (value == null) {
|
Float value = this.driver.getDoubleValue(protocol);
|
||||||
setIsonline(false);
|
if (value == null) {
|
||||||
} else {
|
setIsonline(false);
|
||||||
setIsonline(true);
|
} else {
|
||||||
return value;
|
setIsonline(true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0L;
|
return 0L;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ItemDto> getReadableItemDtos() {
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user