예제 #1
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <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);
        }
예제 #2
0
        /// <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();
            }
        }
예제 #3
0
 /// <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("]");
     }
 }
예제 #4
0
        /// <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();
        }
예제 #5
0
        /// <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>");
            }
        }
예제 #6
0
 public override string ToString()
 {
     return(Nr.ToString() + " " + Fname + " " + Lname + " " + Age.ToString());
 }
예제 #7
0
        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <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
                {
                }
            }
        }
예제 #8
0
        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());
            }
        }
예제 #9
0
 public override string ToString() => Nr.ToString();