Added a top level Route struct

This commit is contained in:
Oliver Jakoubek 2020-06-25 22:13:33 +02:00
parent c892d24c2a
commit ff7bf5fdf8
2 changed files with 101 additions and 4 deletions

1
route.go Normal file
View file

@ -0,0 +1 @@
package feragstring

View file

@ -5,12 +5,96 @@ import "fmt"
type RouteInfo struct { type RouteInfo struct {
FeragMessage FeragMessage
routeName string routeName string
limit int
maxStack int
standard int
parameterN int
maxBundle int
parameterSz int
topsheetMarker int topsheetMarker int
eaMarker int
eaAddressDefinition int eaAddressDefinition int
topsheetTemplateDirectory int
editionName string editionName string
productReferenceNumber int
}
func (ri *RouteInfo) ParameterSz() string {
return fmt.Sprintf("+35%04d", ri.parameterSz)
}
func (ri *RouteInfo) SetParameterSz(parameterSz int) {
ri.parameterSz = parameterSz
}
func (ri *RouteInfo) ProductReferenceNumber() string {
return fmt.Sprintf("+41%02d", ri.productReferenceNumber)
}
func (ri *RouteInfo) SetProductReferenceNumber(productReferenceNumber int) {
ri.productReferenceNumber = productReferenceNumber
}
func (ri *RouteInfo) TopsheetTemplateDirectory() string {
return fmt.Sprintf("+56%03d", ri.topsheetTemplateDirectory)
}
func (ri *RouteInfo) SetTopsheetTemplateDirectory(topsheetTemplateDirectory int) {
ri.topsheetTemplateDirectory = topsheetTemplateDirectory
}
func (ri *RouteInfo) EaMarker() string {
return fmt.Sprintf("+69%1d", ri.eaMarker)
}
func (ri *RouteInfo) SetEaMarker(eaMarker int) {
ri.eaMarker = eaMarker
}
func (ri *RouteInfo) MaxBundle() string {
return fmt.Sprintf("+34%04d", ri.maxBundle)
}
func (ri *RouteInfo) SetMaxBundle(maxBundle int) {
ri.maxBundle = maxBundle
}
func (ri *RouteInfo) ParameterN() string {
return fmt.Sprintf("+33%04d", ri.parameterN)
}
func (ri *RouteInfo) SetParameterN(parameterN int) {
ri.parameterN = parameterN
}
func (ri *RouteInfo) Standard() string {
return fmt.Sprintf("+32%04d", ri.standard)
}
func (ri *RouteInfo) SetStandard(standard int) {
ri.standard = standard
}
func (ri *RouteInfo) MaxStack() string {
return fmt.Sprintf("+31%04d", ri.maxStack)
}
func (ri *RouteInfo) SetMaxStack(maxStack int) {
ri.maxStack = maxStack
}
func (ri *RouteInfo) Limit() string {
return fmt.Sprintf("+30%04d", ri.limit)
}
func (ri *RouteInfo) SetLimit(limit int) {
ri.limit = limit
} }
func (ri *RouteInfo) EditionName() string { func (ri *RouteInfo) EditionName() string {
if ri.editionName == "" {
return ""
}
return fmt.Sprintf("+20%-30s", ri.editionName) return fmt.Sprintf("+20%-30s", ri.editionName)
} }
@ -19,6 +103,9 @@ func (ri *RouteInfo) SetEditionName(editionName string) {
} }
func (ri *RouteInfo) EaAddressDefinition() string { func (ri *RouteInfo) EaAddressDefinition() string {
if ri.eaAddressDefinition == 0 {
return ""
}
return fmt.Sprintf("+91%06d", ri.eaAddressDefinition) return fmt.Sprintf("+91%06d", ri.eaAddressDefinition)
} }
@ -54,9 +141,18 @@ func NewRouteInfo() *RouteInfo {
func (ri *RouteInfo) Payload() string { func (ri *RouteInfo) Payload() string {
data := ri.RouteName() data := ri.RouteName()
data += ri.Limit()
data += ri.MaxStack()
data += ri.Standard()
data += ri.ParameterN()
data += ri.MaxBundle()
data += ri.ParameterSz()
data += ri.TopsheetMarker() data += ri.TopsheetMarker()
data += ri.EaMarker()
data += ri.EaAddressDefinition() data += ri.EaAddressDefinition()
data += ri.TopsheetTemplateDirectory()
data += ri.EditionName() data += ri.EditionName()
data += ri.ProductReferenceNumber()
return data return data
} }