/// <inheritdoc />
        public override XElement ToXElement()
        {
            XElement xml = base.ToXElement();

            if (NetworkLink.HasValue())
            {
                xml.Add(NetworkLink.ToXElement());
            }

            if (StyleSelectors != null)
            {
                foreach (KmlStyleSelector selector in StyleSelectors)
                {
                    xml.Add(selector.ToXElement());
                }
            }

            if (Features != null)
            {
                foreach (KmlFeature feature in Features)
                {
                    xml.Add(feature.ToXElement());
                }
            }

            return(xml);
        }
示例#2
0
文件: Rule6.cs 项目: tkuennen/cset
        private void CheckRule6(NetworkLink link)
        {
            NetworkComponent headComponent = link.SourceComponent;
            NetworkComponent tailComponent = link.TargetComponent;

            if ((headComponent == null) || (tailComponent == null))
            {
                return;
            }
            if (link.Security == Constants.UnTrusted)
            {
                if (headComponent.IsFirewall || tailComponent.IsFirewall)
                {
                    //If there is firewall don't show message
                }
                else
                {
                    String headName = "unnamed";
                    if (!String.IsNullOrWhiteSpace(headComponent.ComponentName))
                    {
                        headName = headComponent.ComponentName;
                    }

                    String tailName = "unnamed";
                    if (!String.IsNullOrWhiteSpace(tailComponent.ComponentName))
                    {
                        tailName = tailComponent.ComponentName;
                    }

                    String text = String.Format(rule6, headName, tailName);
                    SetLineMessage(headComponent, tailComponent, text);
                }
            }
        }
示例#3
0
 public TAPInterface(string name, bool persistent)
 {
     backupMAC       = EmulationManager.Instance.CurrentEmulation.MACRepository.GenerateUniqueMAC();
     Link            = new NetworkLink(this);
     deviceName      = name ?? "";
     this.persistent = persistent;
     Init();
 }
示例#4
0
    // Use this for initialization
    void Start()
    {
        _networkLink = gameObject.AddComponent <NetworkLink>();

        _networkLink.StartPoint.x = -3f;
        _networkLink.StartPoint.y = -3f;

        _networkLink.EndPoint.x = 3f;
        _networkLink.EndPoint.y = 3f;
    }
示例#5
0
        private string findEdgeId(NetworkNode component1, NetworkNode component2, ComponentPairing pair)
        {
            //if we didn't find it here then it's a connector and we need to walk the tree.
            //We will need to walk the tree and find the node we are looking for
            //printGraph(new List<NetworkComponent>(component1));
            NetworkWalk printer = new NetworkWalk();
            NetworkLink link    = printer.FindNodeEdge(component1, component2);

            return(link.ID);
        }
 private IEnumerable <NetworkLink <ISatellite> > FindNeighbors()
 {
     foreach (ISatellite sat in RTCore.Instance.Satellites)
     {
         NetworkLink <ISatellite> link = NetworkManager.GetLink(this, sat);
         if (link != null)
         {
             yield return(link);
         }
     }
 }
示例#7
0
文件: API.cs 项目: jvdnbus/SSAT2
        /// <summary>
        /// Get the maximum range distance between the satellites A and B based on current Range Model
        /// and valid direct connection.
        /// </summary>
        /// <param name="sat_a">The satellite id.</param>
        /// <param name="sat_b">The satellite id.</param>
        /// <returns>Positive number</returns>
        public static double GetMaxRangeDistance(Guid sat_a, Guid sat_b)
        {
            if (RTCore.Instance == null)
            {
                return(0.0);
            }

            //sanity check
            var satelliteA = RTCore.Instance.Network.Where(sat => sat.Guid.Equals(sat_a)).FirstOrDefault();
            var satelliteB = RTCore.Instance.Network.Where(sat => sat.Guid.Equals(sat_b)).FirstOrDefault();

            if (satelliteA == null || satelliteB == null)
            {
                return(0.0);
            }

            //get link object
            NetworkLink <ISatellite> link = null;

            switch (RTSettings.Instance.RangeModelType)
            {
            case RangeModel.RangeModel.Additive:
                link = RangeModelRoot.GetLink(satelliteA, satelliteB);
                break;

            default:
                link = RangeModelStandard.GetLink(satelliteA, satelliteB);
                break;
            }
            if (link == null)
            {
                return(0.0);              //no connection possible
            }
            //get max distance out of multiple antenna connections
            var distance    = 0.0;
            var maxDistance = 0.0;

            for (int i = 0; i < link.Interfaces.Count; i++)
            {
                switch (RTSettings.Instance.RangeModelType)
                {
                case RangeModel.RangeModel.Additive:
                    distance = RangeModelRoot.GetRangeInContext(link.Interfaces[i], satelliteB, satelliteA);
                    break;

                default:
                    distance = RangeModelStandard.GetRangeInContext(link.Interfaces[i], satelliteB, satelliteA);
                    break;
                }
                maxDistance = Math.Max(maxDistance, Double.IsNaN(distance) ? 0.0 : distance);
            }

            return(maxDistance);
        }
