|
|
@ -8,6 +8,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@Data |
|
|
|
public class ItemProtocol { |
|
|
|
|
|
|
|
|
|
|
@ -30,48 +31,48 @@ public class ItemProtocol { |
|
|
|
this.driver = driver; |
|
|
|
} |
|
|
|
|
|
|
|
public String getWeight() { |
|
|
|
return String.valueOf(this.getOpcFloatValue(item_weight)); |
|
|
|
public Float getWeight() { |
|
|
|
return this.getOpcFloatValue(item_weight); |
|
|
|
} |
|
|
|
|
|
|
|
public String getProductCode() { |
|
|
|
return String.valueOf(this.getOpcStringValue(item_product_code)); |
|
|
|
return this.getOpcStringValue(item_product_code); |
|
|
|
} |
|
|
|
|
|
|
|
public String getBatchCode() { |
|
|
|
return String.valueOf(this.getOpcStringValue(item_batch_code)); |
|
|
|
return this.getOpcStringValue(item_batch_code); |
|
|
|
} |
|
|
|
|
|
|
|
public String getProductSpecifications() { |
|
|
|
return String.valueOf(this.getOpcStringValue(item_product_specifications)); |
|
|
|
return this.getOpcStringValue(item_product_specifications); |
|
|
|
} |
|
|
|
|
|
|
|
public String getYear() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_year)); |
|
|
|
public Integer getYear() { |
|
|
|
return this.getOpcIntegerValue(item_year); |
|
|
|
} |
|
|
|
|
|
|
|
public String getMonth() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_month)); |
|
|
|
public Integer getMonth() { |
|
|
|
return this.getOpcIntegerValue(item_month); |
|
|
|
} |
|
|
|
|
|
|
|
public String getDay() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_day)); |
|
|
|
public Integer getDay() { |
|
|
|
return this.getOpcIntegerValue(item_day); |
|
|
|
} |
|
|
|
|
|
|
|
public String getHour() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_hour)); |
|
|
|
public Integer getHour() { |
|
|
|
return this.getOpcIntegerValue(item_hour); |
|
|
|
} |
|
|
|
|
|
|
|
public String getMinute() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_minute)); |
|
|
|
public Integer getMinute() { |
|
|
|
return this.getOpcIntegerValue(item_minute); |
|
|
|
} |
|
|
|
|
|
|
|
public String getSecond() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_second)); |
|
|
|
public Integer getSecond() { |
|
|
|
return this.getOpcIntegerValue(item_second); |
|
|
|
} |
|
|
|
|
|
|
|
public String getFlag() { |
|
|
|
return String.valueOf(this.getOpcIntegerValue(item_flag)); |
|
|
|
public Integer getFlag() { |
|
|
|
return this.getOpcIntegerValue(item_flag); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -81,47 +82,42 @@ public class ItemProtocol { |
|
|
|
return move; |
|
|
|
} |
|
|
|
|
|
|
|
public Boolean getIsonline() { |
|
|
|
return isonline; |
|
|
|
} |
|
|
|
|
|
|
|
public void setIsonline(Boolean isonline) { |
|
|
|
this.isonline = isonline; |
|
|
|
} |
|
|
|
|
|
|
|
Boolean isonline; |
|
|
|
|
|
|
|
public int getOpcIntegerValue(String protocol) { |
|
|
|
Integer value = this.driver.getIntegeregerValue(protocol); |
|
|
|
Integer value = this.driver.getIntegerValue(protocol); |
|
|
|
if (value == null) { |
|
|
|
|
|
|
|
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
|
|
|
setIsonline(false); |
|
|
|
} else { |
|
|
|
setIsonline(true); |
|
|
|
return value; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public String getOpcStringValue(String protocol) { |
|
|
|
String value = this.driver.getStringValue(protocol); |
|
|
|
|
|
|
|
public Float getOpcFloatValue(String protocol) { |
|
|
|
Float value = this.driver.getFloatValue(protocol); |
|
|
|
if (value == null) { |
|
|
|
//throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
|
|
|
|
|
|
|
|
} else { |
|
|
|
return value; |
|
|
|
} |
|
|
|
return "0"; |
|
|
|
return 0f; |
|
|
|
} |
|
|
|
|
|
|
|
public float getOpcFloatValue(String protocol) { |
|
|
|
float value = this.driver.getFloatValue(protocol); |
|
|
|
if (value == 0) { |
|
|
|
public String getOpcStringValue(String protocol) { |
|
|
|
String value = this.driver.getStringValue(protocol); |
|
|
|
if (value == null) { |
|
|
|
//throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)});
|
|
|
|
|
|
|
|
} else { |
|
|
|
return value; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
|
|
|
|
return "0"; |
|
|
|
} |
|
|
|
|
|
|
|
public static List<ItemDto> getReadableItemDtos() { |
|
|
|