严智鑫
2024-12-03 def1eb8623e1444164ae4bce9179d011a89b8c5e
JiuMuMesParent/common/servicebase/src/main/java/com/mes/service/PlcParameter.java
@@ -13,6 +13,8 @@
import java.util.HashMap;
import java.util.Map;
import static com.mes.tools.HexConversion.*;
/**
 * Plc参数
 */
@@ -51,6 +53,11 @@
     * 需要写入的值
     */
    private Object writeValue=null;
    /**
     * 需要写入的值
     */
    private byte[] writeByte=null;
    PlcParameter(){
@@ -95,7 +102,18 @@
    }
    public Object getReadValue() {
        return readValue;
    }
    public String getValueString() {
        return getValueInt()+"";
    }
    public int getValueInt() {
        if(this.readByte==null||this.readByte.length<1){
            //log.info("读取内容为null: {}  :{}",this.getCodeId(),this.readByte);
            return 0;
        }
        return bytesToIntDesc(this.readByte,0);
    }
    public void setReadValue(Object readValue) {
@@ -114,7 +132,23 @@
        return writeValue;
    }
    public void setWriteValue(Object writeValue) {
        this.writeValue = writeValue;
    public byte [] setWriteValue(Object writeValue) {
        //传入值根据参数类型进行转换成字符串保存进写入 字节内并且返回
        byte []sendByte=new byte[13+this.addressLength];
        if ("int".equals(this.type)){
            this.writeByte=intToBytesDesc(Integer.parseInt(writeValue.toString()),this.addressLength);
            return this.writeByte;
        }else if ("word".equals(this.type)){
            this.writeByte=intToBytesDesc(Integer.parseInt(writeValue.toString()),this.addressLength);
            return this.writeByte;
        }else if("string".equals(this.type)){
        }else{
        }
        return null;
    }
    public byte [] getWriteByte() {
        return this.writeByte;
    }
}