Example #1
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;
        }
Example #2
0
        /* This has been moved to a separate class
         * //card list
         * private DmcC input1;
         * private DmcDvi input2;
         * private DmcHd input3;
         * private DmcS input4;
         * private DmcC input5;
         * private Dmc4kHd input6;
         * private DmcVga input7;
         * private DmcStr input8;
         *
         * private Dmc4kCoHdSingle output1_2;
         * private Dmc4kHdoSingle output3_4;
         * private DmcStroSingle output5_6;
         * private DmcCoHdSingle output7_8;
         */

        /// <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 TSW750_w_DMMD8x8()
            : 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);

                ErrorLog.Notice("*** : Constructor");
                ErrorLog.Notice("*** : Current Time is {0}", DateTime.Now);
                myServer = new HttpCwsServer("api");
                myServer.Routes.Add(new HttpCwsRoute("roomname")
                {
                    Name = "ROOMNAME"
                });
                myServer.HttpRequestHandler = new Server_Handler(this);
                myServer.Register();

                //TSW Panel
                myPanel = new Tsw750(0x20, this);

                myPanel.Description         = "Touchpanel";
                myPanel.OnlineStatusChange += new OnlineStatusChangeEventHandler(Device_OnlineStatusChange);
                if (myPanel.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("TDS: Error in Registering myPanel: {0}", myPanel.RegistrationFailureReason);
                }
                else
                {
                    myPanel.SigChange += MyPanel_SigChange;
                }

                //DM Frame

                myFrame = DMFrameMaker.DMFrame(0x19, this);

                /*
                 * myFrame = new DmMd8x8(0x19, this);
                 * input1 = new DmcC(1, myFrame);
                 * input2 = new DmcDvi(2, myFrame);
                 * input3 = new DmcHd(3, myFrame);
                 * input4 = new DmcS(4, myFrame);
                 * input5 = new DmcC(5, myFrame);
                 * input6 = new Dmc4kHd(6, myFrame);
                 * input7 = new DmcVga(7, myFrame);
                 * input8 = new DmcStr(8, myFrame);
                 * output1_2 = new Dmc4kCoHdSingle(1, myFrame);
                 * output3_4 = new Dmc4kHdoSingle(2, myFrame);
                 * output5_6 = new DmcStroSingle(3, myFrame);
                 * output7_8 = new DmcCoHdSingle(4, myFrame);
                 *
                 * myFrame.VideoEnter.BoolValue = true;
                 */

                myFrame.Description         = "DigitalMedia Switcher";
                myFrame.OnlineStatusChange += new OnlineStatusChangeEventHandler(Device_OnlineStatusChange);
                if (myFrame.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("TDS: Error in Registering myFrame: {0}", myFrame.RegistrationFailureReason);
                }
                else
                {
                    myFrame.DMOutputChange += MyFrame_DMOutputChange;
                }
            }
            catch (Exception e)
            {
                ErrorLog.Error("TDS: Error in the constructor: {0}", e.Message);
            }
        }
Example #3
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
        }