state

package
v0.240114.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: CC0-1.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const ContextKey = "run/state-global"

Variables

This section is empty.

Functions

func VmcLock

func VmcLock(ctx context.Context)

func VmcUnLock

func VmcUnLock(ctx context.Context)

Types

type Config

type Config struct {

	// only used for Unmarshal, do not access
	XXX_Include   []ConfigSource `hcl:"include"`
	UpgradeScript string         `hcl:"upgrade_script"`

	Debug struct {
		PprofListen string `hcl:"pprof_listen"`
	}

	Hardware struct {
		// only used for Unmarshal, do not access
		XXX_Devices []DeviceConfig      `hcl:"device"`
		Evend       evend_config.Config `hcl:"evend"`
		Display     struct {
			Framebuffer string `hcl:"framebuffer"`
		}
		HD44780 struct {
			Enable        bool           `hcl:"enable"`
			Codepage      string         `hcl:"codepage"`
			PinChip       string         `hcl:"pin_chip"`
			Pinmap        hd44780.PinMap `hcl:"pinmap"`
			Page1         bool           `hcl:"page1"`
			Width         int            `hcl:"width"`
			ControlBlink  bool           `hcl:"blink"`
			ControlCursor bool           `hcl:"cursor"`
			ScrollDelay   int            `hcl:"scroll_delay"`
		}
		IodinPath string `hcl:"iodin_path"`
		Input     struct {
			EvendKeyboard struct {
				Enable bool `hcl:"enable"`
			} `hcl:"evend_keyboard"`
			DevInputEvent struct {
				Enable bool   `hcl:"enable"`
				Device string `hcl:"device"`
			} `hcl:"dev_input_event"`
		}
		Mdb  mdb_config.Config `hcl:"mdb"`
		Mega struct {
			LogDebug bool   `hcl:"log_debug"`
			Spi      string `hcl:"spi"`
			SpiSpeed string `hcl:"spi_speed"`
			PinChip  string `hcl:"pin_chip"`
			Pin      string `hcl:"pin"`
		}
	}

	Engine engine_config.Config
	Money  struct {
		Scale                  int  `hcl:"scale"`
		CreditMax              int  `hcl:"credit_max"`
		EnableChangeBillToCoin bool `hcl:"enable_change_bill_to_coin"`
		ChangeOverCompensate   int  `hcl:"change_over_compensate"`
	}
	Persist struct {
		Root string `hcl:"root"`
	}
	Tele     tele_config.Config
	UI       ui_config.Config
	Sound    sound.Config
	Watchdog watchdog.Config
	// contains filtered or unexported fields
}

func MustReadConfig

func MustReadConfig(log *log2.Log, fs FullReader, names ...string) *Config

func ReadConfig

func ReadConfig(log *log2.Log, fs FullReader, names ...string) (*Config, error)

func (*Config) ScaleA

func (c *Config) ScaleA(a currency.Amount) currency.Amount

func (*Config) ScaleI

func (c *Config) ScaleI(i int) currency.Amount

func (*Config) ScaleU

func (c *Config) ScaleU(u uint32) currency.Amount

type ConfigSource

type ConfigSource struct {
	Name     string `hcl:"name,key"`
	Optional bool   `hcl:"optional"`
}

type DeviceConfig

type DeviceConfig struct {
	Name     string `hcl:"name,key"`
	Required bool   `hcl:"required"`
}

type FullReader

type FullReader interface {
	Normalize(key string) string
	// nil,nil = not found
	ReadAll(key string) ([]byte, error)
}

type Global

type Global struct {
	Alive        *alive.Alive
	BuildVersion string
	Config       *Config
	Engine       *engine.Engine
	Hardware     hardware // hardware.go
	Inventory    *inventory.Inventory
	Log          *log2.Log
	Tele         tele_api.Teler
	LockCh       chan struct{}

	XXX_money atomic.Value // *money.MoneySystem crutch to import cycle
	XXX_uier  atomic.Value // UIer crutch to import/init cycle

}

