Ejemplo n.º 1
2
        /// <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()
        {
            // subscribe to control system events
            CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);

            // 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;

            // ensure this processor has ethernet
            if (this.SupportsEthernet)
            {
                // create new dmtx401c object and subscribe to its events
                dmTx = new DmTx401C(0x03, this);	// IPID for the dmtx is 3
                dmTx.BaseEvent += dmTx_BaseEvent;
                dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange;
                dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange;
                dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange;
                dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange;
                dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange;
                dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange;
                dmTx.OnlineStatusChange += Device_OnlineStatusChange;

                // create new tt100 object using the dmtx401 constructor, and subscribe to its events
                connectIt = new Tt1xx(dmTx);
                connectIt.ButtonStateChange += connectIt_ButtonStateChange;
                connectIt.OnlineStatusChange += Device_OnlineStatusChange;

                // register the dmtx to this program, the tt100 will be registered as part of the dmtx
                if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason);

                // create new dmrmc100c object and subscribe to its events
                dmRmc = new DmRmcScalerC(0x04, this);	// IPID for the dmtx is 4
                dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange;
                dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived;
                dmRmc.OnlineStatusChange += Device_OnlineStatusChange;
                dmRmc.Scaler.OutputChange += Scaler_OutputChange;

                // register device with the control system
                if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully");
                else
                    ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason);

                // create a new xpanel room object and subscribe to its events
                xPanelUi = new XpanelForSmartGraphics(0x0b, this);
                xPanelUi.SigChange += xPanelUi_SigChange;
                xPanelUi.OnlineStatusChange += Device_OnlineStatusChange;

                // pathway to the SGD file for this ui project
                string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory());

                // make sure file exists in the application directory
                if (File.Exists(xPanelSgdFilePath))
                {
                    // load the SGD file for this ui project
                    xPanelUi.LoadSmartObjects(xPanelSgdFilePath);

                    // create reference for the various smart objects in the ui project
                    dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList];
                    dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList];
                    dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList];

                    // subscribe to the smart object sig events
                    dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange;
                    dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange;
                    dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange;
                }
                else
                {
                    ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time");
                }

                // register device with the control system
                if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Notice(">>> xPanel has been registered successfully");
                else
                    ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason);
            }
            else
            {
                ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run");
            }

            // create a new timer object to track system inactivity or unplugged cables
            ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to easily register and register the additional touchpanel for Lab 1, Level 3, exercise 2
        /// </summary>
        /// <param name="registration">True for registration, false for unregistration</param>
        /// <param name="id">IPID we want to register this touchpanel on</param>
        public void RegisterUnregisterXpanel(bool registration, uint id)
        {
            this.tp02 = new XpanelForSmartGraphics(id, this);

            // YS: We will leave this in so they can understand what is happening
            this.tp02.SigChange += new SigEventHandler(this.Xpanel_SigChange);

            // YS: We will comment this out so they can create this eventhandler with all the logic on their own
            this.tp02.OnlineStatusChange += this.Xpanel_OnlineStatusChange;

            string sgdPath = string.Format(@"{0}/XPanel_Masters2020.sgd", Directory.GetApplicationDirectory());

            if (this.tp02.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                ErrorLog.Error(string.Format(LogHeader + "Error registering XPanel: {0}", this.tp02.RegistrationFailureReason));
            }
            else
            {
                this.tp02.LoadSmartObjects(sgdPath);
                ErrorLog.Notice(string.Format(LogHeader + "Loaded SmartObjects: {0}", this.tp02.SmartObjects.Count));
                foreach (KeyValuePair <uint, SmartObject> smartObject in this.tp02.SmartObjects)
                {
                    smartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(this.Xpanel_SO_SigChange);
                }
            }
        }
Ejemplo n.º 3
0
        /// <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 = 20;

                xp                     = new XpanelForSmartGraphics(0xaa, this);
                xp.SigChange          += new SigEventHandler(xp_SigChange);
                xp.OnlineStatusChange += new OnlineStatusChangeEventHandler(xp_OnlineStatusChange);
                xp.Register();

                matrix = new DmMd8x8(0x20, this);
                matrix.DMInputChange      += new DMInputEventHandler(matrix_DMInputChange);
                matrix.DMOutputChange     += new DMOutputEventHandler(matrix_DMOutputChange);
                matrix.OnlineStatusChange += new OnlineStatusChangeEventHandler(matrix_OnlineStatusChange);
                matrix.Register();

                //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);
            }
        }
Ejemplo n.º 4
0
        /// Constructor
        public ControlSystem()
            : base()
        {
            // Set the number of threads which you want to use in your program
            Thread.MaxNumberOfUserThreads = 20;

            //Subscribe to the controller events (System, Program, and Etherent)
            CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
            CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all UIs.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage, after eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
                }
            }

            return;
        }
Ejemplo n.º 5
0
        /// Constructor 
        public ControlSystem()
            : base()
        {
            // Set the number of threads which you want to use in your program
            Thread.MaxNumberOfUserThreads = 20;

            //Subscribe to the controller events (System, Program, and Etherent)
            CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
            CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all UIs.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage, after eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
            }

            return;
        }
