コード例 #1
0
        private static async void InitializeNodeConnections()
        {
            try
            {
                List <KeyValuePair <string, NodeVm> > connectionUrls = new List <KeyValuePair <string, NodeVm> >();
                try
                {
                    var licensorNodes = await LicensorClient.Instance.GetNodesAsync(null, null, null).ConfigureAwait(false);

                    if (licensorNodes.Any())
                    {
                        connectionUrls.AddRange(licensorNodes
                                                .Where(opt => opt.Id != NodeSettings.Configs.Node.Id)
                                                .Select(opt => new KeyValuePair <string, NodeVm>($"{opt.Domains.FirstOrDefault()}:{opt.NodesPort}", opt)));
                    }
                }
                catch (ResponseException ex)
                {
                    Logger.WriteLog(ex);
                }
                if (connectionUrls.Any())
                {
                    NodeConnector nodeConnector           = new NodeConnector(connectionUrls.Distinct().ToList());
                    IEnumerable <NodeConnection> nodeList = await nodeConnector.ConnectToNodesAsync().ConfigureAwait(false);

                    nodeConnector.Listen(nodeList);
                    AppServiceProvider.Instance.NodeRequestSender.SendConnectRequestAsync(nodeList.ToList());
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(ex);
            }
        }
コード例 #2
0
ファイル: MyNodeView.cs プロジェクト: xeronith/BrainSimulator
        private void InitIoBranches(int branchCount, NodeConnector connector, ICollection <NodeItem> branchList,
                                    IList <PropertyInfo> blocks, bool isInput)
        {
            if (branchCount == 1)
            {
                connector.Enabled = true;
                branchList.Add(m_iconItem);
            }
            else
            {
                for (int i = 0; i < branchCount; i++)
                {
                    string name = (i + 1) + "";

                    if (Node is MyWorkingNode)
                    {
                        name = blocks[i].Name;
                    }

                    NodeLabelItem branch = new NodeLabelItem(MyProject.ShortenMemoryBlockName(name), isInput, !isInput)
                    {
                        Tag       = i,
                        IsPassive = true
                    };

                    branchList.Add(branch);
                    AddItem(branch);
                }
            }
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            // generateLocations();
            // generateRelations();

            var pointRelationships = JsonSerializer.Deserialize <IReadOnlyList <PointRelationship> >(File.ReadAllText(pointRelationshipPath));
            var nodeConnector      = new NodeConnector();

            var sw = new Stopwatch();

            Console.WriteLine("connect start");
            sw.Start();
            var pointNodes = nodeConnector.Connect(pointRelationships);

            sw.Stop();
            Console.WriteLine($"connect stop: {sw.ElapsedMilliseconds}");

            var    distanceCalculator = new DistanceCalculator();
            string source             = "1520000";
            string target             = "2610012";

            Console.WriteLine("calculate start");
            sw.Reset();
            sw.Start();
            Console.WriteLine($"{source}~{target}: {distanceCalculator.CalculateDistance(pointNodes, source, target)}m");
            sw.Stop();
            Console.WriteLine($"calculate stop: {sw.ElapsedMilliseconds}");
        }
コード例 #4
0
        public HyperGraph.Compatibility.ConnectionType CanConnect(NodeConnector from, NodeConnector to)
        {
            if (null == from.Item.Tag && null == to.Item.Tag)
            {
                return(HyperGraph.Compatibility.ConnectionType.Compatible);
            }
            if (null == from.Item.Tag || null == to.Item.Tag)
            {
                return(HyperGraph.Compatibility.ConnectionType.Incompatible);
            }

            if (from.Item.Tag is string && to.Item.Tag is string)
            {
                string fromType = (string)from.Item.Tag;
                string toType   = (string)to.Item.Tag;
                if (fromType.Equals(toType, StringComparison.CurrentCultureIgnoreCase))
                {
                    return(HyperGraph.Compatibility.ConnectionType.Compatible);
                }
                else
                {
                    // Some types have automatic conversion operations
                    if (ShaderPatcherLayer.TypeRules.HasAutomaticConversion(fromType, toType))
                    {
                        return(HyperGraph.Compatibility.ConnectionType.Conversion);
                    }
                }
            }

            return(HyperGraph.Compatibility.ConnectionType.Incompatible);
        }
コード例 #5
0
ファイル: MergeNode.cs プロジェクト: wwwK/FlowGraph
 public MergeInputItem()
 {
     Input = new NodeConnector(this, ConnectorType.Input)
     {
         AllowMultipleConnections = false
     };
 }
コード例 #6
0
		private NodeConnectorDisplay GetConnectorDisplay(NodeConnector c)
		{
			NodeConnectorDisplay d=null;
			if(c==null)
				return null;

			switch(c.ConnectorType)
			{
				case eNodeConnectorType.Curve:
				{
					if(m_CurveConnectorDisplay==null)
						m_CurveConnectorDisplay=new CurveConnectorDisplay();
					d=m_CurveConnectorDisplay;
					break;
				}
				case eNodeConnectorType.Line:
				{
					if(m_LineConnectorDisplay==null)
						m_LineConnectorDisplay=new LineConnectorDisplay();
					d=m_LineConnectorDisplay;
					break;
				}
			}
			return d;
		}
コード例 #7
0
 public bool ContainConnector(NodeConnector _connector)
 {
     if (connector1 == _connector || connector2 == _connector)
     {
         return(true);
     }
     return(false);
 }
コード例 #8
0
    public NodeConnector CreateConnector <T>(string propertyName, T defaultValue = default(T))
    {
        NodeConnector <T> nc = ScriptableObject.CreateInstance <NodeConnector <T> >();

        nc.propertyName = propertyName;
        nc.defaultValue = defaultValue;
        return(nc);
    }
コード例 #9
0
        public MainWindowViewModel()
        {
            WinMan    = new WindowManager();
            connector = new NodeConnector(AllNodes, new MockBlockChain(), new ClientSettings());
            listener  = new NodeListener(AllNodes, new MockBlockChain(), new ClientSettings());

            listener.StartListen(new IPEndPoint(IPAddress.Any, testPortToUse));
        }
コード例 #10
0
    // Use this for initialization
    void Start()
    {
        // Subscribe to the OnUiToggle Event
        StateManager.OnUiToggle += OnUiToggle;
        _lerpTime = StateManager._instance._lerpTime;

        _randomOffset  = Random.Range(0.0f, 0.3f);
        _nodeConnector = GetComponentInChildren <NodeConnector> ();
    }
コード例 #11
0
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public bool CanConnect( NodeConnector from, NodeConnector to )
 {
     if (null == from.Item.Tag || null == to.Item.Tag) return false;
     if (from.Item.Tag.GetType() == to.Item.Tag.GetType())
     {
         return true;
     }
     return false;
 }
コード例 #12
0
ファイル: Graph.Events.cs プロジェクト: wwwK/FlowGraph
        /// <summary>
        /// Handle mouse up
        /// </summary>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button == MouseButtons.Left && EditMode != EGraphEditMode.SelectingBox)
            {
                IElement clickedElement = FindElementAt(m_transformed_location, true);
                if (clickedElement != null)
                {
                    System.Diagnostics.Debug.Print(clickedElement.ToString());
                    clickedElement.As <IMouseUpHandler>()?.OnMouseUp(e);
                    if (clickedElement is Node node)
                    {
                        if (node.Owner is NodeGroup group)
                        {
                            if (!group.Bounds.FullyContains(node.Bounds))
                            {
                                group.RemoveNode(node);
                            }
                        }
                    }
                    else if (clickedElement is NodeConnector)
                    {
                        NodeConnector from = SelectedElement as NodeConnector;
                        if (from != null)
                        {
                            NodeConnector to = (NodeConnector)clickedElement;
                            from.Connect(to);
                            to.Connect(from);
                        }
                    }
                    else if (FindElementAt <NodeGroup>(m_transformed_location, true) is NodeGroup group)
                    {
                        foreach (IElement element in Selection)
                        {
                            if (element is Node elementNode)
                            {
                                if (group.Bounds.FullyContains(elementNode.Bounds))
                                {
                                    group.AddNode(elementNode);
                                }
                            }
                        }
                    }
                    else
                    {
                        Selection.UnselectAll();
                    }
                }
                else
                {
                    Selection.UnselectAll();
                }
            }

            m_dragElement = false;
            SetEditMode(EGraphEditMode.Idle);
        }
コード例 #13
0
ファイル: TagTypeCompatibility.cs プロジェクト: ldh9451/XLE
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public HyperGraph.Compatibility.ConnectionType CanConnect(NodeConnector from, NodeConnector to)
 {
     if (null == from.Item.Tag || null == to.Item.Tag) return ConnectionType.Incompatible;
     if (from.Item.Tag.GetType() == to.Item.Tag.GetType())
     {
         return HyperGraph.Compatibility.ConnectionType.Compatible;
     }
     return HyperGraph.Compatibility.ConnectionType.Incompatible;
 }
コード例 #14
0
ファイル: Node.cs プロジェクト: vinhphu3000/NodeUIGraph
    public void SetOutput <T>(string name, T value)
    {
        NodeConnector nodeOutput = outputs.Find((no) => { return(no.propertyName == name); });

        if (nodeOutput != null)
        {
            ((NodeConnector <T>)nodeOutput).value = value;
        }
    }
コード例 #15
0
 public bool CanConnect(NodeConnector from, NodeConnector to)
 {
     if (from.Node is MyNodeView && to.Node is MyNodeView)
     {
         return(to.Node != from.Node && !to.HasConnection);
     }
     else
     {
         return(false);
     }
 }
コード例 #16
0
 public IntValueItem(ConnectorType type)
 {
     if (type == ConnectorType.Output)
     {
         Output = new NodeConnector(this, ConnectorType.Output);
     }
     else
     {
         Input = new NodeConnector(this, ConnectorType.Input);
     }
 }
