示例#1
0
        /// <summary>
        /// Reads the current configuration of the Raspberry and updates the LCD status information <see cref="updateLCD"/>
        /// </summary>
        /// <param name="i">not used</param>
        /// <returns>The current configuration as human readable string</returns>
        public string GetRaspiConfig(int i)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("IPAddress: " + this.GetIpAddressAsync() + "\n");
            sb.Append("Initialized: " + RasPi.isInitialized() + "\n");
            sb.Append("TestMode: " + RasPi.isTestMode() + "\n");
            sb.Append("LCD: \n");
            sb.Append("\t Initialized: " + this.LCD.isInitialized() + "\n");
            sb.Append("\t Text: " + this.LCD.CurrentTextPlainString + "\n");
            sb.Append("Potentiometer: \n");
            sb.Append("\t Initialized: " + this.Potentiometer.isInitialized() + "\n");
            sb.Append("HI: \n");
            sb.Append("\t Family: " + StorageCfgs.Hi.Family + "\n");
            sb.Append("\t Model: " + StorageCfgs.Hi.Model + "\n");
            sb.Append("\t Available Usercontrols: \n");
            XPinConfig mux_config = HiXmlParser.getMultiplexerConfig(StorageCfgs.Hi.Family, StorageCfgs.Hi.Model);

            foreach (var pair in mux_config.X_Pin_To_Value_Map)
            {
                if (!pair.Value.Equals(""))
                {
                    sb.Append("\t\t X-Pin:" + pair.Key + ", UserControl: " + pair.Value + "\n");
                }
            }

            sb.Append("Status of Usercontrols: \n");
            sb.Append("\t Telecoil detected: " + getTeleCoilStatus() + "\n");
            sb.Append("\t Audio Shoe detected: " + getAudioShoeStatus() + "\n");
            sb.Append("\t LED is On: " + CheckLEDStatus(0) + "\n");

            this.updateLCD();

            return(sb.ToString());
        }
示例#2
0
        /// <summary>
        /// Method to wrap updating the LCD with fixed information.
        /// </summary>
        public void updateLCD()
        {
            if (RasPi.isTestMode())
            {
                return;
            }
            LCD.initiateLCD();

            cancelWritingWait();
            CheckTurnOnBacklight();

            _writingOnLcd = Task.Run(async() => await printOnLcd(), _cts.Token);
        }
