Пример #1
0
 public void Remove(MOE.Common.Models.Approach approach)
 {
     MOE.Common.Models.Approach g = (from r in db.Approaches
                                     where r.ApproachID == approach.ApproachID
                                     select r).FirstOrDefault();
     if (g != null)
     {
         try
         {
             db.Approaches.Remove(g);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             {
                 MOE.Common.Models.Repositories.IApplicationEventRepository repository =
                     MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
                 MOE.Common.Models.ApplicationEvent error = new ApplicationEvent();
                 error.ApplicationName = "MOE.Common";
                 error.Class           = "Models.Repository.ApproachRepository";
                 error.Function        = "Remove";
                 error.Description     = ex.Message;
                 error.SeverityLevel   = ApplicationEvent.SeverityLevels.High;
                 error.Timestamp       = DateTime.Now;
                 repository.Add(error);
                 throw (ex);
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// Constructor for Signal phase
        /// </summary>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="signalId"></param>
        /// <param name="eventData1"></param>
        /// <param name="region"></param>
        /// <param name="detChannel"></param>
        public RLMSignalPhase(DateTime startDate, DateTime endDate, int binSize, double srlvSeconds,
                              int metricTypeID, MOE.Common.Models.Approach approach, bool usePermissivePhase)
        {
            this.srlvSeconds = srlvSeconds;
            this.startDate   = startDate;
            this.endDate     = endDate;
            this.Approach    = approach;

            this.binSize = binSize;

            IsPermissive = usePermissivePhase;

            Models.Repositories.IControllerEventLogRepository controllerRepository =
                Models.Repositories.ControllerEventLogRepositoryFactory.Create();


            if (!Approach.IsProtectedPhaseOverlap)
            {
                GetSignalPhaseData(startDate, endDate, showVolume, binSize, usePermissivePhase);
            }
            else
            {
                totalVolume = controllerRepository.GetTMCVolume(startDate, endDate, Approach.SignalID, Approach.ProtectedPhaseNumber);
                GetSignalOverlapData(startDate, endDate, showVolume, binSize);
            }
        }
Пример #3
0
        public string GetLaneGroupDirection()
        {
            MOE.Common.Models.Repositories.IApproachRepository Approaches = MOE.Common.Models.Repositories.ApproachRepositoryFactory.Create();
            MOE.Common.Models.Approach approach = Approaches.GetApproachByApproachID(LaneGroup.ApproachID);

            return(approach.DirectionType.Description);
        }
Пример #4
0
 /// <summary>
 /// Constructor Used For Data Aggregation
 /// </summary>
 /// <param name="detid"></param>
 /// <param name="signalid"></param>
 /// <param name="channelid"></param>
 /// <param name="laneid"></param>
 /// <param name="approachdirection"></param>
 public Detector(string detid, string signalid, int channelid, MOE.Common.Models.Approach approach, string phasenumber)
 {
     detID    = detid;
     channel  = channelid;
     Approach = approach;
     phase    = phasenumber;
 }
Пример #5
0
 public RLMPlan(DateTime start, DateTime end, int plan, double srlvSeconds, MOE.Common.Models.Approach approach)
 {
     this.srlvSeconds = srlvSeconds;
     startTime        = start;
     endTime          = end;
     planNumber       = plan;
     Approach         = approach;
 }
Пример #6
0
        public void AddOrUpdate(MOE.Common.Models.Approach approach)
        {
            MOE.Common.Models.Approach g = (from r in db.Approaches
                                            where r.ApproachID == approach.ApproachID
                                            select r).FirstOrDefault();
            if (g != null)
            {
                try
                {
                    db.Entry(g).CurrentValues.SetValues(approach);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MOE.Common.Models.Repositories.IApplicationEventRepository repository =
                        MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
                    MOE.Common.Models.ApplicationEvent error = new ApplicationEvent();
                    error.ApplicationName = "MOE.Common";
                    error.Class           = "Models.Repository.ApproachRepository";
                    error.Function        = "Update";
                    error.Description     = ex.Message;
                    error.SeverityLevel   = ApplicationEvent.SeverityLevels.High;
                    error.Timestamp       = DateTime.Now;
                    repository.Add(error);
                    throw;
                }
            }
            else
            {
                try
                {
                    foreach (Detector d in approach.Detectors)
                    {
                        if (d.DetectionTypes == null && d.DetectionTypeIDs != null)
                        {
                            d.DetectionTypes = db.DetectionTypes.Where(dt => d.DetectionTypeIDs.Contains(dt.DetectionTypeID)).ToList();
                        }
                    }
                    db.Approaches.Add(approach);
                    db.SaveChanges();
                }

                catch (Exception ex)
                {
                    MOE.Common.Models.Repositories.IApplicationEventRepository repository =
                        MOE.Common.Models.Repositories.ApplicationEventRepositoryFactory.Create();
                    MOE.Common.Models.ApplicationEvent error = new ApplicationEvent();
                    error.ApplicationName = "MOE.Common";
                    error.Class           = "Models.Repository.ApproachRepository";
                    error.Function        = "Add";
                    error.Description     = ex.Message;
                    error.SeverityLevel   = ApplicationEvent.SeverityLevels.High;
                    error.Timestamp       = DateTime.Now;
                    repository.Add(error);
                    throw;
                }
            }
        }
Пример #7
0
        public Approach(MOE.Common.Models.Approach approach)
        {
            SignalID      = approach.SignalID;
            Direction     = approach.DirectionType.Description;
            ApproachModel = approach;
            detectors     = new DetectorCollection(approach);

            detectorevents = null;
        }
Пример #8
0
        /// <summary>
        /// Default constructor for the DetectorCollection used in the Turning Movement Counts charts
        /// </summary>
        /// <param name="signalID"></param>
        /// <param name="startdate"></param>
        /// <param name="enddate"></param>
        /// <param name="binsize"></param>
        public RLMDetectorCollection(DateTime startdate, DateTime enddate, int binsize,
                                     MOE.Common.Models.Approach approach)
        {
            var dets = approach.GetDetectorsForMetricType(11);

            foreach (MOE.Common.Models.Detector detector in dets)
            {
                MOE.Common.Business.Detector Detector = new Detector(detector, startdate, enddate, binsize);
                DetectorsForRLM.Add(Detector);
            }
            //SortDetectors();
        }
Пример #9
0
        public RLMPlan(DateTime start, DateTime end, int planNumber,
                       List <MOE.Common.Models.Controller_Event_Log> cycleEvents,
                       double srlvSeconds, Models.Approach approach)
        {
            Approach        = approach;
            startTime       = start;
            endTime         = end;
            this.planNumber = planNumber;
            bool usePermissivePhase = false;

            MOE.Common.Models.SPM db = new MOE.Common.Models.SPM();
            List <int>            l  = new List <int> {
                1, 8, 9, 10, 11
            };
            List <MOE.Common.Models.Controller_Event_Log> permEvents = null;

            if (Approach.PermissivePhaseNumber != null)
            {
                usePermissivePhase = true;
                MOE.Common.Models.Repositories.IControllerEventLogRepository cveRepository =
                    MOE.Common.Models.Repositories.ControllerEventLogRepositoryFactory.Create();
                permEvents = cveRepository.GetEventsByEventCodesParam(Approach.SignalID,
                                                                      start, end, l, Approach.ProtectedPhaseNumber);
                foreach (Models.Controller_Event_Log row in cycleEvents)
                {
                    if (row.Timestamp >= start && row.Timestamp <= end && GetEventType(row.EventCode) == RLMCycle.EventType.BeginYellowClearance)
                    {
                        foreach (MOE.Common.Models.Controller_Event_Log permRow in permEvents)
                        {
                            if (GetEventType(permRow.EventCode) == RLMCycle.EventType.BeginYellowClearance)
                            {
                                if (row.Timestamp == permRow.Timestamp)
                                {
                                    usePermissivePhase = false;
                                }
                            }
                        }
                    }
                }
            }
            this.srlvSeconds = srlvSeconds;
            startTime        = start;
            endTime          = end;
            if (usePermissivePhase)
            {
                GetRedCycle(start, end, permEvents);
            }
            else
            {
                GetRedCycle(start, end, cycleEvents);
            }
        }
Пример #10
0
        /// <summary>
        /// Alternate Constructor for PCD type data.
        /// </summary>
        /// <param name="signalid"></param>
        /// <param name="approach"></param>
        public DetectorCollection(MOE.Common.Models.Approach approach)
        {
            _signalId = approach.SignalID;
            MOE.Common.Models.Repositories.ISignalsRepository repository =
                MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create();


            var PCDDetectors = approach.GetDetectorsForMetricType(6);

            foreach (MOE.Common.Models.Detector row in PCDDetectors)
            {
                MOE.Common.Business.Detector Detector = new Detector(row);
                Items.Add(Detector);
            }
        }
Пример #11
0
 public Approach Add(MOE.Common.Models.Approach approach)
 {
     MOE.Common.Models.Approach g = (from r in db.Approaches
                                     where r.ApproachID == approach.ApproachID
                                     select r).FirstOrDefault();
     if (g == null)
     {
         approach = db.Approaches.Add(approach);
         db.SaveChanges();
     }
     else
     {
         this.AddOrUpdate(approach);
         db.SaveChanges();
     }
     return(approach);
 }
Пример #12
0
        /// <summary>
        /// Generates PCD charts for upstream and downstream detectors based on
        /// a Link Pivot Link
        /// </summary>
        /// <param name="upstreamSignalID"></param>
        /// <param name="upstreamDirection"></param>
        /// <param name="downstreamSignalID"></param>
        /// <param name="downstreamDirection"></param>
        /// <param name="delta"></param>
        /// <param name="startDate"></param>
        /// <param name="endDate"></param>
        /// <param name="maxYAxis"></param>
        public LinkPivotPCDDisplay(string upstreamSignalID, string upstreamDirection,
                                   string downstreamSignalID, string downstreamDirection, int delta,
                                   DateTime startDate, DateTime endDate, int maxYAxis)
        {
            MOE.Common.Models.Repositories.ISignalsRepository signalRepository =
                MOE.Common.Models.Repositories.SignalsRepositoryFactory.Create();
            MOE.Common.Models.Signal   upstreamSignal        = signalRepository.GetSignalBySignalID(upstreamSignalID);
            MOE.Common.Models.Signal   downstreamSignal      = signalRepository.GetSignalBySignalID(downstreamSignalID);
            MOE.Common.Models.Approach upApproachToAnalyze   = GetApproachToAnalyze(upstreamSignal, upstreamDirection);
            MOE.Common.Models.Approach downApproachToAnalyze = GetApproachToAnalyze(downstreamSignal, downstreamDirection);

            if (upApproachToAnalyze != null)
            {
                GeneratePCD(upApproachToAnalyze, delta, startDate, endDate, true, maxYAxis);
            }
            if (downApproachToAnalyze != null)
            {
                GeneratePCD(downApproachToAnalyze, delta, startDate, endDate, false, maxYAxis);
            }
        }
Пример #13
0
        public ControllerEventLogs CombineDetectorDataByApproachAndType(DateTime startDate, DateTime endDate, MOE.Common.Models.Approach approach, bool Has_PCD, bool Has_TMC)
        {
            MOE.Common.Models.Repositories.IDetectorRepository gr = MOE.Common.Models.Repositories.DetectorRepositoryFactory.Create();

            string signalId = approach.SignalID;


            if (Has_TMC)
            {
                ApproachCountDetectors.Clear();


                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(5)));
            }

            if (Has_PCD)
            {
                ApproachCountDetectors.Clear();
                ApproachCountDetectors.AddRange(RemoveExitDetectors(approach.GetDetectorsForMetricType(6)));
            }



            List <ControllerEventLogs> eventsList = new List <ControllerEventLogs>();

            ControllerEventLogs MergedEvents = new ControllerEventLogs(signalId, startDate, endDate);

            foreach (Models.Detector detector in ApproachCountDetectors)
            {
                List <int> li = new List <int> {
                    82
                };
                ControllerEventLogs cs = new ControllerEventLogs(signalId, startDate, endDate, detector.DetChannel, li);
                eventsList.Add(cs);
            }

            foreach (ControllerEventLogs Events in eventsList)
            {
                MergedEvents.MergeEvents(Events);
            }


            return(MergedEvents);
        }
Пример #14
0
 public void SetDetectorEvents(MOE.Common.Models.Approach approach, DateTime startdate, DateTime enddate, bool has_pcd, bool has_tmc)
 {
     detectorevents = detectors.CombineDetectorDataByApproachAndType(startdate, enddate, approach, has_pcd, has_tmc);
 }