diff --git a/control_character.go b/control_character.go new file mode 100644 index 0000000..f998c40 --- /dev/null +++ b/control_character.go @@ -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) +} diff --git a/production_drop.go b/production_drop.go index c143f45..2ae7a01 100644 --- a/production_drop.go +++ b/production_drop.go @@ -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 }