public override void Start()
{
var dumpSeq = new Controller.Sequence("Pop Sequence");
dumpSeq.WhenExecuted
.Execute(instance =>
{
relayDirA.SetPower(true);
relayDirB.SetPower(false);
audioPlayer.PlayEffect("Countdown-sequence-5");
instance.WaitFor(TimeSpan.FromSeconds(7));
relayStart.SetPower(true);
instance.WaitFor(TimeSpan.FromSeconds(1.0));
relayStart.SetPower(false);
relayDirA.SetPower(false);
relayDirB.SetPower(false);
});
var resetSeq = new Controller.Sequence("Reset Sequence");
resetSeq.WhenExecuted
.Execute(instance =>
{
relayDirA.SetPower(false);
relayDirB.SetPower(true);
// relayStart.SetPower(true);
// instance.WaitFor(TimeSpan.FromSeconds(0.5));
// relayStart.SetPower(false);
instance.WaitFor(TimeSpan.FromSeconds(3));
relayDirA.SetPower(false);
relayDirB.SetPower(false);
});
this.oscServer.RegisterAction<int>("/osc/arm", (msg, data) =>
{
if (data.Any())
{
if (data.First() != 0)
stateMachine.SetState(States.Armed);
}
});
this.oscServer.RegisterAction<int>("/osc/disarm", (msg, data) =>
{
if (data.Any())
{
if (data.First() != 0)
stateMachine.SetState(States.Idle);
}
});
this.oscServer.RegisterAction<int>("/osc/dump", (msg, data) =>
{
if (data.Any())
{
if (data.First() != 0)
{
if(stateMachine.CurrentState == States.Armed)
stateMachine.SetState(States.Dump);
}
}
});
this.oscServer.RegisterAction<int>("/osc/reset", (msg, data) =>
{
if (data.Any())
{
if (data.First() != 0)
stateMachine.SetState(States.Reset);
}
});
inputNextSong.ActiveChanged += (sender, e) =>
{
if (e.NewState)
{
audioPlayer.NextBackgroundTrack();
}
};
inputArm.ActiveChanged += (sender, e) =>
{
if (e.NewState)
{
stateMachine.SetState(States.Armed);
}
};
inputDisarm.ActiveChanged += (sender, e) =>
{
if (e.NewState)
{
stateMachine.SetState(States.Idle);
}
};
inputDump.ActiveChanged += (sender, e) =>
{
if (e.NewState)
{
if (stateMachine.CurrentState == States.Armed)
stateMachine.SetState(States.Dump);
}
};
inputReset.ActiveChanged += (sender, e) =>
{
stateMachine.SetState(States.Reset);
};
stateMachine.ForFromSequence(States.Dump, dumpSeq);
stateMachine.ForFromSequence(States.Reset, resetSeq);
lightSpot.SetColor(Color.Red, 0);
pulsatingEffect1.AddDevice(lightSpot);
stateMachine.SetState(States.Idle);
}