@@ -4,22 +4,58 @@ import (
44 "errors"
55
66 "github.com/asap2Go/calibrationReader/a2l"
7+ "github.com/rs/zerolog/log"
78)
89
9- func getValue (m * a2l.Module , c * a2l.Characteristic ) (error , interface {}) {
10+ func (cd * CalibrationData ) getSystemConstant (ident string ) (a2l.SystemConstant , error ) {
11+ modPar := cd .A2l .Project .Modules [cd .ModuleIndex ].ModPar
12+ s , exists := modPar .SystemConstants [ident ]
13+ if ! exists {
14+ err := errors .New ("no system constant with name " + ident )
15+ log .Err (err ).Msg ("system constant not found" )
16+ return s , err
17+ }
18+ return s , nil
19+ }
20+
21+ func (cd * CalibrationData ) getCharacteristicValueBinary (c a2l.Characteristic ) (interface {}, error ) {
1022 var err error
23+ rl , err := cd .getRecordLayout (c )
24+ if err != nil {
25+ return nil , err
26+ }
27+ log .Debug ().Msg ("record layout " + rl .Name + "found" )
28+ return err , nil
29+ }
30+
31+ func (cd * CalibrationData ) getCharacteristicValueDecimal () (interface {}, error ) {
32+ return nil , nil
33+ }
1134
12- //get record layout for characteristic
35+ func (cd * CalibrationData ) getCharacteristicValueDisplay () (interface {}, error ) {
36+ return nil , nil
37+ }
38+
39+ func (cd * CalibrationData ) getCharacteristicValueHex () (interface {}, error ) {
40+ return nil , nil
41+ }
42+
43+ // get record layout for a specified characteristic
44+ func (cd * CalibrationData ) getRecordLayout (c a2l.Characteristic ) (a2l.RecordLayout , error ) {
45+ var err error
46+ var rl a2l.RecordLayout
47+ module := cd .A2l .Project .Modules [cd .ModuleIndex ]
1348 if ! c .DepositSet {
1449 err = errors .New ("no deposit set in characteristic " + c .Name )
15- return err , nil
50+ log .Err (err ).Msg ("record layout not found" )
51+ return rl , err
1652 }
17-
18- rl , exists := m .RecordLayouts [c .Deposit ]
53+ var exists bool
54+ rl , exists = module .RecordLayouts [c .Deposit ]
1955 if ! exists {
2056 err = errors .New ("no record layout found for deposit identifier" + c .Deposit + " of characteristic " + c .Name )
21- return err , nil
57+ log .Err (err ).Msg ("record layout not found" )
58+ return rl , err
2259 }
23-
24- return err , nil
60+ return rl , nil
2561}
0 commit comments