Exemplo n.º 1
0
        public FiberCableInfoProjection(IRouteNetworkState routeNetworkQueryService, IFiberNetworkQueryService fiberNetworkQueryService)
        {
            this.routeNetworkQueryService = routeNetworkQueryService;
            this.fiberNetworkQueryService = (FiberNetworkQueryService)fiberNetworkQueryService;

            ProjectEvent <FiberCablePlaced>(OnFiberCablePlaced);
        }
Exemplo n.º 2
0
        public TestRouteNetworkType1(ContainerFixtureBase container)
        {
            this._bus          = container.CommandBus;
            this._queryService = container.ServiceProvider.GetService <IRouteNetworkState>();

            BuildInitalNetwork();
        }
Exemplo n.º 3
0
        public DiagramServiceQuery(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IFiberNetworkQueryService fiberNetworkService, IDataLoaderContextAccessor dataLoader)
        {
            Description = "GraphQL API for generating fiber equiment diagrams.";

            Field <DiagramType>(
                "buildRouteNodeDiagram",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "routeNodeId"
            },
                    new QueryArgument <StringGraphType> {
                Name = "exportGeojsonFileName"
            }
                    ),
                resolve: context =>
            {
                var routeNodeId  = context.GetArgument <Guid>("routeNodeId");
                var jsonFilename = context.GetArgument <string>("exportGeojsonFileName");

                var diagram = new ConduitClosureBuilder().Build(routeNodeId, routeNetworkQueryService, conduitNetworkEqueryService, fiberNetworkService, conduitClosureRepository);

                if (jsonFilename != null)
                {
                    var export = new GeoJsonExporter(diagram);
                    export.Export(jsonFilename);
                }

                return(diagram);
            }
                );
        }
Exemplo n.º 4
0
 public FiberCableCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IFiberNetworkQueryService fiberNetworkQueryService)
 {
     this.repo = aggregateRepository;
     this.conduitNetworkQueryService = conduitNetworkQueryService;
     this.routeNetworkQueryService   = routeNetworkQueryService;
     this.fiberNetworkQueryService   = fiberNetworkQueryService;
 }
Exemplo n.º 5
0
        public void Split(Guid nodeId, IRouteNetworkState routeQueryService)
        {
            var segmentInfo = routeQueryService.GetRouteSegmentInfo(this.Id);

            var nodeInfo = routeQueryService.GetRouteNodeInfo(nodeId);

            // Check that split node is close enough to the segment to be splitted
            var line = ConvertFromLineGeoJson(segmentInfo.Geometry.GeoJsonCoordinates);

            var nodePoint = ConvertFromPointGeoJson(nodeInfo.Geometry.GeoJsonCoordinates);

            var test = line.Distance(nodePoint);

            if (test > 0.000001)
            {
                throw new ArgumentException("Coordinate of node used for splitting the segment is not within allowed distance to segment. The distance is greather than 0.000001 decimal degress (around 5-10 cm) which is not allowed.");
            }

            PlannedRouteSegmentSplitByNode segmentSplitEvent = new PlannedRouteSegmentSplitByNode()
            {
                Id = this.Id, SplitNodeId = nodeId
            };

            RaiseEvent(segmentSplitEvent);
        }
        public EquipmentServiceQuery(IRouteNetworkState routeNetwork)
        {
            Description = "GraphQL API for querying OpenFTTH data";

            Field <StringGraphType>("apiVersion", resolve: context => VersionInfo.VersionString());

            Field <ListGraphType <RouteNodeType> >(
                "routeNodes",
                resolve: context =>
            {
                return(routeNetwork.GetAllRouteNodes());
            }
                );

            Field <RouteNodeType>(
                "routeNode",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "Id"
            }),
                resolve: context =>
            {
                Guid id;
                if (!Guid.TryParse(context.GetArgument <string>("id"), out id))
                {
                    context.Errors.Add(new ExecutionError("Wrong value for guid"));
                    return(null);
                }

                return(routeNetwork.GetRouteNodeInfo(id));
            }
                );


            Field <ListGraphType <RouteSegmentType> >(
                "routeSegments",
                resolve: context => {
                return(routeNetwork.GetAllRouteSegments());
            }
                );

            Field <RouteSegmentType>(
                "routeSegment",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "Id"
            }),
                resolve: context =>
            {
                Guid id;
                if (!Guid.TryParse(context.GetArgument <string>("id"), out id))
                {
                    context.Errors.Add(new ExecutionError("Wrong value for guid"));
                    return(null);
                }
                return(routeNetwork.GetRouteSegmentInfo(id));
            }
                );

            Field <ConduitServiceQuery>("conduitService", resolve: context => new { });
            Field <DiagramServiceQuery>("diagramService", resolve: context => new { });
        }