Ejemplo n.º 6
0
        public override void InitializeSystem()
        {
            try
            {
                tp1 = new XpanelForSmartGraphics(0x03, this);

                tp1.OnlineStatusChange += tp_OnlineChange;
                tp1.UserSpecifiedObject = new Action <bool>(online => { if (online)
                                                                        {
                                                                            UpdateFeedback();
                                                                        }
                                                            });

                tp1.SigChange += tp_SigChange;
                tp1.BooleanOutput[(uint)SystemJoins.PowerToggle].UserObject = new Action <bool>(press => { if (press)
                                                                                                           {
                                                                                                               ToggleSystemPower();
                                                                                                           }
                                                                                                });
                tp1.BooleanOutput[(uint)SystemJoins.PowerTransition].UserObject = new Action <bool>(done => { if (done)
                                                                                                              {
                                                                                                                  UpdatePowerStatusText();
                                                                                                              }
                                                                                                    });

                tp1.Register();
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
Ejemplo n.º 7
0
 private void CreatePanel(uint ipId, string sgdFilename)
 {
     _panel = new XpanelForSmartGraphics(ipId, this);
     _panel.LoadSmartObjects(sgdFilename);
     _panel.SmartObjects[(uint)PanelSmartObjects.DisplayInputList].SigChange += new SmartObjectSigChangeEventHandler(DisplayInputListChange);
     _panel.SigChange += new SigEventHandler(PanelSigChange);
     _panel.Register();
 }
Ejemplo n.º 8
0
 private void CreatePanel(uint ipId, string sgdFilename)
 {
     _panel = new XpanelForSmartGraphics(ipId, this);
     _panel.LoadSmartObjects(sgdFilename);
     _panel.SmartObjects[(uint)PanelSmartObjects.DPad].SigChange += new SmartObjectSigChangeEventHandler(VideoServerDpadChange);
     _panel.SigChange += new SigEventHandler(PanelSigChange);
     _panel.Register();
 }
 void ConfigUserInterfaces()
 {
     OnDebug(eDebugEventType.Info, "Configuring UserInterfaces");
     // create the user interfaces that you want in the project
     ui_01 = new Tsw1060(0x03, this);
     ui_02 = new XpanelForSmartGraphics(0x04, this);
     ConfigUserInterface(ui_01);
     ConfigUserInterface(ui_02);
 }
Ejemplo n.º 10
0
        public XpanelChargerPage(XpanelForSmartGraphics xpanel)
        {
            _xpanel = xpanel;

            _charger                       = ControlSystem.Charger;
            _charger.Responding           += new EventHandler <SscRespondingEventArgs>(_charger_Responding);
            _charger.BaysHandler.Events   += new EventHandler <Chg4NBaysEventArgs>(ChargerBaysHandler_Events);
            _charger.DeviceHandler.Events += new EventHandler <Chg4NDeviceEventArgs>(ChargerDeviceHandler_Events);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Controller" /> class.
        /// </summary>
        /// <param name="tp">The XpanelForSmartGraphics object</param>
        /// <param name="cwsPath">Additional CWS path. May be empty</param>
        public Controller(XpanelForSmartGraphics tp, string cwsPath)
        {
            ErrorLog.Notice($"{LogHeader} Running CWS COntroller Constructor");

            this.cwsPath = cwsPath;

            this.StartServer();

            this.tp = tp;
        }
Ejemplo n.º 12
0
        public XpanelTccPage(XpanelForSmartGraphics xpanel)
        {
            _xpanel = xpanel;

            _tcc                       = ControlSystem.Tcc;
            _tcc.Responding           += new EventHandler <SscRespondingEventArgs>(Device_Responding);
            _tcc.DeviceHandler.Events += new EventHandler <Tcc2DeviceEventArgs>(DeviceHandler_Events);
            _tcc.MeterHandler.Events  += new EventHandler <Tcc2MeterEventArgs>(MeterHandler_Events);
            _tcc.AudioHandler.Events  += new EventHandler <Tcc2AudioEventArgs>(AudioHandler_Events);
            _xpanel.SigChange         += new SigEventHandler(_xpanel_SigChange);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Controller" /> class.
        /// </summary>
        /// <param name="tp">The XpanelForSmartGraphics object</param>
        /// <param name="cwsPath">Additional CWS path. May be empty</param>
        public Controller(XpanelForSmartGraphics tp, string cwsPath)
        {
            ErrorLog.Notice(string.Format($"{LogHeader} Running CWS Controller Constructor"));

            this.cwsPath = cwsPath;
            ErrorLog.Notice(string.Format($"{LogHeader} CWS.Controller path : {cwsPath}"));


            this.StartServer();

            this.tp = tp;
        }
Ejemplo n.º 14
0
        public XpanelReceiverPage(XpanelForSmartGraphics xpanel)
        {
            _xpanel            = xpanel;
            _xpanel.SigChange += new SigEventHandler(_xpanel_SigChange);

            _receiver                       = ControlSystem.Receiver;
            _receiver.Responding           += new EventHandler <SscRespondingEventArgs>(_receiver_Responding);
            _receiver.DeviceHandler.Events += new EventHandler <SldwDeviceEventArgs>(DeviceHandler_Events);
            _receiver.RxHandler.Events     += new EventHandler <SldwRxEventArgs>(RxHandler_Events);
            _receiver.TxHandler.Events     += new EventHandler <SldwTxEventArgs>(TxHandler_Events);
            _receiver.AudioHandler.Events  += new EventHandler <SldwAudioEventArgs>(AudioHandler_Events);
        }
Ejemplo n.º 15
0
        public Xpanel(uint ipId)
        {
            _xpanel = new XpanelForSmartGraphics(ipId, ControlSystem.Instance);

            if (_xpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                ErrorLog.Error("Xpanel could not register: " + _xpanel.RegistrationFailureReason);
            }

            _chargerPage  = new XpanelChargerPage(_xpanel);
            _receiverPage = new XpanelReceiverPage(_xpanel);
            _tccPage      = new XpanelTccPage(_xpanel);
        }
Ejemplo n.º 16
0
        /// 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 = 20;

                // Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(this.ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(this.ControlSystem_ControllerEthernetEventHandler);

                this.appId = InitialParametersClass.ApplicationNumber;

                if (this.SupportsEthernet)
                {
                    this.tpForCWS                     = new XpanelForSmartGraphics(0x90, this);
                    this.tpForCWS.SigChange          += new SigEventHandler(this.Xpanel_SigChange);
                    this.tpForCWS.OnlineStatusChange += this.Xpanel_OnlineStatusChange;

                    string sgdPath = string.Format($"{Directory.GetApplicationDirectory()}/XPanel_v1.sgd");
                    if (this.tpForCWS.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error(string.Format(
                                           $"{LogHeader} Error registering XPanel: {this.tpForCWS.RegistrationFailureReason}"));
                    }
                    else
                    {
                        this.tpForCWS.LoadSmartObjects(sgdPath);
                        ErrorLog.Error($"{LogHeader} Loaded SmartObjects: {this.tpForCWS.SmartObjects.Count}");
                        foreach (KeyValuePair <uint, SmartObject> smartObject in this.tpForCWS.SmartObjects)
                        {
                            smartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(this.Xpanel_SO_SigChange);
                        }
                        // e.g. /Rooms/MSS601Room1/cws/api/config
                        this.controller = new CWS.Controller(this.tpForCWS, "api");
                        ErrorLog.Notice(string.Format(LogHeader + "CWS.Controller started"));
                    }
                }

                // Potential way to make your program more dynamic
                // Not being used in either Lab1 or Lab2
                this.appId = InitialParametersClass.ApplicationNumber;
            }
            catch (Exception e)
            {
                ErrorLog.Error(string.Format(LogHeader + "Error in the constructor: {0}", e.Message));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlSystem" /> class.
        /// 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 = 20;

                // Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(this.ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(this.ControlSystem_ControllerEthernetEventHandler);

                if (this.SupportsEthernet)
                {
                    this.tp01 = new XpanelForSmartGraphics(0x03, this);

                    // YS: We will leave this in so they can understand what is happening
                    this.tp01.SigChange += new SigEventHandler(this.Xpanel_SigChange);

                    // YS: We will comment this out so they can create this eventhandler with all the logic on their own
                    this.tp01.OnlineStatusChange += this.Xpanel_OnlineStatusChange;

                    string sgdPath = string.Format($"{Directory.GetApplicationDirectory()}/XPanel_Masters2020.sgd");

                    if (this.tp01.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error(string.Format(
                                           $"{LogHeader} Error registering XPanel: {this.tp01.RegistrationFailureReason}"));
                    }
                    else
                    {
                        this.tp01.LoadSmartObjects(sgdPath);
                        ErrorLog.Error(string.Format($"{LogHeader} Loaded SmartObjects: {this.tp01.SmartObjects.Count}"));
                        foreach (KeyValuePair <uint, SmartObject> smartObject in this.tp01.SmartObjects)
                        {
                            smartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(this.Xpanel_SO_SigChange);
                        }
                    }
                }

                // e.g. /Rooms/PAULLINCK2/cws/api/interlockstatus/
                this.controller = new CWS.Controller(this.tp01, "api");
            }
            catch (Exception e)
            {
                ErrorLog.Error(string.Format(LogHeader + "Error in the constructor: {0}", e.Message));
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlSystem" /> class.
        /// 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 = 20;

                // Subscribe to the controller events (System, Program, and Ethernet)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(this.ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(this.ControlSystem_ControllerEthernetEventHandler);

                if (this.SupportsEthernet)
                {
                    // TODO: Level 1,2,3. Create new XpanelForSmartGraphics on IPID 03
                    // You can use the XpanelForSmartGraphics defined on line 40

                    tp01 = new XpanelForSmartGraphics(0x03, this);

                    // Example. This is how you can subscribe to the SigChange event handler
                    this.tp01.SigChange += Tp01_SigChange;

                    // TODO: Level 1,2,3. Register the OnlineStatusChange event handler yourself here
                    this.tp01.OnlineStatusChange += Xpanel_OnlineStatusChange;

                    // TODO: Level 1,2,3. After all the event handlers are done, register the touchpanel. Try to check for success
                    tp01.Register();

                    // We have left this in to show how to use Smart Objects
                    // However we are not using them for this exercise
                    // You should only proceed with this if the touchpanel registration was successful!
                    string sgdPath = string.Format(@"{0}/XPanel_Masters2020.sgd", Directory.GetApplicationDirectory());
                    this.tp01.LoadSmartObjects(sgdPath);
                    ErrorLog.Error(string.Format(LogHeader + "Loaded {0} SmartObjects", this.tp01.SmartObjects.Count));
                    foreach (KeyValuePair <uint, SmartObject> smartObject in this.tp01.SmartObjects)
                    {
                        smartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(this.Xpanel_SO_SigChange);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error(string.Format(LogHeader + "Error in the constructor: {0}", e.Message));
            }
        }
Ejemplo n.º 19
0
        private void InitializeUI()
        {
            _panels = new UI(this);

            if (_gw.Registered)
            {
                Log("Office::InitializeUI", "Creating TST-902 on {0}", _gw.Name);
                _tp = new Tst902(_cfg.GetInteger("panel", "rf_id", 0x03), _gw);
                _panels.Add_902(_tp);
            }

            Log("Office::InitializeUI", "Creating XPanel");
            _xpanel = new XpanelForSmartGraphics(_cfg.GetInteger("xpanel", "ip_id", 0x04), _sys);
            _panels.Add(_xpanel);

            Log("Office::InitializeUI", "Registering devices");
            _panels.Register();
        }
Ejemplo n.º 20
0
        /// <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();
        }
Ejemplo n.º 21
0
        /// <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();
        }
Ejemplo n.º 22
0
 /// <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;
     if (this.SupportsEthernet)
     {
         myPanel = new XpanelForSmartGraphics(0x3, this);
         if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
         {
             ErrorLog.Error("Error Registering Xpanel");
         }
         myPanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd");
         foreach (KeyValuePair <uint, SmartObject> mySmartObject in myPanel.SmartObjects)
         {
             mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange);
         }
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// InitializeSystem - this method gets called after the constructor
        /// has finished.
        ///
        /// Use InitializeSystem to:
        /// * Start threads
        /// * Configure ports, such as serial and verisports
        /// * Start and initialize socket connections
        /// Send initial device configurations
        ///
        /// Please be aware that InitializeSystem needs to exit quickly also;
        /// if it doesn't exit in time, the SIMPL#Pro program will exit.
        /// </summary>
        public override void InitializeSystem()
        {
            try
            {
                deskPanel      = new Tsw560(0x03, this);
                deskPanel.Name = "Touch Panel";
                deskPanel.OnlineStatusChange += new OnlineStatusChangeEventHandler(PanelOnlineStatusChange);
                deskPanel.SigChange          += new SigEventHandler(PanelSigChanges);

                deskPanel.ExtenderHardButtonReservedSigs.Use();

                deskPanel.ExtenderHardButtonReservedSigs.TurnButton1BackLightOff();
                deskPanel.ExtenderHardButtonReservedSigs.TurnButton2BackLightOff();
                deskPanel.ExtenderHardButtonReservedSigs.TurnButton3BackLightOff();
                deskPanel.ExtenderHardButtonReservedSigs.TurnButton4BackLightOn();
                deskPanel.ExtenderHardButtonReservedSigs.TurnButton5BackLightOn();

                deskPanel.Register();

                deskPanel.StringInput[10].StringValue = "Beta - Prog";
                deskPanel.StringInput[11].StringValue = "No Input Selected";

                deskXpanel      = new XpanelForSmartGraphics(0x04, this);
                deskXpanel.Name = "Xpanel";
                deskXpanel.OnlineStatusChange += new OnlineStatusChangeEventHandler(PanelOnlineStatusChange);
                deskXpanel.SigChange          += new SigEventHandler(PanelSigChanges);
                deskPanel.Register();

                deskSwitcher = new HdMd6x24kE(0x12, sixByTwoIP, this);
                deskSwitcher.IpInformationChange += new IpInformationChangeEventHandler(deskSwitcherIpInformationChange);
                deskSwitcher.OnlineStatusChange  += new OnlineStatusChangeEventHandler(PanelOnlineStatusChange);
                deskSwitcher.Register();
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}\r\n", e.Message);
            }
        }
Ejemplo n.º 24
0
        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);

                //Subscribe to the touchpanel
                UserInterface            = new XpanelForSmartGraphics(03, this);
                UserInterface.SigChange += new SigEventHandler(UserInterface_SigChange);
                UserInterface.Register();


                //subscribe to comport
                comport = ComPorts[1];
                comport.Register();
                comport.SetComPortSpec(Crestron.SimplSharpPro.ComPort.eComBaudRates.ComspecBaudRate9600,
                                       Crestron.SimplSharpPro.ComPort.eComDataBits.ComspecDataBits8,
                                       Crestron.SimplSharpPro.ComPort.eComParityType.ComspecParityNone,
                                       Crestron.SimplSharpPro.ComPort.eComStopBits.ComspecStopBits1,
                                       Crestron.SimplSharpPro.ComPort.eComProtocolType.ComspecProtocolRS232,
                                       Crestron.SimplSharpPro.ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                       Crestron.SimplSharpPro.ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                       false);


                //interlock function
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// InitializeSystem - this method gets called after the constructor
        /// has finished.
        ///
        /// Use InitializeSystem to:
        /// * Start threads
        /// * Configure ports, such as serial and versiports
        /// * Start and initialize socket connections
        /// Send initial device configurations
        ///
        /// Please be aware that InitializeSystem needs to exit quickly also;
        /// if it doesn't exit in time, the SIMPL#Pro program will exit.
        /// </summary>
        public override void InitializeSystem()  // Remember  HERE we have access to IO, Hardware and Threads
        {
            try
            {
                // ***** Session 3
                // This is ONLY for masters Training session for creating a file to read
                var myMasters = new Masters2021();  // Instantiate our masters 2021 Class to create data for Session 3 file read

                // ***** Session 2
                //Question:  Why did we not have to instantiate the Virtual Console class?
                VirtualConsole.Start(40000); // Launch the virtual Console on port 40000  you can use telnet or even text console in Toolbox
                VirtualConsole.AddNewConsoleCommand(TestFunc, "Test", "This should respond with a message");

                // ***** Session 1
                myClient = new TCPClientHelper("127.0.0.1", 55555);  // Creates our client instance
                myClient.tcpHelperEvent += MyClient_tcpHelperEvent;  // Subscribe to its event handler and what method to pass it to

                myXpanel = new XpanelForSmartGraphics(0x03, this);

                //myXpanel.Register();  // How do we know we have actually registered the Touchpanel?  We should check.

                if (myXpanel.Register() == eDeviceRegistrationUnRegistrationResponse.Success) // Did we actually get the Device?
                {
                    myXpanel.SigChange += MyXpanel_SigChange;                                 //  Subscribe to our event handler
                    // Any other settings for the device
                }
                else
                {
                    // This will write to the error log why the Touch Panel was unable to be registered.
                    ErrorLog.Error("Unable To register Xpanel at IPID{0:X} for Reason {1}", myXpanel.ID, myXpanel.RegistrationFailureReason);
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
        /// <summary>
        /// InitializeSystem - this method gets called after the constructor
        /// has finished.
        ///
        /// Use InitializeSystem to:
        /// * Start threads
        /// * Configure ports, such as serial and verisports
        /// * Start and initialize socket connections
        /// Send initial device configurations
        ///
        /// Please be aware that InitializeSystem needs to exit quickly also;
        /// if it doesn't exit in time, the SIMPL#Pro program will exit.
        /// </summary>
        public override void InitializeSystem()
        {
            try
            {
                ui = new UI();
                ui.DigitalChangeEvent     += new UI.DigitalChangeEventHandler(ui_DigitalChangeEvent);
                ui.AnalogChangeEvent      += new UI.AnalogChangeEventHandler(ui_AnalogChangeEvent);
                ui.SerialChangeEvent      += new UI.SerialChangeEventHandler(ui_SerialChangeEvent);
                ui.SmartObjectChangeEvent += new UI.SmartObjectEventHandler(ui_SmartObjectChangeEvent);

                xpanel            = new XpanelForSmartGraphics(0x03, this);
                xpanel.SigChange += new SigEventHandler(ui.xpanel_SigChange);
                xpanel.LoadSmartObjects(@"\USER\Pincode.sgd");
                foreach (KeyValuePair <uint, SmartObject> kvp in xpanel.SmartObjects)
                {
                    kvp.Value.SigChange += new SmartObjectSigChangeEventHandler(ui.SmartObject_SigChange);
                }
                xpanel.Register();

                //create Pincode object
                pincode = new Pincode(xpanel, 1, "1234");

                pincode.EnableBackdoorPassword("1988");
                pincode.SetPinLimit(4);
                pincode.EnableStarText();

                pincode.PasswordMiscOneDelegate   = () => pincode.ClearText();
                pincode.PasswordMiscTwoDelegate   = () => pincode.ValidatePINEntry();
                pincode.PasswordCorrectDelegate   = () => xpanel.StringInput[1].StringValue = "Password Correct";
                pincode.PasswordIncorrectDelegate = () => xpanel.StringInput[1].StringValue = "Password Incorrect";
            }
            catch (Exception e)
            {
                ErrorLog.Error(">>> Error in InitializeSystem: {0}", e.Message);
            }
        }
Ejemplo n.º 27
0
        /// <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);
            }
        }
Ejemplo n.º 28
0
        /// <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()
        {
            CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ...");

            // 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
            try
            {
                Thread.MaxNumberOfUserThreads = 20;

               //Subscribe to the controller events (System, Program, and Etherent)
                CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator);
                var returnVar = CrestronCresnetHelper.Query();
                if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                {
                    foreach (var item in CrestronCresnetHelper.DiscoveredElementsList)
                    {
                        CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in constructor: {0}", e.Message);
            }

            // Reghister Keypad
            if (this.SupportsCresnet)
            {
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason);
            }

            // Register all devices which the program wants to use
            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all three UIs. This guarantees that they all operate
                // the same way.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage. This should happen after the
                // eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
            }
            // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg
            myIROutputDevice = IROutputPorts[1];
            myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory()));

            return;
        }
Ejemplo n.º 29
0
        /// <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()
        {
            CrestronConsole.PrintLine("Hello World - Program SIMPL#Pro LinckATLSIMPLSharpPro started ...");

            // 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
            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                //Subscribe to the controller events (System, Program, and Etherent)
                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Replies to strings un Upper case", ConsoleAccessLevelEnum.AccessOperator);
                var returnVar = CrestronCresnetHelper.Query();
                if (returnVar == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                {
                    foreach (var item in CrestronCresnetHelper.DiscoveredElementsList)
                    {
                        CrestronConsole.PrintLine("Found Item: {0}, {1}", item.CresnetId, item.DeviceModel);
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in constructor: {0}", e.Message);
            }


            // Reghister Keypad
            if (this.SupportsCresnet)
            {
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("myKeypad failed registration. Cause: {0}", myKeypad.RegistrationFailureReason);
                }
            }

            // Register all devices which the program wants to use
            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0xA5, this);  // Register the Xpanel on IPID 0xA5

                // Register a single eventhandler for all three UIs. This guarantees that they all operate
                // the same way.
                myXpanel.SigChange += new SigEventHandler(MySigChangeHandler);

                // Register the devices for usage. This should happen after the
                // eventhandler registration, to ensure no data is missed.
                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", myXpanel.RegistrationFailureReason);
                }
            }
            // Load IR DriverC:\Users\paul\Documents\GitHubWin10\SIMPLSharp\LinckATLSIMPLSharpPro\LinckATLSIMPLSharpPro\Properties\ControlSystem.cfg
            myIROutputDevice = IROutputPorts[1];
            myIROutputDevice.LoadIRDriver(String.Format(@"{0}\IR\Samsung_LNS4051.ir", Directory.GetApplicationDirectory()));

            return;
        }
