public BridgeApiEisc(string ipid) { Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem); Eisc.Register(); Eisc.SigChange += Eisc_SigChange; Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid); }
public EiscApi(DeviceConfig dc) : base(dc.Key) { JoinMaps = new Dictionary <string, JoinMapBaseAdvanced>(); PropertiesConfig = dc.Properties.ToObject <EiscApiPropertiesConfig>(); //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString()); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); Eisc.SigChange += Eisc_SigChange; Eisc.Register(); AddPostActivationAction(() => { Debug.Console(1, this, "Linking Devices..."); foreach (var d in PropertiesConfig.Devices) { var device = DeviceManager.GetDeviceForKey(d.DeviceKey); if (device == null) { continue; } Debug.Console(1, this, "Linking Device: '{0}'", device.Key); if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. { Debug.Console(2, this, "'{0}' is IBridge", device.Key); var dev = device as IBridge; dev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); } if (!(device is IBridgeAdvanced)) { continue; } Debug.Console(2, this, "'{0}' is IBridgeAdvanced", device.Key); var advDev = device as IBridgeAdvanced; try { advDev.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, null); } catch (NullReferenceException) { Debug.ConsoleWithLog(0, this, "Please update the bridge config to use EiscBridgeAdvanced with this device: {0}", device.Key); } } Debug.Console(1, this, "Devices Linked."); }); }
public EiscApiAdvanced(DeviceConfig dc) : base(dc.Key) { JoinMaps = new Dictionary<string, JoinMapBaseAdvanced>(); PropertiesConfig = dc.Properties.ToObject<EiscApiPropertiesConfig>(); //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString()); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); Eisc.SigChange += Eisc_SigChange; Eisc.Register(); AddPostActivationAction( () => { Debug.Console(1, this, "Linking Devices..."); foreach (var d in PropertiesConfig.Devices) { var device = DeviceManager.GetDeviceForKey(d.DeviceKey); if (device == null) continue; Debug.Console(1, this, "Linking Device: '{0}'", device.Key); if (typeof (IBridge).IsAssignableFrom(device.GetType().GetCType())) { var basicBridge = device as IBridge; if (basicBridge != null) { Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Linking EiscApiAdvanced {0} to device {1} using obsolete join map. Please update the device's join map.", Key, device.Key); basicBridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); } continue; } if (!typeof (IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { continue; } var bridge = device as IBridgeAdvanced; if (bridge != null) bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); } }); }
public EiscApiAdvanced(DeviceConfig dc) : base(dc.Key) { JoinMaps = new Dictionary <string, JoinMapBaseAdvanced>(); PropertiesConfig = dc.Properties.ToObject <EiscApiPropertiesConfig>(); //PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString()); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); Eisc.SigChange += Eisc_SigChange; Eisc.Register(); AddPostActivationAction(() => { Debug.Console(1, this, "Linking Devices..."); foreach (var d in PropertiesConfig.Devices) { var device = DeviceManager.GetDeviceForKey(d.DeviceKey); if (device == null) { continue; } Debug.Console(1, this, "Linking Device: '{0}'", device.Key); //if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. //{ // Debug.Console(2, this, "'{0}' is IBridge", device.Key); //} if (!typeof(IBridgeAdvanced).IsAssignableFrom(device.GetType().GetCType())) { continue; } var bridge = device as IBridgeAdvanced; if (bridge != null) { bridge.LinkToApi(Eisc, d.JoinStart, d.JoinMapKey, this); } } }); }
private const string LogHeader = "[Device] "; // used for writing error messages. public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 20; //Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); // below is setup code to talk to MLX3 on internal gateway remote01 = new Mlx3(0x30, this.ControllerRFGatewayDevice); // reference the internal gateway for the paramGateway field this.remote01.ButtonStateChange += new ButtonEventHandler(this.Remote_SigChange); // setup routine to handle a button press var homepage = (Mlx3Home)this.remote01.AddPage(eWirelessRemotePageTypes.Home, 3); // sets up a home page remote01.OnlineStatusChange += Remote_OnlineStatusChange; // setup routine to handle online/offline status change if (remote01.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error(string.Format(LogHeader + "Error registering RF Remote: {0}", remote01.RegistrationFailureReason)); } else { remote01.ShowPage = homepage; // tells the remote to go to the homepage homepage.CurrentRoom.StringValue = "Office Desk"; // Displays office desk as the room name } // below is the setup code to talk to other processor via EISC eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(0x51, "192.168.2.64", this); this.eisc.SigChange += new SigEventHandler(Eisc_SigChange); // setup routine to look for data from other processor if (eisc.Register() != eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Error("Error registering EISC IPID Reason {1}", eisc.RegistrationFailureReason); CrestronConsole.PrintLine("Error registering EISC IPID Reason {1}", eisc.RegistrationFailureReason); } } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}", e.Message); } }
/// <summary> /// /// </summary> /// <param name="key"></param> /// <param name="name"></param> /// <param name="ipId"></param> public MobileControlDdvc01RoomBridge(string key, string name, uint ipId) : base(key, name) { try { EISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipId, "127.0.0.2", Global.ControlSystem); var reg = EISC.Register(); if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) { Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg); } SourceBridge = new MobileControlDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC); DeviceManager.AddDevice(SourceBridge); } catch (Exception) { throw; } }
public EiscApi(DeviceConfig dc) : base(dc.Key) { PropertiesConfig = JsonConvert.DeserializeObject <EiscApiPropertiesConfig>(dc.Properties.ToString()); Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem); Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange); Eisc.Register(); AddPostActivationAction(() => { Debug.Console(1, this, "Linking Devices..."); foreach (var d in PropertiesConfig.Devices) { var device = DeviceManager.GetDeviceForKey(d.DeviceKey); if (device != null) { if (device is IBridge) // Check for this first to allow bridges in plugins to override existing bridges that apply to the same type. { (device as IBridge).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController) { (device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is GenericComm) { (device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is CameraBase) { (device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is PepperDash.Essentials.Core.DisplayBase) { (device as DisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmChassisController) { (device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmBladeChassisController) { (device as DmBladeChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmpsRoutingController) { (device as DmpsRoutingController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmpsAudioOutputController) { (device as DmpsAudioOutputController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmTxControllerBase) { (device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DmRmcControllerBase) { (device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is GenericRelayDevice) { (device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is IDigitalInput) { (device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is AppleTV) { (device as AppleTV).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is HdMdxxxCEController) { (device as HdMdxxxCEController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is LightingBase) { (device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is DigitalLogger) { (device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } else if (device is PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController) { (device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey); continue; } } } Debug.Console(1, this, "Devices Linked."); }); }
public ControlSystem() : base() { for (int i = 0; i < 20; i++) { currentZone[i] = new UItoZone(); } //currentZone[0].volumeRoutingEvent += new UItoZone.volumeRoutingHandler(UItoZone.routeVolumeToUI); readConfig(@"\NVRAM\AVCONFIG.xml"); if (this.SupportsEthernet) { myEISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(0x90, "127.0.0.2", this); myEISC.SigChange += new SigEventHandler(MySigChangeHandler); swampA = new Swamp24x8(0x30, this); //swampA.SourcesChangeEvent += new SourceEventHandler(swampSpdifEvent); swampA.BaseEvent += new BaseEventHandler(swampBaseEvent); swampA.ZoneChangeEvent += new ZoneEventHandler(SwampZoneEvent); swampA.OnlineStatusChange += new OnlineStatusChangeEventHandler(swampA_OnlineStatusChange); if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("myEISC failed registration. Cause: {0}", myEISC.RegistrationFailureReason); if (swampA.Register() != eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Error("SWAMP failed registration {0}", swampA.RegistrationFailureReason); } for (ushort i = 0; i < 5; i++) { myEISC.StringInput[(ushort)(801 + i)].StringValue = groupNames[i]; } for (ushort i = 1; i <= 24; i++) { myEISC.StringInput[(ushort)(810 + i)].StringValue = sourceNameArray[i]; } myEISC.UShortInput[151].UShortValue = (ushort)UItoZone.numberOfGroups; /*expand.Add(expanderE8[0], 0); expand.Add(expanderE8[1], 1); expand.Add(expanderE8[2], 2); foreach (var expander in expand) { * expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(zoneEvent); if (expander.Key == device) { ErrorLog.Notice("expander.Key, args.z.n {0} {1}", expander.Key, args.Zone.Number); } }*/ if (numberOfExpanders > 0) { int numberOfSwampE8 = 0; int numberOfSwampE4 = 0; int numberOfSwe8 = 0; for (int i = 0; i < numberOfExpanders; i++) { switch (swampExpanderTypes[i]) { case "swampE8": numberOfSwampE8++; maxNumberOfZones += 8; expanderE8[i] = new SwampE8(expanderIDs[i], swampA); expanderE8[i].ZoneChangeEvent += new ZoneEventHandler(E8ZoneEvent); //expand.Add(expanderE8[i], i); //expanderE8[i].ZoneChangeEvent += new zoneEventHandlerz[i](zoneEvent); break; case "swampE4": numberOfSwampE4++; maxNumberOfZones += 4; expanderE4[i] = new SwampE4(expanderIDs[i], swampA); expanderE4[i].ZoneChangeEvent += new ZoneEventHandler(E4ZoneEvent); break; case "SWE8": numberOfSwe8++; maxNumberOfZones += 8; expanderSWE8[i] = new Swe8(expanderIDs[i], swampA); //expanderSWE8[i].ZoneChangeEvent += new ZoneEventHandler(SWE8ZoneEvent); break; default: break; } } //ErrorLog.Notice("E8, E4, SWE8 {0},{1},{2}", numberOfSwampE8, numberOfSwampE4, numberOfSwe8); //ErrorLog.Notice("max#zones {0}", maxNumberOfZones); //ErrorLog.Notice("expanders.count {0}", swampA.Expanders.Count); //ErrorLog.Notice("expanderNumber type {0} {1}", swampA.Expanders[1].Number, swampA.Expanders[1].ExpanderType); } // 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; }
/// <summary> /// ControlSystem Constructor. Starting point for the SIMPL#Pro program. /// Use the constructor to: /// * Initialize the maximum number of threads (max = 400) /// * Register devices /// * Register event handlers /// * Add Console Commands /// /// Please be aware that the constructor needs to exit quickly; if it doesn't /// exit in time, the SIMPL#Pro program will exit. /// /// You cannot send / receive data in the constructor /// </summary> public ControlSystem() : base() { try { Thread.MaxNumberOfUserThreads = 100; // // Lighting // eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications((uint)eIpId.EISC, eiscIP, this); eisc.Description = eiscDescription; if (eisc.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice(">>> The EISC #{0} has been registered successfully", ((uint)eIpId.EISC).ToString("X2")); } else { ErrorLog.Error(">>> The EISC #{0} was not registered: {1}", ((uint)eIpId.EISC).ToString("X2"), eisc.RegistrationFailureReason); } uiAdminWeb = new XpanelForSmartGraphics((uint)eIpId.AdminUIweb, this); uiAdminWeb.Description = uiAdminWebDescription; //uiAdminWeb.SigChange += new SigEventHandler(uiAdminWeb_SigChange); // Add SGD to UI string uiAdminWebSgdFilePath = string.Format("{0}\\{1}", Directory.GetApplicationDirectory(), uiAdminWebSGD); if (File.Exists(uiAdminWebSgdFilePath)) { // load the SGD file for this ui project uiAdminWeb.LoadSmartObjects(uiAdminWebSgdFilePath); ErrorLog.Notice(">>> The {0} #{1} loaded SmartObjects SGD ({2}) loaded", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSGD); } else { ErrorLog.Error(">>> The {0} #{1} could not find {0} SGD file. SmartObjects will not work at this time", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWebSgdFilePath); } if (uiAdminWeb.Register() == eDeviceRegistrationUnRegistrationResponse.Success) { ErrorLog.Notice(">>> The {0} #{1} has been registered successfully", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2")); } else { ErrorLog.Error(">>> The {0} #{1} was not registered: {2}", uiAdminWeb.Description, ((uint)eIpId.AdminUIweb).ToString("X2"), uiAdminWeb.RegistrationFailureReason); } lightsControlUI = new LightsControlUI(new List <BasicTriListWithSmartObject>() { uiAdminWeb }); //Subscribe to the controller events (System, Program, and Ethernet) CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler); } catch (Exception e) { ErrorLog.Error("Error in the constructor: {0}", e.Message); } }