public override Node CreateNode(string pName, Parameters pParameters)
        {
            var node = new Node
            {
                Name = pName,
                Parameters = pParameters,
                TechnologyName = "ANT",
                PropagationModel = NodeNetwork.Instance.PropagationModel,
                Position = new Position { X = -1, Y = -1 }
            };

            return node;
        }
        public EditNodeViewModel(Guid pNodeGuid)
        {
            EditNodeCommand = new EditNodeCommand(this);
            EditSensingPhenomenaCommand = new EditSensingPhenomenaCommand(this);

            mNode = mRepository.Get(n => n.Guid == pNodeGuid);

            if (mNode == null)
            {
                Log.Write(LogLevel.Error, string.Format("Nie można uzyskać węzła z Guid: {0} z repozytorium.", pNodeGuid));
            }
            else
            {
                MapNodeParametersToFields();
            }
        }
 /// <summary>
 /// Creates NodeViewModel instance using Node instance.
 /// </summary>
 public NodeViewModel(Node pNode)
 {
     ShowNodeInfoCommand = new ShowNodeInfoCommand(this);
     SetupBinding(pNode);
 }
        private void SetupBinding(Node pNode)
        {
            if (pNode != null)
            {
                Name = pNode.Name;
                Guid = pNode.Guid;
                NeighboursCount = pNode.Neighbours.Count();
                ConnectionsCount = pNode.Connections.Count(c => c.SecondNode != pNode.Guid);
                TransmissionRange = pNode.Parameters.EstimatedRange.ToString("##0.##") + "[m] ";

                if (Blueprint.Instance.IsGeometryMode) TransmissionRange += "(bez przeszkód)";

                TransmissionRange += string.Format("\n(Czułość odbiornika {0}[dBm])", pNode.Parameters.Sensitivity);
                Position = "[X: " + (int)pNode.Position.X + " Y: " + (int)pNode.Position.Y + "]";
            }
        }
 public void Update(Node pNode)
 {
     SetupBinding(pNode);
 }
 /// <summary>
 /// Replaces information contained in ViewModel for details of selected Node in Node's Neighbours section.
 /// </summary>
 public void BindModel(Node pSelectedNode)
 {
     Node = pSelectedNode;
     SetupBinding();
 }
        private void ConnectWithNeighbours(Node pNode)
        {
            foreach (var neighbour in pNode.Neighbours)
            {
                var nodeLink = new NodeLink
                {
                    Start = pNode.Position,
                    End = neighbour.Position,
                    FirstNode = pNode.Guid,
                    SecondNode = neighbour.Guid,
                    Distance = Tools.GetRealDistanceBetweenNodes(pNode.Position, neighbour.Position),
                    Type = NodeLink.Mode.SimplexToEnd
                };

                nodeLink.Type = neighbour.Neighbours.Any(n => n.Guid == pNode.Guid) ? NodeLink.Mode.Duplex : NodeLink.Mode.SimplexToEnd;

                Log.Write(LogLevel.Info, string.Format("Wyznaczono połączenie między węzłem {0} a węzłem {1} [{2}, {3}]",
                    pNode.Name, neighbour.Name, neighbour.Position.X, neighbour.Position.Y));

                mNodeNetwork.CreateNodeLink(nodeLink);
            }
        }
        private void TryConnectWithSink(Node pNode)
        {
            double nodeSignal, sinkSignal;

            if (mBlueprint.IsGeometryMode)
            {
                nodeSignal = mNodeNetwork.PropagationModel.CountSignalStrength(pNode.Position, mSink.Position, pNode.Parameters) + mSink.Parameters.Gain;
                sinkSignal = mNodeNetwork.PropagationModel.CountSignalStrength(mSink.Position, pNode.Position, mSink.Parameters) + pNode.Parameters.Gain;
            }
            else
            {
                var distance = Tools.GetRealDistanceBetweenNodes(pNode.Position, mSink.Position);

                nodeSignal = mNodeNetwork.PropagationModel.CountSignalStrength(distance, pNode.Parameters) + mSink.Parameters.Gain;
                sinkSignal = mNodeNetwork.PropagationModel.CountSignalStrength(distance, mSink.Parameters) + pNode.Parameters.Gain;
            }

            Log.Write(LogLevel.Info, string.Format("Sygnał nadawany z węzła: {0} dBm, docierający do stacji bazowej: {1} dBm (czułość odbiornika stacji bazowej {2} dBm)\n" +
                                                   "Sygnał nadawany ze stacji bazowej: {3} dBm, docierający do węzła: {4} dBm (czułość odbiornika węzła {5} dBm)",
                                                   pNode.Parameters.SignalStrength, nodeSignal, mSink.Parameters.Sensitivity,
                                                   mSink.Parameters.SignalStrength, sinkSignal, pNode.Parameters.Sensitivity));

            if (nodeSignal >= mSink.Parameters.Sensitivity && sinkSignal >= pNode.Parameters.Sensitivity)
            {
                var nodeLink = new NodeLink
                {
                    Start = pNode.Position,
                    End = mSink.Position,
                    Sink = mSink,
                    FirstNode = pNode.Guid,
                    Distance = Tools.GetRealDistanceBetweenNodes(pNode.Position, mSink.Position),
                    Type = NodeLink.Mode.Duplex
                };

                Log.Write(LogLevel.Info, string.Format("Wyznaczono połączenie między węzłem {0} a stacją bazową [{1},{2}]",
                                                        pNode.Name, mSink.Position.X, mSink.Position.Y));

                mNodeNetwork.CreateNodeLink(nodeLink);
                InSinkRangeNodes.Add(pNode);
            }
            else
            {
                Log.Write(LogLevel.Info, string.Format("Nie jest możliwe dwukierunkowe połączenie węzła {0} ze stacją bazową", pNode.Name));
                NotInSinkRangeNodes.Add(pNode);
            }
        }