Set Properties


Node Information
Sets properties of the specified Serial Port.
General Information
• This node has other options, you can view them by clicking on the info button, this also means according to the node you might be able to add more ports than what is already listed.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Set IN RUN ONE FALSE FALSE
SerialPort IN SerialPort ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.SerialPort
{
    [IsNode("Set Properties")]
    public class SetProperties : Node
    {
        Port set = new Port(PortType.IN, typeof(RUN), AcceptsLinks.ONE, "Set");
        Port serial = new Port(PortType.IN, typeof(System.IO.Ports.SerialPort), AcceptsLinks.ONE, "SerialPort");
        public SetProperties()
        {
            NodeType = KGraph.NodeType.Method;
            Name = "Set Properties";
            AddPort(set);
            AddPort(serial);
            OptionsAvilable = true;
            Information = "Sets properties of the specified Serial Port.";
            InfoContextMenu = GetTypePropertiesMenu(typeof(System.IO.Ports.SerialPort), true);
        }
        public override void OnTypePropertySelected(System.Reflection.PropertyInfo opi)
        {
            Port port = new Port(PortType.IN, opi.PropertyType, AcceptsLinks.ONE, opi.Name, true);
            port.IsRemovable = true;
            AddPort(port);
        }
        public override string Code()
        {
            string serialvalue = GetValue(serial);
            string code = string.Empty;
            foreach (var port in Ports)
            {
                if (port.IsExtra)
                {
                    code += serialvalue + "." + port.Text + " = " + GetValue(port) + ";\r\n";
                }
            }
            return code;
        }
        public override void UpdateResults()
        {
            if (!serial.IsConnected)
            {
                ErrorMessage = "No Serial Port is connected.";
                Status = NodeStatus.ERROR;
            }
            else
            {
                Status = NodeStatus.OK;
            }
        }
    }
}