Пример #1
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;

                //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(String.Format("Info: {0}", SwitcherOutputs[Convert.ToUInt16(eDmps34K250COutputs.Dm1)].CardInputOutputType));
                if (SwitcherOutputs[Convert.ToUInt16(eDmps34K250COutputs.Dm1)].CardInputOutputType == eCardInputOutputType.Dmps3DmOutputBackend)
                {
                    myDmRmc4k100C = new DmRmc4k100C(0x03, (Card.Dmps3DmOutputBackend)SwitcherOutputs[Convert.ToUInt16(eDmps34K250COutputs.Dm1)]);
                }

                myTSW760 = new Tsw760(0x04, this);
                myTSW760.ExtenderSystemReservedSigs.Use();
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}\n", e.Message);
            }
        }
        /// <summary>
        /// Builds and returns an instance of EssentialsPluginTemplateCrestronDevice
        /// </summary>
        /// <param name="dc">device configuration</param>
        /// <returns>plugin device or null</returns>
        /// <remarks>
        /// The example provided below takes the device key, name, properties config and the comms device created.
        /// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device.
        /// </remarks>
        /// <seealso cref="PepperDash.Core.eControlMethod"/>
        public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
        {
            Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type);

            // get the plugin device properties configuration object & check for null
            var propertiesConfig = dc.Properties.ToObject <EssentialsPluginConfigObjectTemplate>();

            if (propertiesConfig == null)
            {
                Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name);
                return(null);
            }

            var controlConfig = CommFactory.GetControlPropertiesConfig(dc);

            if (controlConfig == null)
            {
                var myTouchpanel = new Tsw760(controlConfig.IpIdInt, Global.ControlSystem);

                return(new EssentialsPluginTemplateCrestronDevice(dc.Key, dc.Name, propertiesConfig, myTouchpanel));
            }
            else
            {
                Debug.Console(0, "[{0}] Factory: Unable to get control properties from device config for {1}", dc.Key, dc.Name);
                return(null);
            }
        }
Пример #3
0
        void Initialize(ControlSystem cs, uint ipid, string projectName, bool traceEnabled)
        {
            this.cs           = cs;
            this.TraceEnabled = traceEnabled;
            this.TraceName    = this.GetType().Name;

            // set defaults
            state            = new UserInterfaceState();
            state.page       = Page.Home;
            state.modalPopup = ModalPopup.None;

            panel = new Tsw760(ipid, cs);

            // add callbacks
            panel.OnlineStatusChange += new OnlineStatusChangeEventHandler(PanelOnlineStatusChangeHandler);
            panel.SigChange          += new SigEventHandler(PanelSigChangeHandler);

            // register panel
            if (panel.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
            {
                Trace("Initialize() panel registered successfully.");
            }
            else
            {
                Trace("Initialize() panel failed to register.");
                return;
            }

            // load SmartGraphics objects
            string sgdPath = String.Format("{0}\\{1}.sgd", Directory.GetApplicationDirectory(), projectName);

            if (File.Exists(sgdPath))
            {
                if (panel.LoadSmartObjects(sgdPath) > 0)
                {
                    Trace(String.Format("Initialize() loaded {0} SmartObjects.", panel.SmartObjects.Count));
                    foreach (KeyValuePair <uint, SmartObject> pair in panel.SmartObjects)
                    {
                        pair.Value.SigChange += new SmartObjectSigChangeEventHandler(PanelSmartObjectHandler);
                    }
                }
                else
                {
                    Trace("Initialize() error, couldn't load any SmartObjects!");
                }
            }
            else
            {
                Trace(String.Format("Initialize() error, SGD file: {0}, does not exist.", sgdPath));
            }
        }
Пример #4
0
        private const uint keypadID = 1; // smart graphic object id


        public ControlSystem()  : base()
        {
            Thread.MaxNumberOfUserThreads = 60;

            if (this.SupportsEthernet)
            {
                tsw760 = new Tsw760(0x05, this);
                string TSW760SgdFilePath = string.Format("{0}\\Passcode.sgd", Directory.GetApplicationDirectory());

                if (File.Exists(TSW760SgdFilePath))
                {
                    tsw760.LoadSmartObjects(TSW760SgdFilePath);
                    CrestronConsole.PrintLine("[SYSTEM] TSW SGD FOUND!!!");
                    PasscodeKeypad = tsw760.SmartObjects[keypadID];
                }
                else
                {
                    CrestronConsole.PrintLine("[SYSTEM] Could not find TSW SGD file. TSW SmartObjects will not work at this time");
                }


                if (tsw760.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    CrestronConsole.PrintLine("[SYSTEM] tsw760 has been registered successfully");
                }
                else
                {
                    CrestronConsole.PrintLine("[SYSTEM] tsw760 failed registration. Cause: {0}", tsw760.RegistrationFailureReason);
                }
            }
            else
            {
                CrestronConsole.PrintLine("[SYSTEM] This processor does not support ethernet, so this program will not run");
            }


            /// set up passcode
            PIN = new Passcode();
            PIN.Init(tsw760, PasscodeKeypad, passcodeChangeButton, passcodeTextField);
            PIN.debug_enable = true;
            PIN.SetCallback(PINCodeEntered);
        }
Пример #5
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;
                userInterface            = new Tsw760(03, this);
                userInterface.SigChange += new SigEventHandler(userInterface_SigChange);
                userInterface.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);
            }
        }
