Beispiel #1
0
            /// <summary>
            /// Parses the input entered by the user over serial
            /// Calls WcsCliCmProxy class for processing the input
            /// </summary>
            private static void ContinuousSerialUserInputCapture()
            {
                String inputString = null;

                while (_continue)
                {
                    // Blocking call that will wait until the user enters a command delimited by carriage return or new line
                    inputString = CliSerialPort.ReadUserInputStringFromSerial(new char[] { '\n', '\r' });

                    if (inputString != null)
                    {
                        if (inputString.Equals("exit", StringComparison.InvariantCultureIgnoreCase) || inputString.Equals("quit", StringComparison.InvariantCultureIgnoreCase))
                        {
                            inputString  = "wcscli ";
                            inputString += "-" + WcsCliConstants.terminateCmConnection;
                        }

                        // Execute the command
                        WcsCliCmProxy.InteractiveParseUserCommandGetCmResponse(true, inputString);
                    }
                    Console.Write(WcsCliConstants.consoleString + " " + "");

                    // Write response data from console out to serial
                    CliSerialPort.WriteConsoleOutToSerial();
                } // While loop ends
            }
Beispiel #2
0
            protected override void OnStart(string[] args)
            {
                // Wcscli Serial Service specific code goes here - starts
                try
                {
                    if (!CliSerialPort.CliSerialOpen(_defaultCliServiceComPort, _defaultCliServiceBaudRate))
                    {
                        // Print failure and exit the service
                        if (logWriter != null)
                        {
                            logWriter.WriteLine("Fault when serial port CliSerialOpen is called..");
                        }
                        Environment.Exit(-1);
                    }
                    logWriter.WriteLine("Succesfully started service with name ({0}) at Port ({1})", ServiceName, _defaultCliServiceComPort);
                }
                catch (IOException e)
                {
                    if (logWriter != null)
                    {
                        logWriter.WriteLine("Fault (IOException) at service start " + e.Message);
                    }
                }
                catch (Exception ex)
                {
                    if (logWriter != null)
                    {
                        logWriter.WriteLine("Fault at service start " + ex.ToString());
                    }
                }
                // Wcscli Serial Service specific code goes here - ends

                // onstart code here
                _serviceThread.Start();
                if (logWriter != null)
                {
                    logWriter.WriteLine("Service thread started.. ");
                }

                // populate network controller index.
                Contracts.SharedFunc.EnumerateControllers();
            }
Beispiel #3
0
            protected override void OnStop()
            {
                CliSerialPort.CliSerialClose();

                _continue = false;
                if (_serviceThread != null)
                {
                    _serviceThread.Join(2000);
                }
                if (_serviceThread != null)
                {
                    _serviceThread.Abort();
                }

                if (logWriter != null)
                {
                    logWriter.WriteLine("The END!");
                    logWriter.Close();
                }
            }