Пример #1
0
 public V2Node(NodeMode _mode, Vector3 _worldPos, int _gridX, int _gridY)
 {
     mode          = _mode;
     worldPosition = _worldPos;
     gridX         = _gridX;
     gridY         = _gridY;
 }
Пример #2
0
        private StateNode parseNode(XmlElement node, Declarations decls)
        {
            Console.WriteLine("    Parsing node ...");

            string id = node.GetAttribute("id");

            if (id == null)
            {
                throw new ParseException("Expected id in <location>");
            }

            XmlNode namenode = node.SelectSingleNode("./name");
            string  name     = string.IsNullOrEmpty(getElementText(namenode))
                ? String.Format("Unnamed{0}", _noname++)
                : getElementText(namenode);

            NodeMode mode = NodeMode.Regular;

            if (node.SelectSingleNode("./commited") != null)
            {
                mode = NodeMode.Commited;
            }
            else
            if (node.SelectSingleNode("./urgent") != null)
            {
                mode = NodeMode.Commited;
            }

            StateNode sn = new StateNode(name, id, mode);

            sn.Rules = parseRules(node, sn.Name, decls);
            return(sn);
        }
Пример #3
0
        public SwtichNodeSet(Action <bool> toggleAction, NodeMode mode = NodeMode.ParalleConnection)
        {
            if (toggleAction != null)
            {
                AddSwitchEvent(toggleAction);
            }

            m_Name         = string.Empty;
            SwitchNodeMode = mode;
            m_ChildNodes   = new HashSet <SwitchNode>();
            SwitchTurnMode = TurnMode.TreeDownToTop;
        }
 public TransportTerminalFunction(SynchronousPhysicalInterface spi, NodeMode mode)
 {
     this.spi      = spi;
     rst           = new RegeneratorSectionTermination();
     this.nodeMode = mode;
     if (nodeMode == NodeMode.MULTIPLEXER)
     {
         mst = new MultiplexSectionTermination();
     }
     this.spi.HandleInputData += new HandleInputData(getInputData);
     builder = new FrameBuilder();
 }
 public TransportTerminalFunction(SynchronousPhysicalInterface spi, NodeMode mode)
 {
     this.spi = spi;
     rst = new RegeneratorSectionTermination();
     this.nodeMode = mode;
     if (nodeMode == NodeMode.MULTIPLEXER)
     {
         mst = new MultiplexSectionTermination();
     }
     this.spi.HandleInputData += new HandleInputData(getInputData);
     builder = new FrameBuilder();
 }
Пример #6
0
        public LyraNodeConfig(IConfigurationSection section)
        {
            Database = new LyraDatabaseConfig(section.GetSection("Database"));
            Wallet   = new LyraWalletConfig(section.GetSection("Wallet"));

            try
            {
                Mode = (NodeMode)Enum.Parse(typeof(NodeMode), section.GetSection("Mode").Value, true);
            }
            catch
            {
                Mode = NodeMode.Normal;
            }
        }
Пример #7
0
 public StateNode(string name, string nodeid, NodeMode mode)
 {
     Id = count++;
     if (string.IsNullOrEmpty(name))
     {
         BaseName = String.Format("Unnamed{0}", Id);
     }
     else
     {
         BaseName = name;
     }
     Name   = BaseName;
     NodeId = nodeid;
     Mode   = mode;
 }
Пример #8
0
        /* Adjusts values internal to the node */
        private void AdjustNodeValues(NodeMode modeToChangeTo)
        {
            /* deciding if node is starting or winning node now */
            node.IsStartingNode = (modeToChangeTo == NodeMode.STARTING);
            node.IsWinningNode  = (modeToChangeTo == NodeMode.WINNING);

            if (modeToChangeTo == NodeMode.BLOCKED)            /* node cost adjusted depending of change */
            {
                node.Cost = Int32.MaxValue;                    // means that a node contacting the block will get that price back
                node.NeighborhoodChecker.MaxAcceptedPrice = 0; // means that node creates no links over the price 0, so no links
            }
            else /* reversing 'blocked' values */
            {
                node.Cost = originalNodeCost;
                node.NeighborhoodChecker.MaxAcceptedPrice = originalNodeMaxLinkCost;
            }
        }
Пример #9
0
        /// <summary>
        /// Gets the all points by the NodeCollection contains the specified point.
        /// </summary>
        /// <param name="point"> The input point. </param>
        /// <param name="nodeCollection"> The source NodeCollection. </param>
        /// <param name="matrix"> The matrix. </param>
        /// <returns> The NodeCollection mode. </returns>
        public static NodeCollectionMode ContainsNodeCollectionMode(Vector2 point, NodeCollection nodeCollection, Matrix3x2 matrix)
        {
            if (nodeCollection == null)
            {
                throw new NullReferenceException("NodeCollection is null.");
            }

            for (int i = 0; i < nodeCollection.Count; i++)
            {
                Node     node     = nodeCollection[i];
                NodeMode nodeMode = Node.ContainsNodeMode(point, node, matrix);

                switch (nodeMode)
                {
                case NodeMode.None: break;

                case NodeMode.PointWithChecked:
                {
                    nodeCollection.Index = i;
                    return(NodeCollectionMode.Move);
                }

                case NodeMode.PointWithoutChecked:
                {
                    nodeCollection.Index = i;
                    return(NodeCollectionMode.MoveSingleNodePoint);
                }

                case NodeMode.LeftControlPoint:
                {
                    nodeCollection.Index = i;
                    return(NodeCollectionMode.MoveSingleNodeLeftControlPoint);
                }

                case NodeMode.RightControlPoint:
                {
                    nodeCollection.Index = i;
                    return(NodeCollectionMode.MoveSingleNodeRightControlPoint);
                }
                }
            }

            return(NodeCollectionMode.RectChoose);
        }