示例#8
0
        public Network ParseSVG(string svg, SVGNodeDescription nodeDescription, SVGNodeDescription linkDescription)
        {
            var nodeParser = this.svgParsersService.GetNodeParser(nodeDescription);
            var linkParser = this.svgParsersService.GetLinkParser(linkDescription);
            var svgNodes   = nodeParser.ParseAll(svg);
            var svgLinks   = linkParser.ParseAll(svg);
            var netNodes   = svgNodes.Select(x => NetworkNode.FromProperties(x.Properties));
            var netLinks   = svgLinks.Select(x => NetworkLink.FromProperties(x.Properties));
            var network    = new Network()
            {
                Nodes = netNodes,
                Links = netLinks
            };

            return(network);
        }
示例#9
0
        private static Feature CreateFeature(int index, bool id)
        {
            Feature output;
            int     type = index % 7;

            switch (type)
            {
            case 0:
                output = new Placemark();
                break;

            case 1:
                output = new Folder();
                break;

            case 2:
                output = new Document();
                break;

            case 3:
                output = new NetworkLink();
                break;

            case 4:
                output = new GroundOverlay();
                break;

            case 5:
                output = new ScreenOverlay();
                break;

            default:
                output = new PhotoOverlay();
                break;
            }

            if (id)
            {
                output.Id = "i" + index;
            }
            else
            {
                output.TargetId = "i" + index;
            }
            return(output);
        }
示例#10
0
        internal void AddEdge(NetworkComponent target, NetworkLink link)
        {
            if (target == null)
            {
                return;
            }
            ComponentPairing t = new ComponentPairing()
            {
                Source = this.ComponentGuid,
                Target = target.ComponentGuid
            };

            Connections.Add(target);
            FullyConnectedConnections.Add(new FullNode()
            {
                Source = this, Target = target, Link = link
            });
        }
示例#11
0
        /// <summary>
        /// Return the inital KMZ as requested by the apsim.info web site.
        /// </summary>
        private byte[] MyDataKMZ()
        {
            kml KmlContainer = new kml();

            Document KmlDoc = new Document();

            KmlDoc.Name.Text            = "APSoil characterised soils";
            KmlDoc.Snippet.Text         = "Fully characterised soil sites for use with APSIM and Yield Prophet.";
            KmlDoc.Description.UseCDATA = true;
            KmlDoc.Description.Text     = "<p>The soil sites displayed are from APSoil</p>";
            KmlContainer.Documents.Add(KmlDoc);

            NetworkLink KmlNetworkLink = new NetworkLink("APSoil soils", "All characterised soils");

            KmlNetworkLink.Link.Href.Text         = ourPath + "/ApsoilKML.aspx?Mode=1";
            KmlNetworkLink.Link.RefreshMode.Value = refreshModeEnum.onExpire;
            KmlDoc.Features.NetworkLinks.Add(KmlNetworkLink);

            return(KmlContainer.GetKMZ("APSRU_Sites.kml"));
        }
