Introduced type ControlCharacterSet (+14)

This commit is contained in:
Oliver Jakoubek 2020-07-01 20:30:46 +02:00
parent 76bb097d90
commit 085ed0c8ad
2 changed files with 48 additions and 19 deletions

41
control_character.go Normal file
View file

@ -0,0 +1,41 @@
package feragstring
import "fmt"
type ControlCharacterSet struct {
DontProduce bool
BundlesToSecondaryExit bool
}
func NewControlCharacterSet() *ControlCharacterSet {
cc := ControlCharacterSet{
DontProduce: false,
BundlesToSecondaryExit: false,
}
return &cc
}
func (cc *ControlCharacterSet) SetDontProduce() {
cc.DontProduce = true
}
func (cc *ControlCharacterSet) SetBundlesToSecondaryExit() {
cc.BundlesToSecondaryExit = true
}
func (cc *ControlCharacterSet) GetControlCharactersMessage() string {
var ccCount int
var ccString string
if cc.DontProduce == true {
ccString += "D"
ccCount++
}
if cc.BundlesToSecondaryExit == true {
ccString += "T"
ccCount++
}
if ccCount == 0 {
return ""
}
return fmt.Sprintf("+14%-16s", ccString)
}

View file

@ -4,10 +4,11 @@ import "fmt"
type ProductionDrop struct {
FeragMessage
agentName string
numberOfCopies int
dontProduce bool
topsheetData string
agentName string
numberOfCopies int
ControlCharacters ControlCharacterSet
dontProduce bool
topsheetData string
}
func (pd *ProductionDrop) TopsheetData() string {
@ -33,19 +34,6 @@ 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
}
@ -72,7 +60,7 @@ func NewProductionDrop() *ProductionDrop {
messageStart: "2403",
messageEnd: "!",
},
dontProduce: false,
ControlCharacters: ControlCharacterSet{},
}
return &pd
}
@ -80,7 +68,7 @@ func NewProductionDrop() *ProductionDrop {
func (pd *ProductionDrop) Payload() string {
data := pd.AgentName()
data += pd.NumberOfCopies()
data += pd.ControlCharacter()
data += pd.ControlCharacters.GetControlCharactersMessage()
return data
}