Added test for minimal example. Omit optional values when not set. Added messages for route info, production drop and route end.
This commit is contained in:
parent
9525e7b97f
commit
df964e0ecf
9 changed files with 283 additions and 8 deletions
66
route_info.go
Normal file
66
route_info.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package feragstring
|
||||
|
||||
import "fmt"
|
||||
|
||||
type RouteInfo struct {
|
||||
FeragMessage
|
||||
routeName string
|
||||
topsheetMarker int
|
||||
eaAddressDefinition int
|
||||
editionName string
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) EditionName() string {
|
||||
return fmt.Sprintf("+20%-30s", ri.editionName)
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) SetEditionName(editionName string) {
|
||||
ri.editionName = editionName
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) EaAddressDefinition() string {
|
||||
return fmt.Sprintf("+91%06d", ri.eaAddressDefinition)
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) SetEaAddressDefinition(eaAddressDefinition int) {
|
||||
ri.eaAddressDefinition = eaAddressDefinition
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) TopsheetMarker() string {
|
||||
return fmt.Sprintf("+59%1d", ri.topsheetMarker)
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) SetTopsheetMarker(topsheetMarker int) {
|
||||
ri.topsheetMarker = topsheetMarker
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) SetRouteName(routeName string) {
|
||||
ri.routeName = routeName
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) RouteName() string {
|
||||
return fmt.Sprintf("+11%-13s", ri.routeName)
|
||||
}
|
||||
|
||||
func NewRouteInfo() *RouteInfo {
|
||||
ri := RouteInfo{
|
||||
FeragMessage: FeragMessage{
|
||||
messageStart: "2402",
|
||||
messageEnd: "!",
|
||||
},
|
||||
}
|
||||
return &ri
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) Payload() string {
|
||||
data := ri.RouteName()
|
||||
data += ri.TopsheetMarker()
|
||||
data += ri.EaAddressDefinition()
|
||||
data += ri.EditionName()
|
||||
return data
|
||||
}
|
||||
|
||||
func (ri *RouteInfo) Message() string {
|
||||
message := ri.FeragMessage.MessageTemplate()
|
||||
return message(&ri.FeragMessage, ri.Payload())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue