예제 #1
0
 public PortId(string owningNode, int portIndex, PortType type)
     : this()
 {
     this.OwningNode = owningNode;
     this.PortIndex = portIndex;
     this.PortType = type;
 }
예제 #2
0
 public Port(ComponentBase parentFunclet, int x, int y, PortType pType)
 {
     area = new Rectangle(x, y, Config.PORT_D, Config.PORT_D);
     this.pType = pType;
     this.parentComponent = parentFunclet;
     this.ComponentType = ComponentType.Port;
 }
예제 #3
0
 public static IClientPort Create(PortType type)
 {
     switch (type)
     {
         case PortType.Serial: return new Implementation.Client.Serial();
         default: throw new NotImplementedException();
     }
 }
예제 #4
0
 public PortUtil(string usbVid, string usbPid, string endpointId)
 {
     Int32 vid = Int32.Parse(usbVid, NumberStyles.HexNumber);
     Int32 pid = Int32.Parse(usbPid, NumberStyles.HexNumber);
     _usbFinder = new UsbDeviceFinder(vid, pid);
     _endpointId = GetEndpointId(endpointId);
     _portType = PortType.USB;
 }
예제 #5
0
 public dynPortModel(int index, PortType portType, dynNodeModel owner, string name)
 {
     Index = index;
     IsConnected = false;
     PortType = portType;
     Owner = owner;
     PortName = name;
 }
예제 #6
0
        public override void WriteToXML(XElement root)
        {
            XElement xmldatatype = new XElement("PortDefenition");

            base.WriteToXML(xmldatatype);
            xmldatatype.Add(new XElement("InterfaceGUID", InterfaceGUID.ToString("B")));
            xmldatatype.Add(new XElement("PortType", PortType.ToString()));
            root.Add(xmldatatype);
        }
예제 #7
0
        public PortDefenition CreatePortDefenition(string Name, PortType portType)
        {
            PortDefenition portDef = new PortDefenition();

            portDef.Name     = Name;
            portDef.PortType = portType;
            portDef.GUID     = Guid.NewGuid();
            return(portDef);
        }
예제 #8
0
 /// <summary>
 ///     检查端口是否是保留端口
 /// </summary>
 /// <param name="port">端口</param>
 /// <param name="type">端口类型</param>
 /// <returns>是否是保留端口</returns>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 private static bool IsPortExcluded(int port, PortType type)
 {
     return(type switch
     {
         PortType.TCP => TCPExcludedRanges.Any(range => range[0] <= port && port <= range[1]),
         PortType.UDP => UDPExcludedRanges.Any(range => range[0] <= port && port <= range[1]),
         PortType.Both => IsPortExcluded(port, PortType.TCP) || IsPortExcluded(port, PortType.UDP),
         _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
     });
예제 #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="port"></param>
 /// <param name="portName"></param>
 /// <param name="portType"></param>
 /// <returns>端口是否被占用</returns>
 private static bool PortCheckAndShowMessageBox(int port, string portName, PortType portType = PortType.Both)
 {
     if (!PortHelper.PortInUse(port, portType))
     {
         return(false);
     }
     MessageBoxX.Show(i18N.TranslateFormat("The {0} port is in use.", portName));
     return(true);
 }
예제 #10
0
 internal PortStatus(PortType type, int value0 = 0, int value1 = 0, int value2 = 0, int value3 = 0, int value4 = 0)
 {
     Type        = type;
     this.value0 = value0;
     this.value1 = value1;
     this.value2 = value2;
     this.value3 = value3;
     this.value4 = value4;
 }
예제 #11
0
        public static IClientPort Create(PortType type)
        {
            switch (type)
            {
            case PortType.Serial: return(new Implementation.Client.Serial());

            default: throw new NotImplementedException();
            }
        }
예제 #12
0
    public static void Main()
    {
        try
        {
// <Snippet1>
// <Snippet2>
// <Snippet3>
// <Snippet4>
            ServiceDescription myServiceDescription =
                ServiceDescription.Read("MathService_CS.wsdl");

            PortTypeCollection myPortTypeCollection =
                myServiceDescription.PortTypes;
            int noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: " + noOfPortTypes);

            PortType myNewPortType = myPortTypeCollection["MathServiceSoap"];

// </Snippet4>
            // Get the index in the collection.
            int index = myPortTypeCollection.IndexOf(myNewPortType);
// </Snippet3>
            Console.WriteLine("Removing the PortType named "
                              + myNewPortType.Name);

            // Remove the PortType from the collection.
            myPortTypeCollection.Remove(myNewPortType);
            noOfPortTypes = myServiceDescription.PortTypes.Count;
            Console.WriteLine("\nTotal number of PortTypes: "
                              + noOfPortTypes);

            // Check whether the PortType exists in the collection.
            bool bContains = myPortTypeCollection.Contains(myNewPortType);
            Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: "
                              + bContains);

            Console.WriteLine("Adding the PortType");
            // Insert a new portType at the index location.
            myPortTypeCollection.Insert(index, myNewPortType);
// </Snippet2>

            // Display the number of portTypes after adding a port.
            Console.WriteLine("Total number of PortTypes after "
                              + "adding a new port: " + myServiceDescription.PortTypes.Count);

            bContains = myPortTypeCollection.Contains(myNewPortType);
            Console.WriteLine("Port Type'" + myNewPortType.Name + "' exists: "
                              + bContains);
            myServiceDescription.Write("MathService_New.wsdl");
// </Snippet1>
        }
        catch (Exception e)
        {
            Console.WriteLine("Exception: " + e.Message);
        }
    }
예제 #13
0
 public static UInt16 Count(this PortType type)
 {
     return(type switch
     {
         PortType.Invalid => 1,
         PortType.System => 1024,
         PortType.Register => 48128,
         PortType.Dynamic => 16384,
         _ => throw new NotSupportedException()
     });
예제 #14
0
 /// <summary>
 /// Factory method to create a connector.  Checks to make sure that the start and end ports are valid, 
 /// otherwise returns null.
 /// </summary>
 /// <param name="start">The port where the connector starts</param>
 /// <param name="end">The port where the connector ends</param>
 /// <param name="startIndex"></param>
 /// <param name="endIndex"></param>
 /// <param name="portType"></param>
 /// <returns>The valid connector model or null if the connector is invalid</returns>
 internal static ConnectorModel Make(WorkspaceModel workspaceModel, NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
 {
     if (workspaceModel != null && start != null && end != null && start != end && startIndex >= 0
         && endIndex >= 0 && start.OutPorts.Count > startIndex && end.InPorts.Count > endIndex )
     {
         return new ConnectorModel(workspaceModel, start, end, startIndex, endIndex, portType);
     }
     
     return null;
 }
예제 #15
0
 public void UpdatePortsType(Module module, IList <string> ports, PortType portType)
 {
     foreach (var modulePort in module.Ports)
     {
         if (ports.Contains(modulePort.PortName))
         {
             modulePort.PortType = portType;
         }
     }
 }
예제 #16
0
 public dynPortModel(int index, PortType portType, dynNodeModel owner, string name)
 {
     Index               = index;
     IsConnected         = false;
     PortType            = portType;
     Owner               = owner;
     PortName            = name;
     UsingDefaultValue   = false;
     DefaultValueEnabled = false;
 }
예제 #17
0
 /// <summary>
 /// Factory method to create a connector.  Checks to make sure that the start and end ports are valid, 
 /// otherwise returns null.
 /// </summary>
 /// <param name="start">The port where the connector starts</param>
 /// <param name="end">The port where the connector ends</param>
 /// <param name="startIndex"></param>
 /// <param name="endIndex"></param>
 /// <param name="portType"></param>
 /// <returns>The valid connector model or null if the connector is invalid</returns>
 public static ConnectorModel Make(NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
 {
     if (start != null && end != null && start != end && startIndex >= 0
         && endIndex >= 0 && start.OutPorts.Count > startIndex && end.InPorts.Count > endIndex )
     {
         return new ConnectorModel(start, end, startIndex, endIndex, portType);
     }
     
     return null;
 }
예제 #18
0
            internal static MakeConnectionCommand DeserializeCore(XmlElement element)
            {
                XmlElementHelper helper = new XmlElementHelper(element);
                Guid             nodeId = helper.ReadGuid("NodeId");
                int      portIndex      = helper.ReadInteger("PortIndex");
                PortType portType       = ((PortType)helper.ReadInteger("Type"));
                Mode     mode           = ((Mode)helper.ReadInteger("ConnectionMode"));

                return(new MakeConnectionCommand(nodeId, portIndex, portType, mode));
            }
예제 #19
0
    private int EnumeratePorts(PortType portType)
    {
        RegistryKey hKey = Registry.LocalMachine.OpenSubKey("Drivers\\Active");

        if (hKey != null)
        {
            string [] subKeyNames = hKey.GetSubKeyNames();

            foreach (string szKeyName in subKeyNames)
            {
                RegistryKey hKey2 = hKey.OpenSubKey(szKeyName);

                if (hKey2 != null)
                {
                    string strDriverName   = string.Empty;
                    string strDriverKey    = string.Empty;
                    string strFriendlyName = string.Empty;

                    strDriverName = hKey2.GetValue("Name", string.Empty).ToString();
                    strDriverKey  = hKey2.GetValue("Key", string.Empty).ToString();

                    hKey2.Close();

                    // Check if this is a COM port
                    if (strDriverName.StartsWith("COM"))
                    {
                        hKey2 = Registry.LocalMachine.OpenSubKey(strDriverKey);

                        if (hKey2 != null)
                        {
                            strFriendlyName = hKey2.GetValue("FriendlyName", string.Empty).ToString();
                            hKey2.Close();
                        }

                        if ((PortTypeString[(int)portType].Length == 0) ||
                            strFriendlyName.StartsWith(PortTypeString[(int)portType], StringComparison.CurrentCultureIgnoreCase))
                        {
                            CSerialPortInfo pInfo = new CSerialPortInfo(strDriverName, strFriendlyName);
                            Add(pInfo);
                        }
                    }
                }
            }

            hKey.Close();
        }

        //read bluetooth ports only if type is bluetooth
        if ((PortType.Bluetooth == portType) || (PortType.All == portType))
        {
            AddMsBtPorts();
        }

        return(this.Count);
    }
예제 #20
0
        private static void GetExcludedPortRange(PortType portType, ref List <int[]> targetList)
        {
            var lines   = new List <string>();
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName  = "netsh",
                    Arguments = $" int ipv4 show excludedportrange {portType}",
                    RedirectStandardOutput = true,
                    UseShellExecute        = false,
                    CreateNoWindow         = true
                }
            };

            process.OutputDataReceived += (s, e) =>
            {
                if (e.Data != null)
                {
                    lines.Add(e.Data);
                }
            };
            process.Start();
            process.BeginOutputReadLine();
            process.WaitForExit();

            var splitLine = false;

            foreach (var line in lines)
            {
                if (!splitLine)
                {
                    if (line.StartsWith("-"))
                    {
                        splitLine = true;
                    }
                }
                else
                {
                    if (line == string.Empty)
                    {
                        break;
                    }

                    var value = line.Trim().Split(' ').Where(s => s != string.Empty);

                    var port = 0;
                    var _    = (from s1 in value
                                where int.TryParse(s1, out port)
                                select port).ToArray();

                    targetList.Add(_);
                }
            }
        }
예제 #21
0
        void DoImportContract()
        {
            PortType            port_type = context.WsdlPortType;
            ContractDescription contract = context.Contract;
            int i, j;
            List <MessagePartDescription> parts = new List <MessagePartDescription> ();

            i = 0;
            foreach (Operation op in port_type.Operations)
            {
                OperationDescription opdescr = contract.Operations [i];

                j = 0;
                foreach (OperationMessage opmsg in op.Messages)
                {
                    //SM.MessageDescription
                    MessageDescription msgdescr = opdescr.Messages [j];

                    //OpMsg's corresponding WSMessage
                    Message msg = port_type.ServiceDescription.Messages [opmsg.Message.Name];

                    msgdescr.Body.WrapperNamespace = port_type.ServiceDescription.TargetNamespace;

                    if (opmsg is OperationOutput)
                    {
                        //ReturnValue
                        msg = port_type.ServiceDescription.Messages [opmsg.Message.Name];

                        resolveMessage(msg, msgdescr.Body, parts);
                        if (parts.Count > 0)
                        {
                            msgdescr.Body.ReturnValue = parts [0];
                            parts.Clear();
                        }
                        continue;
                    }

                    /* OperationInput */

                    /* Parts, MessagePartDescription */
                    resolveMessage(msg, msgdescr.Body, parts);
                    foreach (MessagePartDescription p in parts)
                    {
                        msgdescr.Body.Parts.Add(p);
                    }
                    parts.Clear();

                    j++;
                }


                i++;
            }
        }
예제 #22
0
        public CodeGenListInputViewModel(PortType type)
        {
            this.Port = new CodeGenPortViewModel {
                PortType = type
            };

            if (type == PortType.Execution)
            {
                this.PortPosition = PortPosition.Right;
            }
        }
예제 #23
0
 public IPortClient GetClient(PortType portType)
 {
     if (portType == PortType.TCP)
     {
         return(new TCPPortClient());
     }
     else
     {
         return(new UDPPortClient());
     }
 }
예제 #24
0
 public void PortError(PortType type)
 {
     if (type == PortType.TCP)
     {
         _tcpIcon.Image = Properties.Resources.connection_off;
     }
     else
     {
         _serialIcon.Image = Properties.Resources.connection_off;
     }
 }
예제 #25
0
 public OutputDeviceDescriptor(int id, string name, PortType portType, BitArray wChannelMask, uint driverVersion,
                               int manufacturerId, int productId)
 {
     this.id             = id;
     this.name           = name;
     this.portType       = portType;
     this.wChannelMask   = wChannelMask;
     this.driverVersion  = driverVersion;
     this.manufacturerId = manufacturerId;
     this.productId      = productId;
 }
예제 #26
0
파일: Parser.cs 프로젝트: zorroroot/WSSAT
        public List <WSOperation> GetOperations()
        {
            List <WSOperation> lst = new List <WSOperation>();

            if (serviceDescription != null)
            {
                foreach (Service ser in serviceDescription.Services)
                {
                    String webServiceName = ser.Name.ToString();
                    foreach (Port port in ser.Ports)
                    {
                        string  portName = port.Name;
                        string  binding  = port.Binding.Name;
                        Binding bind     = bindColl[binding];

                        if (bind != null)
                        {
                            PortType portTyp = portTypColl[bind.Type.Name];

                            foreach (Operation op in portTyp.Operations)
                            {
                                WSOperation operObj = new WSOperation();
                                operObj.ClassName  = webServiceName;
                                operObj.MethodName = op.Name;

                                if (lst.Where(it => it.ClassName.Equals(operObj.ClassName) && it.MethodName.Equals(operObj.MethodName)).Count() == 0)
                                {
                                    OperationMessageCollection opMsgColl = op.Messages;
                                    OperationInput             opInput   = opMsgColl.Input;
                                    OperationOutput            opOutput  = opMsgColl.Output;
                                    string inputMsg  = opInput.Message.Name;
                                    string outputMsg = opOutput.Message.Name;

                                    Message            msgInput   = msgColl[inputMsg];
                                    List <WSParameter> InputParam = GetParameters(msgInput);

                                    Message            msgOutput    = msgColl[outputMsg];
                                    List <WSParameter> OutputParams = GetParameters(msgOutput);

                                    operObj.Parameters = InputParam;
                                    if (OutputParams != null && OutputParams.Count > 0)
                                    {
                                        operObj.ReturnType = OutputParams[0].TypeName;
                                    }

                                    lst.Add(operObj);
                                }
                            }
                        }
                    }
                }
            }
            return(lst);
        }
예제 #27
0
        private static ConditionResult CheckPort(RequestProcess process, PortType portType)
        {
            switch (process.User.GetPredicate("BombPort" + portType).ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedPort" + portType));
            }
        }
예제 #28
0
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType    = portType;
            Owner       = owner;

            SetPortData(data);

            MarginThickness = new Thickness(0);
            Height          = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #29
0
파일: Port.cs 프로젝트: residuum/JackSharp
 internal unsafe Port(UnsafeStructs.jack_client_t*jackClient, int index, Direction direction, PortType portType, string nameFormat)
 {
     if (nameFormat == null) {
         nameFormat = "{type}{direction}_{index}";
     }
     _jackClient = jackClient;
     Direction = direction;
     Name = CreateName (nameFormat, index, direction, portType);
     PortType = portType;
     _port = RegisterPort (direction, portType);
 }
예제 #30
0
        public CodeGenOutputViewModel(PortType type)
        {
            this.Port = new CodeGenPortViewModel {
                PortType = type
            };

            if (type == PortType.Execution)
            {
                this.PortPosition = PortPosition.Left;
            }
        }
예제 #31
0
 protected override bool CanImportOperation(PortType portType, Operation op)
 {
     foreach (OperationMessage om in op.Messages)
     {
         if (!dc_importer.CanImport(schema_set_in_use, om.Message))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #32
0
파일: PortModel.cs 프로젝트: vtaran/Dynamo
 public PortModel(PortType portType, NodeModel owner, string name)
 {
     IsConnected         = false;
     PortType            = portType;
     Owner               = owner;
     PortName            = name;
     UsingDefaultValue   = false;
     DefaultValueEnabled = false;
     MarginThickness     = new Thickness(0);
     this.Height         = Configurations.PortHeightInPixels;
 }
예제 #33
0
        public Port(Microchip microchip, PortType portType, Int2 localPosition, Int2 localDirection)
        {
            this.microchip = microchip;
            this.portType  = portType;

            this.localPosition  = localPosition;
            this.localDirection = localDirection;

            Assert.IsTrue(localDirection.Absoluted.MinComponent == 0);
            Assert.IsTrue(localDirection.Absoluted.MaxComponent == 1);
        }
예제 #34
0
 public Port findPort(PortType type)
 {
     foreach (Port port in ports)
     {
         if (port.PortType.Equals(type))
         {
             return(port);
         }
     }
     return(null);
 }
예제 #35
0
        void EndConnection(Guid nodeId, int portIndex, PortType portType)
        {
            bool isInPort = portType == PortType.INPUT;

            NodeModel node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel;

            if (node == null)
            {
                return;
            }

            PortModel      portModel         = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex];
            ConnectorModel connectorToRemove = null;

            // Remove connector if one already exists
            if (portModel.Connectors.Count > 0 && portModel.PortType == PortType.INPUT)
            {
                connectorToRemove = portModel.Connectors[0];
                CurrentWorkspace.Connectors.Remove(connectorToRemove);
                portModel.Disconnect(connectorToRemove);
                var startPort = connectorToRemove.Start;
                startPort.Disconnect(connectorToRemove);
            }

            // We could either connect from an input port to an output port, or
            // another way around (in which case we swap first and second ports).
            PortModel firstPort, second;

            if (portModel.PortType != PortType.INPUT)
            {
                firstPort = portModel;
                second    = activeStartPort;
            }
            else
            {
                // Create the new connector model
                firstPort = activeStartPort;
                second    = portModel;
            }

            ConnectorModel newConnectorModel = CurrentWorkspace.AddConnection(firstPort.Owner,
                                                                              second.Owner, firstPort.Index, second.Index, PortType.INPUT);

            // Record the creation of connector in the undo recorder.
            var models = new Dictionary <ModelBase, UndoRedoRecorder.UserAction>();

            if (connectorToRemove != null)
            {
                models.Add(connectorToRemove, UndoRedoRecorder.UserAction.Deletion);
            }
            models.Add(newConnectorModel, UndoRedoRecorder.UserAction.Creation);
            CurrentWorkspace.RecordModelsForUndo(models);
            activeStartPort = null;
        }
예제 #36
0
 internal WsdlContractConversionContext(ContractDescription contract, PortType wsdlPortType)
 {
     this.contract              = contract;
     this.wsdlPortType          = wsdlPortType;
     this.wsdlOperations        = new Dictionary <OperationDescription, Operation>();
     this.operationDescriptions = new Dictionary <Operation, OperationDescription>();
     this.wsdlOperationMessages = new Dictionary <MessageDescription, OperationMessage>();
     this.messageDescriptions   = new Dictionary <OperationMessage, MessageDescription>();
     this.wsdlOperationFaults   = new Dictionary <FaultDescription, OperationFault>();
     this.faultDescriptions     = new Dictionary <OperationFault, FaultDescription>();
     this.operationBindings     = new Dictionary <Operation, Collection <OperationBinding> >();
 }
예제 #37
0
 public ScheminPort(Stream stream, PortType type)
 {
     this.Type = type;
     if (type == PortType.InputPort)
     {
         this.InputStream = new StreamReader(stream, Encoding.UTF8);
     }
     else
     {
         this.OutputStream = new StreamWriter(stream, Encoding.UTF8);
     }
 }
예제 #38
0
        public Edge(IEdgeModel edgeModel) : this()
        {
            m_EdgeModel = edgeModel;

            capabilities = VseUtility.ConvertCapabilities(m_EdgeModel);

            PortType portType = m_EdgeModel?.OutputPortModel?.PortType ?? PortType.Data;

            EnableInClassList("execution", portType == PortType.Execution || portType == PortType.Loop);
            EnableInClassList("event", portType == PortType.Event);
            viewDataKey = m_EdgeModel?.GetId();
        }
예제 #39
0
 public virtual void SerializeNetwork(XmlWriter xmlWriter)
 {
     xmlWriter.WriteStartAttribute("Id");
     xmlWriter.WriteValue(Id.ToString());
     xmlWriter.WriteEndAttribute();
     xmlWriter.WriteStartAttribute("PortType");
     xmlWriter.WriteValue(PortType.ToString());
     xmlWriter.WriteEndAttribute();
     xmlWriter.WriteStartAttribute("ParentNodeId");
     xmlWriter.WriteValue(ParentNode.Guid.ToString());
     xmlWriter.WriteEndAttribute();
 }
예제 #40
0
        private ConnectorModel(WorkspaceModel workspaceModel, NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            this.workspaceModel = workspaceModel;

            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

            if (portType == PortType.INPUT)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
        }
예제 #41
0
        /// <summary>
        /// Doc tai lieu "Ve Port.docx"
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="pType"></param>
        public Port(ComponentBase parent, PortType pType)
        {
            this.ParentComponent = parent;

            Dictionary<string, Point> getPoint = GetPointFromParent(parent);
            if (pType == PortType.Input)
                area = new Rectangle(getPoint["2c"].X, getPoint["2c"].Y, Config.PORT_D, Config.PORT_D);
            else
                area = new Rectangle(getPoint["1c"].X, getPoint["1c"].Y, Config.PORT_D, Config.PORT_D);

            this.pType = pType;
            this.parentComponent = parent;
            this.ComponentType = ComponentType.Port;
        }
예제 #42
0
        private ConnectorModel(NodeModel start, NodeModel end, int startIndex, int endIndex, PortType portType)
        {
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            pStart = start.OutPorts[startIndex];

            PortModel endPort = null;

            if (portType == PortType.INPUT)
                endPort = end.InPorts[endIndex];

            pStart.Connect(this);
            this.Connect(endPort);
            //sw.Stop();
            //Debug.WriteLine(string.Format("{0} elapsed for constructing connector.", sw.Elapsed));
        }
예제 #43
0
        internal void BeginConnection(Guid nodeId, int portIndex, PortType portType)
        {
            int index = portIndex;
            bool isInPort = portType == PortType.INPUT;

            NodeModel node = _model.GetModelInternal(nodeId) as NodeModel;
            PortModel portModel = isInPort ? node.InPorts[index] : node.OutPorts[index];

            // Test if port already has a connection, if so grab it and begin connecting
            // to somewhere else (we don't allow the grabbing of the start connector).
            if (portModel.Connectors.Count > 0 && portModel.Connectors[0].Start != portModel)
            {
                // Define the new active connector
                var c = new ConnectorViewModel(portModel.Connectors[0].Start);
                this.SetActiveConnector(c);

                // Disconnect the connector model from its start and end ports
                // and remove it from the connectors collection. This will also
                // remove the view model.
                ConnectorModel connector = portModel.Connectors[0];
                if (_model.Connectors.Contains(connector))
                {
                    List<ModelBase> models = new List<ModelBase>();
                    models.Add(connector);
                    _model.RecordAndDeleteModels(models);
                    connector.NotifyConnectedPortsOfDeletion();
                }
            }
            else
            {
                try
                {
                    // Create a connector view model to begin drawing
                    var connector = new ConnectorViewModel(portModel);
                    this.SetActiveConnector(connector);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }
        }
예제 #44
0
 public static int GetPort(PortType portType)
 {
     var port = 0;
     switch (portType)
     {
         case PortType.Level1:
             port = 5009;
             break;
         case PortType.Lookup:
             port = 9100;
             break;
         case PortType.Level2:
             port = 9200;
             break;
         case PortType.Admin:
             port = 9300;
             break;
     }
     return port;
 }
예제 #45
0
        public dynPort(int index, PortType portType, dynNodeUI owner, string name)
        {
            InitializeComponent();

            Index = index;

            this.MouseEnter += delegate { foreach (var c in connectors) c.Highlight(); };
            this.MouseLeave += delegate { foreach (var c in connectors) c.Unhighlight(); };

            IsConnected = false;

            PortType = portType;
            Owner = owner;
            PortName = name;

            portGrid.DataContext = this;
            portNameTb.DataContext = this;
            toolTipText.DataContext = this;
            ellipse1Dot.DataContext = this;
            ellipse1.DataContext = Owner;

            portGrid.Loaded += new RoutedEventHandler(portGrid_Loaded);
        }
예제 #46
0
        /// <summary>
        /// Add a dynPort element to this control.
        /// </summary>
        /// <param name="isInput">Is the port an input?</param>
        /// <param name="index">The index of the port in the port list.</param>
        public void AddPort(PortType portType, string name, int index)
        {
            if (portType == PortType.INPUT)
            {
                if (inPorts.Count > index)
                {
                    inPortTextBlocks[inPorts[index]].Text = name;
                }
                else
                {
                    dynPort p = new dynPort(index);

                    //create a text block for the name of the port
                    TextBlock tb = new TextBlock();

                    tb.VerticalAlignment = VerticalAlignment.Center;
                    tb.FontSize = 12;
                    tb.FontWeight = FontWeights.Normal;
                    tb.Foreground = new SolidColorBrush(Colors.Black);
                    tb.Text = name;

                    tb.HorizontalAlignment = HorizontalAlignment.Left;

                    Canvas.SetZIndex(tb, 200);

                    p.PortType = PortType.INPUT;
                    inPorts.Add(p);
                    inPortTextBlocks[p] = tb;
                    gridLeft.Children.Add(p);
                    Grid.SetColumn(p, 0);
                    Grid.SetRow(p, index);

                    //portNamesLeft.Children.Add(tb);
                    gridLeft.Children.Add(tb);
                    Grid.SetColumn(tb, 1);
                    Grid.SetRow(tb, index);

                    p.Owner = this;

                    //register listeners on the port
                    p.PortConnected += new PortConnectedHandler(p_PortConnected);
                    p.PortDisconnected += new PortConnectedHandler(p_PortDisconnected);
                }
            }
        }
예제 #47
0
파일: PortModel.cs 프로젝트: whztt07/Dynamo
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType = portType;
            Owner = owner;
            PortName = data.NickName;
            UsingDefaultValue = false;
            DefaultValueEnabled = false;
            MarginThickness = new Thickness(0);

            if (data.Height == 0)
                this.Height = Configurations.PortHeightInPixels;
            else
                this.Height = data.Height;
        }
예제 #48
0
 public MakeConnectionCommand(Guid nodeId, int portIndex, PortType portType, Mode mode)
 {
     NodeId = nodeId;
     PortIndex = portIndex;
     Type = portType;
     ConnectionMode = mode;
 }
예제 #49
0
        void EndConnection(Guid nodeId, int portIndex, PortType portType)
        {
            bool isInPort = portType == PortType.Input;

            var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel;
            if (node == null)
                return;
            
            PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex];
            ConnectorModel connectorToRemove = null;

            // Remove connector if one already exists
            if (portModel.Connectors.Count > 0 && portModel.PortType == PortType.Input)
            {
                connectorToRemove = portModel.Connectors[0];
                connectorToRemove.Delete();
            }

            // We could either connect from an input port to an output port, or 
            // another way around (in which case we swap first and second ports).
            PortModel firstPort, second;
            if (portModel.PortType != PortType.Input)
            {
                firstPort = portModel;
                second = activeStartPort;
            }
            else
            {
                // Create the new connector model
                firstPort = activeStartPort;
                second = portModel;
            }

            ConnectorModel newConnectorModel = ConnectorModel.Make(
                firstPort.Owner,
                second.Owner,
                firstPort.Index,
                second.Index);

            // Record the creation of connector in the undo recorder.
            var models = new Dictionary<ModelBase, UndoRedoRecorder.UserAction>();
            if (connectorToRemove != null)
                models.Add(connectorToRemove, UndoRedoRecorder.UserAction.Deletion);
            models.Add(newConnectorModel, UndoRedoRecorder.UserAction.Creation);
            WorkspaceModel.RecordModelsForUndo(models, CurrentWorkspace.UndoRecorder);
            activeStartPort = null;
        }
        /// <summary>
        /// Gets a list of all port numbers from a device that are not connected on the given end
        /// </summary>
        /// <param name="device">Device to check</param>
        /// <param name="portType">Check input or output ports</param>
        /// <returns>List of int</returns>
        private static List<int> GetOpenPorts(DeviceWrapper device, PortType portType)
        {
            #region Validation
            if (null == device)
            {
                throw new ArgumentNullException("device");
            }

            if (null == device.Feature)
            {
                throw new ArgumentException("device.Class cannot be null");
            }
            #endregion

            List<int> result = new List<int>();

            using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser())
            {
                ESRI.ArcGIS.Geodatabase.IFeatureClass deviceFtClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass;
                ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(deviceFtClass);
                if (null != deviceHasPorts)
                {
                    ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable;
                    if (null != portTable)
                    {
                        ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                        releaser.ManageLifetime(filter);
                        filter.WhereClause = string.Format("{0}='{1}' AND {2} IS NULL AND {3}='{4}'",
                            deviceHasPorts.OriginForeignKey,
                            device.Feature.get_Value(deviceFtClass.FindField(deviceHasPorts.OriginPrimaryKey)),
                            ConfigUtil.ConnectedCableFieldName,
                            ConfigUtil.PortTypeFieldName,
                            (PortType.Input == portType ? "1" : "2"));

                        ESRI.ArcGIS.Geodatabase.ICursor portCursor = portTable.Search(filter, true);
                        ESRI.ArcGIS.Geodatabase.IRow portRow = portCursor.NextRow();
                        int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName);

                        while (null != portRow)
                        {
                            result.Add((int)portRow.get_Value(portIdIdx));

                            ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portRow);
                            portRow = portCursor.NextRow();
                        }

                        ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(portCursor);
                    }
                }
            }

            return result;
        }
예제 #51
0
        internal int GetPortIndex(PortModel portModel, out PortType portType)
        {
            int index = this.inPorts.IndexOf(portModel);
            if (-1 != index)
            {
                portType = PortType.INPUT;
                return index;
            }

            index = this.outPorts.IndexOf(portModel);
            if (-1 != index)
            {
                portType = PortType.OUTPUT;
                return index;
            }

            portType = PortType.INPUT;
            return -1; // No port found.
        }
예제 #52
0
		internal OperationCollection (PortType portType) 
			: base (portType)
		{
		}
        /// <summary>
        /// Determines if all the ranges fall between 1 to port count
        /// </summary>
        /// <param name="ranges">Ranges to check</param>
        /// <param name="device">Device to check on</param>
        /// <param name="portType">Port type</param>
        /// <returns>True if valid ranges</returns>
        public static bool AreRangesWithinPortCount(List<Range> ranges, DeviceWrapper device, PortType portType)
        {
            bool result = false; // Default to false in case we can't even find the port relationship class

            #region Validation

            if (null == ranges)
            {
                throw new ArgumentNullException("ranges");
            }

            if (null == device)
            {
                throw new ArgumentNullException("device");
            }

            #endregion

            ESRI.ArcGIS.Geodatabase.IFeatureClass ftClass = device.Feature.Class as ESRI.ArcGIS.Geodatabase.IFeatureClass;
            if (null != ftClass)
            {
                using (ESRI.ArcGIS.ADF.ComReleaser releaser = new ESRI.ArcGIS.ADF.ComReleaser())
                {
                    ESRI.ArcGIS.Geodatabase.IRelationshipClass deviceHasPorts = ConfigUtil.GetPortRelationship(ftClass);
                    if (null != deviceHasPorts)
                    {
                        ESRI.ArcGIS.Geodatabase.ITable portTable = deviceHasPorts.DestinationClass as ESRI.ArcGIS.Geodatabase.ITable;
                        int portIdIdx = portTable.FindField(ConfigUtil.PortIdFieldName);

                        if (-1 < portIdIdx)
                        {
                            result = true; // Now that we have the ports, assume we're ok until we find a problem

                            ESRI.ArcGIS.Geodatabase.IQueryFilter filter = new ESRI.ArcGIS.Geodatabase.QueryFilterClass();
                            releaser.ManageLifetime(filter);

                            filter.SubFields = ConfigUtil.PortIdFieldName;
                            filter.WhereClause = string.Format("{0}='{1}' AND {2}='{3}' AND {4} IS NOT NULL",
                                deviceHasPorts.OriginForeignKey,
                                device.Feature.get_Value(ftClass.FindField(deviceHasPorts.OriginPrimaryKey)),
                                ConfigUtil.PortTypeFieldName,
                                PortType.Input == portType ? 1 : 2,
                                ConfigUtil.PortIdFieldName);

                            ((ESRI.ArcGIS.Geodatabase.IQueryFilterDefinition)filter).PostfixClause = string.Format("ORDER BY {0}", ConfigUtil.PortIdFieldName);
                            ESRI.ArcGIS.Geodatabase.ICursor cursor = portTable.Search(filter, true);
                            releaser.ManageLifetime(cursor);

                            int minPort = int.MinValue;
                            int maxPort = int.MaxValue;
                            ESRI.ArcGIS.Geodatabase.IRow row = cursor.NextRow();

                            if (null != row)
                            {
                                minPort = (int)row.get_Value(portIdIdx);

                                while (null != row)
                                {
                                    maxPort = (int)row.get_Value(portIdIdx);
                                    ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(row);

                                    row = cursor.NextRow();
                                }
                            }

                            foreach (Range r in ranges)
                            {
                                if (r.High > maxPort
                                    || minPort > r.Low)
                                {
                                    result = false;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            return result;
        }
예제 #54
0
        private bool ParseIODesc()
        {
            PortType portType = new PortType();
            int bit = 0;
            string func = "";
            for (int i = 0; i < _cardInfo.Channels; i++)
            {
                var queryIO = IOCardCfg.Doc.Descendants(IOCardCfg.NameSpace + "DI").Descendants(IOCardCfg.NameSpace + "DI" + i.ToString())
                    .Attributes().Select(n => new { n.Name, n.Value });
                portType = PortType.DI;
                foreach (var item in queryIO)
                {
                    switch (item.Name.LocalName)
                    {
                        case "bit":
                            bit = Convert.ToInt32(item.Value);
                            break;
                        case "Function":
                            func = item.Value;
                            break;
                        default:
                            break;
                    }
                }
                IOInfo.Add(new IODesc(portType, bit, func));
            }

            for (int i = 0; i < _cardInfo.Channels; i++)
            {
                var queryIO = IOCardCfg.Doc.Descendants(IOCardCfg.NameSpace + "DO").Descendants(IOCardCfg.NameSpace + "DO" + i.ToString())
                    .Attributes().Select(n => new { n.Name, n.Value });
                portType = PortType.DO;
                foreach (var item in queryIO)
                {
                    switch (item.Name.LocalName)
                    {
                        case "bit":
                            bit = Convert.ToInt32(item.Value);
                            break;
                        case "Function":
                            func = item.Value;
                            break;
                        default:
                            break;
                    }
                }
                IOInfo.Add(new IODesc(portType, bit, func));
            }
            return true;
        }
예제 #55
0
 public Port(string portName, PortType portType)
 {
     PortName = portName;
     PortType = portType;
 }
예제 #56
0
        /// <summary>
        /// Creates PortModel.
        /// </summary>
        /// <param name="portType">Type of the Port</param>
        /// <param name="owner">Parent Node</param>
        /// <param name="data">Information about port</param>
        public PortModel(PortType portType, NodeModel owner, PortData data)
        {
            IsConnected = false;
            PortType = portType;
            Owner = owner;

            SetPortData(data);

            MarginThickness = new Thickness(0);
            Height = Math.Abs(data.Height) < 0.001 ? Configurations.PortHeightInPixels : data.Height;
        }
예제 #57
0
        /// <summary>
        /// Add a port to this node. If the port already exists, return that port.
        /// </summary>
        /// <param name="portType"></param>
        /// <param name="data"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public PortModel AddPort(PortType portType, PortData data, int index)
        {
            PortModel p;
            switch (portType)
            {
                case PortType.INPUT:
                    if (inPorts.Count > index)
                    {
                        p = inPorts[index];

                        //update the name on the node
                        //e.x. when the node is being re-registered during a custom
                        //node save
                        p.PortName = data.NickName;
                        if (data.HasDefaultValue)
                        {
                            p.UsingDefaultValue = true;
                            p.DefaultValueEnabled = true;
                        }

                        return p;
                    }

                    p = new PortModel(index, portType, this, data.NickName)
                    {
                        UsingDefaultValue = data.HasDefaultValue,
                        DefaultValueEnabled = data.HasDefaultValue
                    };

                    p.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args)
                    {
                        if (args.PropertyName == "UsingDefaultValue")
                            RequiresRecalc = true;
                    };

                    InPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += p_PortConnected;
                    p.PortDisconnected += p_PortDisconnected;

                    return p;

                case PortType.OUTPUT:
                    if (outPorts.Count > index)
                    {
                        p = outPorts[index];
                        p.PortName = data.NickName;
                        return p;
                    }

                    p = new PortModel(index, portType, this, data.NickName)
                    {
                        UsingDefaultValue = false
                    };

                    OutPorts.Add(p);

                    //register listeners on the port
                    p.PortConnected += p_PortConnected;
                    p.PortDisconnected += p_PortDisconnected;

                    return p;
            }

            return null;
        }
예제 #58
0
        void BeginConnection(Guid nodeId, int portIndex, PortType portType)
        {
            bool isInPort = portType == PortType.Input;
            activeStartPort = null;

            var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel;
            if (node == null)
                return;
            PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex];

            // Test if port already has a connection, if so grab it and begin connecting 
            // to somewhere else (we don't allow the grabbing of the start connector).
            if (portModel.Connectors.Count > 0 && portModel.Connectors[0].Start != portModel)
            {
                activeStartPort = portModel.Connectors[0].Start;
                // Disconnect the connector model from its start and end ports
                // and remove it from the connectors collection. This will also
                // remove the view model.
                ConnectorModel connector = portModel.Connectors[0];
                if (CurrentWorkspace.Connectors.Contains(connector))
                {
                    var models = new List<ModelBase> { connector };
                    CurrentWorkspace.RecordAndDeleteModels(models);
                    connector.Delete();
                }
            }
            else
            {
                activeStartPort = portModel;
            }
        }
예제 #59
0
 public static IPEndPoint GetEndPoint(PortType portType)
 {
     return new IPEndPoint(GetIp(), GetPort(portType));
 }
        /// <summary>
        /// Finds ranges of ports that are not yet connected
        /// </summary>
        /// <param name="device">Device to check for</param>
        /// <param name="portType">Check input ports or output ports?</param>
        /// <returns>List of Range</returns>
        public static List<Range> GetAvailableRanges(DeviceWrapper device, PortType portType)
        {
            if (null == device)
            {
                throw new ArgumentNullException("device");
            }

            List<int> openPorts = new List<int>();

            openPorts.AddRange(GetOpenPorts(device, portType));
            openPorts.Sort();

            List<Range> openRanges = MergeRanges(openPorts);
            return openRanges;
        }