Compare commits
10 commits
e192181ac8
...
1809aed887
Author | SHA1 | Date | |
---|---|---|---|
1809aed887 | |||
4304874fa6 | |||
5037c728bc | |||
e8d1c806fc | |||
7483232487 | |||
b34df92d7e | |||
4b2dda8301 | |||
0a14f56ddb | |||
|
9c4df123df | ||
|
2fda0e577e |
8 changed files with 127 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$" />
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
[![Go Report Card](https://goreportcard.com/badge/github.com/jakoubek/feragstring)](https://goreportcard.com/report/github.com/jakoubek/feragstring)
|
|
||||||
|
|
||||||
# feragstring
|
# feragstring
|
||||||
|
|
||||||
*feragstring* is a Go package for creating a FERAG string file programmatically. If you don't know what FERAG (the company) or a FERAG string is you probably don't need this package ;-)
|
*feragstring* is a Go package for creating a FERAG string file programmatically. If you don't know what FERAG (the company) or a FERAG string is you probably don't need this package ;-)
|
||||||
|
@ -83,7 +81,7 @@ feragString := fs.PrintOut()
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get -u github.com/jakoubek/feragstring
|
go get -u git.sr.ht/~jakoubek/feragstring
|
||||||
```
|
```
|
||||||
|
|
||||||
## Need commercial support?
|
## Need commercial support?
|
||||||
|
|
6
ferag.go
6
ferag.go
|
@ -84,8 +84,10 @@ func (fs *FeragString) PrintOut() string {
|
||||||
// AddProductReference adds a Product Reference instance to the list
|
// AddProductReference adds a Product Reference instance to the list
|
||||||
// of product references of the FeragString
|
// of product references of the FeragString
|
||||||
func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
||||||
fs.ProductReferencesNr++
|
if pr.productReferenceNumber == 0 {
|
||||||
pr.SetProductReferenceNumber(fs.ProductReferencesNr)
|
fs.ProductReferencesNr++
|
||||||
|
pr.SetProductReferenceNumber(fs.ProductReferencesNr)
|
||||||
|
}
|
||||||
if pr.productReferenceNumber == 1 && pr.productUsageType == 0 {
|
if pr.productReferenceNumber == 1 && pr.productUsageType == 0 {
|
||||||
pr.SetProductUsageType(1)
|
pr.SetProductUsageType(1)
|
||||||
}
|
}
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
||||||
module github.com/jakoubek/feragstring
|
module git.sr.ht/~jakoubek/feragstring
|
||||||
|
|
||||||
go 1.14
|
go 1.14
|
||||||
|
|
|
@ -31,6 +31,9 @@ func NewMissingParameter(missingRate, missingSize int) MissingParameter {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) IssueReference() string {
|
func (pr *ProductReference) IssueReference() string {
|
||||||
|
if pr.issueReference == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
return fmt.Sprintf("+99195%-8s", pr.issueReference)
|
return fmt.Sprintf("+99195%-8s", pr.issueReference)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +50,7 @@ func (pr *ProductReference) SetMissingParameter(missingParameter MissingParamete
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) Scatter() string {
|
func (pr *ProductReference) Scatter() string {
|
||||||
return fmt.Sprintf("+99102%06d", pr.scatter)
|
return fmt.Sprintf("+99276%06d", pr.scatter)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) SetScatter(scatter int) {
|
func (pr *ProductReference) SetScatter(scatter int) {
|
||||||
|
@ -119,13 +122,17 @@ func (pr *ProductReference) SetProductName(productName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) ProductReferenceNumber() string {
|
func (pr *ProductReference) ProductReferenceNumber() string {
|
||||||
return fmt.Sprintf("+41%02d", pr.productReferenceNumber)
|
return fmt.Sprintf("+99141%03d", pr.productReferenceNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) SetProductReferenceNumber(productReferenceNumber int) {
|
func (pr *ProductReference) SetProductReferenceNumber(productReferenceNumber int) {
|
||||||
pr.productReferenceNumber = productReferenceNumber
|
pr.productReferenceNumber = productReferenceNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pr *ProductReference) GetProductReferenceNumber() int {
|
||||||
|
return pr.productReferenceNumber
|
||||||
|
}
|
||||||
|
|
||||||
func NewProductReference() *ProductReference {
|
func NewProductReference() *ProductReference {
|
||||||
pr := ProductReference{
|
pr := ProductReference{
|
||||||
FeragMessage: FeragMessage{"2450", "!"},
|
FeragMessage: FeragMessage{"2450", "!"},
|
||||||
|
@ -147,7 +154,7 @@ func (pr *ProductReference) Payload() string {
|
||||||
data += pr.Supervision()
|
data += pr.Supervision()
|
||||||
data += pr.Overlap()
|
data += pr.Overlap()
|
||||||
data += pr.FeedingMode()
|
data += pr.FeedingMode()
|
||||||
data += pr.Scatter()
|
//data += pr.Scatter()
|
||||||
data += pr.MissingParameter()
|
data += pr.MissingParameter()
|
||||||
data += pr.IssueReference()
|
data += pr.IssueReference()
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -2,15 +2,25 @@ package feragstring
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
// ProductionDrop is the struct for one production drop
|
||||||
|
// underneath a route
|
||||||
type ProductionDrop struct {
|
type ProductionDrop struct {
|
||||||
FeragMessage
|
FeragMessage
|
||||||
agentName string
|
agentName string
|
||||||
numberOfCopies int
|
numberOfCopies int
|
||||||
ControlCharacters ControlCharacterSet
|
ControlCharacters ControlCharacterSet
|
||||||
dontProduce bool
|
limit int
|
||||||
topsheetData string
|
maxStack int
|
||||||
|
standard int
|
||||||
|
parameterN int
|
||||||
|
maxBundle int
|
||||||
|
parameterSz int
|
||||||
|
dontProduce bool
|
||||||
|
topsheetData string
|
||||||
|
productReferenceNumbers []int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TopsheetData returns the formatted topsheet data segment
|
||||||
func (pd *ProductionDrop) TopsheetData() string {
|
func (pd *ProductionDrop) TopsheetData() string {
|
||||||
if pd.topsheetData == "" {
|
if pd.topsheetData == "" {
|
||||||
return ""
|
return ""
|
||||||
|
@ -30,30 +40,95 @@ func (pd *ProductionDrop) TopsheetData() string {
|
||||||
return message(&fm, tsdSegment)
|
return message(&fm, tsdSegment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) MaxBundle() string {
|
||||||
|
return fmt.Sprintf("+34%04d", pd.maxBundle)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetMaxBundle(maxBundle int) {
|
||||||
|
pd.maxBundle = maxBundle
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) ParameterN() string {
|
||||||
|
return fmt.Sprintf("+33%04d", pd.parameterN)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetParameterN(parameterN int) {
|
||||||
|
pd.parameterN = parameterN
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) Standard() string {
|
||||||
|
return fmt.Sprintf("+32%04d", pd.standard)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetStandard(standard int) {
|
||||||
|
pd.standard = standard
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) MaxStack() string {
|
||||||
|
return fmt.Sprintf("+31%04d", pd.maxStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetMaxStack(maxStack int) {
|
||||||
|
pd.maxStack = maxStack
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) Limit() string {
|
||||||
|
return fmt.Sprintf("+30%04d", pd.limit)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetLimit(limit int) {
|
||||||
|
pd.limit = limit
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) ParameterSz() string {
|
||||||
|
return fmt.Sprintf("+35%04d", pd.parameterSz)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pd *ProductionDrop) SetParameterSz(parameterSz int) {
|
||||||
|
pd.parameterSz = parameterSz
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetTopsheetData sets the topsheet data to a given string
|
||||||
func (pd *ProductionDrop) SetTopsheetData(topsheetData string) {
|
func (pd *ProductionDrop) SetTopsheetData(topsheetData string) {
|
||||||
pd.topsheetData = topsheetData
|
pd.topsheetData = topsheetData
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pd *ProductionDrop) SetDontProduce() {
|
// ProductReferenceNumbers returns the string of TSL-formatted ProductReferenceNumbers
|
||||||
pd.dontProduce = true
|
func (pd *ProductionDrop) ProductReferenceNumbers() string {
|
||||||
|
var prreffmt string
|
||||||
|
for _, pr := range pd.productReferenceNumbers {
|
||||||
|
prreffmt += fmt.Sprintf("+99141%03d", pr)
|
||||||
|
}
|
||||||
|
return prreffmt
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddProductReferenceNumber adds a numeric ProductReferenceNumber to the production drop
|
||||||
|
func (pd *ProductionDrop) AddProductReferenceNumber(productReferenceNumber int) {
|
||||||
|
pd.productReferenceNumbers = append(pd.productReferenceNumbers, productReferenceNumber)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NumberOfCopies returns the formatted number of copies in the route
|
||||||
func (pd *ProductionDrop) NumberOfCopies() string {
|
func (pd *ProductionDrop) NumberOfCopies() string {
|
||||||
return fmt.Sprintf("+13%05d", pd.numberOfCopies)
|
return fmt.Sprintf("+13%05d", pd.numberOfCopies)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetNumberOfCopies sets the number of copies in the production drop
|
||||||
func (pd *ProductionDrop) SetNumberOfCopies(numberOfCopies int) {
|
func (pd *ProductionDrop) SetNumberOfCopies(numberOfCopies int) {
|
||||||
pd.numberOfCopies = numberOfCopies
|
pd.numberOfCopies = numberOfCopies
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AgentName returns the formatted agent name
|
||||||
func (pd *ProductionDrop) AgentName() string {
|
func (pd *ProductionDrop) AgentName() string {
|
||||||
return fmt.Sprintf("+12%-10s", pd.agentName)
|
return fmt.Sprintf("+12%-10s", pd.agentName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetAgentName sets the agent name to a given string
|
||||||
func (pd *ProductionDrop) SetAgentName(agentName string) {
|
func (pd *ProductionDrop) SetAgentName(agentName string) {
|
||||||
pd.agentName = agentName
|
pd.agentName = agentName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewProductionDrop instantiates a new production drop
|
||||||
|
// struct and returns a pointer to it.
|
||||||
func NewProductionDrop() *ProductionDrop {
|
func NewProductionDrop() *ProductionDrop {
|
||||||
pd := ProductionDrop{
|
pd := ProductionDrop{
|
||||||
FeragMessage: FeragMessage{
|
FeragMessage: FeragMessage{
|
||||||
|
@ -65,13 +140,24 @@ func NewProductionDrop() *ProductionDrop {
|
||||||
return &pd
|
return &pd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Payload returns the formatted FERAG string
|
||||||
|
// for embedding in the message
|
||||||
func (pd *ProductionDrop) Payload() string {
|
func (pd *ProductionDrop) Payload() string {
|
||||||
data := pd.AgentName()
|
data := pd.AgentName()
|
||||||
data += pd.NumberOfCopies()
|
data += pd.NumberOfCopies()
|
||||||
data += pd.ControlCharacters.GetControlCharactersMessage()
|
data += pd.ControlCharacters.GetControlCharactersMessage()
|
||||||
|
data += pd.Limit()
|
||||||
|
data += pd.MaxStack()
|
||||||
|
data += pd.Standard()
|
||||||
|
data += pd.ParameterN()
|
||||||
|
data += pd.MaxBundle()
|
||||||
|
data += pd.ParameterSz()
|
||||||
|
data += pd.ProductReferenceNumbers()
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Message returns the formatted FERAG string
|
||||||
|
// for the production drop
|
||||||
func (pd *ProductionDrop) Message() string {
|
func (pd *ProductionDrop) Message() string {
|
||||||
message := pd.FeragMessage.MessageTemplate()
|
message := pd.FeragMessage.MessageTemplate()
|
||||||
return message(&pd.FeragMessage, pd.Payload())
|
return message(&pd.FeragMessage, pd.Payload())
|
||||||
|
|
4
route.go
4
route.go
|
@ -117,6 +117,10 @@ func (ri *Route) SetTopsheetTemplateDirectory(topsheetTemplateDirectory int) {
|
||||||
ri.topsheetTemplateDirectory = topsheetTemplateDirectory
|
ri.topsheetTemplateDirectory = topsheetTemplateDirectory
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ri *Route) SetEditionName(editionName string) {
|
||||||
|
ri.editionName = editionName
|
||||||
|
}
|
||||||
|
|
||||||
func NewRoute() *Route {
|
func NewRoute() *Route {
|
||||||
r := Route{
|
r := Route{
|
||||||
rampNumber: -1,
|
rampNumber: -1,
|
||||||
|
|
|
@ -11,6 +11,7 @@ type TitleInfo struct {
|
||||||
printObjectName string
|
printObjectName string
|
||||||
titleName string
|
titleName string
|
||||||
publicationDate time.Time
|
publicationDate time.Time
|
||||||
|
issueReference string
|
||||||
countryCode string
|
countryCode string
|
||||||
printObjectColor string
|
printObjectColor string
|
||||||
additionalInfo string
|
additionalInfo string
|
||||||
|
@ -97,12 +98,24 @@ func (ti *TitleInfo) Payload() string {
|
||||||
data := ti.PrintObjectName()
|
data := ti.PrintObjectName()
|
||||||
data += ti.TitleName()
|
data += ti.TitleName()
|
||||||
data += ti.PublicationDate()
|
data += ti.PublicationDate()
|
||||||
|
data += ti.IssueReference()
|
||||||
data += ti.CountryCode()
|
data += ti.CountryCode()
|
||||||
data += ti.PrintObjectColor()
|
data += ti.PrintObjectColor()
|
||||||
data += ti.AdditionalInfo()
|
data += ti.AdditionalInfo()
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ti *TitleInfo) SetIssueReference(issueReference string) {
|
||||||
|
ti.issueReference = issueReference
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ti *TitleInfo) IssueReference() string {
|
||||||
|
if ti.issueReference == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("+99195%8s", ti.issueReference)
|
||||||
|
}
|
||||||
|
|
||||||
// PrintObjectName returns the print object name segment (+93) FERAG-formatted
|
// PrintObjectName returns the print object name segment (+93) FERAG-formatted
|
||||||
func (ti *TitleInfo) PrintObjectName() string {
|
func (ti *TitleInfo) PrintObjectName() string {
|
||||||
if ti.printObjectName == "" {
|
if ti.printObjectName == "" {
|
||||||
|
|
Loading…
Reference in a new issue