コード例 #1
0
 public void UpdateEstimatedTime(Program item, StepRuntime startPoint, ref DateTime time, ref double c, ref bool isActive)
 {
     if (item.StartTime == DateTime.MinValue)
     {
         item.EST = time;
         foreach (var recipe in item.Recipes)
         {
             RecipeService.UpdateEstimatedTime(recipe, startPoint, ref time, ref c, ref isActive);
         }
         item.EET = time;
     }
     else
     {
         time = item.StartTime;
         if (item.EndTime == DateTime.MinValue)
         {
             foreach (var recipe in item.Recipes)
             {
                 RecipeService.UpdateEstimatedTime(recipe, startPoint, ref time, ref c, ref isActive);
             }
             item.EET = time;
         }
         else
         {
             time = item.EndTime;
         }
     }
 }
コード例 #2
0
        //找到最后一个有实际时间的step runtime,如果都没有,那就返回第一个
        private StepRuntime FindStartPoint(out DateTime startTime)
        {
            StepRuntime startPoint = null;

            startTime = Items[0].RequestTime;
            foreach (var item in Items)
            {
                foreach (var rec in item.Recipes)
                {
                    foreach (var step in rec.StepRuntimes)
                    {
                        if (step.EndTime != DateTime.MinValue)
                        {
                            startPoint = step;
                            startTime  = step.EndTime;
                        }
                        else if (step.StartTime != DateTime.MinValue)
                        {
                            startPoint = step;
                            startTime  = step.StartTime;
                        }
                    }
                }
            }
            if (startPoint == null)
            {
                startPoint = Items[0].Recipes[0].StepRuntimes[0];
            }
            return(startPoint);
        }
コード例 #3
0
 internal void UpdateEstimatedTime(Recipe item, StepRuntime startPoint, ref DateTime time, ref double c, ref bool isActive)
 {
     if (item.StartTime == DateTime.MinValue)
     {
         item.EST = time;
         foreach (var sr in item.StepRuntimes)
         {
             StepRuntimeService.UpdateEstimatedTime(sr, startPoint, ref time, ref c, ref isActive);
         }
         item.EET = time;
     }
     else
     {
         time = item.StartTime;
         if (item.EndTime == DateTime.MinValue)
         {
             foreach (var sr in item.StepRuntimes)
             {
                 StepRuntimeService.UpdateEstimatedTime(sr, startPoint, ref time, ref c, ref isActive);
             }
             item.EET = time;
         }
         else
         {
             time = item.EndTime;
         }
     }
 }
コード例 #4
0
        internal TimeSpan GetDuration(StepRuntime sr, ref double CBegin)       //计算Duration,并且为下一个sr更新CBegin
        {
            double   Cend = 0;
            TimeSpan duration;
            var      st = sr.StepTemplate;

            if (st.CutOffConditionType == CutOffConditionTypeEnum.Time_s)
            {
                duration = TimeSpan.FromSeconds(st.CutOffConditionValue);
                Cend     = CBegin + sr.GetCurrentInmA() * duration.TotalHours;
            }
            else
            {
                if (st.CutOffConditionType == CutOffConditionTypeEnum.CRate)
                {
                    Cend = st.CutOffConditionValue * sr.DesignCapacityInmAH;
                }
                else if (st.CutOffConditionType == CutOffConditionTypeEnum.C_mAH)
                {
                    Cend = st.CutOffConditionValue;
                }

                duration = TimeSpan.FromHours(GetTimeInSecondsWithParameters(Cend, CBegin, sr.GetCurrentInmA(), sr.StepTemplate.Coefficient.Slope, sr.StepTemplate.Coefficient.Offset));
            }
            CBegin = Cend;
            return(duration);
        }
コード例 #5
0
 internal void UpdateEstimatedTime(StepRuntime item, StepRuntime startPoint, ref DateTime time, ref double c, ref bool isActive)
 {
     if (isActive)
     {
         UpdateEstimatedTime(item, ref time, ref c);
     }
     else
     {
         if (item == startPoint)
         {
             isActive = true;
             UpdateEstimatedTime(item, ref time, ref c);
         }
     }
 }