Ejemplo n.º 30
0
        // Entry point
        public ControlSystem()
            : base()
        {
            CrestronConsole.PrintLine("ssCertMain started ...");

            GV.MyControlSystem = this;				// Allows access to ControlSystem class outside class definition

            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                CrestronEnvironment.SystemEventHandler += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

                // Injects a new console command for use in text console
                // I am thinking this may be handy to help debug - e.g. fire events to test (like doorbell ringing )...
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Converts string to UPPER case", ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(PrintFullAssembly, "printass", "Loads and Prints Assembly", ConsoleAccessLevelEnum.AccessOperator);
            }
            catch (Exception e)
            {
                ErrorLog.Error("ControlSystem() - Error in constructor: {0}", e.Message);
            }

            #region Keypad
            if (this.SupportsCresnet)
            {
                // NOTE TO PAUL:  Move this to Helper Class - loop through all keypads an register them
                // That might be a good place to name them and give them default stuff - like default room etc.
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myKeypad {0} failed registration. Cause: {1}", 0x25, myKeypad.RegistrationFailureReason);

                // List all the cresnet devices - note: Query might not work for duplicate devices
                PllHelperClass.DisplayCresnetDevices();
            }
            #endregion

            #region Xpanel
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0x03, this);

                myXpanel.SigChange += new SigEventHandler(myXpanel_SigChange);

                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    ErrorLog.Error("myXpanel with SmartGraphics {0} failed registration. Cause: {1}", 0x03, myKeypad.RegistrationFailureReason);
                else
                {
                    myXpanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd");
                    CrestronConsole.PrintLine("sgd");
                    foreach (KeyValuePair<uint, SmartObject>mySmartObject in myXpanel.SmartObjects)
                    {
                        mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObjectValue_SigChange);
                    }

                    // Typically you would create the group in init and then add items throughout the program
                    // NOTE to PAUL: Create Group here and when setting TP Defaults create groups
                    mySigGroup = CreateSigGroup(1, eSigType.String);
                    mySigGroup.Add(myXpanel.StringInput[1]);
                    mySigGroup.Add(myXpanel.StringInput[2]);
                }
            }
            #endregion
        }
        // Entry point
        public ControlSystem()
            : base()
        {
            CrestronConsole.PrintLine("ssCertMain started ...");

            GV.MyControlSystem = this;                          // Allows access to ControlSystem class outside class definition

            try
            {
                Thread.MaxNumberOfUserThreads = 20;

                CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
                CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
                CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

                // Injects a new console command for use in text console
                // I am thinking this may be handy to help debug - e.g. fire events to test (like doorbell ringing )...
                CrestronConsole.AddNewConsoleCommand(UpperCase, "ToUpper", "Converts string to UPPER case", ConsoleAccessLevelEnum.AccessOperator);
                CrestronConsole.AddNewConsoleCommand(PrintFullAssembly, "printass", "Loads and Prints Assembly", ConsoleAccessLevelEnum.AccessOperator);
            }
            catch (Exception e)
            {
                ErrorLog.Error("ControlSystem() - Error in constructor: {0}", e.Message);
            }

            #region Keypad
            if (this.SupportsCresnet)
            {
                // NOTE TO PAUL:  Move this to Helper Class - loop through all keypads an register them
                // That might be a good place to name them and give them default stuff - like default room etc.
                myKeypad = new C2nCbdP(0x25, this);

                myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);

                if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("myKeypad {0} failed registration. Cause: {1}", 0x25, myKeypad.RegistrationFailureReason);
                }

                // List all the cresnet devices - note: Query might not work for duplicate devices
                PllHelperClass.DisplayCresnetDevices();
            }
            #endregion

            #region Xpanel
            if (this.SupportsEthernet)
            {
                myXpanel = new XpanelForSmartGraphics(0x03, this);

                myXpanel.SigChange += new SigEventHandler(myXpanel_SigChange);

                if (myXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("myXpanel with SmartGraphics {0} failed registration. Cause: {1}", 0x03, myKeypad.RegistrationFailureReason);
                }
                else
                {
                    myXpanel.LoadSmartObjects(@"\NVRAM\Xpnl.sgd");
                    CrestronConsole.PrintLine("sgd");
                    foreach (KeyValuePair <uint, SmartObject> mySmartObject in myXpanel.SmartObjects)
                    {
                        mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(SmartObjectValue_SigChange);
                    }

                    // Typically you would create the group in init and then add items throughout the program
                    // NOTE to PAUL: Create Group here and when setting TP Defaults create groups
                    mySigGroup = CreateSigGroup(1, eSigType.String);
                    mySigGroup.Add(myXpanel.StringInput[1]);
                    mySigGroup.Add(myXpanel.StringInput[2]);
                }
            }
            #endregion
        }
