public void Setup() { t0 = 0.AsMinute(); mock = new LinearMosquito(2.0.In(1.min()), t0); received = new List<Timestamped<double>>(); mock.Receive += (v) => { received.Add(v); }; }
public void Control_linear_mosquito_with_pid() { var receivedSeries = new List<Timestamped<double>>(); var t0 = 0.AsMinute(); var setpoint = 10.0.At(t0);//.Add(5.min())); var pid = new PIDAlgorithm(0.5, 0.5, 0.5, 0.0); var mosquito = new LinearMosquito(2.0.In(1.min()), t0); var controlledMosqito = mosquito.ControlledBy(pid); controlledMosqito.Receive += (t) => receivedSeries.Add(t); controlledMosqito.Send(setpoint); var clock = new Clock(t0); clock.Subscribe(mosquito); clock.Tick(5.min()); //while (true) clock.Tick(1.min()); Assert.AreEqual(setpoint, receivedSeries.Last()); }