コード例 #6
0
        //public StepServiceClass StepService { get; set; } = new StepServiceClass();
        //public StepTemplateServiceClass StepTemplateService { get; set; } = new StepTemplateServiceClass();
        //public void Add(StepRuntimeClass item)
        //{
        //using (var uow = new UnitOfWork(new AppDbContext()))
        //{
        //    item.BatteryType = uow.BatteryTypes.GetById(item.BatteryType.Id);
        //    uow.Batteries.Insert(item);
        //    uow.Commit();
        //}
        //Items.Add(item);
        //}
        //public void Remove(int id)
        //{
        //using (var uow = new UnitOfWork(new AppDbContext()))
        //{
        //    uow.Batteries.Delete(id);
        //    uow.Commit();
        //}

        //var item = Items.SingleOrDefault(o => o.Id == id);
        //Items.Remove(item);
        //}
        public void Update(StepRuntime item)
        {
            using (var uow = new UnitOfWork(new AppDbContext()))
            {
                uow.StepRuntimes.Update(item);
                uow.Commit();
            }
            //var edittarget = Items.SingleOrDefault(o => o.Id == item.Id);
            //edittarget.EndTime = item.EndTime;
            //edittarget.IsAbandoned = item.IsAbandoned;
            //edittarget.Loop = item.Loop;
            //edittarget.StartTime = item.StartTime;
            //edittarget.TestRecords = item.TestRecords;
            //edittarget.Name = item.Name;
        }
コード例 #7
0
        internal void StepEnd(Program program, Recipe recipe, StepRuntime stepRuntime, DateTime endTime)
        {
            stepRuntime.EndTime = endTime;

            if (stepRuntime == recipe.StepRuntimes.Last())
            {
                recipe.EndTime = endTime;

                if (recipe == program.Recipes.Last())
                {
                    program.EndTime = endTime;
                }
            }

            UpdateEstimatedTimeChain();
        }
コード例 #8
0
        internal void StepStart(Program program, Recipe recipe, StepRuntime stepRuntime, DateTime startTime)
        {
            if (program.StartTime == DateTime.MinValue)
            {
                program.StartTime = startTime;
            }

            if (recipe.StartTime == DateTime.MinValue)
            {
                recipe.StartTime = startTime;
            }

            stepRuntime.StartTime = startTime;

            UpdateEstimatedTimeChain();
        }
コード例 #9
0
 public void UpdateEstimatedTimeChain(StepRuntime startPoint, DateTime startTime)
 {
     ////var time = startTime;
     //var time = Items[0].RequestTime;
     //double c = 0;
     //bool isActive = false;
     //foreach (var item in Items)
     //{
     //    UpdateEstimatedTime(item, startPoint, ref time, ref c, ref isActive);
     //    if (isActive)
     //    {
     //        SuperUpdate(item);                               //???这里的Update并不能将item中所有的修改都commit到db,所以只好用下面的foreach来补救
     //        foreach (var recipe in item.Recipes)
     //        {
     //            RecipeService.SuperUpdate(recipe);
     //            foreach (var sr in recipe.StepRuntimes)
     //                RecipeService.StepRuntimeService.Update(sr);
     //        }
     //    }
     //}
 }
コード例 #10
0
 internal void UpdateEstimatedTime(StepRuntime item, ref DateTime time, ref double c)
 {
     if (item.StartTime == DateTime.MinValue)
     {
         item.EST = time;
         time    += GetDuration(item, ref c);
         item.EET = time;
     }
     else
     {
         time = item.StartTime;
         if (item.EndTime == DateTime.MinValue)
         {
             time    += GetDuration(item, ref c);
             item.EET = time;
         }
         else
         {
             GetDuration(item, ref c);
             time = item.EndTime;
         }
     }
 }