/// <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
            {
                tp01 = this.MPC3x201TouchscreenSlot;

                if (tp01.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    Debug.Log(">>> MPC3 Touchscreen registered successfully.", Debug.ErrorLevel.None, true);
                }
                else
                {
                    Debug.Log(">>> MPC3 Touchscreen failed to register", Debug.ErrorLevel.Error, true);
                }

                tp01.ButtonStateChange += new ButtonEventHandler(tp01_ButtonStateChange);
                Mpc3Initialize(tp01);
            }
            catch (Exception e)
            {
                Debug.Log(">>> Error in InitializeSystem: " + e.Message, Debug.ErrorLevel.Error, true);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// specifies the touchscreen as a MPC3x201 type
 /// </summary>
 /// <param name="touchscreen"></param>
 public ButtonPanelUtility(MPC3x201Touchscreen touchscreen)
 {
     this._touchscreen = touchscreen;
 }
        /// <summary>
        /// mpc3Initialize - sets initial settings for MPC3x201
        /// </summary>
        /// <param name="tp">MPC3x201Touchscreen</param>
        void Mpc3Initialize(MPC3x201Touchscreen tp)
        {
            //enable buttons
            tp.DisableButtonPressBeeping();
            tp.EnablePowerButton();
            tp.EnableMuteButton();
            tp.EnableVolumeUpButton();
            tp.EnableVolumeDownButton();

            //map buttons to methods
            buttonPanelUtility = new ButtonPanelUtility(tp);
            //change settings
            buttonPanelUtility.EnableNumericalButtons(1, 6);
            buttonPanelUtility.SetVolumeBar(32000);
            buttonPanelUtility.SetActiveBrightness(65535);
            buttonPanelUtility.SetActiveTimeout(3);
            buttonPanelUtility.SetAutoBrightness(false);
            buttonPanelUtility.SetLEDBrightness(65535);
            buttonPanelUtility.SetStandbyBrightness(0);

            //assign buttons to methods
            buttonPanelUtility.AssignButton(eButtonName.Power, new Action(() => CrestronConsole.PrintLine("Power Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Mute, new Action(() => CrestronConsole.PrintLine("Mute Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.VolumeUp, new Action(() => CrestronConsole.PrintLine("VolumeUp Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.VolumeDown, new Action(() => CrestronConsole.PrintLine("VolumeDown Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button1, new Action(() => CrestronConsole.PrintLine("Button1 Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button2, new Action(() => CrestronConsole.PrintLine("Button2 Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button3, new Action(() => CrestronConsole.PrintLine("Button3 Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button4, new Action(() => CrestronConsole.PrintLine("Button4 Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button5, new Action(() => CrestronConsole.PrintLine("Button5 Command Executed")));
            buttonPanelUtility.AssignButton(eButtonName.Button6, new Action(() => CrestronConsole.PrintLine("Button6 Command Executed")));

            //create mutually exclusive set so only one source button can have a high state at a time
            buttonPanelUtility.CreateMutuallyExclusiveSet(new List <Feedback> {
                tp.Feedback1, tp.Feedback2, tp.Feedback3, tp.Feedback4, tp.Feedback5, tp.Feedback6
            });

            //initialize ComPort 1
            if (this.SupportsComPort)
            {
                ComPort comPort01 = this.ComPorts[1];
                if (comPort01.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    Debug.Log(">>> Error registering " + comPort01.ToString(), Debug.ErrorLevel.Error, true);
                }
                else
                {
                    int comSetupSuccess = comPort01.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
                                                                   ComPort.eComDataBits.ComspecDataBits8,
                                                                   ComPort.eComParityType.ComspecParityNone,
                                                                   ComPort.eComStopBits.ComspecStopBits1,
                                                                   ComPort.eComProtocolType.ComspecProtocolRS232,
                                                                   ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                                                   ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                                                   false);
                    if (comSetupSuccess == 0)
                    {
                        Debug.Log(">>> [" + this.ToString() + "] comport setup succeeded.", Debug.ErrorLevel.None, true);
                        this.ComPorts[1].SerialDataReceived += new ComPortDataReceivedEvent(ControlSystem_SerialDataReceived);
                    }
                    else
                    {
                        Debug.Log(">>> [" + this.ToString() + "] comport setup failed.", Debug.ErrorLevel.None, true);
                    }
                }
            }
        }