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
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/hex"
|
||||||
"git.anomalous.dev/57_Wolve/uberbringer/config"
|
"git.anomalous.dev/57_Wolve/uberbringer/config"
|
||||||
fifo "github.com/foize/go.fifo"
|
fifo "github.com/foize/go.fifo"
|
||||||
"github.com/justinmichaelvieira/escpos"
|
"github.com/justinmichaelvieira/escpos"
|
||||||
@@ -8,49 +9,6 @@ import (
|
|||||||
"net"
|
"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) {
|
func newPrintJob(input DataStruct, queue *fifo.Queue) {
|
||||||
var byteLength int
|
var byteLength int
|
||||||
|
|
||||||
@@ -92,7 +50,7 @@ func printJobCreate(input DataStruct, queue *fifo.Queue) {
|
|||||||
for i, item := range input.Data {
|
for i, item := range input.Data {
|
||||||
var SeqNum = i + 1
|
var SeqNum = i + 1
|
||||||
tml.Printf("<darkgrey>[" + config.Project + "]: Job #" + input.JobID + " - creating command " + string(SeqNum) + "</darkgrey>\n")
|
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")
|
tml.Printf("<red>[" + config.Project + "]: Job #" + input.JobID + " bad type</red>\n")
|
||||||
return
|
return
|
||||||
} else if item.Size <= 0 || item.Size > 16 {
|
} else if item.Size <= 0 || item.Size > 16 {
|
||||||
@@ -115,6 +73,22 @@ func printJobCreate(input DataStruct, queue *fifo.Queue) {
|
|||||||
case 5:
|
case 5:
|
||||||
// New Line X amount of times
|
// New Line X amount of times
|
||||||
p.LineFeedD(uint8(item.Size))
|
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")
|
tml.Printf("<green>[" + config.Project + "]: Job #" + input.JobID + " good type</green>\n")
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import (
|
|||||||
"git.anomalous.dev/57_Wolve/uberbringer/snowflake"
|
"git.anomalous.dev/57_Wolve/uberbringer/snowflake"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Queue struct {
|
||||||
|
Data []Item `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
type InputData struct {
|
type InputData struct {
|
||||||
Data []Item `json:"data"`
|
Data []Item `json:"data"`
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user