Пример #1
0
        public void UpdateLimits_Test()
        {
            Continuum thisInst = new Continuum("");

            string Filename = testingFolder + "\\GenMap testing.cfm";

            thisInst.Open(Filename);
            GenMap New_Map = new GenMap(thisInst);

            New_Map.gridReso = 5000;
            New_Map.FindLargestArea();
            New_Map.GetBiggestArea();

            Assert.AreEqual(New_Map.minUTMX_Limit, 426087, 0, "Test 1: Wrong Min UTMX Limit");
            Assert.AreEqual(New_Map.minUTMY_Limit, 3995085, 0, "Test 1: Wrong Min UTMY Limit");
            Assert.AreEqual(New_Map.maxUTMX_Limit, 466087, 0, "Test 1: Wrong Max UTMX Limit");
            Assert.AreEqual(New_Map.maxUTMY_Limit, 4010085, 0, "Test 1: Wrong Max UTMY Limit");
            Assert.AreEqual(New_Map.numX, 9, 0, "Test 1: Wrong Num X");
            Assert.AreEqual(New_Map.numY, 4, 0, "Test 1: Wrong Num Y");
            Assert.AreEqual(New_Map.numGrid, 36, 0, "Test 1: Wrong Num Grid");

            New_Map.gridReso = 1000;
            New_Map.FindLargestArea();
            New_Map.GetBiggestArea();

            Assert.AreEqual(New_Map.minUTMX_Limit, 424087, 0, "Test 2: Wrong Min UTMX Limit");
            Assert.AreEqual(New_Map.minUTMY_Limit, 3993085, 0, "Test 2: Wrong Min UTMY Limit");
            Assert.AreEqual(New_Map.maxUTMX_Limit, 469087, 0, "Test 2: Wrong Max UTMX Limit");
            Assert.AreEqual(New_Map.maxUTMY_Limit, 4014085, 0, "Test 2: Wrong Max UTMY Limit");
            Assert.AreEqual(New_Map.numX, 46, 0, "Test 2: Wrong Num X");
            Assert.AreEqual(New_Map.numY, 22, 0, "Test 2: Wrong Num Y");
            Assert.AreEqual(New_Map.numGrid, 1012, 0, "Test 2: Wrong Num Grid");

            thisInst.Close();
        }
