Beispiel #1
0
        public static void Main()
        {
            // write your code here
            var serial = new SerialLcd(Serial.COM2);

            Thread.Sleep(1000);
            serial.SetSplashScreenText("Bootup!");
        }
Beispiel #2
0
 /// <summary>Displays a message on the LCD</summary>
 /// <param name="messageFirstLine">The message to be displayed on the first line of the LCD</param>
 /// <param name="messageSecondLine">The message to be displayed on the second line of the LCD</param>
 private static void DisplayMessage(string messageFirstLine = "", string messageSecondLine = "")
 {
     if (SerialLcd != null)
     {
         SerialLcd.Clear();
         SerialLcd.Write(messageFirstLine);
         SerialLcd.Write(0, 1, messageSecondLine);
     }
 }
Beispiel #3
0
        /// <summary>Initializes the serial LCD</summary>
        private static void InitializeSerialLcd()
        {
            var serialLcdOutput = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);

            serialLcdOutput.Open();

            SerialLcd = new SerialLcd(serialLcdOutput);
            SerialLcd.Clear();
        }
Beispiel #4
0
        private LcdWriter()
        {
            _serialInterface = new SerialLcd(SerialPorts.COM2);

            ThreadUtil.Start(() =>
            {
                while (true)
                {
                    _serialInterface.ClearDisplay();
                    _serialInterface.SetCursorPosition(1, 1);

                    lock (_lockObject)
                    {
                        _serialInterface.Write(_lcdDisplay);
                    }

                    mutex.WaitOne();
                }
            });
        }
Beispiel #5
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            display = new SerialLcd(Device, Device.SerialPortNames.Com4);
        }
        //-------------------------------------------------------------------------------------------------//

        public EquipmentEngine(string rootFilePath)
            : base(rootFilePath)
        {
            const string STRLOG_MethodName = "EquipmentEngine";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            int  initialiseDelay = 0;
            bool hardwarePresent = true;

            try
            {
                //
                // Determine if hardware is to be used or whether this is running without hardware
                // for testing and debugging
                //
                try
                {
                    hardwarePresent = XmlUtilities.GetBoolValue(this.xmlNodeEquipmentConfig, Consts.STRXML_hardwarePresent, false);
                }
                catch
                {
                    // Key not found or invalid so assume hardware is present
                }

                //
                // Create an instance of the FlexMotion class, must be done before creating the Radiation Counter class
                //
                if (hardwarePresent == true)
                {
                    this.flexMotion = new FlexMotionCntl(this.xmlNodeEquipmentConfig);
                }
                else
                {
                    this.flexMotion = new FlexMotionNone(this.xmlNodeEquipmentConfig);
                }
                initialiseDelay += this.flexMotion.InitialiseDelay;

                //
                // Get the serial LCD communication type
                //
                XmlNode xmlNodeSerialLcd     = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_serialLcd);
                string  strSerialLcdCommType = XmlUtilities.GetXmlValue(xmlNodeSerialLcd, Consts.STRXML_type, false);
                this.serialLcdCommType = (CommunicationTypes)Enum.Parse(typeof(CommunicationTypes), strSerialLcdCommType);

                //
                // Create an instance of the SerialLcd class, must be done before creating the Radiation Counter class
                //
                if (hardwarePresent == true)
                {
                    if (this.serialLcdCommType == CommunicationTypes.Network)
                    {
                        this.serialLcdTcp = new SerialLcdTcp(this.xmlNodeEquipmentConfig);
                        this.serialLcd    = this.serialLcdTcp;
                    }
                    else if (this.serialLcdCommType == CommunicationTypes.Serial)
                    {
                        this.serialLcdSer = new SerialLcdSer(this.xmlNodeEquipmentConfig);
                        this.serialLcd    = this.serialLcdSer;
                    }
                    else if (this.serialLcdCommType == CommunicationTypes.None)
                    {
                        this.serialLcdNone = new SerialLcdNone(this.xmlNodeEquipmentConfig);
                        this.serialLcd     = this.serialLcdNone;
                    }
                    else
                    {
                        throw new ArgumentException(STRERR_SerialLcdCommsTypeNotSpecified);
                    }
                }
                else
                {
                    this.serialLcdNone = new SerialLcdNone(this.xmlNodeEquipmentConfig);
                    this.serialLcd     = this.serialLcdNone;
                }
                initialiseDelay += this.serialLcd.InitialiseDelay;

                //
                // Get the radiation counter type
                //
                XmlNode xmlNodeRadiationCounter = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_radiationCounter, false);
                string  strCounterType          = XmlUtilities.GetXmlValue(xmlNodeRadiationCounter, Consts.STRXML_type, false);
                this.radiationCounterType = (RadiationCounterTypes)Enum.Parse(typeof(RadiationCounterTypes), strCounterType);

                //
                // Create an instance of the radiation counter class
                //
                if (this.radiationCounterType == RadiationCounterTypes.ST360)
                {
                    //
                    // Get the ST360 counter communication type
                    //
                    XmlNode xmlNodeST360Counter     = XmlUtilities.GetXmlNode(this.xmlNodeEquipmentConfig, Consts.STRXML_st360Counter);
                    string  strST360CounterCommType = XmlUtilities.GetXmlValue(xmlNodeST360Counter, Consts.STRXML_type, false);
                    this.st360CounterCommType = (CommunicationTypes)Enum.Parse(typeof(CommunicationTypes), strST360CounterCommType);

                    //
                    // Create an instance of the ST360 counter class depending on the communication type
                    //
                    if (hardwarePresent == true)
                    {
                        if (this.st360CounterCommType == CommunicationTypes.Network)
                        {
                            this.st360CounterTcp = new ST360CounterTcp(this.xmlNodeEquipmentConfig);
                            this.st360Counter    = st360CounterTcp;
                        }
                        else if (this.st360CounterCommType == CommunicationTypes.Serial)
                        {
                            this.st360CounterSer = new ST360CounterSer(this.xmlNodeEquipmentConfig);
                            this.st360Counter    = st360CounterSer;
                        }
                        else
                        {
                            throw new ArgumentException(STRERR_ST360CounterCommsTypeNotSpecified);
                        }
                    }
                    else
                    {
                        this.st360CounterNone = new ST360CounterNone(this.xmlNodeEquipmentConfig);
                        this.st360Counter     = st360CounterNone;
                    }
                    initialiseDelay += this.st360Counter.InitialiseDelay;
                }
                else if (this.radiationCounterType == RadiationCounterTypes.Physics)
                {
                    if (hardwarePresent == true)
                    {
                        if (this.serialLcdCommType == CommunicationTypes.Network)
                        {
                            this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdTcp, this.flexMotion);
                        }
                        else if (this.serialLcdCommType == CommunicationTypes.Serial)
                        {
                            this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdSer, this.flexMotion);
                        }
                        else
                        {
                            throw new ArgumentException(STRERR_SerialLcdCommsTypeNotSpecified);
                        }
                    }
                    else
                    {
                        this.physicsCounter = new PhysicsCounter(this.xmlNodeEquipmentConfig, this.serialLcdNone, this.flexMotion);
                    }
                    initialiseDelay += this.physicsCounter.InitialiseDelay;
                }
                else
                {
                    throw new ArgumentException(STRERR_RadiationCounterTypeNotSpecified);
                }

                //
                // Update the power initialisation delay
                //
                this.powerupInitialiseDelay = initialiseDelay;
                Logfile.Write(STRLOG_InitialiseDelay + initialiseDelay.ToString() + STRLOG_Seconds);
            }
            catch (Exception ex)
            {
                //
                // Log the message and throw the exception back to the caller
                //
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }