Beispiel #1
0
 private void AddLastPlan(Models.Controller_Event_Log planEvent)
 {
     if (planEvent.Timestamp != EndDate)
     {
         PCD.Plan plan = new PCD.Plan(planEvent.Timestamp,
                                      EndDate, planEvent.EventParam);
         Plans.Add(plan);
     }
 }
Beispiel #2
0
 private void AddPlan(Models.Controller_Event_Log startPlanEvent,
                      Models.Controller_Event_Log endPlanEvent)
 {
     if (startPlanEvent.Timestamp != endPlanEvent.Timestamp)
     {
         Plan plan = new Plan(startPlanEvent.Timestamp,
                              endPlanEvent.Timestamp,
                              startPlanEvent.EventParam);
         Plans.Add(plan);
     }
 }
Beispiel #3
0
        public void GetPlanCollection(DateTime startDate, DateTime endDate,
                                      List <MOE.Common.Models.Controller_Event_Log> cycleEvents)
        {
            MOE.Common.Business.ControllerEventLogs ds =
                new ControllerEventLogs(Approach.SignalID, startDate, endDate, new List <int>()
            {
                131
            });
            Models.Controller_Event_Log row = new Models.Controller_Event_Log();
            row.Timestamp = startDate;
            row.SignalID  = Approach.SignalID;
            row.EventCode = 131;
            try
            {
                row.EventParam = ControllerEventLogs.GetPreviousPlan(Approach.SignalID, startDate);

                ds.Events.Insert(0, row);
            }
            catch
            {
                row.EventParam = 0;
                ds.Events.Insert(0, row);
            }
            // remove duplicate plan entries
            ds.MergeEvents(ds);
            for (int i = 0; i < ds.Events.Count(); i++)
            {
                //if this is the last plan then we want the end of the plan
                //to cooincide with the end of the graph
                if (ds.Events.Count() - 1 == i)
                {
                    if (ds.Events[i].Timestamp != endDate)
                    {
                        RLMPlan plan = new RLMPlan(ds.Events[i].Timestamp, endDate, ds.Events[i].EventParam,
                                                   cycleEvents, this.SRLVSeconds, Approach);
                        this.AddItem(plan);
                    }
                }
                //else we add the plan with the next plans' time stamp as the end of the plan
                else
                {
                    if (ds.Events[i].Timestamp != ds.Events[i + 1].Timestamp)
                    {
                        RLMPlan plan = new RLMPlan(ds.Events[i].Timestamp,
                                                   ds.Events[i + 1].Timestamp, ds.Events[i].EventParam, cycleEvents, this.SRLVSeconds, Approach);
                        this.AddItem(plan);
                    }
                }
            }
        }
Beispiel #4
0
        public PlansBase(string signalID, DateTime startDate, DateTime endDate) :
            base(signalID, startDate, endDate, new List <int> {
            131
        })
        {
            //Get the plan Previous to the start date
            //if(this.Events.Count > 0)
            //{
            Models.Controller_Event_Log tempEvent = new Models.Controller_Event_Log();
            tempEvent.SignalID   = signalID;
            tempEvent.Timestamp  = startDate;
            tempEvent.EventCode  = 131;
            tempEvent.EventParam = ControllerEventLogs.GetPreviousPlan(signalID, startDate);

            this.Events.Insert(0, tempEvent);
            //}

            //Remove Duplicate Plans
            int x = -1;
            List <Models.Controller_Event_Log> temp = new List <Models.Controller_Event_Log>();

            foreach (Models.Controller_Event_Log cel in Events)
            {
                temp.Add(cel);
            }
            foreach (Models.Controller_Event_Log cel in temp)
            {
                if (x == -1)
                {
                    x = cel.EventParam;
                }
                else if (x != cel.EventParam)
                {
                    x = cel.EventParam;
                    continue;
                }
                else if (x == cel.EventParam)
                {
                    x = cel.EventParam;
                    this.Events.Remove(cel);
                    continue;
                }
            }
        }
Beispiel #5
0
        private PreemptCycle StartCycle(Models.Controller_Event_Log controller_Event_Log)
        {
            PreemptCycle cycle = new PreemptCycle();


            cycle.CycleStart = controller_Event_Log.Timestamp;

            if (controller_Event_Log.EventCode == 105)
            {
                cycle.EntryStarted = controller_Event_Log.Timestamp;
                cycle.HasDelay     = false;
            }

            if (controller_Event_Log.EventCode == 102)
            {
                cycle.StartInputOn = controller_Event_Log.Timestamp;
                cycle.HasDelay     = true;
            }

            return(cycle);
        }
Beispiel #6
0
        private List <Models.Controller_Event_Log> FindUnknownTerminationEvents(List <Models.Controller_Event_Log> terminationEvents)
        {
            List <Models.Controller_Event_Log> unknownTermEvents = new List <Models.Controller_Event_Log>();

            for (int x = 0; x + 1 < terminationEvents.Count; x++)
            {
                Models.Controller_Event_Log currentEvent = terminationEvents[x];
                Models.Controller_Event_Log nextEvent    = terminationEvents[x + 1];

                if (currentEvent.EventCode == 7 && nextEvent.EventCode == 7)
                {
                    //if (x + 2 <= terminationEvents.Count)
                    //{
                    //    TimeSpan t = terminationEvents[x + 2].Timestamp - terminationEvents[x + 1].Timestamp;

                    unknownTermEvents.Add(currentEvent);
                    //}
                }
            }
            return(unknownTermEvents);
        }
Beispiel #7
0
 private void AddStartingPlan()
 {
     if (Plans.Count > 0 && Plans[0].PlanStart != StartDate)
     {
         Models.Repositories.IControllerEventLogRepository controllerEventLogRepository =
             Models.Repositories.ControllerEventLogRepositoryFactory.Create();
         Models.Controller_Event_Log planEvent = controllerEventLogRepository.GetFirstEventBeforeDate(SignalID,
                                                                                                      131, Plans[0].PlanStart);
         if (planEvent != null)
         {
             Plan plan = new Plan(StartDate,
                                  Plans[0].PlanStart,
                                  planEvent.EventParam);
             Plans.Insert(0, plan);
         }
         else
         {
             Plan plan = new Plan(StartDate,
                                  Plans[0].PlanStart,
                                  0);
             Plans.Insert(0, plan);
         }
     }
 }
Beispiel #8
0
 private void EndCycle(PreemptCycle cycle, Models.Controller_Event_Log controller_Event_Log, List <PreemptCycle> CycleCollection)
 {
     cycle.CycleEnd = controller_Event_Log.Timestamp;
     CycleCollection.Add(cycle);
 }