Example #1
0
 void AddEventSender(int id, SignalEvents signal)
 {
     //GameObject sfx = new GameObject();
     //Gadget gd = sfx.AddComponent<Gadget>();
     //sfx.transform.localScale = new Vector3(1, 1, 1);
     //sfx.transform.localPosition = vec;
     //sfx.name = "SFX" + sfxID.ToString();
     //m_objectList.Add(id, sfx);
     //gd.EvolveToEndlessFX(sfxID, (uint)start);
 }
Example #2
0
 void HandleWaitingEvent(SignalEvents targetID)
 {
     if (m_commandQueue.Count > 0)
     {
         String[] commands = m_commandQueue.Peek();
         if (commands[0].Equals("Wait"))
         {
             if (Byte.Parse(commands[1]) != (Byte)targetID)
             {
                 return;
             }
             else
             {
                 m_commandQueue.Dequeue();
                 Execute();
             }
         }
     }
 }
Example #3
0
        public static void Main(string[] args)
        {
            if (!CommandLine.Parser.Default.ParseArguments(args, options)) {
                return;
            }

            if (String.IsNullOrEmpty(options.InputFile)) {
                Console.WriteLine(options.GetUsage());
                return;
            }

            if (!IsValidFilePath(options.InputFile, true)) {
                Console.WriteLine("Specified input file path not valid");
                return;
            }

            try {
                var sw = new Stopwatch();
                if (options.FilterTimes?.Length == 2) {
                    if (options.FilterTimes[0] > options.FilterTimes[1]) {
                        Console.WriteLine("Start time must be earlier than end time");
                        return;
                    }
                    sw.Start();
                    oplParser = new OPLParser(options.InputFile, options.FilterTimes[0], options.FilterTimes[1]);
                    sw.Stop();
                } else {
                    sw.Start();
                    oplParser = new OPLParser(options.InputFile);
                    sw.Stop();
                }
                Console.WriteLine($"Time spent in OPLParser creation: {sw.Elapsed}");
            }
            catch (ArgumentException e) {
                Console.WriteLine(e.Message);
                return;
            }
            Console.WriteLine("OPL file contains {0} signal elements " +
                "and {1} data entries", oplParser.SignalElementsCount, oplParser.DataEntriesCount);

            if (FilenamesDuplicated()) {
                Console.WriteLine("Cannot export to identical output files");
                return;
            }

            HandleOutput(options.OutputFile, "Exporting element states...",
                oplParser.ExportToCSV);

            HandleOutput(options.SignalProgramsFile, "Exporting signal programs...",
                oplParser.ExportSignalProgramsToCSV);

            if (options.EventSignalElements != null || options.OccupancyDetectorElements != null) {
                // TODO: proper error handling when we specify a signal element name that doesn't exist
                // in the OPL file
                var eventSignalElements = options.EventSignalElements != null ?
                    new List<string>(options.EventSignalElements) :
                    new List<string>();
                var occupancySignalElements = options.OccupancyDetectorElements != null ?
                    new List<string>(options.OccupancyDetectorElements) :
                    new List<string>();

                if (!String.IsNullOrEmpty(options.IntergreenFile) &&
                    !IsValidFilePath(options.IntergreenFile, true)) {
                    Console.WriteLine("Specified intergreen configuration file path not valid");
                    return;
                }
                if (options.BlockingBackConfiguration != null &&
                    !IsValidFilePath(options.BlockingBackConfiguration, true)) {
                    Console.WriteLine("Specified blocking back configuration file path not valid");
                    return;
                }

                var sw = new Stopwatch();
                sw.Start();
                eventParser = new SignalEvents(oplParser, eventSignalElements, occupancySignalElements,
                    options.IntergreenFile, options.BlockingBackConfiguration);
                sw.Stop();

                HandleOutput(options.EventsOutputFile, "Exporting signal events...",
                    eventParser.ExportEventsToCSV);
                Console.WriteLine($"Time spent in signal event analyser: {sw.Elapsed}");

                if (options.TransitAnalyserConfiguration != null) {
                    if (IsValidFilePath(options.TransitAnalyserConfiguration, true)) {
                        Dictionary<string, TimePeriodCollection> blockedRanges = null;
                        if (eventParser.BlockedSignalGroups.Count > 0) {
                            blockedRanges = new Dictionary<string, TimePeriodCollection>();
                            foreach (string name in eventParser.BlockedSignalGroups) {
                                blockedRanges.Add(name, eventParser.GetBlockedRanges(name));
                            }
                        }

                        sw = new Stopwatch();
                        sw.Start();
                        transitAnalyser = new TransitAnalyser(eventParser.GetEventsCopy,
                            new List<string>(options.TransitAnalyserConfiguration), blockedRanges);
                        sw.Stop();

                        HandleOutput(options.AnalyseOutputFile, "Exporting transit movements...",
                            transitAnalyser.ExportToCSV);
                        Console.WriteLine($"Time spent in transit cycle analyser: {sw.Elapsed}");
                    } else {
                        Console.WriteLine("Specified transit analyser configuration file paths not valid");
                    }
                } else {
                    if (!String.IsNullOrEmpty(options.AnalyseOutputFile)) {
                        Console.WriteLine("--analyse-output requires --analyse");
                    }
                }

            } else {
                if (!String.IsNullOrEmpty(options.IntergreenFile)) {
                    Console.WriteLine("--intergreen requires --events");
                }
                if (options.BlockingBackConfiguration != null) {
                    Console.WriteLine("--blocking-back requires --events");
                }
                if (!String.IsNullOrEmpty(options.EventsOutputFile)) {
                    Console.WriteLine("--events-output requires --events");
                }
                if (options.TransitAnalyserConfiguration != null) {
                    Console.WriteLine("--analyse requires --events");
                }
                if (!String.IsNullOrEmpty(options.AnalyseOutputFile)) {
                    Console.WriteLine("--analyse-output requires --events and --analyse");
                }
            }
        }
Example #4
0
 void AddEventSender(int id, SignalEvents signal)
 {
     //GameObject sfx = new GameObject();
     //Gadget gd = sfx.AddComponent<Gadget>();
     //sfx.transform.localScale = new Vector3(1, 1, 1);
     //sfx.transform.localPosition = vec;
     //sfx.name = "SFX" + sfxID.ToString();
     //m_objectList.Add(id, sfx);
     //gd.EvolveToEndlessFX(sfxID, (uint)start);
 }
Example #5
0
    void HandleWaitingEvent(SignalEvents targetID)
    {
        if (m_commandQueue.Count > 0)
        {
            String[] commands = m_commandQueue.Peek();
            if (commands[0].Equals("Wait"))
            {
                if (Byte.Parse(commands[1]) != (Byte)targetID)
                {
                    return;
                }
                else
                {
                    m_commandQueue.Dequeue();
                    Execute();
                }
            }
        }

    }