Exemplo n.º 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());
        }
Exemplo n.º 2
0
        public MultiplexerConfig(string hiFamily, string hiModel)
        {
            StorageCfgs.Hi.Family = hiFamily;
            StorageCfgs.Hi.Model  = hiModel;

            XPinConfig xPinConfig = HiXmlParser.getMultiplexerConfig(hiFamily, hiModel);
            YPinConfig yPinConfig = new YPinConfig();

            _x_pin_to_value_map = xPinConfig._x_pin_to_value_map;
            gpio_To_YPin_Map    = yPinConfig.gpio_To_YPin_Map;

            Debug.WriteLine("\n====================================\n " +
                            "===== Multiplexer Configuration ====\n ");

            RaspberryPi.Instance.Control.Multiplexer.current_multiplexer_state.Clear();

            foreach (int value_x in _x_pin_to_value_map.Keys)
            {
                foreach (string y_value in gpio_To_YPin_Map.Keys)
                {
                    if (y_value.Equals(_x_pin_to_value_map[value_x]))
                    {
                        x_to_y_map.Add(value_x, gpio_To_YPin_Map[y_value]);

                        Debug.WriteLine("Pin {0} is connected to : {1} \n", value_x, y_value);
                        RaspberryPi.Instance.Control.Multiplexer.current_multiplexer_state.Add(value_x, new Tuple <int, string>(gpio_To_YPin_Map[y_value], y_value));
                    }
                }
            }

            Debug.WriteLine("====================================\n ");

            saveConfig();
        }
        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)));
        }