1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- {
- P0046F56202C21000T : {
- name:雷优/单相电表/阀控,
- protocol:{
- ```xcom
- #型号 modbus(crc16)
- def crc_modbus: $crc16($1,0x8005,0xffff,0x0000,1,1)
- # 以上可以定义公共函数
- def modbus_read_req:[$num($addr) $fcode $itom(2,$reg) $itom(2,$reglen) $crc_modbus($group(0,$pos))]
- def modbus_read_resp:[$num($addr) $fcode $ditch(1,{dl=$int($0)}) $ditch($dl, {data=$0}) $ditch(2,{$chk($0,$crc_modbus($group(0,$pos)))})]
- def modbus_write_req:[$num($addr) $fcode $itom(2,$reg) $itom(2,$reglen) $len($1) $1 $crc_modbus($group(0,$pos))]
- def modbus_write_resp:[$num($addr) $fcode $ditch(1,{dl=$int($0)}) $ditch($dl,{data=$0}) $ditch(2,{$chk($0,$crc_modbus($group(0,$pos)))})]
- ```
- # read,write表示读写流程,名称可以自定义,但要与funcpoints的flow绑定名称一致
- read:{
- send:$modbus_read_req()
- recv:$modbus_read_resp()
- },
- write:{
- send:$modbus_write_req($if($1==0, [22H 22H], [11H 11H]))
- recv:$modbus_write_resp()
- }
- },
- funcpoints:{
- 11X:{flow:read, fcode:03H, reg: 0000H, reglen:2, result:$float($data)},
- 12K:{flow:write, fcode:10H, reg: 0db8H, reglen:1, result:$int($data)}
- }
- },
- P056934A925C21000T : {
- name:雷优/485/多回路水表V2,
- protocol:{
- ```xcom
- def chksum: $itom(1,$sum($1)%256)
- # $addr $len 都是输入的参数
- def cj188_read_req: [68H $fcode $sbcd($addr) 01H 3 $itom(3,$seq) $chksum($group(0,$pos)) 16H]
- def cj188_read_resp: [68H $fcode $sbcd($addr) 81H $ditch(1,{dl=$int($0)-3}) $itom(3,$seq) $ditch($dl,{data=$0}) $ditch(1) 16H]
- ```
- # read,write表示读写流程,名称可以自定义,但要与funcpoints的flow绑定名称一致
- read:{
- send:$cj188_read_req()
- recv:$cj188_read_resp()
- },
- write:{
- send:$cj188_write_req()
- recv:$cj188_write_resp()
- }
- },
- funcpoints:{
- 12L:{flow:read, fcode:10H, seq: 0x1f9001, result:$bcd($data,0,4)*0.001},
- 12P:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)*0.0001},
- 14Z:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,11,2)*0.1},
- 13B:{flow:12L, fcode:10H, seq: 0x1f9001, result:$int8($data,13,1)},
- 401:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)},
- 402:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)},
- 403:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)},
- 404:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)},
- 405:{flow:12L, fcode:10H, seq: 0x1f9001, result:$bcd($data,4,4)},
- }
- }
- }
|