コード例 #17
0
 public GrayScaleImageItem()
 {
     Input = new NodeConnector(this, ConnectorType.Input)
     {
         AllowMultipleConnections = false
     };
     Output = new NodeConnector(this, ConnectorType.Output)
     {
         AllowMultipleConnections = false
     };
 }
コード例 #18
0
        public void BackwardPropagationFourNodes()
        {
            //init
            var nodeLayerOneOne = new PropagationNode(1);
            var nodeLayerOneTwo = new PropagationNode(1);

            nodeLayerOneOne.finalValue = 1.0;
            nodeLayerOneTwo.finalValue = 1.0;

            var connectorLayerOneTwoNodeOneOne = new NodeConnector(2.0);
            var connectorLayerOneTwoNodeOneTwo = new NodeConnector(1.0);
            var connectorLayerOneTwoNodeTwoOne = new NodeConnector(3.0);
            var connectorLayerOneTwoNodeTwoTwo = new NodeConnector(4.0);

            var nodeLayerTwoOne = new PropagationNode(2);
            var nodeLayerTwoTwo = new PropagationNode(2);

            nodeLayerTwoOne.finalValue = 1.0;
            nodeLayerTwoTwo.finalValue = 1.0;

            var nodesLayerOne = new List <PropagationNode>
            {
                nodeLayerOneOne,
                nodeLayerOneTwo
            };

            var nodeConnectorsLayerOneTwo = new List <NodeConnector>
            {
                connectorLayerOneTwoNodeOneOne,
                connectorLayerOneTwoNodeOneTwo,
                connectorLayerOneTwoNodeTwoOne,
                connectorLayerOneTwoNodeTwoTwo
            };

            var nodesLayerTwo = new List <PropagationNode>
            {
                nodeLayerTwoOne,
                nodeLayerTwoTwo
            };

            AddNodeConnectors(ref nodesLayerOne, ref nodeConnectorsLayerOneTwo, ref nodesLayerTwo);

            //backpropagate
            nodeLayerTwoOne.Backpropagate(1.5);
            nodeLayerTwoTwo.Backpropagate(0.5);

            //the errors backward are shared depending on the weight, the higher the weight, the higher
            // the share of the error
            Assert.AreEqual(0.7, nodeLayerOneOne.errorBackProp, 0.1);
            Assert.AreEqual(1.3, nodeLayerOneTwo.errorBackProp, 0.1);

            //the updated weight here should be slightly larger than 2.0
            Assert.AreEqual(2.0005, connectorLayerOneTwoNodeOneOne.weight, 0.001);
        }
コード例 #19
0
 public void SetOppositePair(NodeConnector nodeConnector)
 {
     if (nodeConnector == null)
     {
         nextNodeInput = null;
     }
     else
     {
         nextNodeInput = nodeConnector.GetComponent <NodeInput>();
     }
 }
コード例 #20
0
ファイル: NodeInput.cs プロジェクト: Kainkun/Hacker
 public void AddOppositePair(NodeConnector nodeConnector)
 {
     if (nodeConnector == null)
     {
         return;
     }
     else
     {
         previousNodeOutputs.Add(nodeConnector.GetComponent <NodeOutput>());
     }
 }
コード例 #21
0
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public HyperGraph.Compatibility.ConnectionType CanConnect(NodeConnector from, NodeConnector to)
 {
     if (null == from.Item.Tag || null == to.Item.Tag)
     {
         return(ConnectionType.Incompatible);
     }
     if (from.Item.Tag.GetType() == to.Item.Tag.GetType())
     {
         return(HyperGraph.Compatibility.ConnectionType.Compatible);
     }
     return(HyperGraph.Compatibility.ConnectionType.Incompatible);
 }
