Exemple #1
0
        public Node(ushort nodeId, Posistion posistion, Features features, Dictionary <ModelType, Model> primaryElementExtensionModels = null)
        {
            Id        = nodeId;
            Address   = new Address(AddressType.Unicast, nodeId);
            Posistion = posistion;
            Listener  = new Listener(nodeId);

            Elements = new Dictionary <ElementType, Element>()
            {
                { ElementType.primary, new Element()
                  {
                      Address = this.Address
                  } }
            };

            var serverModel = new ConfigurationServerModel(features)
            {
                ElementId = Elements[ElementType.primary].Address.Value
            };

            Elements[ElementType.primary].AddModel(ModelType.ConfigurationServer, serverModel);

            if (primaryElementExtensionModels != null)
            {
                foreach (var item in primaryElementExtensionModels)
                {
                    Elements[ElementType.primary].AddModel(item.Key, item.Value);
                }
            }
            StatusFlag = 0;
        }
Exemple #2
0
        public double DistanceTo(Posistion B)
        {
            var AB = Math.Sqrt(Math.Pow(X - B.X, 2) + Math.Pow(Y - B.Y, 2));

            return(AB);
        }