-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hard-soft-ware/refactoring
partial success in transferring
- Loading branch information
Showing
61 changed files
with
3,798 additions
and
1,110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_]` | ||
) |
Oops, something went wrong.