private async Task BuildLamps(ConfigurationSettings cfg) { //My *north* lamp is the real bulb breakout _nLamp = new ThreeLightLamp(cfg.NorthLampId, _nBulbs, //new Acs712CurrentSensor5A(cfg.NorthRedBulbSensorId, 0) new MockSensor() ); _nLamp.TransitionToState(LampStateEnum.Go).Wait(); await Task.Delay(200); _nLamp.TransitionToState(LampStateEnum.Caution).Wait(); await Task.Delay(200); _nLamp.TransitionToState(LampStateEnum.Stop).Wait(); await Task.Delay(200); //The rest of the lamps are simulated on the breadboard with LEDs _sLamp = new ThreeLightLamp(cfg.SouthLampId, _sBulbs, //new Acs712CurrentSensor30A(cfg.NorthRedBulbSensorId, 2) new MockSensor() ); _sLamp.TransitionToState(LampStateEnum.Go).Wait(); await Task.Delay(200); _sLamp.TransitionToState(LampStateEnum.Caution).Wait(); await Task.Delay(200); _sLamp.TransitionToState(LampStateEnum.Stop).Wait(); await Task.Delay(200); _eLamp = new ThreeLightLamp(cfg.EastLampId, _eBulbs, //new Acs712CurrentSensor5A(cfg.NorthRedBulbSensorId, 3) new MockSensor() ); _eLamp.TransitionToState(LampStateEnum.Caution).Wait(); await Task.Delay(200); _eLamp.TransitionToState(LampStateEnum.Stop).Wait(); await Task.Delay(200); _eLamp.TransitionToState(LampStateEnum.Go).Wait(); await Task.Delay(200); _wLamp = new ThreeLightLamp(cfg.WestLampId, _wBulbs, // new Acs712CurrentSensor30A(cfg.NorthRedBulbSensorId, 1) new MockSensor() ); _wLamp.TransitionToState(LampStateEnum.Caution).Wait(); await Task.Delay(200); _wLamp.TransitionToState(LampStateEnum.Stop).Wait(); await Task.Delay(200); _wLamp.TransitionToState(LampStateEnum.Go).Wait(); }
private void SetupHumidityDependingLamp(IHumiditySensor sensor, ILamp lamp) { ITrigger trigger = sensor.GetHumidityReachedTrigger(80); IAction action = lamp.GetTurnOnAction(); trigger.Attach(action); var twitterClient = new TwitterClient(); trigger.Attach(twitterClient.GetTweetAction("Hello World")); }
public string Map(ILamp lamp) { if (!lamp.Enabled) { return(_disabledLampSymbol); } var lampType = lamp.GetType(); if (_lampMap.TryGetValue(lampType, out var symbol)) { return(symbol); } throw new ArgumentException($"Can not map lamp {lampType.Name} to string."); }
private void SetupDemo() { // Get the area from the controller. IArea area = this.GetArea(Room.ExampleRoom); // Get the single motion detector from the controller. IMotionDetector motionDetector = GetComponent <IMotionDetector>(); ITrigger motionDetectedTrigger = motionDetector.GetMotionDetectedTrigger(); // Get the single temperature and humidity sensor from the controller. ITemperatureSensor temperatureSensor = GetComponent <ITemperatureSensor>(); IHumiditySensor humiditySensor = GetComponent <IHumiditySensor>(); // Get the button with the specified ID from the area (not globally). IButton button = area.GetButton(ExampleRoom.Button1); ITrigger buttonTrigger = button.GetPressedShortlyTrigger(); // Get a test lamp from the area (not globally). ILamp lamp2 = area.GetLamp(ExampleRoom.Lamp2); ILamp lamp3 = area.GetLamp(ExampleRoom.Lamp3); // Integrate the twitter client if the configuration file is available. TwitterClient twitterClient; if (TwitterClientFactory.TryCreateFromDefaultConfigurationFile(out twitterClient)) { RegisterService(new TwitterClient()); IAction tweetAction = twitterClient.GetTweetAction($"Someone is here ({DateTime.Now})... @chkratky"); motionDetectedTrigger.Attach(tweetAction); buttonTrigger.Attach(tweetAction); } // An automation is "Fulfilled" per default. ////var automation = new Automation(new AutomationId("DemoAutomation")) //// .WithTrigger(motionDetectedTrigger) //// .WithActionIfConditionsFulfilled(lamp3.GetTurnOnAction()) //// .WithCondition(ConditionRelation.And, new ComponentIsInStateCondition(lamp2, BinaryStateId.Off)) //// .WithCondition(ConditionRelation.And, new NumericValueSensorHasValueGreaterThanCondition(humiditySensor, 80)); //AddAutomation(automation); SetupTelegramBot(); new PersonalAgentToApiDispatcher(this).ExposeToApi(ApiController); }
public MenuPage(MasterDetailPage Main, DetailPage Detail) { InitializeComponent(); this.BackgroundColor = new Color(99, 172, 213, 0.5);//new Color(255, 255, 255, 0.5); InitUserImage(); MainView = Main; DetailView = Detail; fFile = DependencyService.Get <IFile>(); fLamp = DependencyService.Get <ILamp>(); //PreviewPage = new shSpeak.CameraPreviewPage(); }
protected void TurnOnLamp(ILamp lamp) { lamp.TurnOn(); }
public ReadyLamp(ILamp hardware) { _harware = hardware; }
public Flashlight(ILamp lamp) { _lamp = lamp; _state = new Statemachine.Off(); _state.OnEnter(this); }