| | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import static com.mes.tools.HexConversion.*; |
| | | |
| | | /** |
| | | * Plc参数 |
| | | */ |
| | |
| | | * 需要写入的值 |
| | | */ |
| | | private Object writeValue=null; |
| | | |
| | | /** |
| | | * 需要写入的值 |
| | | */ |
| | | private byte[] writeByte=null; |
| | | |
| | | PlcParameter(){ |
| | | |
| | |
| | | } |
| | | |
| | | 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) { |
| | |
| | | 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; |
| | | } |
| | | } |