Initial commit
This commit is contained in:
commit
0f717cd2af
16 changed files with 574 additions and 0 deletions
66
route_list.go
Normal file
66
route_list.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package feragstring
|
||||
|
||||
import "fmt"
|
||||
|
||||
type RouteListEntry struct {
|
||||
FeragMessage
|
||||
routeName string
|
||||
routeCode int
|
||||
rampNumber int
|
||||
copiesInRoute int
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) CopiesInRoute() string {
|
||||
return fmt.Sprintf("+23%06d", r.copiesInRoute)
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) SetCopiesInRoute(copiesInRoute int) {
|
||||
r.copiesInRoute = copiesInRoute
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) RampNumber() string {
|
||||
return fmt.Sprintf("+25%02d", r.rampNumber)
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) SetRampNumber(rampNumber int) {
|
||||
r.rampNumber = rampNumber
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) RouteCode() string {
|
||||
return fmt.Sprintf("+79%05d", r.routeCode)
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) SetRouteCode(routeCode int) {
|
||||
r.routeCode = routeCode
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) RouteName() string {
|
||||
return fmt.Sprintf("+11%-13s", r.routeName)
|
||||
}
|
||||
|
||||
func (r *RouteListEntry) SetRouteName(routeName string) {
|
||||
r.routeName = routeName
|
||||
}
|
||||
|
||||
func NewRouteListEntry() *RouteListEntry {
|
||||
rl := RouteListEntry{
|
||||
FeragMessage: FeragMessage{
|
||||
messageStart: "2401",
|
||||
messageEnd: "!",
|
||||
},
|
||||
}
|
||||
return &rl
|
||||
}
|
||||
|
||||
func (rl *RouteListEntry) Payload() string {
|
||||
data := rl.RouteName()
|
||||
data += rl.RouteCode()
|
||||
data += rl.RampNumber()
|
||||
data += rl.CopiesInRoute()
|
||||
return data
|
||||
}
|
||||
|
||||
func (rl *RouteListEntry) Message() string {
|
||||
message := rl.FeragMessage.MessageTemplate()
|
||||
return message(&rl.FeragMessage, rl.Payload())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue