// using ctimer to simulate ramping of slider scene is Selected on UI public void SimulateLoadRamp(IRoom allRoomRef, int lightIndex, float rampTo) { LightDevice light = _allLightDevices[lightIndex]; float light1Level = SimplSharpDeviceHelper.UshortToPercent(light.LoadLevel); ushort levelValue1; for (float i = light1Level; i < rampTo; i++) { levelValue1 = SimplSharpDeviceHelper.PercentToUshort(i); allRoomLights.DimmableLights[lightIndex].LightIsAtLevel((sig, component) => { sig.UShortValue = levelValue1; }); light.LoadLevel = levelValue1; } for (float i = light1Level; i > rampTo; i--) { levelValue1 = SimplSharpDeviceHelper.PercentToUshort(i); allRoomLights.DimmableLights[lightIndex].LightIsAtLevel((sig, component) => { sig.UShortValue = levelValue1; }); light.LoadLevel = levelValue1; } }
// using ctimer to simulate ramping of slider when light is turn on/off public void SimulateOnOffLightRamp(object sender, string status) { LightDevice light = (LightDevice)((DimmableLight)sender).UserObject; float vOut = SimplSharpDeviceHelper.UshortToPercent(light.LoadLevel); ushort newLevelValue; if (status == "On") { for (float i = vOut; i < 100; i++) { ushort levelValue = SimplSharpDeviceHelper.PercentToUshort(i); ((DimmableLight)sender).LightIsAtLevel((sig, component) => { sig.UShortValue = levelValue; }); } newLevelValue = SimplSharpDeviceHelper.PercentToUshort(100); light.LoadLevel = newLevelValue; } else { for (float i = vOut; i > 0; i--) { ushort levelValue = SimplSharpDeviceHelper.PercentToUshort(i); ((DimmableLight)sender).LightIsAtLevel((sig, component) => { sig.UShortValue = levelValue; }); } newLevelValue = SimplSharpDeviceHelper.PercentToUshort(0); light.LoadLevel = newLevelValue; } }