コード例 #22
0
 public MirrorItem(RotateFlipType type)
 {
     FlipType = type;
     Input    = new NodeConnector(this, ConnectorType.Input)
     {
         AllowMultipleConnections = false
     };
     Output = new NodeConnector(this, ConnectorType.Output)
     {
         AllowMultipleConnections = false
     };
 }
コード例 #23
0
 public bool CanConnect(NodeConnector from, NodeConnector to)
 {
     if (from.Item.ItemType == to.Item.ItemType)
     {
         return(false);
     }
     if (from.Item.GetType() == to.Item.GetType())
     {
         return(true);
     }
     return(false);
 }
コード例 #24
0
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public bool CanConnect(NodeConnector from, NodeConnector to)
 {
     if (null == from.Item.Tag || null == to.Item.Tag)
     {
         return(false);
     }
     if (from.Item.Tag.GetType() == to.Item.Tag.GetType())
     {
         return(true);
     }
     return(false);
 }
コード例 #25
0
        private void DisconnectAll(NodeConnector connector)
        {
            var connectionsDupe = connector.Node.Connections.ToArray();

            foreach (var i in connectionsDupe)
            {
                if (i.To == connector || i.From == connector)
                {
                    GetGraphModel().Disconnect(i);
                }
            }
        }
コード例 #26
0
        public MainWindowViewModel()
        {
            AllNodes  = new ObservableCollection <Node>();
            tempNodex = new List <Node>();
            var clientSettings = new ClientSettings();

            WinMan    = new WindowManager();
            connector = new NodeConnector(tempNodex, new MockBlockChain(), clientSettings);
            listener  = new NodeListener(new List <Node>(), new MockBlockChain(), clientSettings);

            listener.StartListen(new IPEndPoint(IPAddress.Any, testPortToUse));
        }
コード例 #27
0
ファイル: MinerViewModel.cs プロジェクト: supaFool/Denovo
        public MinerViewModel() : base(650, 650)
        {
            AllNodes = new NodePool(5);
            var fileMan        = new FileManager(NetworkType.TestNet);
            var clientSettings = new ClientSettings(false, NetworkType.TestNet, 5, NodeServiceFlags.NodeNone,
                                                    AllNodes, fileMan, new UtxoDatabase(fileMan), new MemoryPool())
            {
                UserAgent = "/Satoshi:0.20.1/",
                Relay     = false,
                Network   = NetworkType.TestNet,
            };

            connector = new NodeConnector(AllNodes, clientSettings);
        }
コード例 #28
0
        /// <summary>
        /// Initializes a new instance of <see cref="FullClient"/> using the given parameters.
        /// </summary>
        /// <param name="settings">Client settings</param>
        public FullClient(IClientSettings settings)
        {
            Settings  = settings;
            connector = new NodeConnector(settings.AllNodes, settings);
            if (settings.AcceptIncomingConnections)
            {
                listener = new NodeListener(settings.AllNodes, settings);
            }

            connector.ConnectFailureEvent += Connector_ConnectFailureEvent;

            Settings.Blockchain.HeaderSyncEndEvent += Blockchain_HeaderSyncEndEvent;
            Settings.Blockchain.BlockSyncEndEvent  += Blockchain_BlockSyncEndEvent;
            settings.AllNodes.AddRemoveEvent       += AllNodes_AddRemoveEvent;
        }
コード例 #29
0
    NodeConnector GetNodeConnector(string propertyPath, Type propertyType)
    {
        NodeConnector nodeConnector;

        if (nodeConnectors.TryGetValue(propertyPath, out nodeConnector))
        {
            return(nodeConnector);
        }

        nodeConnector = new NodeConnector(this, serializedObject, propertyPath, propertyType);
        connectionTypes.Add(propertyType);
        nodeConnector.OnDeath       += () => postDraw += () => nodeConnectors.Remove(nodeConnector.PropertyPath);
        nodeConnectors[propertyPath] = nodeConnector;
        return(nodeConnector);
    }
コード例 #30
0
        /// <summary>
        /// Gets the connection region of the specified Node Connection
        /// </summary>
        /// <param name="connection">Node connection</param>
        /// <returns><see cref="Region"/> Connection Region</returns>
        public static Region GetConnectionRegion(NodeConnection connection)
        {
            NodeConnector to         = connection.To;
            NodeConnector from       = connection.From;
            RectangleF    toBounds   = to.Bounds;
            RectangleF    fromBounds = from.Bounds;
            float         x1         = (toBounds.Left + toBounds.Right) / 2.0f;
            float         y1         = (toBounds.Top + toBounds.Bottom) / 2.0f;
            float         x2         = (fromBounds.Left + fromBounds.Right) / 2.0f;
            float         y2         = (fromBounds.Top + fromBounds.Bottom) / 2.0f;
            Region        region;

            using (GraphicsPath linePath = GetLinePath(x1, y1, x2, y2, false, extra_thickness: 5.0f).Path)
                region = new Region(linePath);
            return(region);
        }
コード例 #31
0
 public bool CanConnect(NodeConnector from, NodeConnector to)
 {
     if (from.Item.OutputTypes == null ||
         to.Item.InputTypes == null)
     {
         return(false);
     }
     foreach (var outputType in from.Item.OutputTypes)
     {
         foreach (var inputType in to.Item.InputTypes)
         {
             if (outputType == inputType)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #32
0
ファイル: IoConnection.cs プロジェクト: afauch/att-hack
    public void Init()
    {
        // Register the output for the input's event listeners
        // ## THIS IS THE CORE BIT OF LINKING CODE ##
        _output.GetComponent <IOutputModule>().SubscribeToInput(_input.GetComponent <IInputModule>());

        // Register for OnMove events from both of the GameObjects
        _input.GetComponent <DragObject>().OnMove  += OnMove;
        _output.GetComponent <DragObject>().OnMove += OnMove;
        _input.GetComponent <Hover> ().OnMove      += OnMove;
        _output.GetComponent <Hover> ().OnMove     += OnMove;

        // Add the NodeConnectors
        _inputNode = _input.GetComponent <UiComponent>()._nodeConnector;
        _inputNode._connections.Add(this);

        _outputNode = _output.GetComponent <UiComponent> ()._nodeConnector;
        _outputNode._connections.Add(this);
    }
コード例 #33
0
        public void ForwardPropagationFourNodes()
        {
            //init
            var nodeLayerOneOne = new PropagationNode(1);
            var nodeLayerOneTwo = new PropagationNode(1);

            var connectorLayerOneTwoNodeOneOne = new NodeConnector(0.9);
            var connectorLayerOneTwoNodeOneTwo = new NodeConnector(0.2);
            var connectorLayerOneTwoNodeTwoOne = new NodeConnector(0.3);
            var connectorLayerOneTwoNodeTwoTwo = new NodeConnector(0.8);

            var nodeLayerTwoOne = new PropagationNode(2);
            var nodeLayerTwoTwo = new PropagationNode(2);

            var nodesLayerOne = new List <PropagationNode>
            {
                nodeLayerOneOne,
                nodeLayerOneTwo
            };

            var nodeConnectorsLayerOneTwo = new List <NodeConnector>
            {
                connectorLayerOneTwoNodeOneOne,
                connectorLayerOneTwoNodeOneTwo,
                connectorLayerOneTwoNodeTwoOne,
                connectorLayerOneTwoNodeTwoTwo
            };

            var nodesLayerTwo = new List <PropagationNode>
            {
                nodeLayerTwoOne,
                nodeLayerTwoTwo
            };

            AddNodeConnectors(ref nodesLayerOne, ref nodeConnectorsLayerOneTwo, ref nodesLayerTwo);

            nodeLayerOneOne.ForwardValue(1.0);
            nodeLayerOneTwo.ForwardValue(0.5);

            Assert.AreEqual(0.74, nodeLayerTwoOne.finalValue, 0.1);
            Assert.AreEqual(0.64, nodeLayerTwoTwo.finalValue, 0.1);
        }
コード例 #34
0
ファイル: AlwaysCompatible.cs プロジェクト: ldh9451/XLE
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public HyperGraph.Compatibility.ConnectionType CanConnect(NodeConnector @from, NodeConnector to)
 {
     return HyperGraph.Compatibility.ConnectionType.Compatible;
 }
コード例 #35
0
 /// <summary>
 /// Determine if two node item connectors could be connected to each other.
 /// </summary>
 /// <param name="from">From which node connector are we connecting.</param>
 /// <param name="to">To which node connector are we connecting?</param>
 /// <returns><see langword="true"/> if the connection is valid; <see langword="false"/> otherwise</returns>
 public bool CanConnect( NodeConnector @from, NodeConnector to )
 {
     return true;
 }