Exemplo n.º 7
0
 public MultiConduitCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitSpecificationRepository conduitSpecificationRepository)
 {
     this.repo = aggregateRepository;
     this.conduitNetworkQueryService     = conduitNetworkQueryService;
     this.routeNetworkQueryService       = routeNetworkQueryService;
     this.conduitSpecificationRepository = conduitSpecificationRepository;
 }
        public TestRouteNetworkType1(IMediator bus, IRouteNetworkState routeNetworkState)
        {
            this._bus          = bus;
            this._queryService = routeNetworkState;

            BuildInitalNetwork();
        }
Exemplo n.º 9
0
 public ConduitClosureCommandHandler(IAggregateRepository aggregateRepository, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
 {
     this.repo = aggregateRepository;
     this.routeNetworkQueryService   = routeNetworkQueryService;
     this.conduitNetworkQueryService = conduitNetworkQueryService;
     this.conduitClosureRepository   = conduitClosureRepository;
 }
Exemplo n.º 10
0
        public MultiConduitInfoProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = (ConduitNetworkQueryService)conduitNetworkQueryService;

            ProjectEvent <MultiConduitPlaced>(OnMultiConduitPlaced);
            ProjectEvent <MultiConduitOuterConduitCut>(OuterConduitCut);
        }
        public ConduitClosureType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A conduit closure.";

            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");
            Field(x => x.Sides, type: typeof(ListGraphType <ConduitClosureSideType>)).Description("Sides of the closure");
        }
Exemplo n.º 12
0
        public InMemRouteNetworkRepository(ILoggerFactory loggerFactory, IRouteNetworkState routeNetworkState)
        {
            if (null == loggerFactory)
            {
                throw new ArgumentNullException("loggerFactory is null");
            }

            _logger = loggerFactory.CreateLogger <InMemRouteNetworkRepository>();

            _routeNetworkState = routeNetworkState;
        }
Exemplo n.º 13
0
        public ConduitClosureSideType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A specific side of a conduit closure. Sides are numbered clockwise: 1=Top 2=Right 3=Buttom 4=Left";

            Field(x => x.DigramLabel, type: typeof(StringGraphType)).Description("Label the user/system like to be placed along the side. Could e.g. be a street name.");
            Field(x => x.Position, type: typeof(ConduitClosureSideEnumType)).Description("Side position. 1=Top 2=Right 3=Buttom 4=Left");
            Field(x => x.Ports, type: typeof(ListGraphType <ConduitClosurePortType>)).Description("Ports on the side");
        }
