Ejemplo n.º 1
0
        // These functions are run in a seperate thread to allow the main loop to continue executing.
        private void ReconnectHopper()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox);

            hopperConnecting = true;
            while (!hopperRunning)
            {
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to SMART Hopper...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to SMART Hopper...\r\n");
                }

                ConnectToHopper();
                CHelpers.Pause(1000);
                if (CHelpers.Shutdown)
                {
                    return;
                }
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to SMART Hopper\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to SMART Hopper\r\n");
            }
            Hopper.EnableValidator();
            hopperConnecting = false;
        }
Ejemplo n.º 2
0
        private void ReconnectNV11()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox);

            NV11Connecting = true;
            while (!NV11Running)
            {
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to NV11...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to NV11...\r\n");
                }

                ConnectToNV11(null); // Have to pass null as can't update text box from a different thread without invoking

                CHelpers.Pause(1000);
                if (CHelpers.Shutdown)
                {
                    return;
                }
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to NV11\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to NV11\r\n");
            }
            NV11.EnableValidator();
            NV11Connecting = false;
        }
Ejemplo n.º 3
0
        // This function is run in a seperate thread, it allows a reconnection to a validator to happen in the
        // background.
        private void ReconnectValidator()
        {
            OutputMessage m = new OutputMessage(AppendToTextBox); // setup delegate

            while (!validatorRunning)
            {
                if (CHelpers.Shutdown)
                {
                    return;
                }
                // Check for cross-thread access
                if (textBox1.InvokeRequired)
                {
                    textBox1.Invoke(m, new object[] { "Attempting to reconnect to note validator...\r\n" });
                }
                else
                {
                    textBox1.AppendText("Attempting to reconnect to note validator...\r\n");
                }

                // Attempt reconnect (can't pass text box across for output as the class does not
                // deal with threading issues).
                ConnectToNoteValidator();
                CHelpers.Pause(1000);
            }
            if (textBox1.InvokeRequired)
            {
                textBox1.Invoke(m, new object[] { "Reconnected to note validator\r\n" });
            }
            else
            {
                textBox1.AppendText("Reconnected to note validator\r\n");
            }
            Validator.EnableValidator();
        }