/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Opens the port. Throws an exception on failure /// /// </summary> protected override void OpenPort() { string deviceFileName; // set up now deviceFileName = Definitions.A2DIIO_FILENAME; if (Nr > -1 && Nr < 7) { deviceFileName = deviceFileName.Replace("%port%", Nr.ToString()); } else { throw new Exception("Unknown A2D Port:" + Nr.ToString()); } // we open the file. a2dStream = File.Open(deviceFileName, FileMode.Open); if (a2dStream == null) { throw new Exception("Could not open a2d device file:" + deviceFileName); } // we open the reader a2dReader = new StreamReader(a2dStream); PortIsOpen = true; // Console.WriteLine("A2DPort Port Device Enabled: "+ deviceFileName); }
/// <summary> /// Generates XAML for the markdown element. /// </summary> /// <param name="Output">XAML will be output here.</param> /// <param name="TextAlignment">Alignment of text in element.</param> public override void GenerateXAML(XmlWriter Output, TextAlignment TextAlignment) { if (this.Document.TryGetFootnoteNumber(this.key, out int Nr)) { XamlSettings Settings = this.Document.Settings.XamlSettings; string s; Output.WriteStartElement("TextBlock"); Output.WriteAttributeString("Text", Nr.ToString()); Output.WriteStartElement("TextBlock.LayoutTransform"); Output.WriteStartElement("TransformGroup"); Output.WriteStartElement("ScaleTransform"); Output.WriteAttributeString("ScaleX", s = CommonTypes.Encode(Settings.SuperscriptScale)); Output.WriteAttributeString("ScaleY", s); Output.WriteEndElement(); Output.WriteStartElement("TranslateTransform"); Output.WriteAttributeString("Y", Settings.SuperscriptOffset.ToString()); Output.WriteEndElement(); Output.WriteEndElement(); Output.WriteEndElement(); Output.WriteEndElement(); } }
/// <summary> /// Generates plain text for the markdown element. /// </summary> /// <param name="Output">Plain text will be output here.</param> public override void GeneratePlainText(StringBuilder Output) { if (this.Document.TryGetFootnoteNumber(this.key, out int Nr)) { Output.Append(" ["); Output.Append(Nr.ToString()); Output.Append("]"); } }
/// <summary> /// Exports the element to XML. /// </summary> /// <param name="Output">XML Output.</param> public override void Export(XmlWriter Output) { Output.WriteStartElement("FootnoteReference"); if (this.Document.TryGetFootnoteNumber(this.key, out int Nr)) { Output.WriteAttributeString("nr", Nr.ToString()); } else { Output.WriteAttributeString("key", this.key); } Output.WriteEndElement(); }
/// <summary> /// Generates HTML for the markdown element. /// </summary> /// <param name="Output">HTML will be output here.</param> public override void GenerateHTML(StringBuilder Output) { string s; if (this.Document.TryGetFootnoteNumber(this.key, out int Nr)) { s = Nr.ToString(); Output.Append("<sup id=\"fnref-"); Output.Append(s); Output.Append("\"><a href=\"#fn-"); Output.Append(s); Output.Append("\" class=\"footnote-ref\">"); Output.Append(s); Output.Append("</a></sup>"); } }
public override string ToString() { return(Nr.ToString() + " " + Fname + " " + Lname + " " + Age.ToString()); }
/// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= /// <summary> /// Closes the port. Throws an exception on failure, including if the port is /// already closed /// /// This is really just doing the equivalent of a shell command /// echo <gpioID> > /sys/class/gpio/unexport /// after which the /sys/class/gpio/gpio<gpioID> directory should not exist. public virtual void ClosePort() { if (openedInternally) { // do the close try { if (System.IO.Directory.Exists(Definitions.SYSFS_GPIODIR + Definitions.SYSFS_GPIODIRNAMEBASE + Nr)) { System.IO.File.WriteAllText(Definitions.SYSFS_GPIODIR + Definitions.SYSFS_GPIOUNEXPORT, Nr.ToString()); } } catch { } } }
protected virtual void OpenPort() { // do the open try { ValuePath = Definitions.SYSFS_GPIODIR + Definitions.SYSFS_GPIODIRNAMEBASE + Nr + "/" + Definitions.SYSFS_GPIOVALUE; if (!System.IO.Directory.Exists(Definitions.SYSFS_GPIODIR + Definitions.SYSFS_GPIODIRNAMEBASE + Nr)) { System.IO.File.WriteAllText(Definitions.SYSFS_GPIODIR + Definitions.SYSFS_GPIOEXPORT, Nr.ToString()); openedInternally = true; } } catch (Exception err) { Console.WriteLine("Failed to export GPIO " + Nr + " -> " + err.ToString()); } }
public override string ToString() => Nr.ToString();