state

package
v0.210504.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: CC0-1.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func CheckClientWorking added in v0.210504.0

func CheckClientWorking() error

Types

type Config

type Config struct {

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

	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"`
		ChangeOverCompensate int `hcl:"change_over_compensate"`
	}
	Persist struct {
		Root string `hcl:"root"`
	}
	Tele tele_config.Config
	UI   ui_config.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 added in v0.200320.0

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
	// contains filtered or unexported fields
}

func GetGlobal

func GetGlobal(ctx context.Context) *Global

func (*Global) CheckDevices

func (g *Global) CheckDevices() error

func (*Global) ClientBegin added in v0.210323.0

func (g *Global) ClientBegin()

func (*Global) ClientEnd added in v0.210323.0

func (g *Global) ClientEnd()

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 added in v0.200320.0

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

func (*Global) Init

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

If `Init` fails, consider `Global` is in broken state.

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 added in v0.200320.0

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

func (*Global) RegisterCommands added in v0.210225.0

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, priority tele_api.Priority, fun types.TaskFunc) error

func (*Global) Stop

func (g *Global) Stop()

func (*Global) StopWait

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

func (*Global) TextDisplay added in v0.200320.0

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

func (*Global) UI

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

func (*Global) VmcReload added in v0.210425.2

func (g *Global) VmcReload(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 (self *MockFullReader) Normalize(name string) string

func (*MockFullReader) ReadAll

func (self *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 (self OsFullReader) Normalize(path string) string

func (*OsFullReader) ReadAll

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

func (*OsFullReader) SetBase

func (self *OsFullReader) SetBase(path string)

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