public static CenRfgwController GetNewExGatewayController(string key, string name, string id, string gatewayType) { uint uid; eExGatewayType type; try { uid = Convert.ToUInt32(id, 16); type = (eExGatewayType)Enum.Parse(typeof(eExGatewayType), gatewayType, true); var cs = Global.ControlSystem; GatewayBase gw = null; switch (type) { case eExGatewayType.Ethernet: gw = new CenRfgwEx(uid, cs); break; case eExGatewayType.EthernetShared: gw = new CenRfgwExEthernetSharable(uid, cs); break; case eExGatewayType.Cresnet: gw = new CenRfgwExCresnet(uid, cs); break; } return(new CenRfgwController(key, name, gw)); } catch (Exception) { Debug.Console(0, "ERROR: Cannot create EX Gateway, id {0}, type {1}", id, gatewayType); return(null); } }
/// <summary> /// Constructor of the Control System Class. Make sure the constructor always exists. /// If it doesn't exit, the code will not run on your 3-Series processor. /// </summary> public ControlSystem() : base() { // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should // define the max number of threads which we will use in the system. // the right number depends on your project; do not make this number unnecessarily large Thread.MaxNumberOfUserThreads = 20; xp = new XpanelForSmartGraphics(0xaa, this); xp.SigChange += new SigEventHandler(xp_SigChange); xp.Register(); gateway = new CenRfgwEx(0x03, this); lampDimmer = new ClwLdimex1(0x03, gateway); lampDimmer.Description = "Bedroom lamp dimmer"; // this is what shows in the IP table description field lampDimmer.LoadStateChange += new LoadEventHandler(lampDimmer_LoadStateChange); lampDimmer.ParameterRaiseLowerRate = SimplSharpDeviceHelper.SecondsToUshort(4.0f); // ^^^^^^^^^^^^^^^^^^^^ - this is a very helpful class wallDimmer = new ClwDelvexE(0x04, gateway); wallDimmer.DimmerRemoteButtonSettings.ParameterBargraphBehavior = ClwDimExDimmerRemoteButtonSettings.eBargraphBehavior.AlwaysOn; wallDimmer.DimmerRemoteButtonSettings.ParameterBargraphTimeout = SimplSharpDeviceHelper.SecondsToUshort(2.0f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteDoubleTapTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteHoldTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.DimmerRemoteButtonSettings.ParameterRemoteWaitForDoubleTap = eRemoteWaitForDoubleTap.No; wallDimmer.DimmerRemoteButtonSettings.ParameterReservedButtonForLocalMode = 0; wallDimmer.DimmerUISettings.ParameterButtonLogic = eButtonLogic.Remote; wallDimmer.DimmerUISettings.ParameterLEDOnLevel = ushort.MaxValue; wallDimmer.DimmerUISettings.ParameterNightLightLevel = SimplSharpDeviceHelper.PercentToUshort(10.0f); wallDimmer.ParameterDimmerDelayedOffTime = SimplSharpDeviceHelper.SecondsToUshort(1.0f); wallDimmer.ParameterOffFadeTime = SimplSharpDeviceHelper.SecondsToUshort(0.5f); wallDimmer.ParameterPresetFadeTime = SimplSharpDeviceHelper.SecondsToUshort(1.0f); wallDimmer.ParameterRaiseLowerRate = SimplSharpDeviceHelper.SecondsToUshort(3.0f); wallDimmer.DimmingLoads[1].ParameterDimmerMinLevel = ushort.MinValue; wallDimmer.DimmingLoads[1].ParameterDimmerMaxLevel = ushort.MaxValue; wallDimmer.ButtonStateChange += new ButtonEventHandler(wallDimmer_ButtonStateChange); wallDimmer.LoadStateChange += new LoadEventHandler(wallDimmer_LoadStateChange); // registering the gateway after adding all of the devices will register everything at once gateway.Register(); }