Skip to content

Commit

Permalink
Merge pull request #1 from hard-soft-ware/refactoring
Browse files Browse the repository at this point in the history
partial success in transferring
  • Loading branch information
SUNsung authored Sep 10, 2024
2 parents 5f5d8f6 + 997db46 commit 4c133c8
Show file tree
Hide file tree
Showing 61 changed files with 3,798 additions and 1,110 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ on:
push:
paths-ignore:
- '**/*.yml'
- 'verControl.go'
- 'const.go'
- '**/*.txt'
- '*.md'
- '*.pdf'
pull_request:
paths-ignore:
- '**/*.yml'
- 'verControl.go'
- 'const.go'
- '**/*.txt'
- '*.md'
- '*.pdf'
Expand Down
44 changes: 40 additions & 4 deletions 0_test.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
package mpost

import (
"fmt"
"github.com/hard-soft-ware/mpost/enum"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"os"
"testing"
"time"
)

func TestName(t *testing.T) {
a := NewCAcceptor(30*time.Second, 30*time.Second)
a.Open("/dev/ttyUSB0", B)
func TestConnect(t *testing.T) {
return

time.Sleep(5 * time.Second)
a := DefAcceptor
a.AddLog(
log.Output(zerolog.ConsoleWriter{
Out: os.Stdout,
NoColor: false,
TimeFormat: "15:04:05",
}),
"TEST",
false,
)

a.AddHook(enum.EventConnected, func(acceptor *CAcceptor, i int) {
fmt.Println("Connect")

acceptor.SetEnableAcceptance(true)
acceptor.SetEnableBarCodes(true)
acceptor.SetEnableBookmarks(true)
})
a.AddHook(enum.EventDisconnected, func(acceptor *CAcceptor, i int) {
fmt.Println("Disconnect")
})
a.AddHook(enum.EventRejected, func(acceptor *CAcceptor, i int) {
fmt.Println("EventRejected")
})

a.Open("/dev/ttyUSB0", enum.PowerUpE)

time.Sleep(2 * time.Second)
t.Log(a.GetDeviceSerialNumber())
t.Log(a.GetBill())
t.Log(a.GetApplicationPN())
t.Log(a.GetBootPN())
t.Log(a.GetDeviceState().String())

time.Sleep(10 * time.Second)
a.Close()
}
69 changes: 69 additions & 0 deletions _run/fileGenerator/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package main

import (
"fmt"
"github.com/hard-soft-ware/mpost/_run/fileGenerator/generator"
)

////////////////////////////////////

const constDir = "consts"

////

func Cmd() {
obj := generator.Init("Cmd", constDir+"/cmd.go")
val := obj.NewVal()

val.Add(0x10, "Omnibus")
val.Add(0x40, "Calibrate")
val.Add(0x50, "FlashDownload")
val.Add(0x60, "Auxiliary")
val.Add(0x70, "Expanded")

constGenerator(obj, val)
obj.Save(constDir).End()
fmt.Printf("Add: %s %s\n", constDir, obj.Name.Get())
}

func CmdAux() {
obj := generator.Init("CmdAux", constDir+"/cmdAux.go")
val := obj.NewVal()

val.Add(0x00, "SoftwareCRC")
val.Add(0x01, "CashBoxTotal")
val.Add(0x02, "DeviceResets")
val.Add(0x10, "BNFStatus")
val.Add(0x11, "SetBezel")
val.Add(0x0D, "DeviceCapabilities")
val.Add(0x03, "CleDeviceResetsarCashBoxTotal").Delim()

val.Add(0x04, "AcceptorType")
val.Add(0x0E, "AcceptorApplicationID")
val.Add(0x0F, "AcceptorVariantID")
val.Add(0x05, "AcceptorSerialNumber")
val.Add(0x06, "AcceptorBootPartNumber")
val.Add(0x07, "AcceptorApplicationPartNumber")
val.Add(0x08, "AcceptorVariantName")
val.Add(0x09, "AcceptorVariantPartNumber")
val.Add(0x0A, "AcceptorAuditLifeTimeTotals")
val.Add(0x0B, "AcceptorAuditQPMeasures")
val.Add(0x0C, "AcceptorAuditPerformanceMeasures")

constGenerator(obj, val)
obj.Save(constDir).End()
fmt.Printf("Add: %s %s\n", constDir, obj.Name.Get())
}

func Data() {
obj := generator.Init("Data", constDir+"/data.go")
val := obj.NewVal()

val.Add(0x02, "STX") // Начало текста
val.Add(0x03, "ETX") // Конец текста
val.Add(0x06, "ACKMask") // Маска подтверждения

constGenerator(obj, val)
obj.Save(constDir).End()
fmt.Printf("Add: %s %s\n", constDir, obj.Name.Get())
}
187 changes: 187 additions & 0 deletions _run/fileGenerator/enum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
package main

import (
"fmt"
"github.com/hard-soft-ware/mpost/_run/fileGenerator/generator"
)

////////////////////////////////////

const enumDir = "enum"

////

func Status() {
obj := generator.Init("BNFStatus", enumDir+"/status.go")

val := []string{
"Unknown",
"Error",
"OK",
"NotAttached",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func Document() {
obj := generator.Init("Document", enumDir+"/document.go")

val := []string{
"None",
"NoValue",
"Bill",
"Barcode",
"Coupon",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func Orientation() {
obj := generator.Init("Orientation", enumDir+"/orientation.go")

val := []string{
"RightUp",
"RightDown",
"LeftUp",
"LeftDown",
"UnknownOrientation",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func OrientationControl() {
obj := generator.Init("OrientationControl", enumDir+"/orientation_control.go")

val := []string{
"FourWay",
"TwoWay",
"OneWay",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func PowerUp() {
obj := generator.Init("PowerUp", enumDir+"/powerUp.go")

val := []string{
"A",
"B",
"C",
"E",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func PupExt() {
obj := generator.Init("PupExt", enumDir+"/pupExt.go")

val := []string{
"Return",
"OutOfService",
"Stack",
"StackNoCredit",
"Wait",
"WaitNoCredit",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func State() {
obj := generator.Init("State", enumDir+"/state.go")

val := []string{
"Escrow",
"Stacked",
"Returned",
"Rejected",
"Stalled",
"Accepting",
"CalibrateStart",
"Calibrating",
"Connecting",
"Disconnected",
"Downloading",
"DownloadRestart",
"DownloadStart",
"Failed",
"Idling",
"PupEscrow",
"Returning",
"Stacking",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func Bezel() {
obj := generator.Init("Bezel", enumDir+"/bezel.go")

val := []string{
"Standard",
"Platform",
"Diagnostic",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}

func Event() {
obj := generator.Init("Event", enumDir+"/event.go")

val := []string{
"_Begin",
"Connected",
"Escrow",
"PUPEscrow",
"Stacked",
"Returned",
"Rejected",
"Cheated",
"StackerFull",
"CalibrateStart",
"CalibrateProgress",
"CalibrateFinish",
"DownloadStart",
"DownloadRestart",
"DownloadProgress",
"DownloadFinish",
"PauseDetected",
"PauseCleared",
"StallDetected",
"StallCleared",
"JamDetected",
"JamCleared",
"PowerUp",
"InvalidCommand",
"CashBoxAttached",
"CashBoxRemoved",
"Disconnected",
"_End",
}

enumGenerator(obj, val)
obj.Save(enumDir).End()
fmt.Printf("Add: %s %s\n", enumDir, obj.Name.Get())
}
8 changes: 8 additions & 0 deletions _run/fileGenerator/generator/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package generator

//###########################################################//

const (
hText = "/* This file is automatically generated */"
re = `[^a-zA-Z0-9_]`
)
Loading

0 comments on commit 4c133c8

Please sign in to comment.