示例#12
0
        public SMSC9500(Machine machine)
        {
            this.machine = machine;
            MAC          = EmulationManager.Instance.CurrentEmulation.MACRepository.GenerateUniqueMAC();
            Link         = new NetworkLink(this);
            for (int i = 0; i < NumberOfEndpoints; i++)
            {
                dataToggleBit[i] = false;
            }
            endpointDescriptor = new EndpointUSBDescriptor[NumberOfEndpoints];
            for (int i = 0; i < NumberOfEndpoints; i++)
            {
                endpointDescriptor[i] = new EndpointUSBDescriptor();
            }
            fillEndpointsDescriptors(endpointDescriptor);
            interfaceDescriptor[0].EndpointDescriptor   = endpointDescriptor;
            configurationDescriptor.InterfaceDescriptor = interfaceDescriptor;

            rxPacketQueue = new Queue <EthernetFrame>();
        }
 public static double DistanceTo(this ISatellite a, NetworkLink<ISatellite> b)
 {
     return Vector3d.Distance(a.Position, b.Target.Position);
 }
示例#14
0
 public OsXTapInterface(string interfaceNameOrPath)
 {
     Link = new NetworkLink(this);
     originalInterfaceNameOrPath = interfaceNameOrPath;
     Init();
 }
 /// <summary>
 /// Our own version of the distance function, less accurate, but far lower execution cost.
 /// </summary>
 public static double DistanceTo(ISatellite a, NetworkLink<ISatellite> b)
 {
     return Math.Abs(a.Position.x - b.Target.Position.x) +
         Math.Abs(a.Position.y - b.Target.Position.y) +
         Math.Abs(a.Position.z - b.Target.Position.z);
 }
        /// <summary>
        /// Setup for Nunit Tests.
        /// </summary>
        protected override void OnSetup()
        {
            mockLoggingHelper = CreateMock <ILoggingHelper>();
            unit1Guid         = Guid.NewGuid();
            unit2Guid         = Guid.NewGuid();
            unit3Guid         = Guid.NewGuid();
            user1Id           = System.Guid.NewGuid();
            user2Id           = System.Guid.NewGuid();

            var unitBoundary = DbGeometry.PolygonFromText("POLYGON((511570.8590967182 106965.35195621933, 511570.8590967182 107474.95297542136, 512474.1409032818 107474.95297542136, 512474.1409032818 106965.35195621933, 511570.8590967182 106965.35195621933))", 27700);
            var location     = new List <Location>()
            {
                new Location()
                {
                    ID = unit1Guid, Shape = unitBoundary
                }
            };
            var networkLinks = new List <NetworkLink>()
            {
                new NetworkLink()
                {
                    LinkGeometry = unitBoundary,
                }
            };
            var networkLink = new NetworkLink()
            {
                LinkGeometry = unitBoundary,
            };
            var accessLink = new List <AccessLink>()
            {
                new AccessLink()
                {
                    ID = Guid.NewGuid(), NetworkLink = networkLink
                }
            };
            var deliveryPoint = new List <DeliveryPoint>()
            {
                new DeliveryPoint()
                {
                    NetworkNode = new NetworkNode()
                    {
                        Location = new Location()
                        {
                            Shape = unitBoundary
                        }
                    }
                }
            };

            var networkNodeDataDTO = new NetworkNodeDataDTO()
            {
                ID       = Guid.NewGuid(),
                Location = new LocationDataDTO()
                {
                    ID                = Guid.NewGuid(),
                    Shape             = unitBoundary,
                    RowCreateDateTime = DateTime.UtcNow
                }
            };

            var accessLinkDataDTOs = new AccessLinkDataDTO()
            {
                Approved               = true,
                ID                     = Guid.NewGuid(),
                WorkloadLengthMeter    = 40,
                LinkDirectionGUID      = Guid.NewGuid(),
                ConnectedNetworkLinkID = Guid.NewGuid(),
                AccessLinkTypeGUID     = Guid.NewGuid()
            };

            var accessLinkStatus = new AccessLinkStatusDataDTO()
            {
                ID                   = Guid.NewGuid(),
                NetworkLinkID        = Guid.NewGuid(),
                AccessLinkStatusGUID = Guid.NewGuid(),
                StartDateTime        = DateTime.UtcNow,
                RowCreateDateTime    = DateTime.UtcNow
            };

            netWorkLinkDataDto = new NetworkLinkDataDTO()
            {
                ID = Guid.NewGuid(),
                DataProviderGUID    = Guid.NewGuid(),
                NetworkLinkTypeGUID = Guid.NewGuid(),
                StartNodeID         = Guid.NewGuid(),
                EndNodeID           = Guid.NewGuid(),
                LinkLength          = 40,
                LinkGeometry        = unitBoundary,
                RowCreateDateTime   = DateTime.UtcNow,
            };

            var mockAsynEnumerable = new DbAsyncEnumerable <AccessLink>(accessLink);

            mockFmoDbContext = CreateMock <AccessLinkDBContext>();
            mockFmoDbContext.Setup(x => x.SaveChanges()).Returns(1);
            var mockAccessLinkDataService = MockDbSet(accessLink);

            mockFmoDbContext.Setup(x => x.Set <AccessLink>()).Returns(mockAccessLinkDataService.Object);
            mockFmoDbContext.Setup(x => x.AccessLinks).Returns(mockAccessLinkDataService.Object);

            // mockFmoDbContext.Setup(c => c.AccessLinks.AsNoTracking()).Returns(mockAccessLinkDataService.Object);
            mockAccessLinkDataService.Setup(x => x.Include(It.IsAny <string>())).Returns(mockAccessLinkDataService.Object);
            mockAccessLinkDataService.Setup(x => x.AsNoTracking()).Returns(mockAccessLinkDataService.Object);

            var mockAccessLinkDataService1 = MockDbSet(networkLinks);

            mockFmoDbContext.Setup(x => x.Set <NetworkLink>()).Returns(mockAccessLinkDataService1.Object);
            mockFmoDbContext.Setup(x => x.NetworkLinks).Returns(mockAccessLinkDataService1.Object);

            // mockFmoDbContext.Setup(c => c.NetworkLinks.AsNoTracking()).Returns(mockAccessLinkDataService1.Object);
            mockAccessLinkDataService1.Setup(x => x.AsNoTracking()).Returns(mockAccessLinkDataService1.Object);

            var mockAccessLinkDataService4 = MockDbSet(deliveryPoint);

            mockFmoDbContext.Setup(x => x.Set <DeliveryPoint>()).Returns(mockAccessLinkDataService4.Object);
            mockFmoDbContext.Setup(x => x.DeliveryPoints).Returns(mockAccessLinkDataService4.Object);
            mockAccessLinkDataService4.Setup(x => x.AsNoTracking()).Returns(mockAccessLinkDataService4.Object);

            var mockAsynEnumerable2        = new DbAsyncEnumerable <Location>(location);
            var mockAccessLinkDataService2 = MockDbSet(location);

            mockFmoDbContext.Setup(x => x.Set <Location>()).Returns(mockAccessLinkDataService2.Object);
            mockFmoDbContext.Setup(x => x.Locations).Returns(mockAccessLinkDataService2.Object);
            mockFmoDbContext.Setup(c => c.Locations.AsNoTracking()).Returns(mockAccessLinkDataService2.Object);

            mockDatabaseFactory = CreateMock <IDatabaseFactory <AccessLinkDBContext> >();
            mockDatabaseFactory.Setup(x => x.Get()).Returns(mockFmoDbContext.Object);

            var rmTraceManagerMock = new Mock <IRMTraceManager>();

            rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>()));
            mockLoggingHelper.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object);

            testCandidate = new AccessLinkDataService(mockDatabaseFactory.Object, mockLoggingHelper.Object);
        }