示例#3
0
        /// <summary>
        /// Sets the multiplexer configuation to a specific HI
        /// </summary>
        /// <param name="family">HiFamily name of the HI, e.g.: "Pure"</param>
        /// <param name="model_name">HiModel name of the HI: e.g: "312 702 S (DN)"</param>
        public MultiplexerConfig setMultiplexerConfiguration(string family, string model_name)
        {
            Debug.WriteLine(this.GetType().Name + "::: Setting Multiplexer Config:");

            MultiplexerConfig     muxConfig   = new MultiplexerConfig(family, model_name);
            Dictionary <int, int> xToYMapping = muxConfig.getX_to_Y_Mapping();

            if (!RasPi.isTestMode())
            {
                Multiplexer.resetAll();
                foreach (var keyValuePair in xToYMapping)
                {
                    Multiplexer.connectPins(keyValuePair.Key, keyValuePair.Value);
                }
            }
            return(muxConfig);
        }
        private void updateARDVoltage(string device)
        {
            if (!ReceiverConfig.DeviceResistanceMap.ContainsKey(device))
            {
                Debug.Write("Invalid device provided!");
            }

            double resistance = ReceiverConfig.DeviceResistanceMap[device];
            double voltage    = (ADConverter.CurrentDACVoltage1 / (14.00 + resistance)) * resistance;

            Debug.WriteLine("Setting ARD for Device " + device + " to " + voltage.ToString());

            if (!RasPi.isTestMode())
            {
                ADConverter.setDACVoltage2(voltage);
            }
        }
        private static int statusMessageCount = 0; // count messages generated by this method (currently for arbitrary reasons)

        /// <summary>
        /// Executes the Command getStatusXML()
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns>
        /// The current state of the Raspberry Pi: Status of user controls, available features, hardware information.
        /// This method returns an XML-file.
        /// </returns>
        public XDocument getStatusXML()
        {
            XElement xml = new XElement("Operation",
                                        new XAttribute("Timestamp", DateTime.Now.ToString("hh:mm:ss")),
                                        new XAttribute("Message", 1),
                                        new XElement("IPAddress", this.GetIpAddressAsync()),
                                        new XElement("Initialized", RasPi.isInitialized()),
                                        new XElement("TestMode", RasPi.isTestMode())
                                        );

            /* TODO if possible: read & return currently displayed text.
             * Depending whether or not LCD is connected, status information differs. */
            if (this.LCD.isInitialized())
            {
                xml.Add(new XElement("LCD",
                                     new XElement("Initialized", true),
                                     new XElement("Text", this.LCD.CurrentText.ToString())));
            }
            else
            {
                xml.Add(new XElement("LCD",
                                     new XElement("Initialized", false)));
            }
            if (this.Potentiometer.isInitialized())
            {
                xml.Add(new XElement("Potentiometer",
                                     new XElement("Initialized", true),
                                     new XElement("Text", this.Potentiometer.WiperState)));
            }
            else
            {
                xml.Add(new XElement("Potentiometer",
                                     new XElement("Initialized", false)));
            }
            xml.Add(new XElement("LED",
                                 new XElement("Initialized", "?"),                    // possible to update this later on to better reflect whether or not an LED is even attached
                                 new XElement("Status", GPIOinterface.readPin(24)))); // gpio interface read pin led pin 24
            if (this.Multiplexer.isInitialized())
            {
                xml.Add(new XElement("Multiplexer",
                                     new XElement("Initialized", true),
                                     new XElement("Family", StorageCfgs.Hi.Family),
                                     new XElement("ModelName", StorageCfgs.Hi.Model)
                                     ));
                /* Read config from XML and based on that return supported controls of current HI*/
                XPinConfig mux_config = HiXmlParser.getMultiplexerConfig(StorageCfgs.Hi.Family, StorageCfgs.Hi.Model);
                xml.Add(new XElement("HI",
                                     new XElement(YPinConfig.ROCKERSWITCH_STRING, string.Join(",", mux_config.ValueToPins(YPinConfig.ROCKERSWITCH_STRING))),
                                     new XElement(YPinConfig.GROUND, string.Join(",", mux_config.ValueToPins(YPinConfig.GROUND))),
                                     new XElement(YPinConfig.PUSHBUTTON_STRING, string.Join(",", mux_config.ValueToPins(YPinConfig.PUSHBUTTON_STRING))),
                                     new XElement(YPinConfig.AMR, string.Join(",", mux_config.ValueToPins(YPinConfig.AMR))),
                                     new XElement(YPinConfig.AUDIOINPUT, string.Join(",", mux_config.ValueToPins(YPinConfig.AUDIOINPUT))),
                                     new XElement(YPinConfig.REC_DET, string.Join(",", mux_config.ValueToPins(YPinConfig.REC_DET))),
                                     new XElement(YPinConfig.LED, string.Join(",", mux_config.ValueToPins(YPinConfig.LED))),
                                     new XElement(YPinConfig.M, string.Join(",", mux_config.ValueToPins(YPinConfig.M))),
                                     new XElement(YPinConfig.STOP_END, string.Join(",", mux_config.ValueToPins(YPinConfig.STOP_END))),
                                     new XElement(YPinConfig.ENDLESS_VC, string.Join(",", mux_config.ValueToPins(YPinConfig.ENDLESS_VC))),
                                     new XElement(YPinConfig.ARD, string.Join(",", mux_config.ValueToPins(YPinConfig.ARD))),
                                     new XElement(YPinConfig.DET_AUDIO, string.Join(",", mux_config.ValueToPins(YPinConfig.DET_AUDIO))),
                                     new XElement(YPinConfig.DET_TELE, string.Join(",", mux_config.ValueToPins(YPinConfig.DET_TELE)))
                                     ));
            }
            else
            {
                xml.Add(new XElement("Multiplexer",
                                     new XElement("Initialized", false)
                                     ));
            }
            if (this.ADConverter.isInitialized())
            {
                xml.Add(new XElement("ADConverter",
                                     new XElement("Initialized", true),
                                     new XElement("Connected", this.ADConverter.isConnected()),
                                     new XElement("Channel1", this.ADConverter.CurrentDACVoltage1),
                                     new XElement("Channel2", this.ADConverter.CurrentDACVoltage2)
                                     ));
            }
            else
            {
                xml.Add(new XElement("ADConverter",
                                     new XElement("Initialized", false)
                                     ));
            }
            statusMessageCount++; // count send results for no particular reason other than ensuring order of status updates
            return(new XDocument(new XElement(xml)));
        }