Пример #10
0
        /* Sets sprite of GO to match the new mode */
        private void SetSpriteForNewMode(NodeMode modeToChangeTo)
        {
            switch (modeToChangeTo) /* CHANGE GRAPHIC */
            {
            case NodeMode.NORMAL:
                renderer.sprite = normalNodeSprite;
                break;

            case NodeMode.BLOCKED:
                renderer.sprite = blockedNodeSprite;
                break;

            case NodeMode.STARTING:
                renderer.sprite = startingNodeSprite;
                break;

            case NodeMode.WINNING:
                renderer.sprite = winningNodeSprite;
                break;
            }
        }
Пример #11
0
 /* Adjusts values to match new mode and sets sprite for mode */
 private void SwitchMode(NodeMode modeToChangeTo)
 {
     mode = modeToChangeTo; // variable set to now current mode
     AdjustNodeValues(modeToChangeTo);
     SetSpriteForNewMode(modeToChangeTo);
 }
Пример #12
0
 /// <summary>
 /// Handles the NodeModeChangeCommand. Sets the new node mode.
 /// </summary>
 /// <param name="newMode">The new node mode.</param>
 private void HandleNodeModeChange(NodeMode newMode)
 {
     NodeMode = newMode;
 }
Пример #13
0
        public OracleSettings(NodeMode nodeMode, Arguments settings, DataNode section)
        {
            this.NeoscanUrl = settings.GetString("neoscan.api", section.GetString("neoscan.api"));

            this.EthFeeURLs = section.GetNode("eth.fee.urls").Children.Select(x => FeeUrl.FromNode(x)).ToList();
            this.BscFeeURLs = section.GetNode("bsc.fee.urls").Children.Select(x => FeeUrl.FromNode(x)).ToList();

            this.PricerCoinGeckoEnabled = settings.GetBool("pricer.coingecko.enabled", section.GetBool("pricer.coingecko.enabled"));

            var supportedTokens = section.GetNode("pricer.supportedtokens");

            if (supportedTokens == null || supportedTokens.Kind != NodeKind.Array)
            {
                throw new Exception("Config is missing pricer.supportedtokens entry or is not a valid array");
            }

            this.PricerSupportedTokens = supportedTokens.Children.Select(x => PricerSupportedToken.FromNode(x)).ToList();

            this.EthConfirmations    = settings.GetUInt("eth.block.confirmations", section.GetUInt32("eth.block.confirmations"));
            this.EthGasLimit         = settings.GetUInt("eth.gas.limit", section.GetUInt32("eth.gas.limit"));
            this.CryptoCompareAPIKey = settings.GetString("crypto.compare.key", section.GetString("crypto.compare.key"));

            this.SwapColdStorageNeo = settings.GetString("swaps.coldStorage.neo", section.GetString("swaps.coldStorage.neo"));

            var swapNode = section.GetNode("swap.platforms");

            if (swapNode == null || nodeMode == NodeMode.Proxy)
            {
                this.SwapPlatforms = new PlatformSettings[0];
            }
            else
            if (swapNode.Kind != NodeKind.Array)
            {
                throw new Exception("Config has invalid swaps.platform entry, must be a valid array, if you have an old config file please upgrade manually");
            }
            else
            {
                this.SwapPlatforms = new PlatformSettings[swapNode.ChildCount];

                for (int i = 0; i < SwapPlatforms.Length; i++)
                {
                    var node = swapNode.GetNodeByIndex(i);

                    var platformName = node.GetString("name");
                    Console.WriteLine("name: " + platformName);

                    var platform = new PlatformSettings();
                    SwapPlatforms[i] = platform;

                    if (!Enum.TryParse <SwapPlatformChain>(platformName, true, out platform.Chain))
                    {
                        throw new Exception($"Unknown swap platform entry in config: '{platformName}'");
                    }

                    platform.Enabled = node.GetBool("enabled", true);

                    var temp = node.GetString("height", "0");
                    if (!BigInteger.TryParse(temp, out platform.InteropHeight))
                    {
                        throw new Exception($"Invalid interop swap height '{temp}' for platform '{platformName}'");
                    }

                    platform.WIF = node.GetString("wif");
                    if (string.IsNullOrEmpty(platform.WIF))
                    {
                        platform.WIF = null;
                    }


                    if (platform.Chain == SwapPlatformChain.Phantasma)
                    {
                        platform.RpcNodes = new string[0];
                    }
                    else
                    {
                        var rpcNodes = node.GetNode("rpc.nodes");
                        if (rpcNodes == null)
                        {
                            throw new Exception($"Config is missing rpc.nodes for platform '{platformName}'");
                        }

                        platform.RpcNodes = rpcNodes.Children.Select(x => x.Value).ToArray();
                    }
                }

                var specificNeoRpcNodes = section.GetNode("neo.rpc.specific.nodes");

                if (specificNeoRpcNodes != null && specificNeoRpcNodes.ChildCount > 0)
                {
                    var neoPlatform = SwapPlatforms.FirstOrDefault(x => x.Chain == SwapPlatformChain.Neo);
                    if (neoPlatform != null)
                    {
                        neoPlatform.RpcNodes = specificNeoRpcNodes.Children.Select(x => x.Value).ToArray();
                        this.NeoQuickSync    = true;
                    }
                }
            }
        }
Пример #14
0
 /// <summary> Sets the associated node mode of the dependency object. </summary>
 public static void SetAssociatedNodeMode(DependencyObject obj, NodeMode value)
 {
     obj.SetValue(AssociatedNodeModeProperty, value);
 }