コード例 #1
0
        /// <summary>
        /// Execute the Command WritePin
        /// </summary>
        /// <param name="parameters">Represents the GpioPin:Uint16 which shall be written on</param>
        /// <returns>The current status of the requested pin.</returns>
        public string WritePin(UInt16 id)
        {
            GPIOinterface.activatePin(id);
            string retValue = GPIOinterface.readPin(id);

            return(retValue);
        }
コード例 #2
0
 /// <summary>
 /// Can be used to change the state of the (hardware) LED to a new state.
 /// Note: this method uses the instance constant "PIN_ID" to change the state
 /// => new call then e.g.LED.switchToState(ON);
 /// </summary>
 /// <param name="targetState">the state wished to change to</param>
 /// <returns>The GpioPinValue of the concerned Gpio-Pin</returns>
 private string switch_LED_ToState(uint targetState)
 {
     if (targetState == 0)
     {
         GPIOinterface.deactivatePin(GPIO_PIN_ID);
     }
     else
     {
         GPIOinterface.activatePin(GPIO_PIN_ID);
     }
     return(GPIOinterface.readPin(GPIO_PIN_ID));
 }
コード例 #3
0
        /// <summary>
        /// Executes the Command EnableAudioShoe. Send signal that an audio-shoe is connected /disconnected
        /// by pulling up /down the respective pin as defined by documentation.
        /// Compare the circuit diagram for more details.
        /// </summary>
        /// <param name="value">Integer: For 1 activate audioshoe, for 0 deactivate it.</param>
        /// <returns>Current status of AudioShoe-Pin.</returns>
        public string EnableAudioShoe(int value)
        {
            if (value == 1)
            {
                GPIOinterface.activatePin(audioShoe_Pin);
            }
            else if (value == 0)
            {
                GPIOinterface.deactivatePin(audioShoe_Pin);
            }

            return(GPIOinterface.readPin(audioShoe_Pin));
        }
コード例 #4
0
        /// <summary>
        /// Send signal that a tele-coil is detected or undetected by pulling up the respective pin as defined by documentation. Compare the
        /// circuit diagram for more details.
        /// </summary>
        /// <param name="value">Integer: For 1 activate the telecoil. For 0 deactivate it.</param>
        /// <returns>The current status of the teleCoil-pin.</returns>
        public string EnableTeleCoil(int value)
        {
            if (value == 1)
            {
                GPIOinterface.activatePin(teleCoil_Pin);
            }
            else if (value == 0)
            {
                GPIOinterface.deactivatePin(teleCoil_Pin);
            }

            return(GPIOinterface.readPin(teleCoil_Pin));
        }
コード例 #5
0
        /// <summary>
        /// Executes the Command LightLED in dependency of the parsed parameter
        /// </summary>
        /// <param name="parameter">Int to turn on or off the LED (0 or 1)</param>
        /// <returns>The requested parameter.</returns>
        public string LightLED(Int32 requestedParameter)
        {
            const uint ON  = 1;
            const uint OFF = 0;

            lastStateOnRequest = GPIOinterface.readPin(GPIO_PIN_ID);

            if (requestedParameter == ON)
            {
                Debug.WriteLine("Received command LightLED On!");
                currentState = switch_LED_ToState(ON);
            }
            else if (requestedParameter == OFF)
            {
                Debug.WriteLine("Received command LightLED Off!");
                currentState = switch_LED_ToState(OFF);
            }

            Debug.WriteLine(string.Format("Current Value of Pin {0} for writing LED is: {1} and was when requested {2} \n",
                                          GPIO_PIN_ID, currentState, lastStateOnRequest));

            return(requestedParameter.ToString());
        }
コード例 #6
0
 /// <summary>
 /// Executes the Command ResetPin
 /// </summary>
 /// <param name="parameter">represents the GpioPin which shall be reset</param>
 /// <returns>The current state of the deactivated pin represented as string. Should evaluate to "Low".</returns>
 public string ResetPin(UInt16 id)
 {
     GPIOinterface.deactivatePin(id);
     return(GPIOinterface.readPin(id).ToString());
 }
コード例 #7
0
        /// <summary>
        /// Reads pin from GPIOInterface
        /// </summary>
        /// <param name="parameter">represents the GpioPin to read from</param>
        /// <returns>The current state of the requested pin represented as string.</returns>
        public string ReadPin(UInt16 id)
        {
            string currentState = GPIOinterface.readPin(id);

            return(currentState.ToString());
        }
コード例 #8
0
        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)));
        }