Exemplo n.º 14
0
        public void CutInnerConduit(int sequenceNumber, Guid pointOfInterestId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            var multiConduitInfo = conduitNetworkQueryService.GetMultiConduitInfo(Id);

            // Point of interest id check
            if (pointOfInterestId == null || pointOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("PointOfInterestId cannot be null or empty");
            }

            // Inner conduit number check
            if (!multiConduitInfo.Children.OfType <ConduitInfo>().Any(i => i.SequenceNumber == sequenceNumber))
            {
                throw new ArgumentException("Cannot find inner conduit number: " + sequenceNumber + " in multi conduit: " + Id);
            }


            var singleConduitInfo = conduitNetworkQueryService.GetSingleConduitInfo(multiConduitInfo.Children.OfType <ConduitInfo>().Single(i => i.SequenceNumber == sequenceNumber).Id);

            // Multi conduit cut check
            if (!multiConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId || s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("Multi conduit: " + Id + " is not cut at: " + pointOfInterestId + " You cannot cut a inner conduit before the outer conduit is cut.");
            }

            // Inner conduit cut check
            if (singleConduitInfo.Segments.Exists(s => s.FromRouteNodeId == pointOfInterestId || s.ToRouteNodeId == pointOfInterestId))
            {
                throw new ArgumentException("Inner conduit number: " + sequenceNumber + " in multi conduit: " + Id + " is already cut at: " + pointOfInterestId);
            }

            // Check that conduit is cut at a node part of conduit walk of interest
            var walkOfInterest = routeNetworkQueryService.GetWalkOfInterestInfo(multiConduitInfo.WalkOfInterestId);

            if (!walkOfInterest.AllNodeIds.Contains(pointOfInterestId))
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " was not found in walk of interest:" + multiConduitInfo.WalkOfInterestId + " of multi conduit: " + Id);
            }

            // Check that conduit is not cut at ends
            if (walkOfInterest.StartNodeId == pointOfInterestId || walkOfInterest.EndNodeId == pointOfInterestId)
            {
                throw new ArgumentException("The point of interest: " + pointOfInterestId + " is one of the ends in walk of interest:" + multiConduitInfo.WalkOfInterestId + " of multi conduit: " + Id + " This is not allowed. You cannot cut a conduit at its ends.");
            }


            RaiseEvent(new MultiConduitInnerConduitCut
            {
                MultiConduitId             = Id,
                InnerConduitSequenceNumber = sequenceNumber,
                PointOfInterestId          = pointOfInterestId
            });
        }
Exemplo n.º 15
0
        public ConduitServiceQuery(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitSpecificationRepository conduitSpecificationRepository, IDataLoaderContextAccessor dataLoader)
        {
            Description = "GraphQL API for querying the conduit service.";

            Field <ListGraphType <ConduitSpecificationType> >(
                "conduitSpecifications",
                resolve: context =>
            {
                return(conduitSpecificationRepository.GetConduitSpecifications());
            }
                );
        }
Exemplo n.º 16
0
        public SingleConduitInfoProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = (ConduitNetworkQueryService)conduitNetworkQueryService;


            // New single conduits
            ProjectEvent <SingleConduitPlaced>(
                (session, singleConduitPlaced) =>
            {
                return(singleConduitPlaced.SingleConduitId);
            },
                SingleConduitPlaced);

            // Single conduits connected
            ProjectEvent <SingleConduitConnected>(
                (session, singleConduitConnected) =>
            {
                return(singleConduitConnected.SingleConduitId);
            },
                SingleConduitConnected);


            // We also want to update single conduit info when a inner conduit of a multi conduit is added
            ProjectEvent <MultiConduitInnerConduitAdded>(
                (session, innerConduitAdded) =>
            {
                return(innerConduitAdded.ConduitInfo.Id);
            },
                InnerConduitAdded);


            // We also want to update the single conduit info when a inner conduit of a multi conduit is cut
            ProjectEvent <MultiConduitInnerConduitCut>(
                (session, innerConduitAdded) =>
            {
                // To get to the right single conduit, we need look it up through the multi conduit
                var mutltiConduitInfo = this.conduitNetworkQueryService.GetMultiConduitInfo(innerConduitAdded.MultiConduitId);
                return(mutltiConduitInfo.Children.OfType <ConduitInfo>().Single(c => c.SequenceNumber == innerConduitAdded.InnerConduitSequenceNumber).Id);
            },
                InnerConduitCut);


            // We also want to update the single conduit info when a inner conduit of a multi conduit is connected
            ProjectEvent <MultiConduitInnerConduitConnected>(
                (session, innerConduitConnected) =>
            {
                // To get to the right single conduit, we need look it up through the multi conduit
                var mutltiConduitInfo = this.conduitNetworkQueryService.GetMultiConduitInfo(innerConduitConnected.MultiConduitId);
                return(mutltiConduitInfo.Children.OfType <ConduitInfo>().Single(c => c.SequenceNumber == innerConduitConnected.InnerConduitSequenceNumber).Id);
            },
                InnerConduitConnected);
        }
