From 2fda0e577e77e0e2511b0e1c16c542d6d1426888 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Thu, 9 Jul 2020 11:41:49 +0200 Subject: [PATCH 01/10] Added comments to Production Drop. Fixes #10 --- production_drop.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/production_drop.go b/production_drop.go index 2ae7a01..fd77eda 100644 --- a/production_drop.go +++ b/production_drop.go @@ -2,6 +2,8 @@ package feragstring import "fmt" +// ProductionDrop is the struct for one production drop +// underneath a route type ProductionDrop struct { FeragMessage agentName string @@ -11,6 +13,7 @@ type ProductionDrop struct { topsheetData string } +// TopsheetData returns the formatted topsheet data segment func (pd *ProductionDrop) TopsheetData() string { if pd.topsheetData == "" { return "" @@ -30,6 +33,7 @@ func (pd *ProductionDrop) TopsheetData() string { return message(&fm, tsdSegment) } +// SetTopsheetData sets the topsheet data to a given string func (pd *ProductionDrop) SetTopsheetData(topsheetData string) { pd.topsheetData = topsheetData } @@ -38,22 +42,28 @@ func (pd *ProductionDrop) SetDontProduce() { pd.dontProduce = true } +// NumberOfCopies returns the formatted number of copies in the route func (pd *ProductionDrop) NumberOfCopies() string { return fmt.Sprintf("+13%05d", pd.numberOfCopies) } +// SetNumberOfCopies sets the number of copies in the production drop func (pd *ProductionDrop) SetNumberOfCopies(numberOfCopies int) { pd.numberOfCopies = numberOfCopies } +// AgentName returns the formatted agent name func (pd *ProductionDrop) AgentName() string { return fmt.Sprintf("+12%-10s", pd.agentName) } +// SetAgentName sets the agent name to a given string func (pd *ProductionDrop) SetAgentName(agentName string) { pd.agentName = agentName } +// NewProductionDrop instantiates a new production drop +// struct and returns a pointer to it. func NewProductionDrop() *ProductionDrop { pd := ProductionDrop{ FeragMessage: FeragMessage{ @@ -65,6 +75,8 @@ func NewProductionDrop() *ProductionDrop { return &pd } +// Payload returns the formatted FERAG string +// for embedding in the message func (pd *ProductionDrop) Payload() string { data := pd.AgentName() data += pd.NumberOfCopies() @@ -72,6 +84,8 @@ func (pd *ProductionDrop) Payload() string { return data } +// Message returns the formatted FERAG string +// for the production drop func (pd *ProductionDrop) Message() string { message := pd.FeragMessage.MessageTemplate() return message(&pd.FeragMessage, pd.Payload()) From 9c4df123dff015ab6ddc9068a9145a69142ad853 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Thu, 9 Jul 2020 11:42:54 +0200 Subject: [PATCH 02/10] Removed attribute dontProduce from production drop. Fixes #3 --- production_drop.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/production_drop.go b/production_drop.go index fd77eda..cdf38de 100644 --- a/production_drop.go +++ b/production_drop.go @@ -38,10 +38,6 @@ func (pd *ProductionDrop) SetTopsheetData(topsheetData string) { pd.topsheetData = topsheetData } -func (pd *ProductionDrop) SetDontProduce() { - pd.dontProduce = true -} - // NumberOfCopies returns the formatted number of copies in the route func (pd *ProductionDrop) NumberOfCopies() string { return fmt.Sprintf("+13%05d", pd.numberOfCopies) From 0a14f56ddbe090f4f67da68bb1ab08f9c102a6d6 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 08:55:06 +0100 Subject: [PATCH 03/10] Added product reference numbers to production drops. Fixes #13 --- .idea/feragstring.iml | 1 + production_drop.go | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.idea/feragstring.iml b/.idea/feragstring.iml index c956989..5e764c4 100644 --- a/.idea/feragstring.iml +++ b/.idea/feragstring.iml @@ -1,5 +1,6 @@ + diff --git a/production_drop.go b/production_drop.go index cdf38de..6bdbb4a 100644 --- a/production_drop.go +++ b/production_drop.go @@ -6,11 +6,12 @@ import "fmt" // underneath a route type ProductionDrop struct { FeragMessage - agentName string - numberOfCopies int - ControlCharacters ControlCharacterSet - dontProduce bool - topsheetData string + agentName string + numberOfCopies int + ControlCharacters ControlCharacterSet + dontProduce bool + topsheetData string + productReferenceNumbers []int } // TopsheetData returns the formatted topsheet data segment @@ -38,6 +39,20 @@ func (pd *ProductionDrop) SetTopsheetData(topsheetData string) { pd.topsheetData = topsheetData } +// ProductReferenceNumbers returns the string of TSL-formatted ProductReferenceNumbers +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 { return fmt.Sprintf("+13%05d", pd.numberOfCopies) @@ -77,6 +92,7 @@ func (pd *ProductionDrop) Payload() string { data := pd.AgentName() data += pd.NumberOfCopies() data += pd.ControlCharacters.GetControlCharactersMessage() + data += pd.ProductReferenceNumbers() return data } From 4b2dda8301729d97f7512505631e43478812448d Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 09:00:44 +0100 Subject: [PATCH 04/10] Add products with a product reference number A product reference number is only assigned (and the central counter incremented) if the product has no product reference number attached. Fixes #14 --- ferag.go | 6 ++++-- product_reference.go | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ferag.go b/ferag.go index a4ce7be..75563fe 100644 --- a/ferag.go +++ b/ferag.go @@ -84,8 +84,10 @@ func (fs *FeragString) PrintOut() string { // AddProductReference adds a Product Reference instance to the list // of product references of the FeragString func (fs *FeragString) AddProductReference(pr *ProductReference) error { - fs.ProductReferencesNr++ - pr.SetProductReferenceNumber(fs.ProductReferencesNr) + if pr.productReferenceNumber == 0 { + fs.ProductReferencesNr++ + pr.SetProductReferenceNumber(fs.ProductReferencesNr) + } if pr.productReferenceNumber == 1 && pr.productUsageType == 0 { pr.SetProductUsageType(1) } diff --git a/product_reference.go b/product_reference.go index 8e53de2..ddd8d0f 100644 --- a/product_reference.go +++ b/product_reference.go @@ -119,13 +119,17 @@ func (pr *ProductReference) SetProductName(productName 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) { pr.productReferenceNumber = productReferenceNumber } +func (pr *ProductReference) GetProductReferenceNumber() int { + return pr.productReferenceNumber +} + func NewProductReference() *ProductReference { pr := ProductReference{ FeragMessage: FeragMessage{"2450", "!"}, From b34df92d7e248505c4afe0a7077911fad3140e27 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 16:01:03 +0100 Subject: [PATCH 05/10] Add Edition name to route Fixes #15 --- route.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/route.go b/route.go index 41cefb3..72980f7 100644 --- a/route.go +++ b/route.go @@ -117,6 +117,10 @@ func (ri *Route) SetTopsheetTemplateDirectory(topsheetTemplateDirectory int) { ri.topsheetTemplateDirectory = topsheetTemplateDirectory } +func (ri *Route) SetEditionName(editionName string) { + ri.editionName = editionName +} + func NewRoute() *Route { r := Route{ rampNumber: -1, From 7483232487c93e6eb05a7c8cf34370b208e3e773 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 16:01:45 +0100 Subject: [PATCH 06/10] Remove obsolete segment +99102 (scatter) Fixes #16 --- product_reference.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/product_reference.go b/product_reference.go index ddd8d0f..48d4985 100644 --- a/product_reference.go +++ b/product_reference.go @@ -47,7 +47,7 @@ func (pr *ProductReference) SetMissingParameter(missingParameter MissingParamete } 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) { @@ -151,7 +151,7 @@ func (pr *ProductReference) Payload() string { data += pr.Supervision() data += pr.Overlap() data += pr.FeedingMode() - data += pr.Scatter() + //data += pr.Scatter() data += pr.MissingParameter() data += pr.IssueReference() return data From e8d1c806fc5c9f5f24881bf19ab418ea816001b7 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 16:03:31 +0100 Subject: [PATCH 07/10] Added bundle parameters to production drop Fixes #17 --- production_drop.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/production_drop.go b/production_drop.go index 6bdbb4a..34bcc90 100644 --- a/production_drop.go +++ b/production_drop.go @@ -9,6 +9,12 @@ type ProductionDrop struct { agentName string numberOfCopies int ControlCharacters ControlCharacterSet + limit int + maxStack int + standard int + parameterN int + maxBundle int + parameterSz int dontProduce bool topsheetData string productReferenceNumbers []int @@ -34,6 +40,54 @@ func (pd *ProductionDrop) TopsheetData() string { 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) { pd.topsheetData = topsheetData @@ -92,6 +146,12 @@ func (pd *ProductionDrop) Payload() string { data := pd.AgentName() data += pd.NumberOfCopies() 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 } From 5037c728bc15ff60ffffd82563c99dd1adfc1a77 Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 17:04:31 +0100 Subject: [PATCH 08/10] Support Issue Reference in Title Info Fixes #12 --- title_info.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/title_info.go b/title_info.go index 366d3e2..2478c21 100644 --- a/title_info.go +++ b/title_info.go @@ -11,6 +11,7 @@ type TitleInfo struct { printObjectName string titleName string publicationDate time.Time + issueReference string countryCode string printObjectColor string additionalInfo string @@ -97,12 +98,24 @@ func (ti *TitleInfo) Payload() string { data := ti.PrintObjectName() data += ti.TitleName() data += ti.PublicationDate() + data += ti.IssueReference() data += ti.CountryCode() data += ti.PrintObjectColor() data += ti.AdditionalInfo() 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 func (ti *TitleInfo) PrintObjectName() string { if ti.printObjectName == "" { From 4304874fa63ad184b26b6caa564286fcd1ff369c Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Fri, 24 Mar 2023 17:04:48 +0100 Subject: [PATCH 09/10] Show Issue Reference in Product Reference only if set Fixes #18 --- product_reference.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/product_reference.go b/product_reference.go index 48d4985..0f205b4 100644 --- a/product_reference.go +++ b/product_reference.go @@ -31,6 +31,9 @@ func NewMissingParameter(missingRate, missingSize int) MissingParameter { } func (pr *ProductReference) IssueReference() string { + if pr.issueReference == "" { + return "" + } return fmt.Sprintf("+99195%-8s", pr.issueReference) } From 1809aed887a175a683b8e7117a26f418bf16c73e Mon Sep 17 00:00:00 2001 From: Oliver Jakoubek Date: Tue, 16 Apr 2024 20:24:06 +0200 Subject: [PATCH 10/10] Renamed module from github.com/jakoubek/feragstring to git.sr.ht/~jakoubek/feragstring --- README.md | 4 +--- go.mod | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index afa9480..fd7d6e5 100644 --- a/README.md +++ b/README.md @@ -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* 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 ```bash -go get -u github.com/jakoubek/feragstring +go get -u git.sr.ht/~jakoubek/feragstring ``` ## Need commercial support? diff --git a/go.mod b/go.mod index e29fa7b..ad81db9 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ -module github.com/jakoubek/feragstring +module git.sr.ht/~jakoubek/feragstring go 1.14