public GetConnectedRoadsCommand(RoadLinkManager source)
        {
            if (source == null)
            {
                throw new ArgumentNullException();
            }

            Source = source;
        }
        public ConnectRoadToZoneCommand(RoadLinkManager source, RoadplusService service)
        {
            if (source == null ||
                service == null)
            {
                throw new ArgumentNullException();
            }

            Source = source;
            Service = service;
        }
Ejemplo n.º 3
0
        public DensityMessage(string jsonlocation, RoadLinkManager roads)
        {
            if (jsonlocation == null ||
                roads == null)
            {
                throw new ArgumentNullException();
            }

            JsonLocation = jsonlocation;
            Roads = roads;
        }
Ejemplo n.º 4
0
        public RoadplusService(Settings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            else if (!Directory.Exists(settings.HttpRoot))
            {
                Directory.CreateDirectory(settings.HttpRoot);
            }

            IPAddress ip = IPAddress.Parse(settings.IP);

            channels = new List<Channel>();

            if (settings.EnableHttp)
            {
                httpService = new HttpService(
                    new IPEndPoint(
                    ip,
                    settings.HttpPort),
                    settings.HttpRoot);
            }

            roadLinkService = new RoadLinkManager(
                new CommandProcessorText(),
                new TextFormatter(),
                settings.BaudRate,
                settings.RoadDetectTimeOut);

            roadLinkService.CommandProcessor.RegisteredCommands.AddRange(
            new ICommand[]
            {
                new TemperatureMessage(Path.Combine(settings.HttpRoot, "data.json")),
                    new DensityMessage(Path.Combine(settings.HttpRoot, "data.json"), roadLinkService)
            }); 

            channels.Add(roadLinkService);

            CommandProcessorJson processorJson = new CommandProcessorJson();
            processorJson.RegisteredCommands.AddRange(
            new ICommand[]
            {
                new CreateZoneCommand(),
                new CreateSchoolCommand(),
                new CreateRoadConstructionCommand(),
                new EdgeSetCommand(),

                new GetZonesCommand(),
                new GetSchoolsCommand(),
                new GetRoadconstructionsCommand(),

                new RemoveZoneCommand(),
                new RemoveSchoolCommand(),
                new RemoveRoadConstructionCommand(),

                new ConnectRoadToZoneCommand(roadLinkService, this),
                new GetConnectedRoadsCommand(roadLinkService),

                new GetMapCommand()
            });

            websocketService = new WSSessionManager(
                new IPEndPoint(
                    ip,
                    settings.Port),
                processorJson,
                new JsonFormatter());

            channels.Add(websocketService);
        }