Exemplo n.º 17
0
        public RouteNodeInfoProjection(IRouteNetworkState routeNetworkQueryService)
        {
            this.routeNetworkQueryService = (RouteNetworkState)routeNetworkQueryService;

            ProjectEvent <RouteNodePlanned>(
                (session, domainEvent) =>
            {
                return(domainEvent.Id);
            },
                OnRouteNodeAdded
                );
        }
        public FindNearestRouteNodeQueryHandler(ILoggerFactory loggerFactory, IEventStore eventStore, IRouteNetworkRepository routeNodeRepository, IRouteNetworkState routeNetworkState)
        {
            if (null == loggerFactory)
            {
                throw new ArgumentNullException("loggerFactory is null");
            }

            _logger = loggerFactory.CreateLogger <FindNearestRouteNodeQueryHandler>();

            _eventStore          = eventStore;
            _routeNodeRepository = routeNodeRepository;
            _routeNetworkState   = routeNetworkState;
        }
        public RouteNetworkEventHandler(ILoggerFactory loggerFactory, IRouteNetworkState networkState, IEventStore eventStore, ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
        {
            if (null == loggerFactory)
            {
                throw new ArgumentNullException("loggerFactory is null");
            }

            _logger = loggerFactory.CreateLogger <RouteNetworkEventHandler>();

            _networkState      = networkState;
            _eventStore        = eventStore;
            _commandDispatcher = commandDispatcher;
            _queryDispatcher   = queryDispatcher;
        }
        public RouteSegmentGraphFunctions(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitClosureRepository conduitClosureRepository, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;
            this.conduitClosureRepository    = conduitClosureRepository;

            Description = "Route segment graph functions";

            Field <ListGraphType <RouteNodeType> >(
                "neighborNodes",
                resolve: context =>
            {
                List <RouteNodeInfo> result = new List <RouteNodeInfo>();

                var routeSegment = context.Source as RouteSegmentInfo;

                foreach (var neighbor in routeSegment.NeighborElements)
                {
                    result.Add((RouteNodeInfo)neighbor);
                }

                return(result);
            });


            Field <ListGraphType <RouteSegmentType> >(
                "neighborSegments",
                resolve: context =>
            {
                List <RouteSegmentInfo> result = new List <RouteSegmentInfo>();

                var routeSegment = context.Source as RouteSegmentInfo;

                foreach (var neighbor in routeSegment.NeighborElements)
                {
                    var neighborNeighbors = neighbor.NeighborElements;

                    foreach (var neighborNeighbor in neighborNeighbors)
                    {
                        if (neighborNeighbor != routeSegment)
                        {
                            result.Add((RouteSegmentInfo)neighborNeighbor);
                        }
                    }
                }

                return(result);
            });
        }
        public RouteNetworkEventConsumer(ILoggerFactory loggerFactory, IEventStore eventStore, IOptions <KafkaSetting> kafkaSetting, IOptions <EventStoreDatabaseSetting> eventStoreDatabaseSetting, IOptions <GeoDatabaseSetting> geoDatabaseSetting, IToposTypedEventObservable <RouteNetworkEditOperationOccuredEvent> eventDispatcher, RouteNetworkEventHandler routeNetworkEventHandler, IRouteNetworkState routeNetworkState, ICommandDispatcher commandDispatcher, IQueryDispatcher queryDispatcher)
        {
            _loggerFactory             = loggerFactory;
            _logger                    = _loggerFactory.CreateLogger <RouteNetworkEventConsumer>();
            _eventStore                = eventStore;
            _kafkaSetting              = kafkaSetting.Value;
            _eventStoreDatabaseSetting = eventStoreDatabaseSetting.Value;
            _geoDatabaseSetting        = geoDatabaseSetting.Value;

            _commandDispatcher = commandDispatcher;
            _queryDispatcher   = queryDispatcher;

            _eventDispatcher          = eventDispatcher;
            _routeNetworkEventHandler = routeNetworkEventHandler;
            _routeNetworkState        = routeNetworkState;
        }
Exemplo n.º 22
0
        public FiberNetworkQueryService(IDocumentStore documentStore, IRouteNetworkState routeNetworkQueryService)
        {
            this._documentStore            = documentStore;
            this._routeNetworkQueryService = routeNetworkQueryService;
            this._pointOfInterestIndex     = new PointOfInterestIndex(routeNetworkQueryService);


            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <FiberCableInfo, FiberCableInfo>();
            });


            _mapper = config.CreateMapper();

            Load();
        }
