Integration of Route into feragstring and production drop
This commit is contained in:
parent
ff7bf5fdf8
commit
5387d9b9ae
3 changed files with 189 additions and 15 deletions
50
ferag.go
50
ferag.go
|
@ -11,6 +11,8 @@ type FeragString struct {
|
|||
TitleEnd *TitleEnd
|
||||
ProductReferences []*ProductReference
|
||||
ProductReferencesNr int
|
||||
Routes []*Route
|
||||
RouteCount int
|
||||
RouteListEntries []*RouteListEntry
|
||||
RouteListEntryCount int
|
||||
RouteInfoEntries []*RouteInfo
|
||||
|
@ -40,21 +42,32 @@ func (fs *FeragString) PrintOut() string {
|
|||
info += pr.Message()
|
||||
}
|
||||
|
||||
for _, rl := range fs.RouteListEntries {
|
||||
info += rl.Message()
|
||||
// create route list entries for every route
|
||||
for _, rt := range fs.Routes {
|
||||
info += rt.GetRouteListEntry().Message()
|
||||
}
|
||||
|
||||
for _, ri := range fs.RouteInfoEntries {
|
||||
info += ri.Message()
|
||||
// create route info for every route
|
||||
// including embedded production drops
|
||||
for _, rt := range fs.Routes {
|
||||
info += rt.GetRouteMessage()
|
||||
}
|
||||
|
||||
for _, pd := range fs.ProductionDropEntries {
|
||||
info += pd.Message()
|
||||
}
|
||||
|
||||
for _, re := range fs.RouteEndEntries {
|
||||
info += re.Message()
|
||||
}
|
||||
//for _, rl := range fs.RouteListEntries {
|
||||
// info += rl.Message()
|
||||
//}
|
||||
//
|
||||
//for _, ri := range fs.RouteInfoEntries {
|
||||
// info += ri.Message()
|
||||
//}
|
||||
//
|
||||
//for _, pd := range fs.ProductionDropEntries {
|
||||
// info += pd.Message()
|
||||
//}
|
||||
//
|
||||
//for _, re := range fs.RouteEndEntries {
|
||||
// info += re.Message()
|
||||
//}
|
||||
|
||||
// +2441 | last message is the corresponding title end
|
||||
info += fs.TitleEnd.Message()
|
||||
|
@ -71,6 +84,17 @@ func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fs *FeragString) AddRoute(r *Route) error {
|
||||
fs.RouteCount++
|
||||
fs.Routes = append(fs.Routes, r)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fs *FeragString) NextRouteCode() int {
|
||||
return fs.RouteCount + 1
|
||||
//return fs.RouteListEntryCount + 1
|
||||
}
|
||||
|
||||
func (fs *FeragString) AddRouteListEntry(rl *RouteListEntry) error {
|
||||
fs.RouteListEntryCount++
|
||||
//if rl.routeCode == 0 {
|
||||
|
@ -80,10 +104,6 @@ func (fs *FeragString) AddRouteListEntry(rl *RouteListEntry) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (fs *FeragString) NextRouteCode() int {
|
||||
return fs.RouteListEntryCount + 1
|
||||
}
|
||||
|
||||
func (fs *FeragString) AddRouteInfo(ri *RouteInfo) error {
|
||||
fs.RouteInfoEntries = append(fs.RouteInfoEntries, ri)
|
||||
return nil
|
||||
|
|
|
@ -6,6 +6,48 @@ type ProductionDrop struct {
|
|||
FeragMessage
|
||||
agentName string
|
||||
numberOfCopies int
|
||||
dontProduce bool
|
||||
topsheetData string
|
||||
}
|
||||
|
||||
func (pd *ProductionDrop) TopsheetData() string {
|
||||
if pd.topsheetData == "" {
|
||||
return ""
|
||||
}
|
||||
tsd := pd.topsheetData
|
||||
if len(tsd) > 5996 {
|
||||
tsd = tsd[:5996]
|
||||
}
|
||||
|
||||
tsdSegment := fmt.Sprintf("+58%s", tsd)
|
||||
|
||||
fm := FeragMessage{
|
||||
messageStart: "2414",
|
||||
messageEnd: "!",
|
||||
}
|
||||
message := fm.MessageTemplate()
|
||||
return message(&fm, tsdSegment)
|
||||
}
|
||||
|
||||
func (pd *ProductionDrop) SetTopsheetData(topsheetData string) {
|
||||
pd.topsheetData = topsheetData
|
||||
}
|
||||
|
||||
func (pd *ProductionDrop) ControlCharacter() string {
|
||||
var ccCount int
|
||||
var cc string
|
||||
if pd.dontProduce == true {
|
||||
cc += "D"
|
||||
ccCount++
|
||||
}
|
||||
if ccCount == 0 {
|
||||
return ""
|
||||
}
|
||||
return fmt.Sprintf("+14%-16s", cc)
|
||||
}
|
||||
|
||||
func (pd *ProductionDrop) SetDontProduce() {
|
||||
pd.dontProduce = true
|
||||
}
|
||||
|
||||
func (pd *ProductionDrop) NumberOfCopies() string {
|
||||
|
@ -30,6 +72,7 @@ func NewProductionDrop() *ProductionDrop {
|
|||
messageStart: "2403",
|
||||
messageEnd: "!",
|
||||
},
|
||||
dontProduce: false,
|
||||
}
|
||||
return &pd
|
||||
}
|
||||
|
@ -37,6 +80,7 @@ func NewProductionDrop() *ProductionDrop {
|
|||
func (pd *ProductionDrop) Payload() string {
|
||||
data := pd.AgentName()
|
||||
data += pd.NumberOfCopies()
|
||||
data += pd.ControlCharacter()
|
||||
return data
|
||||
}
|
||||
|
||||
|
|
110
route.go
110
route.go
|
@ -1 +1,111 @@
|
|||
package feragstring
|
||||
|
||||
type Route struct {
|
||||
routeName string
|
||||
routeCode int
|
||||
rampNumber int
|
||||
copiesInRoute int
|
||||
limit int
|
||||
maxStack int
|
||||
standard int
|
||||
parameterN int
|
||||
maxBundle int
|
||||
parameterSz int
|
||||
topsheetMarker int
|
||||
eaMarker int
|
||||
eaAddressDefinition int
|
||||
topsheetTemplateDirectory int
|
||||
editionName string
|
||||
productReferenceNumber int
|
||||
ProductionDrops []*ProductionDrop
|
||||
}
|
||||
|
||||
func (r *Route) GetRouteListEntry() *RouteListEntry {
|
||||
rle := NewRouteListEntry()
|
||||
rle.SetRouteName(r.routeName)
|
||||
rle.SetRouteCode(r.routeCode)
|
||||
rle.SetRampNumber(r.rampNumber)
|
||||
rle.SetCopiesInRoute(r.copiesInRoute)
|
||||
return rle
|
||||
}
|
||||
|
||||
func (r *Route) GetRouteMessage() string {
|
||||
ri := NewRouteInfo()
|
||||
ri.SetRouteName(r.routeName)
|
||||
info := ri.Message()
|
||||
|
||||
for _, pd := range r.ProductionDrops {
|
||||
info += pd.Message()
|
||||
info += pd.TopsheetData()
|
||||
}
|
||||
|
||||
re := NewRouteEnd()
|
||||
re.SetRouteName(r.routeName)
|
||||
info += re.Message()
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
func (r *Route) AddProductionDrop(pd *ProductionDrop) error {
|
||||
r.ProductionDrops = append(r.ProductionDrops, pd)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Route) SetRouteName(routeName string) {
|
||||
r.routeName = routeName
|
||||
}
|
||||
|
||||
func (r *Route) SetRouteCode(routeCode int) {
|
||||
r.routeCode = routeCode
|
||||
}
|
||||
|
||||
func (r *Route) SetRampNumber(rampNumber int) {
|
||||
r.rampNumber = rampNumber
|
||||
}
|
||||
|
||||
func (r *Route) SetCopiesInRoute(copiesInRoute int) {
|
||||
r.copiesInRoute = copiesInRoute
|
||||
}
|
||||
|
||||
func (ri *Route) SetLimit(limit int) {
|
||||
ri.limit = limit
|
||||
}
|
||||
|
||||
func (ri *Route) SetMaxStack(maxStack int) {
|
||||
ri.maxStack = maxStack
|
||||
}
|
||||
|
||||
func (ri *Route) SetStandard(standard int) {
|
||||
ri.standard = standard
|
||||
}
|
||||
|
||||
func (ri *Route) SetParameterN(parameterN int) {
|
||||
ri.parameterN = parameterN
|
||||
}
|
||||
|
||||
func (ri *Route) SetMaxBundle(maxBundle int) {
|
||||
ri.maxBundle = maxBundle
|
||||
}
|
||||
|
||||
func (ri *Route) SetTopsheetMarker(topsheetMarker int) {
|
||||
ri.topsheetMarker = topsheetMarker
|
||||
}
|
||||
|
||||
func (ri *Route) SetEaMarker(eaMarker int) {
|
||||
ri.eaMarker = eaMarker
|
||||
}
|
||||
|
||||
func (ri *Route) SetTopsheetTemplateDirectory(topsheetTemplateDirectory int) {
|
||||
ri.topsheetTemplateDirectory = topsheetTemplateDirectory
|
||||
}
|
||||
|
||||
func (ri *Route) SetProductReferenceNumber(productReferenceNumber int) {
|
||||
ri.productReferenceNumber = productReferenceNumber
|
||||
}
|
||||
|
||||
func NewRoute() *Route {
|
||||
r := Route{
|
||||
rampNumber: -1,
|
||||
}
|
||||
return &r
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue