Skip to content

Commit

Permalink
continued implementation of reading out hex values
Browse files Browse the repository at this point in the history
added offset
  • Loading branch information
asap2Go committed Nov 18, 2022
1 parent b24b350 commit 4a37d6c
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 116 deletions.
33 changes: 20 additions & 13 deletions a2l/offset_4.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ import (
"github.com/rs/zerolog/log"
)

type offset4 struct {
position uint16
positionSet bool
datatype DataTypeEnum
datatypeSet bool
/*
Offset4 is the description of the 'offset' parameter in the deposit structure to compute the axis points for
fixed characteristic curves and fixed characteristic maps (see also keyword
FIX_AXIS_PAR). The axis points for fixed characteristic curves or fixed characteristic
maps are derived from the two 'offset' and 'shift' parameters as follows:
Xi = Offset + (i - 1)*2Shift i = { 1...numberofaxispts }
*/
type Offset4 struct {
Position uint16
PositionSet bool
Datatype DataTypeEnum
DatatypeSet bool
}

func parseOffset4(tok *tokenGenerator) (offset4, error) {
o4 := offset4{}
func parseOffset4(tok *tokenGenerator) (Offset4, error) {
o4 := Offset4{}
var err error
forLoop:
for {
Expand All @@ -28,23 +35,23 @@ forLoop:
err = errors.New("unexpected token " + tok.current())
log.Err(err).Msg("offset4 could not be parsed")
break forLoop
} else if !o4.positionSet {
} else if !o4.PositionSet {
var buf uint64
buf, err = strconv.ParseUint(tok.current(), 10, 16)
if err != nil {
log.Err(err).Msg("offset4 position could not be parsed")
break forLoop
}
o4.position = uint16(buf)
o4.positionSet = true
o4.Position = uint16(buf)
o4.PositionSet = true
log.Info().Msg("offset4 position successfully parsed")
} else if !o4.datatypeSet {
o4.datatype, err = parseDataTypeEnum(tok)
} else if !o4.DatatypeSet {
o4.Datatype, err = parseDataTypeEnum(tok)
if err != nil {
log.Err(err).Msg("offset4 datatype could not be parsed")
break forLoop
}
o4.datatypeSet = true
o4.DatatypeSet = true
log.Info().Msg("offset4 datatype successfully parsed")
break forLoop
}
Expand Down
33 changes: 20 additions & 13 deletions a2l/offset_5.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ import (
"github.com/rs/zerolog/log"
)

type offset5 struct {
position uint16
positionSet bool
datatype DataTypeEnum
datatypeSet bool
/*
Offset5 is the description of the 'offset' parameter in the deposit structure to compute the axis points for
fixed characteristic curves and fixed characteristic maps (see also keyword
FIX_AXIS_PAR). The axis points for fixed characteristic curves or fixed characteristic
maps are derived from the two 'offset' and 'shift' parameters as follows:
Xi = Offset + (i - 1)*2Shift i = { 1...numberofaxispts }
*/
type Offset5 struct {
Position uint16
PositionSet bool
Datatype DataTypeEnum
DatatypeSet bool
}

func parseOffset5(tok *tokenGenerator) (offset5, error) {
o5 := offset5{}
func parseOffset5(tok *tokenGenerator) (Offset5, error) {
o5 := Offset5{}
var err error
forLoop:
for {
Expand All @@ -28,23 +35,23 @@ forLoop:
err = errors.New("unexpected token " + tok.current())
log.Err(err).Msg("offset5 could not be parsed")
break forLoop
} else if !o5.positionSet {
} else if !o5.PositionSet {
var buf uint64
buf, err = strconv.ParseUint(tok.current(), 10, 16)
if err != nil {
log.Err(err).Msg("offset5 position could not be parsed")
break forLoop
}
o5.position = uint16(buf)
o5.positionSet = true
o5.Position = uint16(buf)
o5.PositionSet = true
log.Info().Msg("offset5 position successfully parsed")
} else if !o5.datatypeSet {
o5.datatype, err = parseDataTypeEnum(tok)
} else if !o5.DatatypeSet {
o5.Datatype, err = parseDataTypeEnum(tok)
if err != nil {
log.Err(err).Msg("offset5 datatype could not be parsed")
break forLoop
}
o5.datatypeSet = true
o5.DatatypeSet = true
log.Info().Msg("offset5 datatype successfully parsed")
break forLoop
}
Expand Down
33 changes: 20 additions & 13 deletions a2l/offset_x.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ import (
"github.com/rs/zerolog/log"
)

type offsetX struct {
position uint16
positionSet bool
datatype DataTypeEnum
datatypeSet bool
/*
OffsetX is the description of the 'offset' parameter in the deposit structure to compute the axis points for
fixed characteristic curves and fixed characteristic maps (see also keyword
FIX_AXIS_PAR). The axis points for fixed characteristic curves or fixed characteristic
maps are derived from the two 'offset' and 'shift' parameters as follows:
Xi = Offset + (i - 1)*2Shift i = { 1...numberofaxispts }
*/
type OffsetX struct {
Position uint16
PositionSet bool
Datatype DataTypeEnum
DatatypeSet bool
}

func parseOffsetX(tok *tokenGenerator) (offsetX, error) {
ox := offsetX{}
func parseOffsetX(tok *tokenGenerator) (OffsetX, error) {
ox := OffsetX{}
var err error
forLoop:
for {
Expand All @@ -28,23 +35,23 @@ forLoop:
err = errors.New("unexpected token " + tok.current())
log.Err(err).Msg("offsetX could not be parsed")
break forLoop
} else if !ox.positionSet {
} else if !ox.PositionSet {
var buf uint64
buf, err = strconv.ParseUint(tok.current(), 10, 16)
if err != nil {
log.Err(err).Msg("offsetx position could not be parsed")
break forLoop
}
ox.position = uint16(buf)
ox.positionSet = true
ox.Position = uint16(buf)
ox.PositionSet = true
log.Info().Msg("offsetx position successfully parsed")
} else if !ox.datatypeSet {
ox.datatype, err = parseDataTypeEnum(tok)
} else if !ox.DatatypeSet {
ox.Datatype, err = parseDataTypeEnum(tok)
if err != nil {
log.Err(err).Msg("offsetx datatype could not be parsed")
break forLoop
}
ox.datatypeSet = true
ox.DatatypeSet = true
log.Info().Msg("offsetx datatype successfully parsed")
break forLoop
}
Expand Down
27 changes: 17 additions & 10 deletions a2l/offset_y.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import (
"github.com/rs/zerolog/log"
)

/*
OffsetY is the description of the 'offset' parameter in the deposit structure to compute the axis points for
fixed characteristic curves and fixed characteristic maps (see also keyword
FIX_AXIS_PAR). The axis points for fixed characteristic curves or fixed characteristic
maps are derived from the two 'offset' and 'shift' parameters as follows:
Xi = Offset + (i - 1)*2Shift i = { 1...numberofaxispts }
*/
type offsetY struct {
position uint16
positionSet bool
datatype DataTypeEnum
datatypeSet bool
Position uint16
PositionSet bool
Datatype DataTypeEnum
DatatypeSet bool
}

func parseOffsetY(tok *tokenGenerator) (offsetY, error) {
Expand All @@ -28,23 +35,23 @@ forLoop:
err = errors.New("unexpected token " + tok.current())
log.Err(err).Msg("offsetY could not be parsed")
break forLoop
} else if !oy.positionSet {
} else if !oy.PositionSet {
var buf uint64
buf, err = strconv.ParseUint(tok.current(), 10, 16)
if err != nil {
log.Err(err).Msg("offsety position could not be parsed")
break forLoop
}
oy.position = uint16(buf)
oy.positionSet = true
oy.Position = uint16(buf)
oy.PositionSet = true
log.Info().Msg("offsety position successfully parsed")
} else if !oy.datatypeSet {
oy.datatype, err = parseDataTypeEnum(tok)
} else if !oy.DatatypeSet {
oy.Datatype, err = parseDataTypeEnum(tok)
if err != nil {
log.Err(err).Msg("offsety datatype could not be parsed")
break forLoop
}
oy.datatypeSet = true
oy.DatatypeSet = true
log.Info().Msg("offsety datatype successfully parsed")
break forLoop
}
Expand Down
33 changes: 20 additions & 13 deletions a2l/offset_z.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ import (
"github.com/rs/zerolog/log"
)

type offsetZ struct {
position uint16
positionSet bool
datatype DataTypeEnum
datatypeSet bool
/*
OffsetZ is the description of the 'offset' parameter in the deposit structure to compute the axis points for
fixed characteristic curves and fixed characteristic maps (see also keyword
FIX_AXIS_PAR). The axis points for fixed characteristic curves or fixed characteristic
maps are derived from the two 'offset' and 'shift' parameters as follows:
Xi = Offset + (i - 1)*2Shift i = { 1...numberofaxispts }
*/
type OffsetZ struct {
Position uint16
PositionSet bool
Datatype DataTypeEnum
DatatypeSet bool
}

func parseOffsetZ(tok *tokenGenerator) (offsetZ, error) {
oz := offsetZ{}
func parseOffsetZ(tok *tokenGenerator) (OffsetZ, error) {
oz := OffsetZ{}
var err error
forLoop:
for {
Expand All @@ -28,23 +35,23 @@ forLoop:
err = errors.New("unexpected token " + tok.current())
log.Err(err).Msg("offsetZ could not be parsed")
break forLoop
} else if !oz.positionSet {
} else if !oz.PositionSet {
var buf uint64
buf, err = strconv.ParseUint(tok.current(), 10, 16)
if err != nil {
log.Err(err).Msg("offsetz position could not be parsed")
break forLoop
}
oz.position = uint16(buf)
oz.positionSet = true
oz.Position = uint16(buf)
oz.PositionSet = true
log.Info().Msg("offsetz position successfully parsed")
} else if !oz.datatypeSet {
oz.datatype, err = parseDataTypeEnum(tok)
} else if !oz.DatatypeSet {
oz.Datatype, err = parseDataTypeEnum(tok)
if err != nil {
log.Err(err).Msg("offsetz datatype could not be parsed")
break forLoop
}
oz.datatypeSet = true
oz.DatatypeSet = true
log.Info().Msg("offsetz datatype successfully parsed")
break forLoop
}
Expand Down
Loading

0 comments on commit 4a37d6c

Please sign in to comment.