Beispiel #1
0
        public static void Main(string[] args)
        {
            // Showing the Header of the Simulation Program in the Console
            if (ReadFarmSettings.outputMode != "str")
            {
                ReadFarmSettings.ShowHeader();
            }

            // Declaring a new simulation object
            PVPlant      = new Simulation();
            SiteSettings = new XmlDocument();

            // Load CSYX file
            try
            {
                if (args.Length == 0)
                {
                    // Set batch mode to true, and Ask user for all the arguments
                    Console.WriteLine("Status: You are running CASSYS in batch mode.");
                    Console.WriteLine("Status: You will need to provide a CASSYS Site File (.CSYX), Input File, and Output File Path.");
                    Console.WriteLine("Enter CASSYS Site (.CSYX) File Path: ");
                    String SimFilePath = Console.ReadLine();
                    Console.WriteLine("Enter Input file path (.csv file): ");
                    SimInputFilePath = Console.ReadLine();
                    Console.WriteLine("Enter an Output file path (.csv file, Note: if the file exists this will append your results to the file): ");
                    SimOutputFilePath = Console.ReadLine();

                    SiteSettings.Load(SimFilePath.Replace("\\", "/"));
                    ErrorLogger.RunFileName = SimFilePath;
                    ErrorLogger.Clean();
                }
                else
                {
                    // Get .CSYX file name from CMDPrompt, and Load document
                    SiteSettings.Load(args[0]);
                    ErrorLogger.RunFileName = args[0];
                }

                // Assigning Xml document to ReadFarmSettings to allow reading of XML document. Check CSYX version
                ReadFarmSettings.doc = SiteSettings;
                ReadFarmSettings.CheckCSYXVersion();

                // Variable Parameter mode
                if (ReadFarmSettings.doc.SelectSingleNode("/Site/Iterations/Iteration1") != null)
                {
                    variableParameters(args);
                }
                else if (args.Length == 1)
                {
                    // Running the Simulation based on the CASSYS Configuration File provided
                    ReadFarmSettings.batchMode = false;
                    PVPlant.Simulate(SiteSettings);
                    // Show the end of simulation message, window should be kept open for longer
                    ReadFarmSettings.ShowFooter();
                }
                else if (args.Length == 3)
                {
                    // Set batch mode to true, and Run from command prompt arguments directly
                    ReadFarmSettings.batchMode = true;
                    PVPlant.Simulate(SiteSettings, _Input: args[1], _Output: args[2]);
                }
                else if (args.Length == 0)
                {
                    PVPlant.Simulate(SiteSettings, _Input: SimInputFilePath.Replace("\\", "/"), _Output: SimOutputFilePath.Replace("\\", "/"));
                }
                else
                {
                    // CASSYS needs a site file name to run, so warn the user and exit the program.
                    ErrorLogger.Log("No site file provided for CASSYS to simulate. Please select a valid .CSYX file.", ErrLevel.FATAL);
                }
            }
            catch (Exception)
            {
                ErrorLogger.Log("CASSYS was unable to access or load the Site XML file. Simulation has ended.", ErrLevel.FATAL);
            }
        }