Exemplo n.º 23
0
        public ConduitSpecificationType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IConduitSpecificationRepository conduitSpecificationRepository, IDataLoaderContextAccessor dataLoader)
        {
            Description = "A specification of a conduit, that might be shared among manufacturer product models.";

            Field <ConduitKindEnumType>("Kind", "Kind of conduit (multi or single conduit)");
            Field(x => x.Id, type: typeof(IdGraphType)).Description("Guid property");
            Field(x => x.SequenceNumber, type: typeof(IdGraphType)).Description("The position of the conduit inside a multi conduit. Field only populated on inner conduits (conduits inside a multi conduit)");
            Field <ConduitShapeKindEnumType>("Shape", "Shape of conduit - flat, round etc.");
            Field <ConduitColorEnumType>("Color", "Color of the conduit itself");
            Field(x => x.InnerDiameter, type: typeof(IdGraphType)).Description("Inner diameter of the conduit");
            Field(x => x.OuterDiameter, type: typeof(IdGraphType)).Description("Outer diameter of the conduit");

            Field(x => x.ProductModels, type: typeof(ListGraphType <ProductModelInfoType>)).Description("Product models that use this specification");

            Field(x => x.ChildSpecifications, type: typeof(ListGraphType <ConduitSpecificationType>)).Description("Product models that use this specification");
        }
        public ConduitNetworkQueryService(IDocumentStore documentStore, IRouteNetworkState routeNetworkQueryService)
        {
            this.documentStore            = documentStore;
            this.routeNetworkQueryService = routeNetworkQueryService;
            this._pointOfInterestIndex    = new PointOfInterestIndex(routeNetworkQueryService);


            var config = new MapperConfiguration(cfg => {
                cfg.CreateMap <SingleConduitInfo, SingleConduitInfo>();
                cfg.CreateMap <MultiConduitInfo, MultiConduitInfo>();
            });


            _mapper = config.CreateMapper();

            Load();
        }
