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); } }
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); } } }
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}"); }
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); }
public MergeInputItem() { Input = new NodeConnector(this, ConnectorType.Input) { AllowMultipleConnections = false }; }
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; }
public bool ContainConnector(NodeConnector _connector) { if (connector1 == _connector || connector2 == _connector) { return(true); } return(false); }
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); }
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)); }
// 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> (); }
/// <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; }
/// <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); }
/// <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; }
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; } }
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); } }
public IntValueItem(ConnectorType type) { if (type == ConnectorType.Output) { Output = new NodeConnector(this, ConnectorType.Output); } else { Input = new NodeConnector(this, ConnectorType.Input); } }
public GrayScaleImageItem() { Input = new NodeConnector(this, ConnectorType.Input) { AllowMultipleConnections = false }; Output = new NodeConnector(this, ConnectorType.Output) { AllowMultipleConnections = false }; }
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); }
public void SetOppositePair(NodeConnector nodeConnector) { if (nodeConnector == null) { nextNodeInput = null; } else { nextNodeInput = nodeConnector.GetComponent <NodeInput>(); } }
public void AddOppositePair(NodeConnector nodeConnector) { if (nodeConnector == null) { return; } else { previousNodeOutputs.Add(nodeConnector.GetComponent <NodeOutput>()); } }
/// <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); }
public MirrorItem(RotateFlipType type) { FlipType = type; Input = new NodeConnector(this, ConnectorType.Input) { AllowMultipleConnections = false }; Output = new NodeConnector(this, ConnectorType.Output) { AllowMultipleConnections = false }; }
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); }
/// <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); }
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); } } }
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)); }
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); }
/// <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; }
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); }
/// <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); }
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); }
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); }
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); }
/// <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; }
/// <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; }