Skip to content

Commit

Permalink
BugFixes
Browse files Browse the repository at this point in the history
Fixes several wrongly used methods
  • Loading branch information
asap2Go committed Dec 6, 2022
1 parent da5e5a5 commit 7c4a663
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 59 deletions.
10 changes: 5 additions & 5 deletions axis_pts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (cv *CharacteristicValues) getAxisPointsX(cd *CalibrationData, rl *a2l.Reco
if rl.FixNoAxisPtsX.NumberOfAxisPointsSet {
noAxisPts = uint32(rl.FixNoAxisPtsX.NumberOfAxisPoints)
} else if !rl.FixNoAxisPtsX.NumberOfAxisPointsSet {
buf, isInt := cv.NoAxisPtsXValue.(int)
buf, isInt := cv.noAxisPtsXValue.(int)
if !isInt {
err = errors.New("could not convert number of axisPts datatype to int")
log.Err(err).Msg("could not retrieve NoAxisPointsX value")
Expand Down Expand Up @@ -51,7 +51,7 @@ func (cv *CharacteristicValues) getAxisPointsY(cd *CalibrationData, rl *a2l.Reco
if rl.FixNoAxisPtsY.NumberOfAxisPointsSet {
noAxisPts = uint32(rl.FixNoAxisPtsY.NumberOfAxisPoints)
} else if !rl.FixNoAxisPtsY.NumberOfAxisPointsSet {
buf, isInt := cv.NoAxisPtsYValue.(int)
buf, isInt := cv.noAxisPtsYValue.(int)
if !isInt {
err = errors.New("could not convert number of axisPts datatype to int")
log.Err(err).Msg("could not retrieve NoAxisPointsY value")
Expand Down Expand Up @@ -85,7 +85,7 @@ func (cv *CharacteristicValues) getAxisPointsZ(cd *CalibrationData, rl *a2l.Reco
if rl.FixNoAxisPtsZ.NumberOfAxisPointsSet {
noAxisPts = uint32(rl.FixNoAxisPtsZ.NumberOfAxisPoints)
} else if !rl.FixNoAxisPtsZ.NumberOfAxisPointsSet {
buf, isInt := cv.NoAxisPtsZValue.(int)
buf, isInt := cv.noAxisPtsZValue.(int)
if !isInt {
err = errors.New("could not convert number of axisPts datatype to int")
log.Err(err).Msg("could not retrieve NoAxisPointsZ value")
Expand Down Expand Up @@ -119,7 +119,7 @@ func (cv *CharacteristicValues) getAxisPoints4(cd *CalibrationData, rl *a2l.Reco
if rl.FixNoAxisPts4.NumberOfAxisPointsSet {
noAxisPts = uint32(rl.FixNoAxisPts4.NumberOfAxisPoints)
} else if !rl.FixNoAxisPts4.NumberOfAxisPointsSet {
buf, isInt := cv.NoAxisPts4Value.(int)
buf, isInt := cv.noAxisPts4Value.(int)
if !isInt {
err = errors.New("could not convert number of axisPts datatype to int")
log.Err(err).Msg("could not retrieve NoAxisPoints4 value")
Expand Down Expand Up @@ -153,7 +153,7 @@ func (cv *CharacteristicValues) getAxisPoints5(cd *CalibrationData, rl *a2l.Reco
if rl.FixNoAxisPts5.NumberOfAxisPointsSet {
noAxisPts = uint32(rl.FixNoAxisPts5.NumberOfAxisPoints)
} else if !rl.FixNoAxisPts5.NumberOfAxisPointsSet {
buf, isInt := cv.NoAxisPts5Value.(int)
buf, isInt := cv.noAxisPts5Value.(int)
if !isInt {
err = errors.New("could not convert number of axisPts datatype to int")
log.Err(err).Msg("could not retrieve NoAxisPoints5 value")
Expand Down
55 changes: 27 additions & 28 deletions calib_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,90 +571,90 @@ func (cd *CalibrationData) getValuesFromHex(cv *CharacteristicValues) {
err = errors.New("undefined case in record layout")
log.Err(err).Msg("axisRescaleX not implemented")
case "DistOpX":
cv.DistOpXValue, err = cd.getDistOpX(rl, &curPos)
cv.distOpXValue, err = cd.getDistOpX(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for distOpX of characteristic '" + cv.characteristic.Name + "'")
}
case "DistOpY":
cv.DistOpYValue, err = cd.getDistOpY(rl, &curPos)
cv.distOpYValue, err = cd.getDistOpY(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for distOpY of characteristic '" + cv.characteristic.Name + "'")
}
case "DistOpZ":
cv.DistOpZValue, err = cd.getDistOpZ(rl, &curPos)
cv.distOpZValue, err = cd.getDistOpZ(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for distOpZ of characteristic '" + cv.characteristic.Name + "'")
}
case "DistOp4":
cv.DistOp4Value, err = cd.getDistOp4(rl, &curPos)
cv.distOp4Value, err = cd.getDistOp4(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for distOp4 of characteristic '" + cv.characteristic.Name + "'")
}
case "DistOp5":
cv.DistOp5Value, err = cd.getDistOp5(rl, &curPos)
cv.distOp5Value, err = cd.getDistOp5(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for distOp5 of characteristic '" + cv.characteristic.Name + "'")
}
case "FncValues":
//interesting part

case "Identification":
cv.IdentificationValue, err = cd.getDistOp5(rl, &curPos)
cv.identificationValue, err = cd.getIdentification(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for identification of characteristic '" + cv.characteristic.Name + "'")
}
case "NoAxisPtsX":
cv.NoAxisPtsXValue, err = cd.getNoAxisPtsX(rl, &curPos)
cv.noAxisPtsXValue, err = cd.getNoAxisPtsX(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noAxisPtsX of characteristic '" + cv.characteristic.Name + "'")
}
case "NoAxisPtsY":
cv.NoAxisPtsYValue, err = cd.getNoAxisPtsY(rl, &curPos)
cv.noAxisPtsYValue, err = cd.getNoAxisPtsY(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noAxisPtsY of characteristic '" + cv.characteristic.Name + "'")
}
case "NoAxisPtsZ":
cv.NoAxisPtsZValue, err = cd.getNoAxisPtsZ(rl, &curPos)
cv.noAxisPtsZValue, err = cd.getNoAxisPtsZ(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noAxisPtsZ of characteristic '" + cv.characteristic.Name + "'")
}
case "NoAxisPts4":
cv.NoAxisPts4Value, err = cd.getNoAxisPts4(rl, &curPos)
cv.noAxisPts4Value, err = cd.getNoAxisPts4(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noAxisPts4 of characteristic '" + cv.characteristic.Name + "'")
}
case "NoAxisPts5":
cv.NoAxisPts5Value, err = cd.getNoAxisPts5(rl, &curPos)
cv.noAxisPts5Value, err = cd.getNoAxisPts5(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noAxisPts5 of characteristic '" + cv.characteristic.Name + "'")
}
case "NoRescaleX":
cv.NoAxisPts5Value, err = cd.getNoAxisPts5(rl, &curPos)
cv.noRescaleXValue, err = cd.getNoRescaleX(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for noRescaleX of characteristic '" + cv.characteristic.Name + "'")
}
case "OffsetX":
cv.OffsetXValue, err = cd.getOffsetX(rl, &curPos)
cv.offsetXValue, err = cd.getOffsetX(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for offsetX of characteristic '" + cv.characteristic.Name + "'")
}
case "OffsetY":
cv.OffsetYValue, err = cd.getOffsetY(rl, &curPos)
cv.offsetYValue, err = cd.getOffsetY(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for offsetY of characteristic '" + cv.characteristic.Name + "'")
}
case "OffsetZ":
cv.OffsetZValue, err = cd.getOffsetZ(rl, &curPos)
cv.offsetZValue, err = cd.getOffsetZ(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for offsetZ of characteristic '" + cv.characteristic.Name + "'")
}
case "Offset4":
cv.Offset4Value, err = cd.getOffset4(rl, &curPos)
cv.offset4Value, err = cd.getOffset4(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for offset4 of characteristic '" + cv.characteristic.Name + "'")
}
case "Offset5":
cv.Offset5Value, err = cd.getOffset5(rl, &curPos)
cv.offset5Value, err = cd.getOffset5(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for offset5 of characteristic '" + cv.characteristic.Name + "'")
}
Expand All @@ -663,52 +663,51 @@ func (cd *CalibrationData) getValuesFromHex(cv *CharacteristicValues) {
if err != nil {
log.Err(err).Msg("could not get offset from reserved datasize characteristic '" + cv.characteristic.Name + "'")
}

/*RIP_ADDR_X-Y-Z-4-5-W
are only used to store interpolation results,
so they are not read from hex as there is nothing to read
*/
case "RipAddrW":
case "RipAddrX":
case "RipAddrY":
case "RipAddrZ":
case "RipAddr4":
case "RipAddr5":*/

/*SRC_ADDR_X-Y-Z-4-5 define a input quantity meaning a measurement that determines which point of an axis is chosen for reading a value from a given characteristic.
case "RipAddr5":
/*SRC_ADDR_X-Y-Z-4-5
define a input quantity meaning a measurement that determines which point of an axis is chosen for reading a value from a given characteristic.
e.g. given a curve where the x-Axis is the rpm of the engine and the values are
a defined relative engine load:
x 1000 2000 3000 4000 5000 6000
v 12 27 38 42 49 18
then if the input quantity for this curve would be the measurement of the current rpm of the engine
depending on the rpm a value is chosen.
depending on the rpm a value is chosen.*/
case "SrcAddrX":
case "SrcAddrY":
case "SrcAddrZ":
case "SrcAddr4":
case "SrcAddr5":
*/
case "ShiftOpX":
cv.ShiftOpXValue, err = cd.getShiftOpX(rl, &curPos)
cv.shiftOpXValue, err = cd.getShiftOpX(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for shiftOpX of characteristic '" + cv.characteristic.Name + "'")
}
case "ShiftOpY":
cv.ShiftOpYValue, err = cd.getShiftOpY(rl, &curPos)
cv.shiftOpYValue, err = cd.getShiftOpY(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for shiftOpY of characteristic '" + cv.characteristic.Name + "'")
}
case "ShiftOpZ":
cv.ShiftOpZValue, err = cd.getShiftOpZ(rl, &curPos)
cv.shiftOpZValue, err = cd.getShiftOpZ(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for shiftOpZ of characteristic '" + cv.characteristic.Name + "'")
}
case "ShiftOp4":
cv.ShiftOp4Value, err = cd.getShiftOp4(rl, &curPos)
cv.shiftOp4Value, err = cd.getShiftOp4(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for shiftOp4 of characteristic '" + cv.characteristic.Name + "'")
}
case "ShiftOp5":
cv.ShiftOp5Value, err = cd.getShiftOp5(rl, &curPos)
cv.shiftOp5Value, err = cd.getShiftOp5(rl, &curPos)
if err != nil {
log.Err(err).Msg("could not get value for shiftOp5 of characteristic '" + cv.characteristic.Name + "'")
}
Expand Down
50 changes: 24 additions & 26 deletions characteristic_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@ type CharacteristicValues struct {
AxisZValues interface{}
Axis4Values interface{}
Axis5Values interface{}
DistOpXValue interface{}
DistOpYValue interface{}
DistOpZValue interface{}
DistOp4Value interface{}
DistOp5Value interface{}
IdentificationValue interface{}
NoAxisPtsXValue interface{}
NoAxisPtsYValue interface{}
NoAxisPtsZValue interface{}
NoAxisPts4Value interface{}
NoAxisPts5Value interface{}
NoRescaleXValue interface{}
OffsetXValue interface{}
OffsetYValue interface{}
OffsetZValue interface{}
Offset4Value interface{}
Offset5Value interface{}
ShiftOpXValue interface{}
ShiftOpYValue interface{}
ShiftOpZValue interface{}
ShiftOp4Value interface{}
ShiftOp5Value interface{}
valuesBin interface{}
valuesHex interface{}
valuesDec interface{}
valuesPhy interface{}
distOpXValue interface{}
distOpYValue interface{}
distOpZValue interface{}
distOp4Value interface{}
distOp5Value interface{}
identificationValue interface{}
noAxisPtsXValue interface{}
noAxisPtsYValue interface{}
noAxisPtsZValue interface{}
noAxisPts4Value interface{}
noAxisPts5Value interface{}
noRescaleXValue interface{}
offsetXValue interface{}
offsetYValue interface{}
offsetZValue interface{}
offset4Value interface{}
offset5Value interface{}
shiftOpXValue interface{}
shiftOpYValue interface{}
shiftOpZValue interface{}
shiftOp4Value interface{}
shiftOp5Value interface{}
ValuesDec interface{}
ValuesPhy interface{}
}

func (cv *CharacteristicValues) getCharacteristicValueDecimal() (interface{}, error) {
Expand Down

0 comments on commit 7c4a663

Please sign in to comment.