Generic NaN types (#3120)

This commit is contained in:
premultiply 2022-04-10 14:27:09 +02:00 • committed by GitHub
parent 68db9b27dc
commit 4113139e97
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -25,13 +25,13 @@ render: |
register: # manual non-sunspec register configuration
address: 30773 # SMA Modbus Profile: DC power input [1]
type: holding
decode: int32sma
decode: int32nan
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30961 # SMA Modbus Profile: DC power input [2]
type: holding
decode: int32sma
decode: int32nan
{{- end }}
{{- if eq .usage "battery" }}
source: calc
@ -41,14 +41,14 @@ render: |
register: # manual non-sunspec register configuration
address: 30851 # SMA Modbus Profile: Battery voltage
type: holding
decode: uint32sma
decode: uint32nan
scale: 0.01
- source: modbus
{{- include "modbus" . | indent 6 }}
register: # manual non-sunspec register configuration
address: 30843 # SMA Modbus Profile: Battery current
type: holding
decode: int32sma
decode: int32nan
scale: 0.001
soc:
source: modbus
@ -56,5 +56,5 @@ render: |
register: # manual non-sunspec register configuration
address: 30845 # SMA Modbus Profile: Battery state of charge
type: holding
decode: uint32sma
decode: uint32nan
{{- end }}

View file

@ -296,13 +296,13 @@ func RegisterOperation(r Register) (rs485.Operation, error) {
case "int16":
op.Transform = rs485.RTUInt16ToFloat64
op.ReadLen = 1
case "int16sma":
case "int16nan":
op.Transform = decodeNaN16(1<<15, rs485.RTUInt16ToFloat64)
op.ReadLen = 1
case "uint16":
op.Transform = rs485.RTUUint16ToFloat64
op.ReadLen = 1
case "uint16sma":
case "uint16nan":
op.Transform = decodeNaN16(0xFFFF, rs485.RTUUint16ToFloat64)
op.ReadLen = 1
case "bool16":
@ -316,7 +316,7 @@ func RegisterOperation(r Register) (rs485.Operation, error) {
// 32 bit
case "int32":
op.Transform = rs485.RTUInt32ToFloat64
case "int32sma":
case "int32nan":
op.Transform = decodeNaN32(1<<31, rs485.RTUInt32ToFloat64)
case "int32s":
op.Transform = rs485.RTUInt32ToFloat64Swapped
@ -324,7 +324,7 @@ func RegisterOperation(r Register) (rs485.Operation, error) {
op.Transform = rs485.RTUUint32ToFloat64
case "uint32s":
op.Transform = rs485.RTUUint32ToFloat64Swapped
case "uint32sma":
case "uint32nan":
op.Transform = decodeNaN32(0xFFFFFFFF, rs485.RTUUint32ToFloat64)
case "float32", "ieee754":
op.Transform = rs485.RTUIeee754ToFloat64
@ -335,7 +335,7 @@ func RegisterOperation(r Register) (rs485.Operation, error) {
case "uint64":
op.Transform = rs485.RTUUint64ToFloat64
op.ReadLen = 4
case "uint64sma":
case "uint64nan":
op.Transform = decodeNaN64(0xFFFFFFFFFFFFFFFF, rs485.RTUUint64ToFloat64)
op.ReadLen = 4
case "float64":