//------------------------------------------------------------------------------------------------------- private void RunOneYear() { // Block Rentry if (!_inRunOneYear) { _inRunOneYear = true; int ProviderSize = ProviderClass.NumberOfProviders; ReportHeader lineout = new ReportHeader(); string ReportString = ""; string[] AllStrings = new string[ProviderSize]; string ScName = ScenarioNameTextBox.Text; int _runYear = 0; //---------------------------- if (_OneYearNotStarted) { // Resett the simulation WSim.Simulation_Initialize(); OutputListBox.Items.Clear(); OutputListBox.Items.Add(ReportTitle()); lineout = ReportClass.FullHeader(WSim, 20, false, true); OutputListBox.Items.Add(lineout[0]); OutputListBox.Items.Add(lineout[1]); SetAllModelValues(WS_InputPanel.GetAllValues()); _OneYearStart = WSim.Simulation_Start_Year; _OneYearStop = WSim.Simulation_End_Year; if (OutputReportCheckBox.Checked) { if (ContinuousCheckBox.Checked) { ReportString = ReportTextBox.Text; } else { ReportString = ""; } ReportString += ReportTitle() + System.Environment.NewLine + ReportClass.FullHeader(WSim, 0, true, false)[0] + System.Environment.NewLine; ReportTextBox.Text = ReportString; } _OneYearNotStarted = false; } // _oneYearNotSTarted true // Set New Year // Clear this just to be safe ReportString = ""; // Run One year of model SetAllModelValues(WS_InputPanel.GetAllValues()); // Lock the model WSim.LockSimulation(); _runYear = WSim.Simulation_NextYear(); AllStrings = ReportClass.AnnualFullData(WSim, ScName, _runYear, 20, false); for (int i = 0; i < ProviderSize; i++) { OutputListBox.Items.Add(AllStrings[i]); } if (OutputReportCheckBox.Checked) { ReportString = ReportTextBox.Text; AllStrings = ReportClass.AnnualFullData(WSim, ScName, _runYear, 20, true); for (int i = 0; i < ProviderSize; i++) { ReportString += AllStrings[i]; } ReportTextBox.Text = ReportString; } if (_runYear == _OneYearStop) { WSim.Simulation_Stop(); MessageBox.Show("Simulation has ended, next run will restart simulation!"); _OneYearNotStarted = true; } _inRunOneYear = false; } }
internal void RunModel() { if (!_InRunModel) { _InRunModel = true; string ScName = ScenarioNameTextBox.Text; //string lineout = ""; string ReportString = ""; int ProviderSize = ProviderClass.NumberOfProviders; string[] AllStrings = new string[ProviderSize]; // Resett the simulation WSim.Simulation_Initialize(); // Fetch all the Input fields SimulationInputs SimInputs = WS_InputPanel.GetAllValues(); SetAllModelValues(SimInputs); //SetStatusBar StatusLabel1.Text = "Running Simulation " + ScenarioNameTextBox.Text; StatusProgressBar.Maximum = WSim.Simulation_End_Year - WSim.Simulation_Start_Year; StatusProgressBar.Value = 1; StatusProgressBar.Visible = true; // Lock the model WSim.LockSimulation(); // Reset Memory Status ShowMemory(); // Add a Title and Header OutputListBox.Items.Clear(); OutputListBox.Items.Add(ReportTitle()); //string[] header = new string[2]; ReportHeader header = new ReportHeader(); header = ReportClass.FullHeader(WSim, 20, false, true); OutputListBox.Items.Add(header[2]); OutputListBox.Items.Add(header[0]); OutputListBox.Items.Add(header[1]); if (OutputReportCheckBox.Checked) { if (ContinuousCheckBox.Checked) { ReportString = ReportTextBox.Text; } else { ReportString = ""; } ReportString += ReportTitle() + System.Environment.NewLine + ReportClass.FullHeader(WSim, 0, true, false)[0] + System.Environment.NewLine; } // OK run the model int runyear = 0; int cnt = 0; foreach (int year in WSim.simulationYears()) { runyear = WSim.Simulation_NextYear(); AllStrings = ReportClass.AnnualFullData(WSim, ScName, runyear, 20, false); for (int i = 0; i < ProviderSize; i++) { OutputListBox.Items.Add(AllStrings[i]); } if (OutputReportCheckBox.Checked) { AllStrings = ReportClass.AnnualFullData(WSim, ScName, runyear, 20, true); for (int i = 0; i < ProviderSize; i++) { ReportString += AllStrings[i]; } } StatusProgressBar.Value = cnt; cnt++; } // Stop Model WSim.Simulation_Stop(); StatusProgressBar.Visible = false; // output report if (OutputReportCheckBox.Checked) { ReportTextBox.Text = ReportString + System.Environment.NewLine; } // Set output to default StatusLabel1.Text = ""; ModelControlsTabControl.SelectedTab = OutputTabPage; OutputTabPage.Select(); // Allow entry _InRunModel = false; } }