Пример #2
0
        public void Unwaked_Maps()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            Continuum thisInst = new Continuum("");

            string fileName = saveFolder + "\\Maps_Unwaked";

            if (File.Exists(fileName + ".cfm"))
            {
                File.Delete(fileName + ".cfm");
                File.Delete(fileName + ".mdf");
                File.Delete(fileName + "_log.ldf");
            }

            thisInst.savedParams.savedFileName       = fileName + ".cfm";
            thisInst.UTM_conversions.savedDatumIndex = 0;
            thisInst.UTM_conversions.UTMZoneNumber   = 16;
            thisInst.UTM_conversions.hemisphere      = "Northern";

            thisInst.modeledHeight = 80;
            thisInst.SaveFile(true);

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load topo data
            string topoFile = testingFolder + "\\Topo & LC\\Findlay\\Findlay Topo.tif";

            BackgroundWork.Vars_for_BW Vars_for_BW = new BackgroundWork.Vars_for_BW();
            Vars_for_BW.thisInst = thisInst;
            Vars_for_BW.Filename = topoFile;
            thisInst.BW_worker   = new BackgroundWork();
            thisInst.BW_worker.Call_BW_TopoImport(Vars_for_BW);

            while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
            {
                Thread.Sleep(1000);
            }

            if (thisInst.BW_worker.WasReturned)
            {
                Assert.Fail();
            }

            // Called in BackgroundWorker RunWorkerCompleted
            thisInst.SaveFile(true);
            thisInst.updateThe.AllTABs(thisInst);
            thisInst.BW_worker.Close();

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one met TAB file
            thisInst.metList.isTimeSeries = false;
            thisInst.ofdMets.FileName     = testingFolder + "\\Met TAB files\\Findlay\\Paulding Findlay coords.TAB";
            thisInst.ImportMetsTAB();

            // The following are all called in btnMetTAB_Click
            thisInst.turbineList.ClearAllWSEsts();
            thisInst.updateThe.AllTABs(thisInst);

            if (thisInst.topo.gotTopo == true)
            {
                if (thisInst.chkUseSR.Checked == true && thisInst.topo.gotSR == true)
                {
                    thisInst.topo.useSR = true;
                }
                else
                {
                    thisInst.topo.useSR = false;
                }

                if (thisInst.chk_Use_Sep.Checked == true)
                {
                    thisInst.topo.useSepMod = true;
                }
                else
                {
                    thisInst.topo.useSepMod = false;
                }

                // Call background worker to run calculations
                // In background worker, performs exposure and grid stat calculations, finds path of nodes and does site calibration.
                thisInst.BW_worker = new BackgroundWork();
                BackgroundWork.Vars_for_BW metArgs = new BackgroundWork.Vars_for_BW();
                metArgs.thisInst = thisInst;

                thisInst.BW_worker.Call_BW_MetCalcs(metArgs);

                while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
                {
                    Thread.Sleep(1000);
                }

                if (thisInst.BW_worker.WasReturned)
                {
                    Assert.Fail();
                }

                thisInst.SaveFile(true);
                thisInst.updateThe.AllTABs(thisInst);
                thisInst.BW_worker.Close();
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one met TAB file
            thisInst.metList.isTimeSeries = false;
            thisInst.ofdMets.FileName     = testingFolder + "\\Met TAB files\\Findlay\\Wapakoneta Findlay coords.TAB";
            thisInst.ImportMetsTAB();

            // The following are all called in btnMetTAB_Click
            thisInst.turbineList.ClearAllWSEsts();
            thisInst.updateThe.AllTABs(thisInst);

            if (thisInst.topo.gotTopo == true)
            {
                if (thisInst.chkUseSR.Checked == true && thisInst.topo.gotSR == true)
                {
                    thisInst.topo.useSR = true;
                }
                else
                {
                    thisInst.topo.useSR = false;
                }

                if (thisInst.chk_Use_Sep.Checked == true)
                {
                    thisInst.topo.useSepMod = true;
                }
                else
                {
                    thisInst.topo.useSepMod = false;
                }

                // Call background worker to run calculations
                // In background worker, performs exposure and grid stat calculations, finds path of nodes and does site calibration.
                thisInst.BW_worker = new BackgroundWork();
                BackgroundWork.Vars_for_BW metArgs = new BackgroundWork.Vars_for_BW();
                metArgs.thisInst = thisInst;

                thisInst.BW_worker.Call_BW_MetCalcs(metArgs);

                while (thisInst.BW_worker.DoWorkDone == false && thisInst.BW_worker.WasReturned == false) // RunWorkerCompleted isn't getting called (?) so killing BW_Worker once it reaches end of DoWork
                {
                    Thread.Sleep(1000);
                }

                if (thisInst.BW_worker.WasReturned)
                {
                    Assert.Fail();
                }

                thisInst.SaveFile(true);
                thisInst.updateThe.AllTABs(thisInst);
                thisInst.BW_worker.Close();
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Load one turbine
            string turbineFile = testingFolder + "\\Turbine sites\\Findlay\\Ball 2 Turbines.csv";

            thisInst.LoadTurbines(turbineFile);

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Analyze mets
            thisInst.BW_worker = new BackgroundWork();
            BackgroundWork.Vars_for_BW theArgs = new BackgroundWork.Vars_for_BW();
            theArgs.thisInst = thisInst;
            thisInst.BW_worker.Call_BW_MetCalcs(theArgs);

            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();

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Generate map

            GenMap newMap = new GenMap(thisInst);

            newMap.cboWhatToMap.SelectedIndex = 2;

            // if there are existing maps, use the coordinates from the last one created
            int numMaps = thisInst.mapList.ThisCount;

            if (numMaps > 0 && thisInst.savedParams.genMapMinUTMX == 0)
            {
                newMap.gridReso = thisInst.mapList.mapItem[numMaps - 1].reso;
                newMap.minUTMX  = thisInst.mapList.mapItem[numMaps - 1].minUTMX;
                newMap.maxUTMX  = newMap.minUTMX + (thisInst.mapList.mapItem[numMaps - 1].numX - 1) * thisInst.mapList.mapItem[numMaps - 1].reso;
                newMap.minUTMY  = thisInst.mapList.mapItem[numMaps - 1].minUTMY;
                newMap.maxUTMY  = newMap.minUTMY + (thisInst.mapList.mapItem[numMaps - 1].numY - 1) * thisInst.mapList.mapItem[numMaps - 1].reso;
            }
            else if (thisInst.savedParams.genMapMinUTMX != 0)
            {
                newMap.minUTMX  = thisInst.savedParams.genMapMinUTMX;
                newMap.maxUTMX  = thisInst.savedParams.genMapMaxUTMX;
                newMap.minUTMY  = thisInst.savedParams.genMapMinUTMY;
                newMap.maxUTMY  = thisInst.savedParams.genMapMaxUTMY;
                newMap.gridReso = thisInst.savedParams.genMapReso;
            }
            else
            {
                newMap.gridReso = 250;
            }

            newMap.gridReso        = 2000;
            newMap.txtMapReso.Text = newMap.gridReso.ToString();
            newMap.FindLargestArea();
            newMap.UpdateTextboxes();
            newMap.GetBiggestArea();

            newMap.chkMetsToUse.Items.Clear();
            thisMet = null;

            for (int j = 0; j < thisInst.metList.ThisCount; j++)
            {
                thisMet = thisInst.metList.metItem[j];
                newMap.chkMetsToUse.Items.Add(thisMet.name, true);
            }

            thisInst.metList.AreAllMetsMCPd();

            if (thisInst.metList.isTimeSeries == false || thisInst.metList.allMCPd == false)
            {
                newMap.cboUseTimeSeries.SelectedIndex = 0;     // Use Avg Dist.
                newMap.cboUseTimeSeries.Enabled       = false; // User has no choice if not time series model
            }
            else
            {
                newMap.cboUseTimeSeries.SelectedIndex = 0;    // Use Avg Dist.
                newMap.cboUseTimeSeries.Enabled       = true; // User can choose to generate map using average distributions or using GenerateTimeSeries
            }

            newMap.GetMapSettings();
            thisInst.mapList.AddMap(newMap.mapName, newMap.minUTMX, newMap.minUTMY, newMap.gridReso, newMap.numX, newMap.numY, newMap.whatToMap,
                                    newMap.powerCurve, thisInst, false, new Wake_Model(), newMap.metsUsed, newMap.models, newMap.useTimeSeries);

            while (thisInst.BW_worker.DoWorkDone == false)
            {
                Thread.Sleep(1000);
            }

            thisInst.BW_worker.Close();

            Assert.AreEqual(thisInst.mapList.ThisCount, numMaps + 1, "Didn't create map");

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            // Generate map

            newMap = new GenMap(thisInst);
            newMap.cboWhatToMap.SelectedIndex = 2;

            // if there are existing maps, use the coordinates from the last one created
            numMaps = thisInst.mapList.ThisCount;

            if (numMaps > 0 && thisInst.savedParams.genMapMinUTMX == 0)
            {
                newMap.gridReso = thisInst.mapList.mapItem[numMaps - 1].reso;
                newMap.minUTMX  = thisInst.mapList.mapItem[numMaps - 1].minUTMX;
                newMap.maxUTMX  = newMap.minUTMX + (thisInst.mapList.mapItem[numMaps - 1].numX - 1) * thisInst.mapList.mapItem[numMaps - 1].reso;
                newMap.minUTMY  = thisInst.mapList.mapItem[numMaps - 1].minUTMY;
                newMap.maxUTMY  = newMap.minUTMY + (thisInst.mapList.mapItem[numMaps - 1].numY - 1) * thisInst.mapList.mapItem[numMaps - 1].reso;
            }
            else if (thisInst.savedParams.genMapMinUTMX != 0)
            {
                newMap.minUTMX  = thisInst.savedParams.genMapMinUTMX;
                newMap.maxUTMX  = thisInst.savedParams.genMapMaxUTMX;
                newMap.minUTMY  = thisInst.savedParams.genMapMinUTMY;
                newMap.maxUTMY  = thisInst.savedParams.genMapMaxUTMY;
                newMap.gridReso = thisInst.savedParams.genMapReso;
            }
            else
            {
                newMap.gridReso = 250;
            }

            newMap.gridReso        = 2000;
            newMap.txtMapReso.Text = newMap.gridReso.ToString();
            newMap.FindAreaAroundTurbines();

            newMap.chkMetsToUse.Items.Clear();
            thisMet = null;

            for (int j = 0; j < thisInst.metList.ThisCount; j++)
            {
                thisMet = thisInst.metList.metItem[j];
                newMap.chkMetsToUse.Items.Add(thisMet.name, true);
            }

            thisInst.metList.AreAllMetsMCPd();

            if (thisInst.metList.isTimeSeries == false || thisInst.metList.allMCPd == false)
            {
                newMap.cboUseTimeSeries.SelectedIndex = 0;     // Use Avg Dist.
                newMap.cboUseTimeSeries.Enabled       = false; // User has no choice if not time series model
            }
            else
            {
                newMap.cboUseTimeSeries.SelectedIndex = 0;    // Use Avg Dist.
                newMap.cboUseTimeSeries.Enabled       = true; // User can choose to generate map using average distributions or using GenerateTimeSeries
            }

            newMap.GetMapSettings();
            thisInst.mapList.AddMap(newMap.mapName, newMap.minUTMX, newMap.minUTMY, newMap.gridReso, newMap.numX, newMap.numY, newMap.whatToMap,
                                    newMap.powerCurve, thisInst, false, new Wake_Model(), newMap.metsUsed, newMap.models, newMap.useTimeSeries);

            while (thisInst.BW_worker.DoWorkDone == false)
            {
                Thread.Sleep(1000);
            }

            thisInst.BW_worker.Close();

            Assert.AreEqual(thisInst.mapList.ThisCount, numMaps + 1, "Didn't create map");

            thisInst.SaveFile(true);
            thisInst.Close();
        }