void lampDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) { CrestronConsole.PrintLine("Lamp dimmer: {0}", EventIds[args.EventId]); } // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: xp.BooleanInput[1].BoolValue = !lampDimmer.DimmingLoads[1].IsOn; xp.BooleanInput[2].BoolValue = lampDimmer.DimmingLoads[1].IsOn; break; case LoadEventIds.LevelChangeEventId: xp.UShortInput[1].UShortValue = lampDimmer.DimmingLoads[1].LevelFeedback.UShortValue; break; case LoadEventIds.LevelInputChangedEventId: xp.UShortInput[1].CreateRamp(lampDimmer.DimmingLoads[1].Level.RampingInformation); break; default: break; } }
void wallDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) { CrestronConsole.PrintLine("Wall dimmer: {0}", EventIds[args.EventId]); } // see below }
void din8sw8_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { // ILiveDebug.WriteLine(args.Load.Number.ToString()); //throw new NotImplementedException(); }
void load_LoadEventHandler(LightingBase currentDevice, LoadEventArgs args) { var hub = MessageHub.Instance; if (EventIds.ContainsKey(args.EventId)) { CrestronConsole.PrintLine("MessgeID: {0} Device {1}: {2}", sequence++, currentDevice.ID, EventIds[args.EventId]); } // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: if (args.Load is SwitchedLoad) { // this._ison = ((SwitchedLoad)(args.Load)).IsOn; LoadOnEvent message = new LoadOnEvent(this); message.IsOn = this.IsOn(); hub.Publish <LoadOnEvent>(message); } else if (args.Load is BasicDimmingLoad) { LoadOnEvent mess = new LoadOnEvent(this); mess.IsOn = this.IsOn(); hub.Publish <LoadOnEvent>(mess); break; } break; case LoadEventIds.LevelChangeEventId: var dimmer = ((ClwDimmingLoad)(args.Load)); _levelFB = dimmer.LevelFeedback.UShortValue; CrestronConsole.PrintLine("Processing Ramp Level Event: {0}", _levelFB); if (currentState == loadState.Raise || currentState == loadState.Lower || currentState == loadState.StopLower || currentState == loadState.StopRaise) { if (expectedMessageCount == 3) { CrestronConsole.PrintLine("Start Ramp Level: {0}", _levelFB); //Swallow the initial Level Message (for now); expectedMessageCount--; break; } else if (expectedMessageCount == 2) { expectedMessageCount--; break; //Next to last message (pulse) } else if (expectedMessageCount == 1) { //Final state (store in Level); CrestronConsole.PrintLine("End Ramp Level: {0}", _levelFB); expectedMessageCount--; _level = dimmer.LevelFeedback.UShortValue; SetLevelFB(_level); currentState = loadState.Steady; break; } } else if (currentState == loadState.Toggle) { if (expectedMessageCount == 2) { //Swallow first level expectedMessageCount--; break; } else if (expectedMessageCount == 1) { CrestronConsole.PrintLine("End State based on Toggle: {0}", _levelFB); expectedMessageCount--; _level = dimmer.LevelFeedback.UShortValue; SetLevelFB(_level); currentState = loadState.Steady; break; } } else { if (currentState == loadState.Steady) { CrestronConsole.PrintLine("Toggle state encountered: {0}", _levelFB); currentState = loadState.Toggle; expectedMessageCount = 1; break; } } break; case LoadEventIds.LevelInputChangedEventId: break; case LoadEventIds.PresetLoadIsAtEventId: break; case LoadEventIds.LastPresetCalledEventId: var dimmer2 = ((ClwDimmingLoad)(args.Load)); var lastPreset = dimmer2.LastPresetCalled(); if (lastPreset != null) { LoadPresetCalledEvent presetMessage = new LoadPresetCalledEvent(this); presetMessage.PresetNumber = lastPreset.Number; hub.Publish <LoadPresetCalledEvent>(presetMessage); } else { } break; case LoadEventIds.LowerEventId: if (currentState == loadState.Lower) { CrestronConsole.PrintLine("I was lowering, stopping lower"); currentState = loadState.StopLower; } else { CrestronConsole.PrintLine("In default Lower block"); currentState = loadState.Lower; expectedMessageCount = 3; } LoadLowerEvent lowerMessage = new LoadLowerEvent(this); hub.Publish <LoadLowerEvent>(lowerMessage); break; case LoadEventIds.RaiseEventId: if (currentState == loadState.Raise) { CrestronConsole.PrintLine("I was raising, stopping raise"); currentState = loadState.StopRaise; } else { CrestronConsole.PrintLine("In default Raise block"); currentState = loadState.Raise; expectedMessageCount = 3; } LoadRaiseEvent raiseMessage = new LoadRaiseEvent(this); hub.Publish <LoadRaiseEvent>(raiseMessage); break; case LoadEventIds.OffReleaseEventId: currentState = loadState.Toggle; expectedMessageCount = 2; LoadButtonOffReleaseEvent offReleaseMessage = new LoadButtonOffReleaseEvent(this); hub.Publish <LoadButtonOffReleaseEvent>(offReleaseMessage); break; default: break; } }
void wallDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) CrestronConsole.PrintLine("Wall dimmer: {0}", EventIds[args.EventId]); // see below }
void lampDimmer_LoadStateChange(LightingBase lightingObject, LoadEventArgs args) { if (EventIds.ContainsKey(args.EventId)) CrestronConsole.PrintLine("Lamp dimmer: {0}", EventIds[args.EventId]); // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: xp.BooleanInput[1].BoolValue = !lampDimmer.DimmingLoads[1].IsOn; xp.BooleanInput[2].BoolValue = lampDimmer.DimmingLoads[1].IsOn; break; case LoadEventIds.LevelChangeEventId: xp.UShortInput[1].UShortValue = lampDimmer.DimmingLoads[1].LevelFeedback.UShortValue; break; case LoadEventIds.LevelInputChangedEventId: xp.UShortInput[1].CreateRamp(lampDimmer.DimmingLoads[1].Level.RampingInformation); break; default: break; } }
void load_LoadEventHandler(LightingBase currentDevice, LoadEventArgs args) { //Need to review this code/handler to better support multiple loads on device var hub = MessageHub.Instance; //if (EventIds.ContainsKey(args.EventId)) // CrestronConsole.PrintLine("MessgeID: {0} Device {1}: {2}", sequence++, currentDevice.ID, EventIds[args.EventId]); // use this structure to react to the different events switch (args.EventId) { case LoadEventIds.IsOnEventId: { //Shouldn't matter if Switch vs Dimmer if (this.IsOn()) { LoadIsOnEvent message = new LoadIsOnEvent(this); hub.Publish <LoadIsOnEvent>(message); } else { LoadIsOffEvent message = new LoadIsOffEvent(this); hub.Publish <LoadIsOffEvent>(message); } } break; case LoadEventIds.LevelChangeEventId: { //If Level is/was 65535 //You can expect two level events with no prior warning (This means button was pressed); var dimmer = ((ClwDimmingLoad)(args.Load)); _levelFB = dimmer.LevelFeedback.UShortValue; if (currentState == LoadState.Raise || currentState == LoadState.Lower || currentState == LoadState.StopLower || currentState == LoadState.StopRaise) { if (expectedMessageCount == 3) { //Swallow the initial Level Message (for now); _startLevel = _levelFB; expectedMessageCount--; break; } else if (expectedMessageCount == 2) { expectedMessageCount--; break; //Next to last message (pulse) } else if (expectedMessageCount == 1) { //Final state (store in Level); _endLevel = _levelFB; expectedMessageCount--; _level = dimmer.LevelFeedback.UShortValue; SetLevelFB(_level); currentState = LoadState.Steady; break; } } else if (currentState == LoadState.Toggle) { if (expectedMessageCount == 2) { //Swallow first level _startLevel = _levelFB; expectedMessageCount--; break; } else if (expectedMessageCount == 1) { expectedMessageCount--; _endLevel = _levelFB; _level = _levelFB; SetLevelFB(_level); currentState = LoadState.Steady; break; } } else { if (currentState == LoadState.Steady) { //This only gets called when load is at MAX 65535 and we keep pushing to go max again //This really shouldn't trigger an event (as we already should have this level) //Let's process it anyway _startLevel = _levelFB; currentState = LoadState.Toggle; expectedMessageCount = 1; break; } } } break; case LoadEventIds.LevelInputChangedEventId: { } break; case LoadEventIds.PresetLoadIsAtEventId: { } break; case LoadEventIds.FastOffEventId: { //We must handle this currentState = LoadState.Toggle; expectedMessageCount = 2; LoadOffEvent message = new LoadOffEvent(this); message.Time = _fastOnOffTime; hub.Publish <LoadOffEvent>(message); } break; case LoadEventIds.FastFullOnEventId: { //Need to handle this var dimmer = ((ClwDimmingLoad)(args.Load)); // var last1Preset = dimmer12.LastPresetCalled(); currentState = LoadState.Toggle; expectedMessageCount = 2; LoadOnEvent message = new LoadOnEvent(this); message.Time = _fastOnOffTime; //lpresetMessage.PresetNumber = last1Preset.Number; hub.Publish <LoadOnEvent>(message); } break; case LoadEventIds.LastPresetCalledEventId: { //This is preset to go full on //I'm not handling other presets right now //Switch somehow has "PressOn" triggered to preset var dimmer = ((ClwDimmingLoad)(args.Load)); var lastPreset = dimmer.LastPresetCalled(); currentState = LoadState.Toggle; expectedMessageCount = 2; if (lastPreset != null) { LoadOnEvent message = new LoadOnEvent(this); message.Time = _presetFadeTime; // presetMessage.PresetNumber = lastPreset.Number; hub.Publish <LoadOnEvent>(message); } else { } } break; case LoadEventIds.LowerEventId: { //Basic lower if (currentState == LoadState.Lower) { currentState = LoadState.StopLower; } else { currentState = LoadState.Lower; expectedMessageCount = 3; } LoadLowerEvent message = new LoadLowerEvent(this); hub.Publish <LoadLowerEvent>(message); } break; case LoadEventIds.RaiseEventId: { //Basic Raise if (currentState == LoadState.Raise) { currentState = LoadState.StopRaise; } else { currentState = LoadState.Raise; expectedMessageCount = 3; } LoadRaiseEvent message = new LoadRaiseEvent(this); hub.Publish <LoadRaiseEvent>(message); } break; case LoadEventIds.OffReleaseEventId: { //Off Release //We don't do anything with Off Press? //Holding Off just triggers a lower currentState = LoadState.Toggle; expectedMessageCount = 2; LoadOffEvent message = new LoadOffEvent(this); message.Time = _offFadeTime; hub.Publish <LoadOffEvent>(message); } break; default: { } break; } }