private static void Main(string[] args) { int exitCode = 0; OptionSet options = new OptionSet { { "c|configuration=", "Path to configuration file", v => _configurationPath = v }, { "p|printfile=", "Path to print file", v => _printFilePath = v }, { "h|?|help", "Show help and syntax summary", v => _showHelp = v != null } }; options.Parse(args); if (_showHelp) { options.WriteOptionDescriptions(Console.Out); Console.WriteLine(); Console.WriteLine("DaySimController requires these additional properties:"); Console.WriteLine(" RemoteUsername=your_username"); Console.WriteLine(" RemotePassword=your_password"); Console.WriteLine(" RemoteMachines=pormdlppw01|E:\\test\\Daysim.exe|/c=config.properties|/p=dclog.txt,sdmdlppw01|E:\\test\\Daysim.exe|/c=config.properties|/p=dclog.txt"); Console.WriteLine(" RemoteCopySPFilesToRemoteMachines=false"); Console.WriteLine(); Console.WriteLine("All machines, including master, need the exact same folder and file setup"); Console.WriteLine("This includes inputs since inputs are not copied from the master to the slaves"); Console.WriteLine("Each machine's folder needs to be shared so DaySim can access it remotely"); Console.WriteLine("Exceptions, or hanging, is probably due to configuration/path issues"); Console.WriteLine("It is best to setup with the simplest possible file/folder setup"); Console.WriteLine("Windows RPC server must be enabled on the remote machines"); Console.WriteLine(); Console.WriteLine("If you do not provide a configuration then the default is to use {0}, in the same directory as the executable.", ConfigurationManagerRSG.DEFAULT_CONFIGURATION_NAME); Console.WriteLine(); Console.WriteLine("If you do not provide a printfile then the default is to create {0}, in the same directory as the executable.", PrintFile.DEFAULT_PRINT_FILENAME); Console.WriteLine(); Console.WriteLine("Please press any key to exit"); Console.ReadKey(); Environment.Exit(exitCode); } Console.WriteLine("Configuration file: " + _configurationPath); if (!File.Exists(_configurationPath)) { throw new Exception("Configuration file '" + _configurationPath + "' does not exist. You must pass in a DaySim configuration file with -c or --configuration"); } ConfigurationManagerRSG configurationManager = new ConfigurationManagerRSG(_configurationPath); Global.Configuration = configurationManager.Open(); Global.Configuration = configurationManager.ProcessPath(Global.Configuration, _configurationPath); Global.PrintFile = configurationManager.ProcessPrintPath(Global.PrintFile, _printFilePath); Controller.BeginProgram(); }
private static void Merge() { var householdHeader = false; var personHeader = false; var householdDayHeader = false; var jointTourHeader = false; var fullHalfTourHeader = false; var partialHalfTourHeader = false; var personDayHeader = false; var tourHeader = false; var tripHeader = false; var tdmTripListHeader = false; var machines = RemoteMachine.GetAll(); for (var i = 0; i < machines.Count; i++) { var machine = machines[i]; var configurationManager = new ConfigurationManagerRSG(machine.ConfigurationPath.ToUncPath(machine.Name)); var configuration = configurationManager.Open(); var household = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputHouseholdPath)); AppendFile(household, new FileInfo(Global.GetOutputPath(configuration.OutputHouseholdPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref householdHeader); var person = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputPersonPath)); AppendFile(person, new FileInfo(Global.GetOutputPath(configuration.OutputPersonPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref personHeader); var householdDay = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputHouseholdDayPath)); AppendFile(householdDay, new FileInfo(Global.GetOutputPath(configuration.OutputHouseholdDayPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref householdDayHeader); if (!string.IsNullOrEmpty(configuration.OutputJointTourPath)) { var jointTour = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputJointTourPath)); AppendFile(jointTour, new FileInfo(Global.GetOutputPath(configuration.OutputJointTourPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref jointTourHeader); } if (!string.IsNullOrEmpty(configuration.OutputFullHalfTourPath)) { var fullHalfTour = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputFullHalfTourPath)); AppendFile(fullHalfTour, new FileInfo(Global.GetOutputPath(configuration.OutputFullHalfTourPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref fullHalfTourHeader); } if (!string.IsNullOrEmpty(configuration.OutputPartialHalfTourPath)) { var partialHalfTour = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputPartialHalfTourPath)); AppendFile(partialHalfTour, new FileInfo(Global.GetOutputPath(configuration.OutputPartialHalfTourPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref partialHalfTourHeader); } var personDay = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputPersonDayPath)); AppendFile(personDay, new FileInfo(Global.GetOutputPath(configuration.OutputPersonDayPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref personDayHeader); var tour = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputTourPath)); AppendFile(tour, new FileInfo(Global.GetOutputPath(configuration.OutputTourPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref tourHeader); var trip = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputTripPath)); AppendFile(trip, new FileInfo(Global.GetOutputPath(configuration.OutputTripPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref tripHeader); var tdmTripList = new FileInfo(Global.GetOutputPath(Global.Configuration.OutputTDMTripListPath)); AppendFile(tdmTripList, new FileInfo(Global.GetOutputPath(configuration.OutputTDMTripListPath).ToUncPath(machine.Name).ToIndexedPath(i)), ref tdmTripListHeader); } }
private static void Main(string[] args) { int exitCode = 0; #if RELEASE //don't use try catch in release mode since wish to have Visual Studio debugger stop on unhandled exceptions try { #endif OptionSet options = new OptionSet { { "c|configuration=", "Path to configuration file", v => _configurationPath = v }, { "o|overrides=", "comma delimited name=value pairs to override configuration file values", v => _overrides = v }, { "p|printfile=", "Path to print file", v => _printFilePath = v }, { "s|start=", "Start index of household range", v => _start = int.Parse(v) }, { "e|end=", "End index of household range", v => _end = int.Parse(v) }, { "i|index=", "Cluser index", v => _index = int.Parse(v) }, { "v|version", "Show version information", v => _showVersion = v != null }, { "h|?|help", "Show help and syntax summary", v => _showHelp = v != null } }; options.Parse(args); if (_showHelp) { options.WriteOptionDescriptions(Console.Out); Console.WriteLine(); Console.WriteLine("If you do not provide a configuration then the default is to use {0}, in the same directory as the executable.", ConfigurationManagerRSG.DEFAULT_CONFIGURATION_NAME); Console.WriteLine(); Console.WriteLine("If you do not provide a printfile then the default is to create {0}, in the output directory.", PrintFile.DEFAULT_PRINT_FILENAME); if (Environment.UserInteractive && !Console.IsInputRedirected) { Console.WriteLine("Please press any key to exit"); Console.ReadKey(); } Environment.Exit(exitCode); } //end showHelp else if (_showVersion) { PrintVersion(); if (Environment.UserInteractive && !Console.IsInputRedirected) { Console.WriteLine("Please press any key to exit"); Console.ReadKey(); } Environment.Exit(exitCode); } //end if _showVersion Console.WriteLine("Configuration file: " + _configurationPath); if (!File.Exists(_configurationPath)) { throw new Exception("Configuration file '" + _configurationPath + "' does not exist. You must pass in a DaySim configuration file with -c or --configuration"); } ConfigurationManagerRSG configurationManager = new ConfigurationManagerRSG(_configurationPath); Global.Configuration = configurationManager.Open(); Global.Configuration = configurationManager.OverrideConfiguration(Global.Configuration, _overrides); Global.Configuration = configurationManager.ProcessPath(Global.Configuration, _configurationPath); Global.PrintFile = configurationManager.ProcessPrintPath(Global.PrintFile, _printFilePath); string message = string.Format("--overrides = {0}", _overrides); Console.WriteLine(message); if (Global.PrintFile != null) { Global.PrintFile.WriteLine(message); } Engine.InitializeDaySim(); Engine.BeginProgram(_start, _end, _index); //Engine.BeginTestMode(); #if RELEASE //don't use try catch in release mode since wish to have Visual Studio debugger stop on unhandled exceptions } catch (Exception e) { string message = e.ToString(); //even though Global.PrintFile.Dispose(); is called in Finally, it is useful to also //call it here because many times I would forget to close the output window and would be unable to delete outputs //in this odd case I wish I could put the finally before the catch if (Global.PrintFile != null) { Global.PrintFile.WriteLine(message); } Console.WriteLine(); Console.Error.WriteLine(message); if (Environment.UserInteractive && !Console.IsInputRedirected) { Console.WriteLine(); Console.WriteLine("Please press any key to exit"); Console.ReadKey(); } exitCode = 2; } #endif #if DEBUG string lockCounts = ParallelUtility.getLockCounts(); Console.WriteLine(lockCounts); if (Global.PrintFile != null) { Global.PrintFile.WriteLine(lockCounts); } #endif if (Global.PrintFile != null) { Global.PrintFile.Dispose(); } Environment.Exit(exitCode); }