示例#1
0
        public void GetNearestStandardValueTest10()
        {
            RCModel rc     = new RCModel();
            double  target = rc.GetNearestStandardValue(0.52, 192);

            Assert.AreEqual(0.517, target);
        }
示例#2
0
        public void ConvertFromColorBandsTest2()
        {
            RCModel rc     = new RCModel();
            double  target = rc.ConvertFromColorBands(4, 3, 2, 1);

            Assert.AreEqual(4320.0, target);
        }
示例#3
0
        public void ConvertFromColorBandsTest1()
        {
            RCModel rc     = new RCModel();
            double  target = rc.ConvertFromColorBands(0, 0, 0, 0);

            Assert.AreEqual(0.0, target);
        }
示例#4
0
        public void ConvertFromColorBandsTest3()
        {
            RCModel rc     = new RCModel();
            double  target = rc.ConvertFromColorBands(4, 5, 6, 7);

            Assert.AreEqual(456.0e7, target);
        }
示例#5
0
        public static void GetFilePaths(ref TableMakerModel tableMakerModel)
        {
            var project  = tableMakerModel.Project;
            var programs = tableMakerModel.Programs;
            var testers  = tableMakerModel.Testers;

            OCVModel      ocvModel      = new OCVModel();
            RCModel       rcModel       = new RCModel();
            MiniModel     miniModel     = new MiniModel();
            StandardModel standardModel = new StandardModel();
            AndroidModel  androidModel  = new AndroidModel();

            tableMakerModel.OCVModel      = ocvModel;
            tableMakerModel.RCModel       = rcModel;
            tableMakerModel.MiniModel     = miniModel;
            tableMakerModel.StandardModel = standardModel;
            tableMakerModel.AndroidModel  = androidModel;

            ocvModel.FilePath = OCVTableMaker.GetOCVTableFilePath(project);
            rcModel.FilePath  = RCTableMaker.GetRCTableFilePath(project);
            List <string> strFilePaths;

            GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "mini", out strFilePaths);
            miniModel.FilePaths = strFilePaths;
            GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "standard", out strFilePaths);
            standardModel.FilePaths = strFilePaths;
            GetDriverFilePaths(project.BatteryType.Manufacturer, project.BatteryType.Name, project.AbsoluteMaxCapacity.ToString(), "android", out strFilePaths);
            androidModel.FilePaths = strFilePaths;
        }
示例#6
0
        public void GetNearestStandardValueTest1()
        {
            RCModel rc     = new RCModel(123);
            double  target = rc.GetNearestStandardValue(123, 24);

            Assert.AreEqual(120, target);
        }
示例#7
0
        public void ConvertFromColorBandsTest4()
        {
            RCModel rc     = new RCModel();
            double  target = rc.ConvertFromColorBands(9, 8, 7, 3);

            Assert.AreEqual(987.0e3, target);
        }
示例#8
0
        public void GetNearestStandardValueTest4()
        {
            RCModel rc     = new RCModel();
            double  target = rc.GetNearestStandardValue(10833, 96);

            Assert.AreEqual(10700, target);
        }
        public static void GetRCModel(List <SourceData> SDList, Project project, ref RCModel rcModel)
        {
            RCModel output = rcModel;

            output.SourceList = SDList;
            Int32 iMinVoltage;
            Int32 iMaxVoltage;

            TableMakerService.GetVoltageBondary(SDList, out iMinVoltage, out iMaxVoltage);
            output.MinVoltage = iMinVoltage;
            output.MaxVoltage = iMaxVoltage;
            foreach (var sd in SDList)
            {
                if (!output.listfTemp.Contains(sd.fTemperature))  //not exist in list add it
                {
                    output.listfTemp.Add(sd.fTemperature);
                }
                if (!output.listfCurr.Contains(sd.fCurrent))          //not exis in list add it
                {
                    output.listfCurr.Add(sd.fCurrent);
                }
            }
            UInt32 uErr = 0;

            CreateRCPoints_TableMini(ref uErr, ref output, SDList, project);
        }