Ejemplo n.º 32
0
        /// <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;

#if IncludeSampleCode
            //Subscribe to the controller events (System, Program, and Etherent)
            CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(ControlSystem_ControllerSystemEventHandler);
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ControlSystem_ControllerProgramEventHandler);
            CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(ControlSystem_ControllerEthernetEventHandler);

            // Register all devices which the program wants to use
            // Check if device supports Ethernet
            if (this.SupportsEthernet)
            {
                My750    = new Tsw750(0x03, this);                  // Register the TSW750 on IPID 0x03
                My550    = new Tsw550(0x04, this);                  // Register the TSW550 on IPID 0x04
                MyXpanel = new XpanelForSmartGraphics(0x05, this);  // Register the Xpanel on IPID 0x05

                // Register a single eventhandler for all three UIs. This guarantees that they all operate
                // the same way.
                My750.SigChange    += new SigEventHandler(MySigChangeHandler);
                My550.SigChange    += new SigEventHandler(MySigChangeHandler);
                MyXpanel.SigChange += new SigEventHandler(MySigChangeHandler);



                // Register the devices for usage. This should happen after the
                // eventhandler registration, to ensure no data is missed.

                if (My750.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("My750 failed registration. Cause: {0}", My750.RegistrationFailureReason);
                }
                if (My550.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("My550 failed registration. Cause: {0}", My550.RegistrationFailureReason);
                }
                if (MyXpanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("MyXpanel failed registration. Cause: {0}", MyXpanel.RegistrationFailureReason);
                }
            }

            if (this.SupportsComPort)
            {
                MyCOMPort = this.ComPorts[1];
                MyCOMPort.SerialDataReceived += new ComPortDataReceivedEvent(myComPort_SerialDataReceived);

                if (MyCOMPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("COM Port couldn't be registered. Cause: {0}", MyCOMPort.DeviceRegistrationFailureReason);
                }

                if (MyCOMPort.Registered)
                {
                    MyCOMPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate38400,
                                             ComPort.eComDataBits.ComspecDataBits8,
                                             ComPort.eComParityType.ComspecParityNone,
                                             ComPort.eComStopBits.ComspecStopBits1,
                                             ComPort.eComProtocolType.ComspecProtocolRS232,
                                             ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                             ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                             false);
                }
            }