示例#17
0
 private void OnLinkRemove(ISatellite a, NetworkLink<ISatellite> link)
 {
     mEdges.Remove(new BidirectionalEdge<ISatellite>(a, link.Target, link.Port));
 }
 public USBEthernetControlModelDevice()
 {
     Link = new NetworkLink(this);
 }
 /// <summary>
 /// Our own version of the distance function, less accurate, but far lower execution cost.
 /// </summary>
 public static double DistanceTo(ISatellite a, NetworkLink <ISatellite> b)
 {
     return((Math.Abs(a.Position.x - b.Target.Position.x) +
             Math.Abs(a.Position.y - b.Target.Position.y) +
             Math.Abs(a.Position.z - b.Target.Position.z)) * DIST_FACTOR);
 }
示例#20
0
        public void ExtractNetworkFromXml(XmlDocument xDoc)
        {
            //create a dictionary of connected graphs
            //go through the document creating each node and its connections
            //have a dictionary of nodes to see if we saw this node already
            //if so do not recreate it.
            //if not create the node and it's connections
            //once the graph is built pick a node and start moving through them
            //to extract minimal spanning tree(s)
            //then walk the tree to evaluate node rules

            XmlNodeList objectNodes       = xDoc.SelectNodes("/mxGraphModel/root/object[not(@redDot)]");
            XmlNodeList zoneNodes         = xDoc.SelectNodes("//*[@zone=\"1\"]");
            XmlNodeList mxCellLinkObjects = xDoc.SelectNodes("/mxGraphModel/root/object[mxCell/@edge='1']");
            XmlNodeList mxCellLinks       = xDoc.SelectNodes("//*[@edge=\"1\"]");

            XmlNodeList mxCellLayers = xDoc.SelectNodes("//*[@parent=\"0\" and @id]");

            foreach (XmlNode layer in mxCellLayers)
            {
                string id = layer.Attributes["id"].Value;
                layers.Add(id, new NetworkLayer()
                {
                    ID        = id,
                    LayerName = layer.Attributes["value"] != null ? layer.Attributes["value"].Value : Constants.DEFAULT_LAYER_NAME,
                    Visible   = layer.Attributes["visible"] != null ? (layer.Attributes["visible"].Value == "0" ? false : true) : true
                });
            }

            foreach (XmlNode node in zoneNodes)
            {
                //determine if it is an edge or a node
                //if it is an node look it up(should be new)
                //and create it
                //if it is an edge then we need to save it until all the nodes are created
                //once we have them all start connecting everything up.

                //if it is a zone then just skip it
                if (((XmlElement)node).HasAttribute("zone"))
                {
                    string zone = node.Attributes["id"].Value;

                    zones.Add(zone, new NetworkZone()
                    {
                        ID       = zone,
                        ZoneType = node.Attributes["ZoneType"].Value,
                        SAL      = node.Attributes["SAL"].Value
                    });
                }
            }


            foreach (XmlNode node in objectNodes)
            {
                //determine if it is an edge or a node
                //if it is an node look it up(should be new)
                //and create it
                //if it is an edge then we need to save it until all the nodes are created
                //once we have them all start connecting everything up.

                //if it is a zone then just skip it
                if (((XmlElement)node).HasAttribute("zone"))
                {
                    continue;
                }


                //do a little preprocessing to get the attribute values
                var styleString = node.FirstChild.Attributes["style"].Value;


                // if it is a group then skip it
                if (styleString.Split(';').Contains("group"))
                {
                    continue;
                }


                int nodeType = 0;

                string imgPath;
                if (DrawIOParsingHelps.DecodeQueryParameters(styleString.Replace("image;", "")).TryGetValue("image", out imgPath))
                {
                    if (!imageToTypePath.TryGetValue(imgPath.Replace("img/cset/", ""), out nodeType))
                    {
                    }
                }
                else
                {
                    //I think we can assume
                    nodeType = 49;// "MSC";
                }

                //get the parent value if it is in the layers dictionary then set the
                //visible value to the value of the parent
                //else set it to visible
                string       layername = node.FirstChild.Attributes["parent"].Value;
                NetworkLayer layer;
                bool         IsVisible = true;
                if (layers.TryGetValue(layername, out layer))
                {
                    if (!layer.Visible)
                    {
                        //if it is not visible skip it.
                        continue;
                    }
                }

                //extract the geometry to a point on the component
                NetworkGeometry geometry = new NetworkGeometry(node.FirstChild.FirstChild);

                NetworkComponent dnode;
                string           id = node.Attributes["id"].Value;
                if (nodes.TryGetValue(id, out dnode))
                {
                    //this should never happen we should never have a duplicate id
                }
                else
                {
                    dnode = new NetworkComponent()
                    {
                        ComponentGuid       = ((XmlElement)node).HasAttribute("ComponentGuid") ? Guid.Parse(node.Attributes["ComponentGuid"].Value) : new Guid(),
                        ID                  = node.Attributes["id"].Value,
                        ComponentName       = ((XmlElement)node).HasAttribute("label") ? node.Attributes["label"].Value : "",
                        Component_Symbol_Id = nodeType,
                        //ComponentType = nodeType,
                        IsVisible = IsVisible,
                        Parent_id = layername,
                        Geometry  = geometry
                    };

                    NetworkZone myzone;
                    if (zones.TryGetValue(layername, out myzone))
                    {
                        dnode.Zone = myzone;
                    }
                    else
                    {
                        dnode.Zone = defaultZone;
                    }
                    nodes.Add(id, dnode);
                }
            }

            //the mxCellLinks list also has the objects
            //so we keep track of the child id's and
            //if we see them again in the raw links
            //then just skip it.
            foreach (XmlNode node in mxCellLinkObjects)
            {
                XmlElement xNode = (XmlElement)node;
                var        link  = new NetworkLink();
                foreach (XmlAttribute a in node.Attributes)
                {
                    link.setValue(a.Name, a.Value);
                }
                Links.Add(link);
                var childnode = ((XmlElement)xNode.FirstChild);
                //find each node
                //add them to each other
                if (childnode.HasAttribute("source") && childnode.HasAttribute("target"))
                {
                    NetworkComponent start  = findNode(childnode.Attributes["source"].Value);
                    NetworkComponent target = findNode(childnode.Attributes["target"].Value);
                    //map any other attributes
                    link.SourceComponent = start;
                    link.TargetComponent = target;
                    start?.AddEdge(target, link);
                    target?.AddEdge(start, link);
                }
            }
            foreach (XmlNode node in mxCellLinks)
            {
                XmlElement xNode = (XmlElement)node;
                if (((XmlElement)xNode.ParentNode).Name == "object")
                {
                    continue;//skip it
                }
                //find each node
                //add them to each other
                if (xNode.HasAttribute("source") && xNode.HasAttribute("target"))
                {
                    NetworkComponent start  = findNode(node.Attributes["source"].Value);
                    NetworkComponent target = findNode(node.Attributes["target"].Value);
                    //map any other attributes
                    var link = new NetworkLink();
                    link.ID = xNode.Attributes["id"].Value;
                    link.SourceComponent = start;
                    link.TargetComponent = target;
                    Links.Add(link);
                    start?.AddEdge(target, link);
                    target?.AddEdge(start, link);
                }
            }
            this.nodes = PostProcessConnectors.RemoveConnectors(nodes);
        }
示例#21
0
 /// <summary>Finds the distance between an ISatellite and the target of a connection</summary>
 /// <returns>The distance in meters.</returns>
 /// <param name="sat">The satellite from which the distance is to be measured.</param>
 /// <param name="link">The network node to whose destination the distance is to be measured.</param>
 public static double DistanceTo(this ISatellite sat, NetworkLink<ISatellite> link)
 {
     return Vector3d.Distance(sat.Position, link.Target.Position);
 }
示例#22
0
 /// <summary>Finds the distance between an ISatellite and the target of a connection</summary>
 /// <returns>The distance in meters.</returns>
 /// <param name="sat">The satellite from which the distance is to be measured.</param>
 /// <param name="link">The network node to whose destination the distance is to be measured.</param>
 public static double DistanceTo(this ISatellite sat, NetworkLink <ISatellite> link)
 {
     return(Vector3d.Distance(sat.Position, link.Target.Position));
 }
示例#23
0
 public USBEthernetEmulationModelDevice()
 {
     Link = new NetworkLink(this);
 }