Ejemplo n.º 1
0
func Test_RunSimulation(t *testing.T) {
	var m sm.Machine
	err := json.Unmarshal([]byte(`{
		"name" : "Example",
		"states" : [ "idle", "working" ],
		"transitions" : {
			"idle" : { "working" : [ { "type" : "deterministic", "parameter" : 1 } ] },
			"working" : { "idle" : [ { "type" : "deterministic", "parameter" : 1 } ] }
		}
	}`), &m)
	assert.Nil(t, err)

	e := engine.NewEnvironment()
	e.AddMachine(hps.IMachine(&m))

	hits := counters.Hits{}
	working, _ := m.GetState("working")
	working.Entering(hits.StateHandler())

	limits := engine.NewLimits()
	limits.Time = 1.0
	e.Run(limits)

	assert.NotEqual(t, 0, hits.Value)
}
Ejemplo n.º 2
0
func NewMachine(name string, kind string) *Machine {
	m := &Machine{}
	m.name = name
	m.kind = kind
	m.properties = map[string]*hps.Property{}
	m.machines = map[string]hps.IMachine{}
	_ = hps.IMachine(m)
	return m
}