#endif
        }
Ejemplo n.º 33
0
        /// <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 = 20;

                // * Register devices

                xPanel             = new XpanelForSmartGraphics((uint)eIpId.xPanel, this);
                xPanel.Description = xPanelDescription;
                // Add SGD to tswPanel
                string xPanelSgdFilePath = Directory.GetApplicationDirectory() + Path.DirectorySeparatorChar + xPanelSgdFileName;
                // make sure file exists in the application directory
                if (File.Exists(xPanelSgdFilePath))
                {
                    // load the SGD file for this ui project
                    try
                    {
                        xPanel.LoadSmartObjects(xPanelSgdFilePath);
                    }
                    catch (Exception)
                    {
                        ErrorLog.Error(">>> {0} (IPID 0x{1:X2}) Could not find {0} SGD file. SmartObjects will not work at this time", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFilePath);
                    }
                    ErrorLog.Notice(">>> {0} (IPID 0x{1:X2}) SmartObjects loaded from {2}", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFileName);
                }
                else
                {
                    ErrorLog.Error(">>> {0} (IPID 0x{1:X2}) Could not find {2} SGD file. SmartObjects will not work at this time", xPanel.Name, (uint)eIpId.xPanel, xPanelSgdFilePath);
                }

                if (xPanel.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Notice(">>> {0} (IPID 0x{1:X2}) has been registered successfully", xPanel.Name, (uint)eIpId.xPanel);
                }
                else
                {
                    ErrorLog.Error(">>> {0} (IPID 0x{1:X2})  was not registered: {2}", xPanel.Name, (uint)eIpId.xPanel, xPanel.RegistrationFailureReason);
                }

                xPanel.UserSpecifiedObject = new AuthenticatedSubPageManager(
                    Authenticate,
                    xPanel,
                    new PinLockSubPage(pinLockSubPageParameters),
                    60000,
                    new List <SubPage>()
                {
                }
                    );

                // * Register event handlers

                //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);

                xPanel.SigChange += new SigEventHandler(EventHandlers.ActionEventHandler);
                xPanel.SmartObjects[2].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler);

                xPanel.BooleanOutput[100].UserObject = new Action <bool>(x => { if (!x)
                                                                                {
                                                                                    ((AuthenticatedSubPageManager)xPanel.UserSpecifiedObject).Lock();
                                                                                }
                                                                         });

                // local tests
                xPanel.SigChange += new SigEventHandler(panel_SigChange);
                xPanel.BaseEvent += new BaseEventHandler(xPanel_BaseEvent);
                foreach (var kv in xPanel.SmartObjects)
                {
                    kv.Value.SigChange += new SmartObjectSigChangeEventHandler(so_SigChange);
                }

                ((AuthenticatedSubPageManager)xPanel.UserSpecifiedObject).Authenticated += new EventHandler <AuthenticatedSubPageManager.AuthenticatedEventArgs>(ControlSystem_Authenticated);

                // Panels Smart Objects

                SmartObjectReferenceListHelper smartObjectReferenceListHelper = new SmartObjectReferenceListHelper(xPanel.SmartObjects[smartObjectReferenceListParameters.Id], smartObjectReferenceListParameters);
                xPanel.SmartObjects[smartObjectReferenceListParameters.Id].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler);
                List <int> range = new List <int>()
                {
                    1, 2
                };
                smartObjectReferenceListHelper.NumberOfItems = (ushort)range.Count;
                foreach (uint itemIndex in range)
                {
                    uint itemIndexFix = itemIndex;
                    SmartObjectReferenceListItem item = smartObjectReferenceListHelper.Items[itemIndex];
                    smartObjectReferenceListHelper.Items[itemIndex].BooleanOutput[1].UserObject = new Action <bool>(x =>
                    {
                        if (x)
                        {
                            CrestronConsole.PrintLine("Item: {0}", item.Id);
                            item.UShortInput[1].UShortValue = (ushort)(item.UShortInput[1].UShortValue + 1);
                        }
                    });
                }

                xPanel.SmartObjects[smartObjectDynamicListHelperParameters.Id].SigChange += new SmartObjectSigChangeEventHandler(EventHandlers.ActionEventHandler);

                CrestronConsole.AddNewConsoleCommand(ConsoleCommandTest, "test", "Test plug", ConsoleAccessLevelEnum.AccessOperator);
                ActionsManager.RegisterAction(Action1, "Action 1", "Action1 description");
                ActionsManager.RegisterAction(Action2, "Action 2", "Action2 description");
                ActionsManager.RegisterAction(Action2, "Action 2", "Action2 description", "special Action 2", "special Action2 params");
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}\r\n{1}", e.Message, e.StackTrace);
            }
        }