示例#10
0
        private void RecipeToDb(List <CommodityShadow> commodityList, string recipeName, string recipeDescription,
                                RecipeCategory recipeCategory, Recipe recipe = null)
        {
            var rcModel = new RCModel(_dbPath);
            var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
            var recipeModel          = new RecipeModel(_dbPath);
            var commodityModel       = new CommodityModel(_dbPath);

            if (recipe == null)
            {
                recipe = recipeModel.CreateRecipe(recipeName, recipeDescription);
            }

            rcModel.CreateRC(recipe, recipeCategory);

            foreach (var commodityShadow in commodityList)
            {
                if (commodityShadow.Commodity != null)
                {
                    recipeCommodityModel.CreateRecipeCommodity(recipe, commodityShadow.Commodity, commodityShadow.Value,
                                                               commodityShadow.Unit.ToString());
                }
                else
                {
                    var commodity = commodityModel.CreateCommodity(commodityShadow.Name);
                    recipeCommodityModel.CreateRecipeCommodity(recipe, commodity, commodityShadow.Value,
                                                               commodityShadow.Unit.ToString());
                }
            }
        }
示例#11
0
        public void GetNearestStandardValueTest5()
        {
            RCModel rc     = new RCModel();
            double  target = rc.GetNearestStandardValue(9999, 24);

            Assert.AreEqual(9100, target);
        }
示例#12
0
        public static void GetStandardModel(OCVModel ocvModel, RCModel rcModel, ref StandardModel standardModel)
        {
            standardModel.iOCVVolt = ocvModel.iOCVVolt;

            standardModel.fCTABase  = rcModel.fCTABase;
            standardModel.fCTASlope = rcModel.fCTASlope;
            standardModel.listfCurr = rcModel.listfCurr;
            standardModel.listfTemp = rcModel.listfTemp;
            standardModel.outYValue = rcModel.outYValue;
        }
        public static void GetAndroidModel(OCVModel ocvModel, RCModel rcModel, ref AndroidModel androidModel)
        {
            androidModel.iOCVVolt = ocvModel.iOCVVolt;

            androidModel.fCTABase  = rcModel.fCTABase;
            androidModel.fCTASlope = rcModel.fCTASlope;
            androidModel.listfCurr = rcModel.listfCurr;
            androidModel.listfTemp = rcModel.listfTemp;
            androidModel.outYValue = rcModel.outYValue;
        }
示例#14
0
        // POST: api/RCModel
        public void Post([FromBody] RCModel value)
        {
            var myProject = WebApiApplication.Projects[value.ProjectId];

            value.Id       = myProject.UsedRCModel.Count;
            value.DateTime = DateTime.Now;
            if (value.PhotoSceneId == null)
            {
                value.PhotoSceneId = "前端没有PhotoSceneId";
            }
        }
示例#15
0
 private async void UpdateRCModelProgress(RCModel rcModel)
 {
     await Task.Run(() =>
     {
         //费时间的操作
         string progress = "";
         if (progress == "complete")
         {
             //下载obj,同时更改statu为完成,下载完成后创建task,
         }
     });
 }
示例#16
0
        public ScrapeVM(string dbPath)
        {
            _commodityModel       = new CommodityModel(dbPath);
            _recipeModel          = new RecipeModel(dbPath);
            _rcModel              = new RCModel(dbPath);
            _recipeCommodityModel = new RecipeCommodityModel(dbPath);

            var recipeCategoryVm = new RecipeCategoryVM(dbPath);

            _scrape = new Scrape(this);
            _scrape.SetContentCategoryDropdown(recipeCategoryVm.GetRecipeCategories());
            _scrape.ShowDialog();
        }
        public void DeleteAllContent()
        {
            // All Model are initialized
            var commodiytModel       = new CommodityModel(_dbPath);
            var rcModel              = new RCModel(_dbPath);
            var recipeCategoryModel  = new RecipeCategoryModel(_dbPath);
            var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
            var recipeModel          = new RecipeModel(_dbPath);

            // All data is wiped
            rcModel.DeleteAllRC();
            recipeCommodityModel.DeleteAllRecipeCommodities();
            recipeCategoryModel.DeleteRecipeCategory();
            recipeModel.DeleteRecipes();
            commodiytModel.DeleteCommodity();
        }
        public static TableMakerProduct GenerateRCTable(Project project, RCModel rcModel)
        {
            var    OutFolder    = $@"{GlobalSettings.RootPath}{project.BatteryType.Name}\{project.Name}\{GlobalSettings.ProductFolderName}";
            string filePath     = Path.Combine(OutFolder, rcModel.FilePath);//GetRCTableFilePath(project);
            var    strRCHeader  = GetRCFileHeader(project, rcModel.fCTABase, rcModel.fCTASlope);
            var    strRCContent = GetRCFileContent(rcModel.outYValue, project.VoltagePoints, rcModel.listfTemp, rcModel.listfCurr);

            //UInt32 uErr = 0;
            TableMakerService.CreateFile(filePath, strRCHeader.Concat(strRCContent).ToList());
            TableMakerProduct tmp = new TableMakerProduct();

            tmp.FilePath = filePath;
            tmp.IsValid  = true;
            tmp.Project  = project;
            return(tmp);
        }