Exemplo n.º 25
0
        private static void PlaceCable(IRouteNetworkState routeNetworkQueryService, IMediator commandBus, Guid cableId, int nFibers, Guid startNodeParam, Guid endNodeId)
        {
            var startNode = routeNetworkQueryService.GetRouteNodeInfo(startNodeParam);

            List <Guid> result = new List <Guid>();

            List <IGraphElement> graphElements = new List <IGraphElement>();

            graphElements.AddRange(routeNetworkQueryService.GetAllRouteNodes());
            graphElements.AddRange(routeNetworkQueryService.GetAllRouteSegments());

            // remove element, so it has to be routed left through the pf and junctions
            var elementToRemove = graphElements.Find(g => g.Id == Guid.Parse("b95000fb-425d-4cd3-9f45-66e8c5000050"));

            graphElements.Remove(elementToRemove);

            var graph = new Graph(graphElements);

            var shortestPathResult = graph.ShortestPath(startNode.Id.ToString(), endNodeId.ToString()).ToList();

            var cableWalkOfInterest = new List <Guid>();

            foreach (var item in shortestPathResult)
            {
                cableWalkOfInterest.Add(item.Id);
            }

            // Walk of interest for cable
            var registerMultiConduitWalk = new RegisterWalkOfInterestCommand()
            {
                WalkOfInterestId = Guid.NewGuid(),
                RouteElementIds  = cableWalkOfInterest
            };

            commandBus.Send(registerMultiConduitWalk).Wait();

            // Place cable
            var placeCable1 = new PlaceFiberCableCommand()
            {
                FiberCableId     = cableId,
                WalkOfInterestId = registerMultiConduitWalk.WalkOfInterestId,
                NumberOfFibers   = nFibers
            };

            commandBus.Send(placeCable1).Wait();
        }
        public ConduitClosureTerminalType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkQueryService;

            var traversal = new TraversalHelper(routeNetworkQueryService);

            Description = "A specific terminal part of a condult closure port. Terminal are like sides and ports numbered clockwise reflecting their position. Only single conduits or cables can be attached to terminals.";

            Field(x => x.Position, type: typeof(IntGraphType)).Description("Terminal position/number.");

            Field(x => x.LineSegment, type: typeof(ConduitSegmentType)).Description("The single conduit or cable attacthed to the terminal.");

            Field(x => x.ConnectionKind, type: typeof(ConduitClosureInternalConnectionKindType)).Description("The type of connection the cable or single conduit segment has (or don't have) to another port terminal in the closure.");

            Field(x => x.ConnectedToSide, type: typeof(ConduitClosureSideEnumType)).Description("The other end side position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field(x => x.ConnectedToPort, type: typeof(IntGraphType)).Description("The other end port position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field(x => x.ConnectedToTerminal, type: typeof(IntGraphType)).Description("The other end terminal position/number, if the cable/conduit segment is connected to another cable/conduit segment (attached to another port terminal) or passing through to another port terminal.");

            Field <StringGraphType>(
                "DiagramLabel",
                resolve: context =>
            {
                // If conduit segment, show end node name
                if (context.Source.LineSegment != null && context.Source.LineSegment is ConduitSegmentInfo)
                {
                    var conduitSegmentInfo = context.Source.LineSegment as ConduitSegmentInfo;
                    var lineInfo           = traversal.CreateTraversalInfoFromSegment(conduitSegmentInfo);

                    if (context.Source.LineSegmentEndKind == ConduitEndKindEnum.Incomming)
                    {
                        return(lineInfo.StartRouteNode.Name);
                    }
                    else
                    {
                        return(lineInfo.EndRouteNode.Name);
                    }
                }


                return(null);
            });
        }
        public ConduitClosureAttachmentProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = conduitNetworkQueryService;
            this.conduitClosureRepository   = conduitClosureRepository;

            // Conduit passing by attached to closure
            ProjectEvent <ConduitClosurePassingByConduitAttached>(
                (session, multiConduitEndAttached) =>
            {
                return(multiConduitEndAttached.ConduitClosureId);
            },
                OnConduitClosurePassingByConduitAttached);


            // Conduit end attached to closure
            ProjectEvent <ConduitClosureConduitEndAttached>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosureConduitEndAttached);


            // Inner conduit added to multi conduit
            ProjectEvent <MultiConduitInnerConduitAdded>((session, e) =>
            {
                // Try find conduit closure affected by inner conduit addition
                if (conduitClosureRepository.CheckIfConduitClosureIsRelatedToLine(e.MultiConduitId))
                {
                    var conduitClosure = conduitClosureRepository.GetConduitClosureInfoByRelatedLineId(e.MultiConduitId);

                    if (conduitClosure.Sides.Exists(s => s.Ports.Exists(p => p.MultiConduitId == e.MultiConduitId)))
                    {
                        return(conduitClosure.Id);
                    }
                }

                return(Guid.Empty);
            },
                                                         OnMultiConduitInnerConduitAdded);
        }
