public BasePortView(BasePort port, IEdgeConnectorListener connectorListener) : this( orientation : port.orientation == BasePort.Orientation.Horizontal ? Orientation.Horizontal : Orientation.Vertical, direction : port.direction == BasePort.Direction.Input ? Direction.Input : Direction.Output, capacity : port.capacity == BasePort.Capacity.Single ? Capacity.Single : Capacity.Multi, port.type, connectorListener) { }
public void Initialize(BaseGraphView _graphView, IEnumerable <Type> nodeTypes) { graphView = _graphView; this.nodeTypes = nodeTypes; this.nodePortMap.Clear(); foreach (var nodeType in nodeTypes) { if (nodePortMap.ContainsKey(nodeType)) { continue; } PortInfo portInfo = new PortInfo(); foreach (FieldInfo item in ReflectionHelper.GetFieldInfos(nodeType)) { if (AttributeHelper.TryGetFieldAttribute(item, out NodeValueAttribute nodeValueAttribute)) { continue; } BasePort port = null; if (AttributeHelper.TryGetFieldAttribute(item, out InputPortAttribute inputAttr)) { port = new BasePort(inputAttr.name, inputAttr.orientation, inputAttr.direction, inputAttr.capacity, item.FieldType); portInfo.InPorts.Add(port); } if (AttributeHelper.TryGetFieldAttribute(item, out OutputPortAttribute outputAttr)) { port = new BasePort(outputAttr.name, outputAttr.orientation, outputAttr.direction, outputAttr.capacity, item.FieldType); portInfo.OutPorts.Add(port); } } nodePortMap.Add(nodeType, portInfo); } }
private void DeleteEdges() { List <Edge> removeEdges = new List <Edge>(); edges.ForEach(e => { LogicPort li = e.input as LogicPort; LogicPort lo = e.output as LogicPort; //BasePort input = (e.input is LogicPort li) ? li.basePort : null; //BasePort output = (e.output is LogicPort lo) ? lo.basePort : null; if (li == null || lo == null || !BasePort.Connected(li.basePort, lo.basePort) || (li.node as LogicNode).WasRemoved || (lo.node as LogicNode).WasRemoved) { if (li != null && li.IsEdgeDragging(e)) { return; } if (lo != null && lo.IsEdgeDragging(e)) { return; } if (!removeEdges.Contains(e)) { removeEdges.Add(e); } return; } }); RemoveEdges(removeEdges); }
public override async Task ExecuteAsync() { await BasePort.EnqueueCommand(this); BasePort.BeginCommand(this); BasePort.SerialPort.WriteLine("ATH"); }
/// <summary> /// Constructor /// </summary> /// <param name="address">IP address of the device exposing the MALOS 0MQ sockets</param> /// <param name="basePort">MALOS base port to use</param> public Driver(string address, BasePort basePort) { this.address = address; switch (basePort) { case BasePort.Imu: this.basePort = imuPort; break; case BasePort.Humidity: this.basePort = humidityPort; break; case BasePort.Everloop: this.basePort = everloopPort; break; case BasePort.Pressure: this.basePort = pressurePort; break; case BasePort.UV: this.basePort = uvPort; break; case BasePort.Mic: this.basePort = micArrayPort; break; case BasePort.Vision: this.basePort = visionPort; break; } }
private void DisconnectAllPorts() { foreach (var p in ports) { BasePort.DisconnectAll(p.Value); } }
/// <summary> /// Initializes the Follower connection to the Leader /// </summary> private static void StartClient() { try { if (!Initialized && Enabled) { int serverPort = Settings.Instance.ServerPort; ServerUri = new Uri(ServerUri.AbsoluteUri.Replace(BasePort.ToString(), serverPort.ToString())); SharedComposites.CheckReplaceOutOfGameHook(); Logr.Log("Initializing Client Service connection to {0}", ServerUri.AbsoluteUri + "Follow"); BasicHttpBinding binding = new BasicHttpBinding { OpenTimeout = TimeSpan.FromMilliseconds(5000), SendTimeout = TimeSpan.FromMilliseconds(5000), CloseTimeout = TimeSpan.FromMilliseconds(5000) }; EndpointAddress endPointAddress = new EndpointAddress(ServerUri.AbsoluteUri + "Follow"); HttpFactory = new ChannelFactory <IFollowService>(binding, endPointAddress); HttpProxy = HttpFactory.CreateChannel(); Initialized = true; } } catch (Exception ex) { Logr.Log("Exception in ClientInitialize() {0}", ex); } }
void OnPortAdded(BasePort port) { BasePortView portView = NewPortView(port); portView.SetUp(port, Owner); portViews[port.name] = portView; if (portView.orientation == Orientation.Horizontal) { if (portView.direction == Direction.Input) { inputContainer.Add(portView); } else { outputContainer.Add(portView); } } else { if (portView.direction == Direction.Input) { topPortContainer.Add(portView); } else { bottomPortContainer.Add(portView); } } RefreshPorts(); }
public void SetUp(BasePort port, BaseGraphView graphView) { Model = port; GraphView = graphView; portName = port.name; tooltip = port.name; }
public override void Connect(Edge edge) { base.Connect(edge); if (basePort.Direction == PortDirection.Output) { BasePort.Connect((edge.input as LogicPort).basePort, basePort); } }
public LogicPort(BasePort basePort) : base(Orientation.Horizontal, GetDirection(basePort.Direction), GetCapacity(basePort.CapacityMode), basePort.PortType) { portName = basePort.Name; this.basePort = basePort; myEdgeConnector = new EdgeConnector <Edge>(new EC()); this.AddManipulator(myEdgeConnector); }
internal void Deserialize(BasePort port) { for (int i = 0; i < refParents.Count; i++) { if (refParents[i] != null && refParents[i].TryGetPort(refNames[i], out BasePort reference)) { port.AddReference(reference); } } }
public LogicPort(BasePort basePort, Node nodeParent) : base(Orientation.Horizontal, basePort.GetDirection() == BasePort.Direction.input ? Direction.Input : Direction.Output, basePort.GetDirection() == BasePort.Direction.input ? Capacity.Single : Capacity.Multi, basePort.GetPortType()) { portName = basePort.Name; this.basePort = basePort; this.nodeParent = nodeParent; this.AddManipulator(new EdgeConnector <Edge>(new EC())); }
private void DisconnectEdge(Edge e) { LogicPort li = e.input as LogicPort; LogicPort lo = e.output as LogicPort; if (li == null || lo == null) { return; } BasePort.Disconnect(li.basePort, lo.basePort); }
public override Task ExecuteAsync() { BasePort.EnqueueCommand(this).Wait(); BasePort.BeginCommand(this); tcs = new TaskCompletionSource <bool>(); BasePort.SerialPort.WriteLine("AT+COLP=1"); Task.Delay(200).Wait(); BasePort.SerialPort.WriteLine("ATD" + phoneNumber + ";"); IsDialed = true; return(tcs.Task); }
public override Task ExecuteAsync() { BasePort.EnqueueCommand(this).Wait(); BasePort.BeginCommand(this); tcs = new TaskCompletionSource <bool>(); BasePort.SerialPort.WriteLine("AT+CMGF=1"); Task.Delay(200).Wait(); BasePort.SerialPort.WriteLine("AT+CSCS=\"UCS2\""); Task.Delay(200).Wait(); BasePort.SerialPort.WriteLine($"AT+CMGS=\"{computedPhoneNumber}\""); return(tcs.Task); }
private void GeneratePort(BasePort basePort) { LogicPort port = new LogicPort(basePort); if (basePort.Direction == PortDirection.Input) { inputContainer.Add(port); } else { outputContainer.Add(port); } }
private void GenerateLogicPort(BasePort basePort) { LogicPort portView = new LogicPort(basePort, NodeData); if (basePort.GetDirection() == BasePort.Direction.input) { inputContainer.Add(portView); } else { outputContainer.Add(portView); } }
public SerPort(BasePort basePort) { this.name = basePort.Name; this.capacityMode = basePort.CapacityMode; this.direction = basePort.Direction; this.portType = basePort.PortType.AssemblyQualifiedName; var refs = new List <BasePort>(); foreach (BasePort port in basePort.GetReferences()) { if (!refs.Contains(port)) { refs.Add(port); refParents.Add(port.Parent); refNames.Add(port.Name); } } }
public override List <Port> GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter) { List <Port> compatiblePorts = new List <Port>(); ports.ForEach(p => { bool isCompatible = !p.Equals(startPort); isCompatible &= !p.node.Equals(startPort.node); isCompatible &= p.direction != startPort.direction; isCompatible &= p.direction == Direction.Input && BasePort.IsCompatible(p.portType, startPort.portType) || p.direction == Direction.Output && BasePort.IsCompatible(startPort.portType, p.portType); isCompatible &= !p.connections.Any(e => Equals(e.input, startPort) || Equals(e.output, startPort)); if (isCompatible) { compatiblePorts.Add(p); } }); return(compatiblePorts); }
/// <summary> 拖拽到符合条件的接口上松开时触发 </summary> public virtual void OnDrop(GraphView graphView, Edge edge) { BaseGraphView tempGraphView = graphView as BaseGraphView; BaseNode from = (edge.output.node as BaseNodeView).Model; BasePort fromPort = (edge.output as BasePortView).Model; BaseNode to = (edge.input.node as BaseNodeView).Model; BasePort toPort = (edge.input as BasePortView).Model; // 如果连线不是一个新建的连线就重定向 if (edge.userData is BaseConnection connection) { tempGraphView.CommandDispacter.Do(new ConnectionRedirectCommand(tempGraphView.Model, connection, from, fromPort.name, to, toPort.name)); } else { tempGraphView.CommandDispacter.Do(new ConnectCommand(tempGraphView.Model, from, fromPort.name, to, toPort.name)); } }
public virtual BasePortView NewPortView(BasePort port) { return(new BasePortView(port, new EdgeConnectorListener(Owner))); }
public bool TryGetPort(string name, out BasePort port) { Init(); return(ports.TryGetValue(name, out port)); }
void OnPortRemoved(BasePort port) { portViews[port.name].RemoveFromHierarchy(); portViews.Remove(port.name); RefreshPorts(); }