示例#19
0
        public void UpdateRecipe(List <CommodityShadow> commodityList, string recipeName, string recipeDescription,
                                 RecipeCategory recipeCategory, Recipe recipe)
        {
            using (var scope = new TransactionScope())
            {
                var rcModel = new RCModel(_dbPath);
                var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
                var recipeModel          = new RecipeModel(_dbPath);

                // We do not want to delete the recipe, since this will change its place
                // on the list, but we delete all the connections to other tuples!
                rcModel.DeleteRC(recipe);

                recipeCommodityModel.DeleteRecipeCommodities(recipe);

                recipeModel.EditRecipe(recipe, recipeName, recipeDescription);

                RecipeToDb(commodityList, recipeName, recipeDescription, recipeCategory, recipe);

                scope.Complete();
            }
        }
        private static bool CreateRCPoints_TableMini(ref uint uErr, ref RCModel output, List <SourceData> sdList, Project project)
        {
            bool bReturn = true;        //cause below will use bReturn &= xxxx

            foreach (List <Int32> il in output.outYValue)
            {
                il.Clear();
            }
            output.outYValue.Clear();
            output.listfTemp.Sort();
            output.listfCurr.Sort();
            output.listfCurr.Reverse();

            List <float> fCTAKeod = new List <float>();        //save Keod value, = Max_Diff_Temp * 10 / Joules_value for each current_temperature

            foreach (float ft in output.listfTemp)             //from low temperature to list
            {
                foreach (float fc in output.listfCurr)         //from low current to list
                {
                    foreach (var sds in sdList)
                    {
                        if ((sds.fTemperature == ft) &&
                            (sds.fCurrent == fc))
                        {
                            {
                                List <Int32> il16tmp = new List <Int32>();
                                //Int32 iCountP = 0;
                                float fCCount = 0;
                                float fMaxDiff = 0, fCalTmp = 0;
                                if (sds.AdjustedExpData.Count < 1)
                                {
                                    uErr     = 1;
                                    bReturn &= false;
                                    break;      //foreach (SourceData sds in bdsBatRCSource)
                                }
                                else
                                {
                                    if (!CreateYPoints_CTAV0026(project.VoltagePoints, ref il16tmp, ref fMaxDiff, ref fCCount, sds.AdjustedExpData, ref uErr, project.AbsoluteMaxCapacity, 0))
                                    {
                                        bReturn &= false;
                                    }
                                    else
                                    {
                                    }
                                    output.outYValue.Add(il16tmp);      //if error, still add into RCYvalue
                                    fCalTmp   = fCCount;
                                    fMaxDiff *= 10;
                                    fMaxDiff /= fCalTmp;
                                    fCTAKeod.Add(fMaxDiff);
                                    break;
                                }
                            }
                        }
                    }
                }
            }



            List <float> fAvgPerCurrent = new List <float>(); //save Keod'_favg for each temperature, skip Max_Keod_value and Min_Keod_value to calculate average
            List <float> fCTACurrent    = new List <float>(); //save Keod'_favg for each temperature, skip Max_Keod_value and Min_Keod_value to calculate average

            if (true)
            {
                float fCalTmp = 0, fCalMax = 0, fCalMin = 10000;
                int   idxKeod = 0;
                for (int jj = 0; jj < output.listfCurr.Count(); jj++)
                {
                    fCalTmp = 0;
                    fCalMax = 0;
                    fCalMin = 10000;
                    for (int ii = 0; ii < output.listfTemp.Count(); ii++)
                    {
                        idxKeod = ((ii * output.listfCurr.Count()) + jj);
                        if (idxKeod < fCTAKeod.Count())
                        {
                            fCalTmp += fCTAKeod[idxKeod];
                            if (fCTAKeod[idxKeod] > fCalMax)
                            {
                                fCalMax = fCTAKeod[idxKeod];
                            }
                            if (fCTAKeod[idxKeod] < fCalMin)
                            {
                                fCalMin = fCTAKeod[idxKeod];
                            }
                        }
                        else
                        {
                            bReturn = false;
                            break;  //for (int jj = 0; jj < listfCurr.Count(); jj++)
                        }
                    }
                    if (!bReturn)
                    {
                        uErr = 1;
                        break;      //for (int ii = 0; ii < listfTemp.Count(); ii++)
                    }
                    else
                    {
                        fCalTmp -= fCalMax;
                        fCalTmp -= fCalMin;
                        fCalTmp /= (output.listfTemp.Count() - 2);
                        fAvgPerCurrent.Add(fCalTmp);
                        fCTACurrent.Add(Math.Abs((float)(output.listfCurr[jj] / 1000)));
                    }
                }
                if (fAvgPerCurrent.Count() != output.listfCurr.Count())
                {
                    uErr    = 1;
                    bReturn = false;
                }
            }

            double fSquare, fCTABase, fCTASlope;

            CalculateCTASlopeBase(fCTACurrent, fAvgPerCurrent, 0, fAvgPerCurrent.Count(), out fSquare, out fCTABase, out fCTASlope);
            fCTASlope       *= 10000;
            fCTASlope        = (float)((int)(fCTASlope + 0.5));
            fCTABase         = (float)((int)(fCTABase * 10000 + 0.5));
            output.fCTABase  = fCTABase;
            output.fCTASlope = fCTASlope;

            return(bReturn);
        }
        } = 1;                                                        //(A200831)francis, for table_mini
        #region Mini
        public static void GetMiniModel(List <SourceData> ocvSource, List <SourceData> rcSource, OCVModel ocvModel, RCModel rcModel, Project project, ref MiniModel miniModel)
        {
            MiniModel output = miniModel;

            output.iOCVVolt  = ocvModel.iOCVVolt;
            output.fCTABase  = rcModel.fCTABase;
            output.fCTASlope = rcModel.fCTASlope;
            List <short> ilstOutIR;
            var          num = (iNumOfMiniPoints + 1) * rcModel.listfTemp.Count;
            List <float> flstRC_T;

            List <List <float> > fLstRCM_Volt;

            GetLstRCM_Volt(ocvSource, rcSource, rcModel, out fLstRCM_Volt);
            GetLstRC_T(fLstRCM_Volt, out flstRC_T);
            List <float> flstOCV;

            GetLstTblM_OCV(ocvSource, out flstOCV);
            GetLstOutIR(num, iNumOfMiniPoints + 1, rcModel.listfCurr, flstOCV, flstRC_T, out ilstOutIR);
            List <float> flstTotalAcc;

            GetLstTotalAcc(out flstTotalAcc, project, rcSource, rcModel);
            List <double> poly2EstFACC;
            List <double> poly2EstIR;

            GetPoly(rcModel.listfTemp, ilstOutIR, flstTotalAcc, out poly2EstFACC, out poly2EstIR);
            output.poly2EstFACC = poly2EstFACC;
            output.poly2EstIR   = poly2EstIR;
        }
        private static void GetLstRCM_Volt(List <SourceData> ocvSource, List <SourceData> rcSource, RCModel rcModel, out List <List <float> > fLstRCM_Volt)
        {
            fLstRCM_Volt = new List <List <float> >();
            Int32 iMinVoltage = rcModel.MinVoltage;
            //Int32 iMaxVoltage;
            //GetVoltageBondary(rcSource, out iMinVoltage, out iMaxVoltage);
            var listfTemp = rcModel.listfTemp;
            var fc        = rcModel.listfCurr[0];

            float fFullCapacity = rcSource[0].fAbsMaxCap - rcSource[0].fCapacityDiff;
            float fACCMiniStep  = fMiniTableSteps * 0.01F * (fFullCapacity);

            foreach (float ft in listfTemp)     //from low temperature to list
            {
                foreach (var sds in rcSource)
                {
                    if ((sds.fTemperature == ft) &&
                        (sds.fCurrent == fc))
                    {
                        int          i            = 0;
                        var          inListRCData = sds.AdjustedExpData;
                        float        fPreVol      = inListRCData[0].fVoltage;
                        List <float> flstTmp      = new List <float>();
                        for (int j = 0; j < inListRCData.Count; j++)
                        {
                            if (i < iNumOfMiniPoints)
                            {
                                if (inListRCData[j].fAccMah < (i * fACCMiniStep))
                                {
                                    fPreVol = inListRCData[j].fVoltage;
                                }
                                else
                                {
                                    flstTmp.Add(fPreVol);
                                    i++;
                                }
                            }
                        }
                        for (int ij = flstTmp.Count; ij <= iNumOfMiniPoints; ij++)
                        {
                            flstTmp.Add(iMinVoltage);
                        }

                        fLstRCM_Volt.Add(flstTmp);
                    }
                }
            }
        }
        private static void GetLstTotalAcc(out List <float> flstTotalAcc, Project project, List <SourceData> rcSource, RCModel rcModel)
        {
            flstTotalAcc = new List <float>();
            List <float> fYPointACCall      = new List <float>();
            var          listfTemp          = rcModel.listfTemp;
            var          listfCurr          = rcModel.listfCurr;
            var          TableVoltagePoints = project.VoltagePoints;

            foreach (float ft in listfTemp)     //from low temperature to list
            {
                foreach (float fc in listfCurr) //from low current to list
                {
                    foreach (var sds in rcSource)
                    {
                        if ((sds.fTemperature == ft) &&
                            (sds.fCurrent == fc))
                        {
                            int        i = 0, j = 0, iCountP = 0;
                            float      fPreSoC = -99999, fPreVol = -99999, fAvgSoc = -99999, fPreTemp = -9999, fPreCCount = 0;//, fAccCount = 0; ;
                            List <int> ypoints         = new List <int>();
                            float      fDesignCapacity = 3080;
                            float      fCapaciDiff     = 0;
                            float      fRefMaxDiff     = 0;
                            float      fRefCCount      = 0;
                            //(A200902)Francis, use the low_cur header setting to calculate
                            List <float> flstTmp = new List <float>();
                            float        fAccCap = 0.0f;

                            //(M140718)Francis,
                            i = 0; j = 0;
                            var inListRCData = sds.AdjustedExpData;
                            for (i = 0; i < TableVoltagePoints.Count; i++)
                            {
                                for (; j < inListRCData.Count; j++)
                                {
                                    //(A20201015), memorize maximum accumulated capacity
                                    if (Math.Abs(inListRCData[j].fAccMah) > fAccCap)
                                    {
                                        fAccCap = Math.Abs(inListRCData[j].fAccMah);//(A20200813)
                                    }
                                    if (j >= iCountP)
                                    {
                                        if (fPreTemp == -9999)
                                        {
                                            iCountP   += 1;
                                            fPreTemp   = inListRCData[j].fTemperature;
                                            fPreCCount = inListRCData[j].fAccMah;
                                        }
                                        else
                                        {
                                            //strDbg = string.Format("j={0:d}, diff= {1:f}, sum befor ={2:f}", j, (inListRCData[j].fTemperature - fPreTemp), fRefSumDiff);
                                            //Debug.WriteLine(strDbg);
                                            if (fRefMaxDiff < (inListRCData[j].fTemperature - fPreTemp))
                                            {
                                                fRefMaxDiff = (inListRCData[j].fTemperature - fPreTemp);
                                            }
                                            iCountP += 1;
                                            /*fAccCount*/
                                            fRefCCount = (float)Math.Abs(inListRCData[j].fAccMah - fPreCCount);
                                        }
                                    }
                                    //

                                    if (TableVoltagePoints[i] < inListRCData[j].fVoltage)
                                    {
                                        fPreSoC = inListRCData[j].fAccMah;
                                        fPreVol = inListRCData[j].fVoltage;
                                    }
                                    else
                                    {
                                        if ((fPreSoC != -99999) && (fPreVol != -99999))
                                        {
                                            fAvgSoc  = (fPreVol - TableVoltagePoints[i]) / (fPreVol - inListRCData[j].fVoltage);
                                            fAvgSoc *= (fPreSoC - inListRCData[j].fAccMah);
                                            fAvgSoc += inListRCData[j].fAccMah;
                                            if ((i + 1) < TableVoltagePoints.Count)
                                            {
                                                if (TableVoltagePoints[i + 1] > inListRCData[j].fVoltage)
                                                {
                                                }
                                                else
                                                {
                                                    fPreSoC = -99999;
                                                    fPreVol = -99999;
                                                }
                                            }
                                            else
                                            {
                                                fPreSoC = -99999;
                                                fPreVol = -99999;
                                            }
                                        }
                                        else
                                        {
                                            if (j == 0)
                                            {
                                                fAvgSoc = 0F;
                                            }
                                            else
                                            {
                                                j += 1;
                                            }
                                        }
                                        break; //for(; j<)
                                    }
                                }              //for (; j < inListRCData.Count; j++)
                                if (j < inListRCData.Count)
                                {
                                    if (fAvgSoc != -99999)
                                    {
                                        fAvgSoc  = (fDesignCapacity - fCapaciDiff - fAvgSoc); //convert to remaining
                                        fAvgSoc *= (10000 / fDesignCapacity);                 //convert to 10000C
                                    }
                                }
                                else
                                {
                                    DataRow rdtmp = null;
                                    for (int ij = inListRCData.Count - 1; ij >= 0; ij--)
                                    {
                                        if (Math.Abs(inListRCData[ij].fCurrent - 0) > 5)
                                        {
                                            rdtmp = inListRCData[ij];
                                            break;
                                        }
                                    }
                                    if (rdtmp != null)
                                    {
                                        if (Math.Abs(TableVoltagePoints[i] - rdtmp.fVoltage) < 10)
                                        {
                                            fAvgSoc  = (fDesignCapacity - fCapaciDiff - inListRCData[inListRCData.Count - 1].fAccMah); //convert to remaining
                                            fAvgSoc *= (10000 / fDesignCapacity);                                                      //convert to 10000C
                                        }
                                        else
                                        {
                                        }
                                    }
                                    else
                                    {
                                    }
                                }
                                if (fAvgSoc > 10000)
                                {
                                    fAvgSoc = 10000.0F;
                                }
                                //if (fAvgSoc < 0) fAvgSoc = -9999.0F;
                                if (fAvgSoc < 0)
                                {
                                    fAvgSoc = 0;             //fAvgSoc -= 1.0F;
                                }
                                ypoints.Add(Convert.ToInt32(Math.Round(fAvgSoc, 0)));
                                //i += 1;
                                if (i >= TableVoltagePoints.Count)
                                {
                                    break;
                                }
                            }   //for (i = 0; i < TableVoltagePoints.Count; i++)

                            if (ypoints.Count == TableVoltagePoints.Count - 1)
                            {
                                fAvgSoc  = inListRCData[inListRCData.Count - 1].fAccMah;
                                fAvgSoc  = (fDesignCapacity - fCapaciDiff - fAvgSoc); //convert to remaining
                                fAvgSoc *= (10000 / fDesignCapacity);                 //convert to 10000C
                                if (fAvgSoc > 10000)
                                {
                                    fAvgSoc = 10000.0F;
                                }
                                if (fAvgSoc < 0)
                                {
                                    fAvgSoc = -9999.0F;
                                }
                                ypoints.Add(Convert.ToInt32(Math.Round(fAvgSoc, 0)));
                                i += 1;
                            }

                            if (ypoints.Count == TableVoltagePoints.Count)
                            {
                                ypoints.Sort();
                            }
                            else
                            {
                                for (int ii = ypoints.Count; ii < TableVoltagePoints.Count; ii++)
                                {
                                    ypoints.Add(0);
                                }
                                ypoints.Sort();
                                //because leakage of information, CreateNewErrorLog() need to be done outside of this funciton
                            }
                            //(A200902)francis, table_mini
                            fYPointACCall.Add(fAccCap);
                        }
                    }
                }
            }

            for (int j = 0; j < listfTemp.Count; j++)
            {
                flstTotalAcc.Add(fYPointACCall[j * listfCurr.Count]);
            }
        }
        public void PopulateDBDummyData()
        {
            DeleteAllContent();
            // All Model are initialized
            var commodiytModel       = new CommodityModel(_dbPath);
            var rcModel              = new RCModel(_dbPath);
            var recipeCategoryModel  = new RecipeCategoryModel(_dbPath);
            var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
            var recipeModel          = new RecipeModel(_dbPath);
            // Add some cool recipes yes.

            // Creating Categories
            var recipeCategoryAftensmad = recipeCategoryModel.CreateRecipeCategory("Aftensmad");
            var recipeCategoryDessert   = recipeCategoryModel.CreateRecipeCategory("Dessert");

            // Creating some recipies
            var recipeLasagna = recipeModel.CreateRecipe("Lasagne",
                                                         "Kødsovs: Svits kødet i olie i en bred gryde, til det har skiftet farve.\nPil og hak løgene. Skræl gulerod og selleri og hak det fint. Svits løg, hvidløg og grøntsager et par minutter. Tilsæt lauerbærblade, oregano, timian, salt og peber.\nOstesauce: Semlt smærret i en gryde. Drys melet i og pisk blandingen sammen. Pisk mælken i lidt ad gangen og kog saucen igennem nogle minutter. Rør osten i.\nSmag til med revet muskat, salt og peber.\nSmør et ovnfast fad eller en lille bradepande.\nSaml lasagnen: Læg lasagneplader, kødsauce og ostesauce = spring evt. ostesaucen over i midten, det er vigtigt, at der er nok til at dzkke overfladen. Drys parmesan over.\nLad lasagnen trække ca. 20 in. (eller til pladerne er bløde), inden den kommer i ovnen. Bag lasagnen i ovnen ved 180 grader i ca. 50 min. Lad den hvile 5 min. inden udskæring.\n\nTIP: Hvis man bruger friske lasagneplader, skal lasagnen ikke trække i 20 m in.\nTilsæt evt. flere grøntsager til kødsaucen, fx 1 squasch, 1 peberfrugt, el. 1 pastinak, skåret i tern.");

            var recipeBananaSplit = recipeModel.CreateRecipe("Banana split",
                                                             "Lav chokoladesirup: \n" +
                                                             "Bring alle ingredienserne i kog under omrøring. Køl det så af. Chokoladesiruppen kan holde sig længe i køleskabet.\n\n" +
                                                             "Lav bananasplit: \n" +
                                                             "Flæk bananen og læg hver halvdel på langs i skålen. En klassisk banana split skal helst serveres i en aflang glasskål af nogenlunde samme længde som bananen. \n" +
                                                             "Læg tre kugler is i midten, en kugle vanille-, en kugle chokolade- og en kugle jordbæris. Pynt vanilleisen med chokoladesirup, jordbærisen med hakket ananas og chokoladeisen med jordbærskiver. Pynt yderligere med flødeskum, hakkede hasselnødder, mere chokoladesirup og 2-3 røde cocktailbær. En banana split skal være stor og vulgær at se på - så hold endelige ikke igen!");

            // Now we need to bind them together! We do need these objects :D
            rcModel.CreateRC(recipeLasagna, recipeCategoryAftensmad);
            rcModel.CreateRC(recipeBananaSplit, recipeCategoryDessert);

            var salt = commodiytModel.CreateCommodity("Salt");

            // Adding commodities
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Lasagneplader"),
                                                       250, Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Hakket oksekød"),
                                                       500, Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Olie"), 1,
                                                       Units.spsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Løg"), 2,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Gulerod"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Selleri"), 100,
                                                       Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Laurbærblade"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Oregano"), 2,
                                                       Units.tsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Timian"), 1,
                                                       Units.tsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, salt, 0.75, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Peber"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Hvidløg"), 3,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Hakkede tomater"),
                                                       1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Tomatpure"), 3,
                                                       Units.spsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Oksebuillon"), 3,
                                                       Units.dl.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Smør"), 25,
                                                       Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Hvedemel"), 3,
                                                       Units.spsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Mælk"), 6,
                                                       Units.dl.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Muskatnød"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeLasagna, commodiytModel.CreateCommodity("Parmasan"), 50,
                                                       Units.g.ToString());


            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Banan"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Vanile is"),
                                                       1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit,
                                                       commodiytModel.CreateCommodity("Chokolade is"), 1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Jordbær is"),
                                                       1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Ananas"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Jordbær"), 1,
                                                       Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit,
                                                       commodiytModel.CreateCommodity("Chokoladesirup"), 1, Units.spsk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit,
                                                       commodiytModel.CreateCommodity("Hassel nødder"), 1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("cocktailbær"),
                                                       3, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Vand"), 2,
                                                       Units.dl.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Sukker"), 150,
                                                       Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, commodiytModel.CreateCommodity("Kakao"), 60,
                                                       Units.g.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit,
                                                       commodiytModel.CreateCommodity("Vanileessens"), 1, Units.stk.ToString());
            recipeCommodityModel.CreateRecipeCommodity(recipeBananaSplit, salt, 5, Units.g.ToString());
        }
示例#25
0
        public RecipeToCategory GetRecipeCategory(Recipe recipe)
        {
            var rcModel = new RCModel(_dbPath);

            return(rcModel.GetCategory(recipe));
        }