Create new type and remove un-used code
Some checks failed
Create Release & Upload Assets / Upload Assets To Gitea w/ goreleaser (push) Failing after 9s
Some checks failed
Create Release & Upload Assets / Upload Assets To Gitea w/ goreleaser (push) Failing after 9s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"git.anomalous.dev/57_Wolve/uberbringer/config"
|
||||
fifo "github.com/foize/go.fifo"
|
||||
"github.com/justinmichaelvieira/escpos"
|
||||
@@ -8,49 +9,6 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type Queue struct {
|
||||
Data []Item `json:"data"`
|
||||
}
|
||||
|
||||
type QueueItem struct {
|
||||
JobID string
|
||||
SequenceNumber int
|
||||
Type int
|
||||
Bold bool
|
||||
Size int
|
||||
Text string
|
||||
}
|
||||
|
||||
// constructor function
|
||||
func (std *QueueItem) fillDefaults() {
|
||||
|
||||
// setting default values
|
||||
// if no values present
|
||||
if std.JobID == "" {
|
||||
std.JobID = "000000000000000000"
|
||||
}
|
||||
|
||||
if std.SequenceNumber == 0 {
|
||||
std.SequenceNumber = 0
|
||||
}
|
||||
|
||||
if std.Type == 0 {
|
||||
std.Type = 0
|
||||
}
|
||||
|
||||
if std.Bold == false {
|
||||
std.Bold = false
|
||||
}
|
||||
|
||||
if std.Size == 0 {
|
||||
std.Size = 1
|
||||
}
|
||||
|
||||
if std.Text == "" {
|
||||
std.Text = "NULL"
|
||||
}
|
||||
}
|
||||
|
||||
func newPrintJob(input DataStruct, queue *fifo.Queue) {
|
||||
var byteLength int
|
||||
|
||||
@@ -92,7 +50,7 @@ func printJobCreate(input DataStruct, queue *fifo.Queue) {
|
||||
for i, item := range input.Data {
|
||||
var SeqNum = i + 1
|
||||
tml.Printf("<darkgrey>[" + config.Project + "]: Job #" + input.JobID + " - creating command " + string(SeqNum) + "</darkgrey>\n")
|
||||
if item.Type <= 0 || item.Type > 5 {
|
||||
if item.Type <= 0 || item.Type > 6 {
|
||||
tml.Printf("<red>[" + config.Project + "]: Job #" + input.JobID + " bad type</red>\n")
|
||||
return
|
||||
} else if item.Size <= 0 || item.Size > 16 {
|
||||
@@ -115,6 +73,22 @@ func printJobCreate(input DataStruct, queue *fifo.Queue) {
|
||||
case 5:
|
||||
// New Line X amount of times
|
||||
p.LineFeedD(uint8(item.Size))
|
||||
case 6:
|
||||
// Decode Base64Raw Input
|
||||
/*
|
||||
base64_decoded, err := base64.StdEncoding.DecodeString(item.Text)
|
||||
if err != nil {
|
||||
tml.Printf("<red>[" + config.Project + "]: Job #" + input.JobID + " base64 decode failed</red>\n")
|
||||
return
|
||||
}
|
||||
*/
|
||||
hex_decoded, err := hex.DecodeString(item.Text)
|
||||
if err != nil {
|
||||
tml.Printf("<red>[" + config.Project + "]: Job #" + input.JobID + " hex decode failed</red>\n")
|
||||
return
|
||||
}
|
||||
|
||||
p.WriteRaw([]byte(hex_decoded))
|
||||
}
|
||||
|
||||
tml.Printf("<green>[" + config.Project + "]: Job #" + input.JobID + " good type</green>\n")
|
||||
|
||||
@@ -16,6 +16,10 @@ import (
|
||||
"git.anomalous.dev/57_Wolve/uberbringer/snowflake"
|
||||
)
|
||||
|
||||
type Queue struct {
|
||||
Data []Item `json:"data"`
|
||||
}
|
||||
|
||||
type InputData struct {
|
||||
Data []Item `json:"data"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user