void Awake() { t = new FSM(); t.OnMove(string.Empty, "Start", OnStarted); t.OnEvent("Start.FixedUpdate, Start2.FixedUpdate", (s, e, args) => { Debug.LogFormat("State: {0}, Event: {1}, Args[0]= {2}, t = {3}", s, e, args[0], time); if (s == "Start") { time += (float) args[0]; if (time > 10.0f) { time = 0.0f; t.Move("Start2"); } } }); t.OnEvent("Start2.FixedUpdate", Start2FixedUpdate); }
static void Init() { c = new FSM(); c.OnTrigger("NULL.connect", args => { if (args.Length != 0 && args[0] is Library.SerialNumber) { Target = Z.CopySerialNumber((Library.SerialNumber) args[0]); } else { Target = new Library.SerialNumber(); Target.Part = new byte[8]; } V.Navigate("Connect"); V.ConnectTrigger("connecting", Target); Z.Connect(); c.Move("connect"); }); c.OnTrigger("connect.connect", args => { V.ConnectTrigger("connecting", Target); Z.Connect(); }); c.OnTrigger("connect.connected", args => { if (Target.Part != null && Z.IsNullSerialNumber(Target) == false && Z.IsSerialNumber(Target) == false) { V.ConnectTrigger("unexpected_serial", Target); Library.Disconnect(Z.Handle); return; } V.ConnectTrigger("connected"); T.Trigger("connected"); }); c.OnTrigger("connect.booted", args => { V.ConnectTrigger("booted"); }); c.OnTrigger("connect.not_connected", args => { V.ConnectTrigger("not_connected"); T.Trigger("not_connected"); }); c.OnTrigger("connect.not_still", args => { V.ConnectTrigger("not_still"); T.Trigger("not_still"); }); c.OnTrigger("connect.need_to_update", args => { V.ConnectTrigger("need_to_update"); T.Trigger("need_to_update"); }); c.OnTrigger("connect.drone_not_associated", args => { V.ConnectTrigger("drone_not_associated"); T.Trigger("drone_not_associated"); }); c.OnTrigger("connect.bad_update", args => { V.ConnectTrigger("bad_update"); T.Trigger("bad_update"); }); c.OnTrigger("connect.firmware_upgrade_start", args => { if (Z.IgnoreConnecting == false) V.ConnectTrigger("firmware_upgrade_start"); T.Trigger("firmware_upgrade_start"); }); c.OnTrigger("connect.firmware_upgrade_in_progress", args => { int percentage = LibZano.Library.GetFirmwareUploadProgress(Z.Handle); if (Z.IgnoreConnecting == false) V.ConnectTrigger("firmware_upgrade_in_progress", percentage); T.Trigger("firmware_upgrade_in_progress", percentage); }); c.OnTrigger("connect.firmware_upgrade_start_complete", args => { if (Z.IgnoreConnecting == false) V.ConnectTrigger("firmware_upgrade_start_complete"); T.Trigger("firmware_upgrade_start_complete"); }); c.OnTrigger("connect.firmware_upgrade_start_failed", args => { if (Z.IgnoreConnecting == false) V.ConnectTrigger("firmware_upgrade_start_failed"); T.Trigger("firmware_upgrade_start_failed"); }); }