crabmusket / gosunspec

SunSpec domain model and use cases for Go. UNMAINTAINED
BSD 3-Clause "New" or "Revised" License
2 stars 6 forks source link

Cross-block scale factors not supported #37

Open andig opened 5 years ago

andig commented 5 years ago

Some models like e.g. 160 MPPT apparently define scale factors inside the fixed block and use them out of the repeating block. These "referenced" scale factors are currently not supported.

Example with corresponding modbus data:

--------- Model 160 mppt ---------
-- Definition --
Length: 28 (0x1c words, 0x38 bytes)
Blocks: 2
-- block #0 -
Length: 8
   0    0       DCA_SF          sunssf
   1    0       DCV_SF          sunssf
   2    0       DCW_SF          sunssf
   3    0      DCWH_SF          sunssf
   4    0          Evt          bitfield32
   6    0            N          count
   7    0       TmsPer          uint16
-- block #1 - module
Length: 20
   0    0           ID          uint16
   1    8        IDStr          string
   9    0          DCA A        uint16
  10    0          DCV V        uint16
  11    0          DCW W        uint16
  12    0         DCWH Wh       acc32
  14    0          Tms Secs     uint32
  16    0          Tmp C        int16
  17    0         DCSt          enum16
  18    0        DCEvt          bitfield32
-- Data --
modbus: send 00 22 00 00 00 06 7e 03 9e af 00 08
modbus: recv 00 22 00 00 00 13 7e 03 10 ff ff 00 00 00 02 80 00 ff ff ff ff 00 02 ff ff
    sunssf DCA_SF                     -1
    sunssf DCV_SF                      0
    sunssf DCW_SF                      2
    sunssf DCWH_SF                -32768
bitfield32 Evt                4294967295
     count N                           2
    uint16 TmsPer                  65535        NaN
modbus: send 00 23 00 00 00 06 7e 03 9e b7 00 14
modbus: recv 00 23 00 00 00 2b 7e 03 28 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 01 a5 00 02 00 00 00 00 ff ff ff ff 80 00 ff ff ff ff ff ff
    uint16 ID                          1       1.00
    string IDStr
    uint16 DCA                         4       4.00
    uint16 DCV                       421     421.00
    uint16 DCW                         2       2.00
     acc32 DCWH                        0       0.00
    uint32 Tms                4294967295        NaN
     int16 Tmp                    -32768        NaN
    enum16 DCSt                    65535
bitfield32 DCEvt              4294967295
modbus: send 00 24 00 00 00 06 7e 03 9e cb 00 14
modbus: recv 00 24 00 00 00 2b 7e 03 28 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 01 98 00 01 00 00 00 00 ff ff ff ff 80 00 ff ff ff ff ff ff
    uint16 ID                          2       2.00
    string IDStr
    uint16 DCA                         2       2.00
    uint16 DCV                       408     408.00
    uint16 DCW                         1       1.00
     acc32 DCWH                        0       0.00
    uint32 Tms                4294967295        NaN
     int16 Tmp                    -32768        NaN
    enum16 DCSt                    65535

Notice how e.g. DCA is not scaled by 10^-1 and how the power is not amps x volts.