-
Notifications
You must be signed in to change notification settings - Fork 0
/
gbl.go
124 lines (108 loc) · 2.25 KB
/
gbl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package types
import (
"context"
"fmt"
"time"
"github.com/AlexTransit/vender/currency"
"github.com/AlexTransit/vender/log2"
// "github.com/AlexTransit/vender/log2"
tele_api "github.com/AlexTransit/vender/tele"
)
// var Log = *log2.NewStderr(log2.LDebug)
var (
VMC *VMCType = nil
UI *UItype = nil
TeleN tele_api.Teler
Log *log2.Log
)
type VMCType struct {
Version string
Lock bool
NeedRestart bool
InputEnable bool
UiState uint32
ReportInv uint32
Client struct {
WorkTime time.Time
Input string
Light bool
}
HW struct {
Display struct {
L1 string
L2 string
GdisplayValid bool
Gdisplay string
}
}
MonSys MonSysStruct
}
type MonSysStruct struct {
Dirty currency.Amount
}
type UItype struct { //nolint:maligned
FrontResult UIMenuResult
Menu map[string]MenuItemType
}
type UIMenuResult struct {
Item MenuItemType
Cream uint8
Sugar uint8
QRPaymenID string
PaymenId int64
QRPayAmount uint32
}
func (mit *MenuItemType) String() string {
return fmt.Sprintf("menu code=%s price=%d(raw) name='%s'", mit.Code, mit.Price, mit.Name)
}
type MenuItemType struct {
Disabled bool
Name string
D Doer
Price currency.Amount
Code string
CreamMax uint8
SugarMax uint8
}
type Doer interface {
Validate() error
Do(context.Context) error
String() string // for logs
}
func init() {
VMC = new(VMCType)
UI = new(UItype)
}
func SetLight(v bool) {
if VMC.Client.Light == v {
return
}
VMC.Client.Light = v
// Log.Infof("light = %v", v)
}
func ShowEnvs() string {
s := fmt.Sprintf("GBL=%+v", VMC)
// Log.Info(s)
return s
}
// преобразование тюнинга в байт
// 0 = дефолтные значение. если менялось то +1 для телеметрии
// convert tuning to byte
// 0 = default value. if changed then +1 for telemetry
func TuneValueToByte(currentValue uint8, defaultValue uint8) []byte {
if currentValue == defaultValue {
return nil
}
return []byte{currentValue + 1}
}
func (evk *VMCType) EvendKeyboardInput(v bool) {
if evk.InputEnable == v {
return
}
// Log.Infof("evend keyboard: %v", v)
evk.InputEnable = v
}
func TeleError(s string) {
// Log.Info(s)
TeleN.ErrorStr(s)
}