Ejemplo n.º 34
0
        public ControlSystem()
            : base()
        {
            try
            {
                Thread.MaxNumberOfUserThreads = 20;
                //Hello World Crestron Console
                CrestronConsole.AddNewConsoleCommand(HelloPrinting, "HelloWorld", "Prints Hello & the text that follows", ConsoleAccessLevelEnum.AccessOperator);
                //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);
                CrestronConsole.PrintLine("DefaultConstructor Complete"); //Hello World
                #region Keypad
                if (this.SupportsCresnet)                                 //Make sure the system has CresNet
                {
                    myKeypad = new C2nCbdP(0x25, this);
                    myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);
                    if (myKeypad.NumberOfVersiPorts > 0) //VersiPort addtion
                    {
                        for (uint i = 1; i < 2; i++)
                        {
                            myKeypad.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalInput);
                            myKeypad.VersiPorts[i].VersiportChange += new VersiportEventHandler(ControlSystem_VersiportChange);
                        }
                    }

                    if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success) // Hello World Keypad
                    {
                        ErrorLog.Error("Error Registering Keypad on ID 0x25: {0}", myKeypad.RegistrationFailureReason);
                    }
                    else
                    {
                        myKeypad.Button[1].Name = eButtonName.Up;
                        myKeypad.Button[2].Name = eButtonName.Down;
                    }
                }
                #endregion
                #region KeypadWithQuery
                //Define Keypad with Device Query
                if (this.SupportsCresnet)
                {
                    var QueryResponse = CrestronCresnetHelper.Query();
                    if (QueryResponse == CrestronCresnetHelper.eCresnetDiscoveryReturnValues.Success)
                    {
                        //foreach (CrestronCresnetHelper.DiscoveredDeviceElement Item in CrestronCresnetHelper.DiscoveredElementsList)  //Gets a little long so we do the var in instead and it works it out
                        foreach (var Item in CrestronCresnetHelper.DiscoveredElementsList)
                        {
                            if (Item.DeviceModel.ToUpper().Contains("C2N-CBD"))
                            {
                                if (myKeypad == null) //Check to make sure we have not done created it already.
                                {
                                    myKeypad = new C2nCbdP(Item.CresnetId, this);
                                    myKeypad.ButtonStateChange += new ButtonEventHandler(myKeypad_ButtonStateChange);
                                    if (myKeypad.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                                    {
                                        ErrorLog.Error("Error Registering Keypad: {0}", myKeypad.RegistrationFailureReason);
                                        myKeypad = null;
                                    }
                                }
                            }
                        }
                    }
                }
                #endregion
                #region IR
                if (this.SupportsIROut)
                {
                    if (ControllerIROutputSlot.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error Registering IR Slot: {0}", ControllerIROutputSlot.DeviceRegistrationFailureReason);
                    }
                    else
                    {
                        myPort = IROutputPorts[1];
                        myPort.LoadIRDriver(@"\NVRAM\AppleTV.ir");
                        foreach (string s in myPort.AvailableStandardIRCmds())
                        {
                            CrestronConsole.PrintLine("AppleTV Std: {0}", s);
                        }
                        foreach (string s in myPort.AvailableIRCmds())
                        {
                            CrestronConsole.PrintLine("AppleTV Std: {0}", s);
                        }
                    }
                }
                #endregion
                #region VersiPort
                if (this.SupportsVersiport)
                {
                    for (uint i = 1; i <= 2; i++)
                    {
                        if (this.VersiPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                        {
                            ErrorLog.Error("Error Registering Versiport 1: {0}", this.VersiPorts[i].DeviceRegistrationFailureReason);
                        }
                        else
                        {
                            this.VersiPorts[i].SetVersiportConfiguration(eVersiportConfiguration.DigitalOutput);
                        }
                    }
                }
                #endregion
                #region ComPorts
                if (this.SupportsComPort)
                {
                    for (uint i = 1; i <= 2; i++)
                    {
                        this.ComPorts[i].SerialDataReceived += new ComPortDataReceivedEvent(ControlSystem_SerialDataReceived);
                        if (this.ComPorts[i].Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                        {
                            ErrorLog.Error("Error Registering ComPort{0}: {1}", i, ComPorts[i].DeviceRegistrationFailureReason);
                        }
                        else
                        {
                            this.ComPorts[i].SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate19200,
                                                            ComPort.eComDataBits.ComspecDataBits8,
                                                            ComPort.eComParityType.ComspecParityNone,
                                                            ComPort.eComStopBits.ComspecStopBits1,
                                                            ComPort.eComProtocolType.ComspecProtocolRS232,
                                                            ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                                            ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                                            false);
                        }
                    }
                }
                #endregion1
                #region Touchpanel
                if (this.SupportsEthernet)
                {
                    myPanel            = new XpanelForSmartGraphics(0x03, this);
                    myPanel.SigChange += new SigEventHandler(myPanel_SigChange);
                    if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error in Registering xPanel: {0}", myPanel.RegistrationFailureReason);
                    }
                    else
                    {
                        myPanel.LoadSmartObjects(@"\NVRAM\xpnl.sgd");
                        CrestronConsole.PrintLine("Loaded SmartObjects: {0}", myPanel.SmartObjects.Count);
                        foreach (KeyValuePair <uint, SmartObject> mySmartObject in myPanel.SmartObjects)
                        {
                            mySmartObject.Value.SigChange += new SmartObjectSigChangeEventHandler(Value_SigChange);
                        }
                        MySigGroup = CreateSigGroup(1, eSigType.String);
                        MySigGroup.Add(myPanel.StringInput[1]);
                        MySigGroup.Add(myPanel.StringInput[2]);
                    }
                }
                #endregion
                #region EISC
                if (this.SupportsEthernet)
                {
                    myEISC            = new EthernetIntersystemCommunications(0x04, "127.0.0.2", this);
                    myEISC.SigChange += new SigEventHandler(myEISC_SigChange);
                    if (myEISC.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Error in Registering EISC: {0}", myEISC.RegistrationFailureReason);
                    }
                    else
                    {
                        myEISC.SigChange -= myEISC_SigChange;
                    }
                }
                #endregion
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }