New SerialPort


Node Information
Creates a new Serial Port.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
New IN RUN MULTIPLE FALSE FALSE
Open IN RUN MULTIPLE FALSE FALSE
Close IN RUN MULTIPLE FALSE FALSE
SerialPort OUT SerialPort MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.SerialPort
{
    [IsNode("New Serial Port")]
    public class SerialPort : Node
    {
        Port createNew = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "New");
        Port open = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Open");
        Port close = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Close");
        Port serial = new Port(PortType.OUT, typeof(System.IO.Ports.SerialPort), AcceptsLinks.MULTIPLE, "SerialPort");
        public SerialPort()
        {
            NodeType = KGraph.NodeType.Variable;
            ReturnType = typeof(System.IO.Ports.SerialPort);
            Name = "New SerialPort";
            AddPort(createNew);
            AddPort(open);
            AddPort(close);
            AddPort(serial);
            Information = "Creates a new Serial Port.";
        }
        public override string Code()
        {
            return "null";
        }
        public override string ConstructorCode()
        {
            return this.ID + " = new System.IO.Ports.SerialPort();";
        }
        public override void UpdateResults()
        {
            createNew.Instructions = this.ID + " = new System.IO.Ports.SerialPort();\r\n";
            serial.Instructions = this.ID;
            open.Instructions = this.ID + ".Open();";
            close.Instructions = this.ID + ".Close();";
        }
    }
}