Exemplo n.º 1
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);
            }
        }