ReadTo


Node Information
Reads up to the specified value in the input buffer.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
SerialPort IN SerialPort ONE FALSE FALSE
Value IN String ONE FALSE FALSE
Result OUT String MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.SerialPort
{
    [IsNode("ReadTo")]
    public class ReadTo : Node
    {
        Port serial = new Port(PortType.IN, typeof(System.IO.Ports.SerialPort), AcceptsLinks.ONE, "SerialPort");
        Port val = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Value");
        Port outdata = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Result");
        public ReadTo()
        {
            Name = "ReadTo";
            NodeType = KGraph.NodeType.Function;
            AddPort(serial);
            AddPort(val);
            AddPort(outdata);
            Information = "Reads up to the specified value in the input buffer.";
        }
        public override string Code()
        {
            return "return " + GetValue(serial) + ".ReadTo(" + GetValue(val) + ")";
        }
        public override void UpdateResults()
        {
            if (!serial.IsConnected)
            {
                ErrorMessage = "No Serial Port is connected.";
                Status = NodeStatus.ERROR;
                return;
            }
            else
            {
                Status = NodeStatus.OK;
            }
        }
    }
}