func GetGlobal

func GetGlobal(ctx context.Context) *Global

func (*Global) CheckDevices

func (g *Global) CheckDevices() error

func (*Global) ClientBegin

func (g *Global) ClientBegin(ctx context.Context)

func (*Global) ClientEnd

func (g *Global) ClientEnd(ctx context.Context)

func (*Global) Display

func (g *Global) Display() (*display.Display, error)

func (*Global) Error

func (g *Global) Error(err error, args ...interface{})

func (*Global) Fatal

func (g *Global) Fatal(err error, args ...interface{})

func (*Global) GetDevice

func (g *Global) GetDevice(name string) (types.Devicer, error)

Reference registered, inited device

func (*Global) GetDeviceConfig

func (g *Global) GetDeviceConfig(name string) (DeviceConfig, error)

func (*Global) Init

func (g *Global) Init(ctx context.Context, cfg *Config) error

func (*Global) Iodin

func (g *Global) Iodin() (*iodin.Client, error)

func (*Global) Mdb

func (g *Global) Mdb() (*mdb.Bus, error)

func (*Global) Mega

func (g *Global) Mega() (*mega.Client, error)

func (*Global) MustInit

func (g *Global) MustInit(ctx context.Context, cfg *Config)

func (*Global) MustTextDisplay

func (g *Global) MustTextDisplay() *text_display.TextDisplay

func (*Global) RegisterCommands

func (g *Global) RegisterCommands(ctx context.Context)

func (*Global) RegisterDevice

func (g *Global) RegisterDevice(name string, dev types.Devicer, probe func() error) error

Drivers call RegisterDevice to declare device support. probe is called only for devices enabled in config.

func (*Global) ScheduleSync

func (g *Global) ScheduleSync(ctx context.Context, fun types.TaskFunc) error

func (*Global) ShowPicture added in v0.220206.0

func (g *Global) ShowPicture(pict Pic)

func (*Global) ShowQR added in v0.220214.0

func (g *Global) ShowQR(t string)

func (*Global) Stop

func (g *Global) Stop()

func (*Global) StopWait

func (g *Global) StopWait(timeout time.Duration) bool

func (*Global) TextDisplay

func (g *Global) TextDisplay() (*text_display.TextDisplay, error)

func (*Global) UI

func (g *Global) UI() types.UIer

func (*Global) UpgradeVender added in v0.221212.0

func (g *Global) UpgradeVender()

func (*Global) VmcStop

func (g *Global) VmcStop(ctx context.Context)

func (*Global) VmcStopWOInitRequared added in v0.221220.0

func (g *Global) VmcStopWOInitRequared(ctx context.Context)

type MockFullReader

type MockFullReader struct {
	Map map[string]string
}

func NewMockFullReader

func NewMockFullReader(sources map[string]string) *MockFullReader

func (*MockFullReader) Normalize

func (ofr *MockFullReader) Normalize(name string) string

func (*MockFullReader) ReadAll

func (ofr *MockFullReader) ReadAll(name string) ([]byte, error)

type OsFullReader

type OsFullReader struct {
	// contains filtered or unexported fields
}

func NewOsFullReader

func NewOsFullReader() *OsFullReader

func (OsFullReader) Normalize

func (ofr OsFullReader) Normalize(path string) string

func (*OsFullReader) ReadAll

func (ofr *OsFullReader) ReadAll(path string) ([]byte, error)

func (*OsFullReader) SetBase

func (ofr *OsFullReader) SetBase(path string)

type Pic added in v0.220206.0

type Pic uint32
const (
	PictureBoot Pic = iota
	PictureIdle
	PictureClient
	PictureMake
	PictureBroken
	PictureQRPayError
	PicturePayReject
)

Directories

Path Synopsis
Sorry, workaround to import cycles.
Sorry, workaround to import cycles.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL