Пример #1
0
 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)
 {
 }
Пример #2
0
 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);
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        public override async Task ExecuteAsync()
        {
            await BasePort.EnqueueCommand(this);

            BasePort.BeginCommand(this);
            BasePort.SerialPort.WriteLine("ATH");
        }
Пример #5
0
        /// <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;
            }
        }
Пример #6
0
 private void DisconnectAllPorts()
 {
     foreach (var p in ports)
     {
         BasePort.DisconnectAll(p.Value);
     }
 }
Пример #7
0
        /// <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);
            }
        }
Пример #8
0
        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();
        }
Пример #9
0
        public void SetUp(BasePort port, BaseGraphView graphView)
        {
            Model     = port;
            GraphView = graphView;

            portName = port.name;
            tooltip  = port.name;
        }
Пример #10
0
        public override void Connect(Edge edge)
        {
            base.Connect(edge);

            if (basePort.Direction == PortDirection.Output)
            {
                BasePort.Connect((edge.input as LogicPort).basePort, basePort);
            }
        }
Пример #11
0
        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);
        }
Пример #12
0
 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);
         }
     }
 }
Пример #13
0
        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()));
        }
Пример #14
0
        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);
        }
Пример #15
0
 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);
 }
Пример #16
0
 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);
 }
Пример #17
0
        private void GeneratePort(BasePort basePort)
        {
            LogicPort port = new LogicPort(basePort);

            if (basePort.Direction == PortDirection.Input)
            {
                inputContainer.Add(port);
            }
            else
            {
                outputContainer.Add(port);
            }
        }
Пример #18
0
        private void GenerateLogicPort(BasePort basePort)
        {
            LogicPort portView = new LogicPort(basePort, NodeData);

            if (basePort.GetDirection() == BasePort.Direction.input)
            {
                inputContainer.Add(portView);
            }
            else
            {
                outputContainer.Add(portView);
            }
        }
Пример #19
0
        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);
                }
            }
        }
Пример #20
0
        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);
        }
Пример #21
0
        /// <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));
            }
        }
Пример #22
0
 public virtual BasePortView NewPortView(BasePort port)
 {
     return(new BasePortView(port, new EdgeConnectorListener(Owner)));
 }
Пример #23
0
 public bool TryGetPort(string name, out BasePort port)
 {
     Init();
     return(ports.TryGetValue(name, out port));
 }
Пример #24
0
 void OnPortRemoved(BasePort port)
 {
     portViews[port.name].RemoveFromHierarchy();
     portViews.Remove(port.name);
     RefreshPorts();
 }