/// <summary> /// Execute presssing one rockerswitch /// </summary> /// <param name="rsw">expected "up" ord "down"</param> /// <param name="durationCategorie">expected string defined in <see cref="DurationConfig"/></param> /// <returns>content of rsw+(duration) </returns> public string PressRockerSwitch(string rsw, string durationCategorie) { if (rsw == null || durationCategorie == null) { throw new Exception("Received invalid paremeterlist"); } int duration = DurationConfig.getDuration(durationCategorie); Debug.WriteLine("\n Execute {0} with Parameter {3} duration {1}({2}) \n", this.GetType().Name, durationCategorie, duration, rsw); UInt16 pushButton_Pin; if (rsw == "down") { pushButton_Pin = GpioMap.rockerSwitchDownPin; } else if (rsw == "up") { pushButton_Pin = GpioMap.rockerSwitchUpPin; } else { throw new Exception("Invalid Rockerswitch submitted"); } GPIOinterface.activatePin(pushButton_Pin); Task.Delay(duration).Wait(); GPIOinterface.deactivatePin(pushButton_Pin); return(rsw + "(" + duration + ")"); }
/// <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); }
private void pressRockerSwitch(UInt16 pin, int ticks) { for (int i = 0; i < ticks; ++i) { GPIOinterface.activatePin(pin); Task.Delay(1000).Wait(); GPIOinterface.deactivatePin(pin); Task.Delay(1000).Wait(); } }
/// <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)); }
/// <summary> /// Executes the Command PressPushButton. For this the respective Pushbutton is activated and deactivated after /// a user-provided duration using the raspberry-class methods. /// </summary> /// <param name="durationCategorie">expected string defined in <see cref="DurationConfig"/> </param> /// <returns>The provided duration as string</returns> public string PressPushButton(string durationCategorie) { int duration = DurationConfig.getDuration(durationCategorie); Debug.WriteLine("\n Execute {0} with Parameters duration {1}({2}) \n", this.GetType().Name, durationCategorie, duration); GPIOinterface.activatePin(pushButton_Pin); Task.Delay(duration).Wait(); GPIOinterface.deactivatePin(pushButton_Pin); return(duration.ToString()); }
/// <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)); }
/// <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)); }
/// <summary> /// Method can be used to trigger combinations as wished. For now it activats multiple pins at the same time. /// Currently we use 3 buttons: rockerswitch_down, rockerswitch_up and pushbutton. /// </summary> /// <param name="pb">"PB" to activate Pushbutton otherwise NULL</param> /// <param name="rsu">"RSU" to activate RockerSwitchUP otherwise NULL</param> /// <param name="rsd">"RSD" to activate RockerSwitchDown otherwise NULL</param> /// <param name="durationCategorie">expected string defined in <see cref="DurationConfig"/> </param> /// <returns>provided duration</returns> public string PressCombination(string pb, string rsu, string rsd, string durationCategorie) { int duration = DurationConfig.getDuration(durationCategorie); Debug.WriteLine("\n Execute {0} with Parameters PB={1}, RSD={2}, RSU={3} and duration {4}({5}) \n", this.GetType().Name, pb, rsd, rsu, durationCategorie, duration); if (pb == null && rsd == null && rsu == null && durationCategorie == null) { throw new Exception("Invalid parameterlist received"); } if (rsd == "RSD" & rsu == "RSU") { throw new Exception("Tester tried to press both rockerswitches in combination"); } if (pb == "PB") { GPIOinterface.activatePin(GpioMap.pushButton_Pin); } if (rsu == "RSU" & rsd == null) { GPIOinterface.activatePin(GpioMap.rockerSwitchUpPin); } if (rsd == "RSD" & rsu == null) { GPIOinterface.activatePin(GpioMap.rockerSwitchDownPin); } Task.Delay(duration).Wait(); GPIOinterface.deactivatePin(GpioMap.pushButton_Pin); GPIOinterface.deactivatePin(GpioMap.rockerSwitchDownPin); GPIOinterface.deactivatePin(GpioMap.rockerSwitchUpPin); return(duration.ToString()); }
/// <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()); }
/// <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()); }
/// <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()); }
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))); }