diff --git a/route.go b/route.go new file mode 100644 index 0000000..f43903c --- /dev/null +++ b/route.go @@ -0,0 +1 @@ +package feragstring diff --git a/route_info.go b/route_info.go index 717eb3f..5b3380d 100644 --- a/route_info.go +++ b/route_info.go @@ -4,13 +4,97 @@ import "fmt" type RouteInfo struct { FeragMessage - routeName string - topsheetMarker int - eaAddressDefinition int - editionName string + routeName string + limit int + maxStack int + standard int + parameterN int + maxBundle int + parameterSz int + topsheetMarker int + eaMarker int + eaAddressDefinition int + topsheetTemplateDirectory int + 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 { + if ri.editionName == "" { + return "" + } return fmt.Sprintf("+20%-30s", ri.editionName) } @@ -19,6 +103,9 @@ func (ri *RouteInfo) SetEditionName(editionName string) { } func (ri *RouteInfo) EaAddressDefinition() string { + if ri.eaAddressDefinition == 0 { + return "" + } return fmt.Sprintf("+91%06d", ri.eaAddressDefinition) } @@ -54,9 +141,18 @@ func NewRouteInfo() *RouteInfo { func (ri *RouteInfo) Payload() string { 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.EaMarker() data += ri.EaAddressDefinition() + data += ri.TopsheetTemplateDirectory() data += ri.EditionName() + data += ri.ProductReferenceNumber() return data }