/// <summary> Sets number of MERRA2 data based on dropdown selection. </summary> public void Set_Num_MERRA_Nodes(Continuum thisInst) { if (merraData == null) { numMERRA_Nodes = Convert.ToInt16(thisInst.cboNumMERRA_Nodes.SelectedItem.ToString()); } else if (numMERRA_Data != 0) { if (((thisInst.cboNumMERRA_Nodes.SelectedIndex == 0 && merraData[0].numMERRA_Nodes != 1) || (thisInst.cboNumMERRA_Nodes.SelectedIndex == 1 && merraData[0].numMERRA_Nodes != 4) || (thisInst.cboNumMERRA_Nodes.SelectedIndex == 2 && merraData[0].numMERRA_Nodes != 16)) && thisInst.okToUpdate == true && merraData[0].GotWindTS(thisInst.UTM_conversions)) { numMERRA_Nodes = Convert.ToInt16(thisInst.cboNumMERRA_Nodes.SelectedItem.ToString()); merraData = null; } else { numMERRA_Nodes = Convert.ToInt16(thisInst.cboNumMERRA_Nodes.SelectedItem.ToString()); } } else { numMERRA_Nodes = Convert.ToInt16(thisInst.cboNumMERRA_Nodes.SelectedItem.ToString()); } thisInst.ChangesMade(); }
public void IceThrow_Test() { Continuum thisInst = new Continuum(""); string fileName = "C:\\Users\\liz_w\\Desktop\\Continuum 3 GUI Testing\\SaveFolder\\OneMetTABAndGrossNet_1"; thisInst.Open(fileName + ".cfm"); int numIceThrowsPerDay = thisInst.GetNumIceThrowsPerDay(); int numIceDaysPerYear = thisInst.GetNumIcingDays(); thisInst.siteSuitability.numIceDaysPerYear = numIceDaysPerYear; thisInst.siteSuitability.iceThrowsPerIceDay = numIceThrowsPerDay; BackgroundWork.Vars_for_BW varsForBW = new BackgroundWork.Vars_for_BW(); varsForBW.thisInst = thisInst; thisInst.BW_worker = new BackgroundWork(); thisInst.BW_worker.Call_BW_IceThrow(varsForBW); while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) { Thread.Sleep(1000); } if (thisInst.BW_worker.WasReturned) { Assert.Fail(); } thisInst.BW_worker.Close(); // Called in RunCompleted thisInst.updateThe.SiteSuitabilityDropdown(thisInst, "Ice Throw"); thisInst.updateThe.IcingYearsDropDown(thisInst); thisInst.updateThe.SiteSuitabilityTAB(thisInst); thisInst.ChangesMade(); thisInst.updateThe.ColoredButtons(thisInst); Assert.AreNotEqual(thisInst.siteSuitability.yearlyIceHits.Length, 0, "Didn't calculate ice throw"); Assert.AreNotEqual(thisInst.siteSuitability.yearlyIceHits[0].iceHits.Length, 0, "Didn't calculate ice throw"); thisInst.Close(); }
private void btnOK_Click(object sender, EventArgs e) { // Reads in entered name, UTMX, UTMY, and string number. if ( valid, adds to turbine list and calls background worker to perform turbine calcs (if done before) string name = ""; double UTMX = 0; double UTMY = 0; int stringNum = 0; bool inputTurbine = false; Check_class check = new Check_class(); try { name = txtName.Text; } catch { MessageBox.Show("Invalid entry for turbine name", "Continuum 3"); return; } try { UTMX = Convert.ToSingle(txtUTMX.Text); } catch { MessageBox.Show("Invalid entry for easting", "Continuum 3"); return; } try { UTMY = Convert.ToSingle(txtUTMY.Text); } catch { MessageBox.Show("Invalid entry for northing", "Continuum 3"); return; } try { stringNum = Convert.ToInt16(txtStrNum.Text); } catch { stringNum = 0; } if (name == "" || UTMX == 0 || UTMY == 0) { MessageBox.Show("Need valid entries for all fields", "Continuum 3"); return; } else { inputTurbine = check.NewTurbOrMet(thisInst.topo, name, UTMX, UTMY, true); if (inputTurbine == true) { thisInst.turbineList.AddTurbine(name, UTMX, UTMY, stringNum); } thisInst.updateThe.AllTABs(thisInst); thisInst.ChangesMade(); Close(); } }
/// <summary> Reads wake loss model settings from form and adds wake model to list and calls background_worker to conduct turbine calcs. </summary> public void GenWakeModel() { int wakeModelType = ReadWakeModelType(); double horizExp = ReadHorizExp(); TurbineCollection.PowerCurve thisPowerCurve = GetPowerCurve(); double avgTI = ReadTI(); string wakeCombo = ReadWakeCombo(); double DW_Spacing = 0; double CW_Spacing = 0; double ambRough = 0; if (wakeModelType == 1) { // read in inputs for DAWM DW_Spacing = ReadDW_Spacing(); CW_Spacing = ReadCW_Spacing(); ambRough = ReadAmbRough(); } // Check to see if wake model has been added bool wakeModelExists = thisInst.wakeModelList.WakeModelExists(wakeModelType, horizExp, avgTI, thisPowerCurve.name, DW_Spacing, CW_Spacing, ambRough, wakeCombo); if (wakeModelExists == false) { thisInst.wakeModelList.AddWakeModel(wakeModelType, horizExp, avgTI, thisPowerCurve, DW_Spacing, CW_Spacing, ambRough, wakeCombo); } int wakeModelInd = 0; for (int i = 0; i < thisInst.wakeModelList.NumWakeModels; i++) { if (thisInst.wakeModelList.wakeModels[i].wakeModelType == wakeModelType && thisInst.wakeModelList.wakeModels[i].horizWakeExp == horizExp && thisInst.wakeModelList.wakeModels[i].powerCurve.name == thisPowerCurve.name && thisInst.wakeModelList.wakeModels[i].ambTI == avgTI && thisInst.wakeModelList.wakeModels[i].comboMethod == wakeCombo) { if (wakeModelType == 1) { if (thisInst.wakeModelList.wakeModels[i].DW_Spacing == DW_Spacing && thisInst.wakeModelList.wakeModels[i].CW_Spacing == CW_Spacing && thisInst.wakeModelList.wakeModels[i].ambRough == ambRough) { wakeModelInd = i; break; } } else { wakeModelInd = i; break; } } } if (thisInst.turbineList.TurbineCount > 0) { if (thisInst.turbineList.turbineEsts[0].EstsExistForWakeModel(thisInst.wakeModelList.wakeModels[wakeModelInd], thisInst.wakeModelList)) { MessageBox.Show("Wake losses have already been calculated with this model and settings.", "Continuum 3"); return; } } else { Close(); return; } if (thisInst.turbineList.turbineEsts[0].EstsExistForWakeModel(thisInst.wakeModelList.wakeModels[wakeModelInd], thisInst.wakeModelList) == false) { BackgroundWork.Vars_for_TurbCalcs argsForBW = new BackgroundWork.Vars_for_TurbCalcs(); if (thisInst.metList.ThisCount > 0) { argsForBW.thisInst = thisInst; argsForBW.thisWakeModel = thisInst.wakeModelList.wakeModels[wakeModelInd]; argsForBW.MCP_Method = thisInst.Get_MCP_Method(); // Call background worker to run calculations thisInst.BW_worker = new BackgroundWork(); thisInst.BW_worker.Call_BW_TurbCalcs(argsForBW); thisInst.ChangesMade(); } } else { // Update Net turb tab Update updateThe = new Update(); updateThe.NetTurbineEstsTAB(thisInst); } Close(); }