Exemplo n.º 28
0
        public ConduitClosure(Guid conduitClosureId, Guid pointOfInterestId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository) : this()
        {
            // Id check
            if (conduitClosureId == null || conduitClosureId == Guid.Empty)
            {
                throw new ArgumentException("ConduitClosureId cannot be null or empty");
            }

            // Point of interest id check
            if (pointOfInterestId == null || pointOfInterestId == Guid.Empty)
            {
                throw new ArgumentException("PointOfInterestId cannot be null or empty");
            }

            // Check that point of interest (node) exists
            if (!routeNetworkQueryService.CheckIfRouteNodeIdExists(pointOfInterestId))
            {
                throw new ArgumentException("PointOfInterestId: " + pointOfInterestId + " not found in the route network.");
            }

            // Check that conduit closure do not already exists
            if (conduitClosureRepository.CheckIfConduitClosureAlreadyExists(conduitClosureId))
            {
                throw new ArgumentException("A conduit closure with id: " + conduitClosureId + " already exists.");
            }

            // Check that a conduit closure is not already added to point of interest. This is not allowed, each conduit closure must be placed in its own node.
            if (conduitClosureRepository.CheckIfRouteNodeContainsConduitClosure(pointOfInterestId))
            {
                throw new ArgumentException("A conduit closure: " + conduitClosureRepository.GetConduitClosureInfoByRouteNodeId(pointOfInterestId).Id + " is already placed in the specified point of interest (route node): " + pointOfInterestId + " Only one conduit closure is allowed per point of interest (route node).");
            }


            var conduitClosurePlaced = new ConduitClosurePlaced()
            {
                ConduitClosureId  = conduitClosureId,
                PointOfInterestId = pointOfInterestId
            };

            RaiseEvent(conduitClosurePlaced);
        }
Exemplo n.º 29
0
        public ConduitClosurePortType(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IDataLoaderContextAccessor dataLoader)
        {
            this.routeNetworkQueryService    = routeNetworkQueryService;
            this.conduitNetworkEqueryService = conduitNetworkEqueryService;

            Description = "A specific port sitting on a side of a condult closure. Ports are like sides numbered clockwise reflecting their position. Only multi conduits can be attached to ports. A port might have no multi conduit attached, in the case were single conduits or cables are connected to the closure port terminals without being part of (running inside) a multi conduit.";

            Field(x => x.DiagramLabel, type: typeof(StringGraphType)).Description("Label informaion the user like to be displayed on the port. Could e.g. be a the multi conduit model type.");

            Field(x => x.Position, type: typeof(IntGraphType)).Description("Port position/number.");

            Field(x => x.MultiConduitSegment, type: typeof(ConduitSegmentType)).Description("The multi conduit segment attached to the port. Null of no multi conduit is used.");

            Field(x => x.ConnectionKind, type: typeof(ConduitClosureInternalConnectionKindType)).Description("The type of connection the multi conduit segment has (or don't have) to another port in the closure.");

            Field(x => x.ConnectedToSide, type: typeof(ConduitClosureSideEnumType)).Description("The other end side position/number, if the multi conduit segment is connected to another multi conduit segment (attached to another port) or passing through to another port.");

            Field(x => x.ConnectedToPort, type: typeof(IntGraphType)).Description("The other end port position/number, if the multi conduit segment is connected to another multi conduit segment (attached to another port) or passing through to another port.");

            Field(x => x.Terminals, type: typeof(ListGraphType <ConduitClosureTerminalType>)).Description("Terminals of the port.");
        }
Exemplo n.º 30
0
        public ConduitClosureLifecyleEventProjection(IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkQueryService, IConduitClosureRepository conduitClosureRepository)
        {
            this.routeNetworkQueryService   = routeNetworkQueryService;
            this.conduitNetworkQueryService = conduitNetworkQueryService;
            this.conduitClosureRepository   = conduitClosureRepository;

            // Conduits closure placed
            ProjectEvent <ConduitClosurePlaced>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosurePlaced);

            // Conduit closure removed
            DeleteEvent <ConduitClosureRemoved>(
                (session, e) =>
            {
                return(e.ConduitClosureId);
            },
                OnConduitClosureRemoved);
        }