Esempio n. 1
0
 public void should_turn_on_green_light()
 {
     using (var device = new PhysicalDevice(new DelcomHid()))
     {
         device.Open();
         device.TurnOn(Color.Green);
         Thread.Sleep(1000);
     }
 }
Esempio n. 2
0
 public void should_start_buzzer()
 {
     using (var device = new PhysicalDevice(new DelcomHid()))
     {
         device.Open();
         device.StartBuzzer(100, 2, 20, 20);
         Thread.Sleep(3000);
     }
 }
Esempio n. 3
0
 public void should_flash_red_light()
 {
     using (var device = new PhysicalDevice(new DelcomHid()))
     {
         device.Open();
         device.Flash(Color.Red);
         Thread.Sleep(3000);
     }
 }
Esempio n. 4
0
        public void SetMemento(Memento memento)
        {
            Log.Information("=> DelcomConfiguration.SetMemento");
            if (memento.Key != key)
                Log.Warning("Possible attempt to load non-Delcom configuration");

            var element = memento.Element;
            var profilesElement = element.Element("profiles");
            if (profilesElement != null)
            {
                foreach (var profileElement in profilesElement.Elements("profile"))
                {
                    var profile = new MonitoringProfile();
                    profile.SetMemento(profileElement);
                    profiles.Add(profile);
                }
            }
            else
                Log.Warning("Missing element: profiles");

            var devicesElement = element.Element("devices");
            if (devicesElement != null)
            {
                foreach (var deviceElement in devicesElement.Elements("device"))
                {
                    var device = new DelcomDevice();
                    device.SetMemento(deviceElement);
                    device.Profile = Profiles.Single(p => p.Id == device.ProfileId);
                    AddOutputDevice(device);
                }
            }
            else
                Log.Warning("Missing element: devices");

            for (uint i = 1; ; i++)
            {
                var delcom = new DelcomHid();
                if (delcom.OpenNthDevice(i) != 0)
                    break;

                var physicalDevice = new PhysicalDevice(delcom);
                var deviceId = physicalDevice.Id;

                var delcomDevice = outputDevices.OfType<DelcomDevice>().SingleOrDefault(d => d.PhysicalDeviceId == deviceId);
                if (delcomDevice != null)
                    delcomDevice.PhysicalDevice = physicalDevice;
            }
        }
Esempio n. 5
0
 public void should_allow_all_lights_and_sound_at_once()
 {
     using (var device = new PhysicalDevice(new DelcomHid()))
     {
         device.Open();
         device.TurnOn(Color.Green);
         device.TurnOn(Color.Yellow);
         device.TurnOn(Color.Red);
         device.StartBuzzer(50, 2, 20, 10);
         Thread.Sleep(1000);
     }
 }
Esempio n. 6
0
 public void should_ignore_requests_to_stop_if_buzzer_not_started()
 {
     using (var device = new PhysicalDevice(new DelcomHid()))
     {
         device.Open();
         device.StopBuzzer();
     }
 }
Esempio n. 7
0
 public void x_should_turn_off_all_lights_and_sounds_when_finalized()
 {
     var device = new PhysicalDevice(new DelcomHid());
     device.Open();
     device.TurnOn(Color.Green);
     device.TurnOn(Color.Yellow);
     device.TurnOn(Color.Red);
     device.StartBuzzer(150, 2, 20, 10);
     Thread.Sleep(1000);
 }