public static void StartTimerForTestEvents() { IBus bus = RabbitHutch.CreateBus("host=localhost"); Observable .Timer(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10)) .Subscribe( x => { var random = new Random(); var heartCmd = new HeartRateCommand() { CommandId = Guid.NewGuid().ToString(), HeartRate = Convert.ToInt16(random.Next(60, 65)) }; bus.Publish(heartCmd); Console.WriteLine("Published test HeartRateCommand."); }); Observable .Timer(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(50)) .Subscribe( x => { var random = new Random(); var mediationStateCmd = new MeditationStateCommand() { CommandId = Guid.NewGuid().ToString(), State = Convert.ToInt16(random.Next(0, 5)) }; bus.Publish(mediationStateCmd); Console.WriteLine("Published test MeditationStateCommand."); }); Console.WriteLine("StartTimerForTestEvents()...."); }
public void RunTests() { var random = new Random(); for (int i = 0; i < 5; i++) { var colorCmd = new ColorControlCommand() { CommandId = Guid.NewGuid().ToString(), ColorBlue = Convert.ToInt16(random.Next(1, 210)), ColorGreen = Convert.ToInt16(random.Next(1, 210)), ColorRed = Convert.ToInt16(random.Next(1, 210)) }; var heartCmd = new HeartRateCommand() { CommandId = Guid.NewGuid().ToString(), HeartRate = Convert.ToInt16(random.Next(60, 170)) }; bus.Publish(colorCmd); bus.Publish(heartCmd); } }
public void RunTestsForever() { var random = new Random(); while (true) { var colorCmd = new ColorControlCommand() { CommandId = Guid.NewGuid().ToString(), ColorBlue = Convert.ToInt16(random.Next(1, 210)), ColorGreen = Convert.ToInt16(random.Next(1, 210)), ColorRed = Convert.ToInt16(random.Next(1, 210)) }; var heartCmd = new HeartRateCommand() { CommandId = Guid.NewGuid().ToString(), HeartRate = Convert.ToInt16(random.Next(60, 170)) }; bus.Publish(colorCmd); bus.Publish(heartCmd); Thread.Sleep(50); } }
private static void HandleHeartRateCommand(HeartRateCommand obj) { throw new NotImplementedException(); }