public void GetPlanCollection(DateTime startDate, DateTime endDate, List <Controller_Event_Log> cycleEvents, SPM db) { var ds = new ControllerEventLogs(Approach.SignalID, startDate, endDate, new List <int> { 131 }, db); var row = new 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 (var 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) { var plan = new RLMPlan(ds.Events[i].Timestamp, endDate, ds.Events[i].EventParam, cycleEvents, SRLVSeconds, Approach); 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) { var plan = new RLMPlan(ds.Events[i].Timestamp, ds.Events[i + 1].Timestamp, ds.Events[i].EventParam, cycleEvents, SRLVSeconds, Approach); AddItem(plan); } } } }
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; } } }