Пример #6
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;

                hdmi_switcher = new HDMISwitcher(165, HDMI_SWITCHER_IP, this);

                userInterface            = new Tsw760(03, this);
                userInterface.SigChange += new SigEventHandler(userInterface_Sigchange);
                userInterface.Register();

                //A4 is 164 in hexidecial notaion
                lighting = new Glpp1DimFlv3CnPm(164, this);
                lighting.Register();

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

                //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);
            }
        }
Пример #7
0
        public override void InitializeSystem()
        {
            try
            {
                if (SupportsSwitcherOutputs)
                {
                    try
                    {
                        dmVideoRouting  = new dmpsVideoRouting(SwitcherInputs, SwitcherOutputs, this.SystemControl as Dmps3SystemControl, SwitcherOutputs[(uint)eDmps3200cOutputs.Hdmi] as Crestron.SimplSharpPro.DM.Cards.Card.Dmps3HdmiOutput, SwitcherInputs[(uint)eDmps3200cInputs.Dm] as Crestron.SimplSharpPro.DM.Cards.Card.Dmps3DmInput);
                        DMOutputChange += new Crestron.SimplSharpPro.DM.DMOutputEventHandler(dmVideoRouting.DMOutputChange);
                        DMSystemChange += new DMSystemEventHandler(dmVideoRouting.DMSystemChange);
                        DMInputChange  += new DMInputEventHandler(dmVideoRouting.DMInputChange);
                        dmVideoRouting.DMPSVideoEvent      += new dmpsVideoRouting.DMPSVideoOutChangeEventhandler(dmVideoRouting_DMPSVideoEvent);
                        dmVideoRouting.DMPSVideoSyncChange += new dmpsVideoRouting.DMPSVideoSyncChangeEvent(dmVideoRouting_DMPSVideoSyncChange);
                        dmVideoRouting.DMPSDmInputChange   += new dmpsVideoRouting.DMPSDmInputChangeEvent(dmVideoRouting_DMPSDmInputChange);
                        dmVideoRouting.DMPSHDMIChange      += new dmpsVideoRouting.DMPSHDMiMuteChangeEvene(dmVideoRouting_DMPSHDMIChange);


                        dmAudioControl  = new dmpsAudioControls(SwitcherOutputs[(uint)eDmps3200cOutputs.Program] as Crestron.SimplSharpPro.DM.Cards.Card.Dmps3ProgramOutput, SwitcherInputs);
                        DMOutputChange += new DMOutputEventHandler(dmAudioControl.DMOutputChange);
                        dmAudioControl.AudioLevelChange  += new dmpsAudioControls.AudioLevelChangeEvent(dmAudioControl_AudioLevelChange);
                        dmAudioControl.AudioSourceChange += new dmpsAudioControls.AudioSourceChangeEvent(dmAudioControl_AudioSourceChange);
                        dmAudioControl.AmpMixerChange    += new dmpsAudioControls.AmpMixerChangeEvent(dmAudioControl_AmpMixerChange);
                        dmAudioControl.AmpPowerChange    += new dmpsAudioControls.AmpPowerChangeEvent(dmAudioControl_AmpPowerChange);

                        DmTx201C _dmTX201c = new DmTx201C(0x08, SwitcherInputs[(uint)eDmps3200cInputs.Dm] as DMInput);
                        dmTX = new DmpxTS(_dmTX201c);
                        dmTX.DmTXAudioChangeEvent += new DmpxTS.DmTxAudioChangeEventHandler(dmTX_DmTXAudioChangeEvent);
                        dmTX.DmTXVideoChangeEvent += new DmpxTS.DmTxVideoChangeEventHandler(dmTX_DmTXVideoChangeEvent);
                    }
                    catch (Exception e)
                    {
                        CrestronConsole.PrintLine("Error is SwitcherOutputs Constructor is: " + e);
                    }
                }

                uiLogic = new TouchPanel();
                uiLogic.AnalogChangeEvent  += new TouchPanel.AnalogChangeEventHandler(uiLogic_AnalogChangeEvent);
                uiLogic.DigitalChangeEvent += new TouchPanel.DigitalChangeEventHandler(uiLogic_DigitalChangeEvent);

                userInterface            = new Tsw760(0x03, this);
                userInterface.SigChange += new SigEventHandler(uiLogic.userInterface_SigChange);
                userInterface.Register();
                CrestronConsole.PrintLine("Touchpanel Registration Feedback is: " + userInterface.Registered);

                dmGeneralControl = new dmps3200General(this);
                dmGeneralControl.DMPS3FrontpanelChange += new dmps3200General.DMPS3FrontPanelEventHandler(dmGeneralControl_DMPS3FrontpanelChange);
                dmGeneralControl.DMPS3PowerEventChange += new dmps3200General.DMPSSystemPowerEventHandler(dmGeneralControl_DMPS3PowerEventChange);

                dmRelays = new DMPSRelays(this);
                dmRelays.RelayChangeEvent += new DMPSRelays.RelayChangeEventHandler(dmRelays_RelayChangeEvent);

                dmIo = new DMPSIOS(this);
                dmIo.IOChangeEvent += new DMPSIOS.IOChangeEventHandler(dmIo_IOChangeEvent);

                dmVideoRouting.HDMIMute(true);
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
Пример #8
0
        /// <summary>
        /// Config constructor
        /// </summary>
        public EssentialsTouchpanelController(string key, string name, string type, CrestronTouchpanelPropertiesConfig props, uint id)
            : base(key, name)
        {
            Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Creating touchpanel hardware...");
            type = type.ToLower();
            try
            {
                if (type == "crestronapp")
                {
                    var app = new CrestronApp(id, Global.ControlSystem);
                    app.ParameterProjectName.Value = props.ProjectName;
                    Panel = app;
                }
                else if (type == "tsw550")
                {
                    Panel = new Tsw550(id, Global.ControlSystem);
                }
                else if (type == "tsw552")
                {
                    Panel = new Tsw552(id, Global.ControlSystem);
                }
                else if (type == "tsw560")
                {
                    Panel = new Tsw560(id, Global.ControlSystem);
                }
                else if (type == "tsw750")
                {
                    Panel = new Tsw750(id, Global.ControlSystem);
                }
                else if (type == "tsw752")
                {
                    Panel = new Tsw752(id, Global.ControlSystem);
                }
                else if (type == "tsw760")
                {
                    Panel = new Tsw760(id, Global.ControlSystem);
                }
                else if (type == "tsw1050")
                {
                    Panel = new Tsw1050(id, Global.ControlSystem);
                }
                else if (type == "tsw1052")
                {
                    Panel = new Tsw1052(id, Global.ControlSystem);
                }
                else if (type == "tsw1060")
                {
                    Panel = new Tsw1060(id, Global.ControlSystem);
                }
                else
                {
                    Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW controller with type '{0}'", type);
                    return;
                }
            }
            catch (Exception e)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create TSW base class. Panel will not function: {0}", e.Message);
                return;
            }

            // Reserved sigs
            if (Panel is TswFt5ButtonSystem)
            {
                var tsw = Panel as TswFt5ButtonSystem;
                tsw.ExtenderSystemReservedSigs.Use();
                tsw.ExtenderSystemReservedSigs.DeviceExtenderSigChange
                    += ExtenderSystemReservedSigs_DeviceExtenderSigChange;

                tsw.ButtonStateChange += new ButtonEventHandler(Tsw_ButtonStateChange);
            }

            if (Panel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
            {
                Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason);
            }

            // Give up cleanly if SGD is not present.
            var sgdName = Global.FilePathPrefix + "sgd" + Global.DirectorySeparator + props.SgdFile;

            if (!File.Exists(sgdName))
            {
                Debug.Console(0, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName);

                sgdName = Global.ApplicationDirectoryPathPrefix + Global.DirectorySeparator + "SGD" + Global.DirectorySeparator + props.SgdFile;

                if (!File.Exists(sgdName))
                {
                    Debug.Console(0, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName);
                    return;
                }
            }

            Panel.LoadSmartObjects(sgdName);
            Panel.SigChange += Panel_SigChange;
        }
Пример #9
0
        public override void InitializeSystem()
        {
            try
            {
                // List of all Touchscreens in system
                IList <BasicTriListWithSmartObject> panelList = new List <BasicTriListWithSmartObject>();

                Tsw1060 touchScreen1060 = new Tsw1060(0x0C, this);
                touchScreen1060.Register();

                Tsw760 touchScreen760 = new Tsw760(0x0A, this);
                touchScreen760.Register();

                Tsw560 touchScreen560 = new Tsw560(0x0E, this);
                touchScreen560.Register();

                Tsw560P touchScreen560P = new Tsw560P(0x0D, this);
                touchScreen560P.Register();

                CrestronApp mobileApp = new CrestronApp(0x0B, this);
                mobileApp.ParameterProjectName.Value = "ch5-sample-project";
                mobileApp.Register();

                panelList.Add(touchScreen1060);
                panelList.Add(touchScreen760);
                panelList.Add(touchScreen560);
                panelList.Add(touchScreen560P);
                panelList.Add(mobileApp);

                // ---------------------------------------------------------------------------------------------------------------
                // Create Contract Instance to program all touchscreens in system. This Contract Reference will globablly program
                // Lights, Source Selection, and ContactList
                // ---------------------------------------------------------------------------------------------------------------

                // Contract Instance
                var globalContract = new Contract(panelList.ToArray());

                // Sample Programming of Lights/Scenes for all Touchscreens
                var demoLightingLogic = new DemoRoomLogic(globalContract.Room);

                // Sample Programming of Contact List for all Touchscreens
                var demoContactListingLogic = new DemoContactListingLogic(globalContract.ContactList);

                // Sample Programming of Source Selection for all Touchscreens
                var demoSourceSelectionLogic = new DemoSourceSelectLogic(globalContract.SourceList);


                // --------------------------------------------------------------------------------------------------------------
                // Creating Multiple Contract Instances for each Touchscreen to program VIDEO CAMERA PAGE.
                // This will allow each Touchscreen Device to independantly play a different video camera.
                // For example TSW1060 can watch camera 2 while TSW760 can watch camera 1 and so on.
                // --------------------------------------------------------------------------------------------------------------

                //Contract Instance for TSW1060
                Touchscreen1060Contract    = new Contract(touchScreen1060);
                Touchscreen1060VideoCamera = new DemoVideoCameraLogic(Touchscreen1060Contract.CameraList);

                // Contact Instance for TSW760
                Touchscreen760Contract    = new Contract(touchScreen760);
                Touchscreen760VideoCamera = new DemoVideoCameraLogic(Touchscreen760Contract.CameraList);

                // Contact Instance for TSW560
                Touchscreen560Contract    = new Contract(touchScreen560);
                Touchscreen560VideoCamera = new DemoVideoCameraLogic(Touchscreen560Contract.CameraList);

                // Contact Instance for TSW560P
                Touchscreen560PContract    = new Contract(touchScreen560P);
                Touchscreen560PVideoCamera = new DemoVideoCameraLogic(Touchscreen560PContract.CameraList);

                // Contact Instance for MobileApp
                MobileAppContract    = new Contract(mobileApp);
                MobileAppVideoCamera = new DemoVideoCameraLogic(MobileAppContract.CameraList);
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }