コード例 #1
0
        /*private void bgwRunServiceVolsCalcs_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
         * {
         *  Project = new ProjectData(AnalysisMode.Planning);
         *
         *  string testParameter = this.cboTestParameter.Text;
         *  float[] testParameterBoundaries = ServiceVolumeArterialInputs.GetTestParameterValues(testParameter);
         *  List<ServiceVolumes> serviceVolResults = new List<ServiceVolumes>();
         *
         *  for (float iterateBoundary = testParameterBoundaries[0]; iterateBoundary <= testParameterBoundaries[1]; iterateBoundary += testParameterBoundaries[2])
         *  {
         *      ServiceVolumes SerVols = new ServiceVolumes(iterateBoundary, testParameter);
         *      ServiceVolumeArterialInputs InputsOneLane = new ServiceVolumeArterialInputs(false, testParameter, iterateBoundary);
         *      ServiceVolumeArterialInputs InputsMultiLane = new ServiceVolumeArterialInputs(true, testParameter, iterateBoundary);
         *      this.lblIteration.Text = "Iteration: " + Math.Round(iterateBoundary,2).ToString();
         *      CalcsServiceVolumes.ServiceVolsAuto(Project, SerVols, InputsOneLane, InputsMultiLane);
         *      serviceVolResults.Add(SerVols);
         *  }
         *  //e.Cancel = true;
         *  ServiceVolResultsOutput.WriteServiceVolResultsData("Service Volume Outputs.csv", serviceVolResults);
         *
         *  //ServiceVolumeArterialInputs InputsOneLane = new ServiceVolumeArterialInputs(false, TestParameter, 0);
         *  //ServiceVolumeArterialInputs InputsMultiLane = new ServiceVolumeArterialInputs(true, TestParameter, 0);
         *  //CalcsServiceVolumes.ServiceVolsAuto(Project, SerVols, InputsOneLane, InputsMultiLane);
         * }*/

        private void bgwRunServiceVolsCalcs_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            if (SerVolTables.Count == 0)
            {
                MessageBox.Show("Please read in a Service Volumes Input File first.");
            }
            else
            {
                Project = new ProjectData(AnalysisMode.Planning);

                string  testParameter                   = this.cboTestParameter.Text;
                float[] testParameterBoundaries         = ServiceVolumeArterialInputs.GetTestParameterValues(testParameter);
                int     numberOfTestParmsPerTable       = (int)(((testParameterBoundaries[1] - testParameterBoundaries[0]) / testParameterBoundaries[2]) + 1);
                List <ServiceVolumes> serviceVolResults = new List <ServiceVolumes>();

                foreach (SerVolTablesByClass SerVolTablesForClasses in SerVolTables)
                {
                    foreach (SerVolTablesByMultiLane SerVolTablesForNumLanes in SerVolTablesForClasses.SerVolTablesMultiLane)
                    {
                        for (float iterateBoundary = testParameterBoundaries[0]; iterateBoundary <= testParameterBoundaries[1]; iterateBoundary += testParameterBoundaries[2])
                        {
                            ServiceVolumes SerVols = new ServiceVolumes(iterateBoundary, testParameter, SerVolTablesForClasses.ArtAreaType, SerVolTablesForNumLanes.ArtClass);

                            SerVolTablesForNumLanes.SerVolTables[0] = ServiceVolumeTableFDOT.ChangeTestParameterValue(SerVolTablesForNumLanes.SerVolTables[0], testParameter, iterateBoundary);
                            SerVolTablesForNumLanes.SerVolTables[1] = ServiceVolumeTableFDOT.ChangeTestParameterValue(SerVolTablesForNumLanes.SerVolTables[1], testParameter, iterateBoundary);
                            this.lblIteration.Text = "Iteration: " + Math.Round(iterateBoundary, 2).ToString();
                            CalcsServiceVolumes.ServiceVolsAutoNew(Project, SerVols, SerVolTablesForNumLanes.SerVolTables[0], SerVolTablesForNumLanes.SerVolTables[1]);
                            serviceVolResults.Add(SerVols);
                        }
                    }
                }

                ServiceVolResultsOutput.WriteServiceVolResultsDataNew("Service Volume Outputs.csv", serviceVolResults, numberOfTestParmsPerTable);
                MessageBox.Show("Calculations Finished! Please check out the \"Service Volume Outputs.csv\" file.");
            }
        }
コード例 #2
0
        public void WriteXmlFile(string filename, bool previewMode, ProjectData Project, ArterialData Art, List <IntersectionData> Int, List <LinkData> Seg, ServiceVolumes SerVol, bool overVCMessage, bool writeResults)
        {
            XmlTextWriter xtw = new XmlTextWriter(filename, System.Text.Encoding.UTF8);

            //indent tags by 2 characters
            xtw.Formatting  = Formatting.Indented;
            xtw.Indentation = 2;
            //enclose attributes' values in float quotes
            xtw.QuoteChar = '"';
            xtw.WriteStartDocument(true);
            if (previewMode == true)
            {
                string XSLfileName     = XSLfileName = Application.StartupPath + "\\APauto1.xsl";
                string InstructionText = "type=\"text/xsl\" href=\"" + XSLfileName + "\"";
                xtw.WriteProcessingInstruction("xml-stylesheet", InstructionText);
            }
            //write <TMML> information
            xtw.WriteStartElement("TMML");
            xtw.WriteAttributeString("Facility", "Arterial");
            //write <PROJECT> information
            xtw.WriteStartElement("PROJECT");
            xtw.WriteElementString("FileName", Project.FileName);  //("FileName", filename)
            xtw.WriteElementString("Analyst", Project.AnalystName);
            xtw.WriteElementString("Date", Project.AnalysisDate.ToString());
            xtw.WriteElementString("Agency", Project.Agency);
            xtw.WriteElementString("Comment", Project.UserNotes);

            if (Project.Mode == ModeType.AutoOnly)
            {
                xtw.WriteElementString("ModalAnalysis", "Auto Only");
            }
            else if (Project.Mode == ModeType.SignalOnly)
            {
                xtw.WriteElementString("ModalAnalysis", "Isolated Signal");
            }

            if (Project.DirectionAnalysisMode == DirectionType.PeakDirection)
            {
                xtw.WriteElementString("AnalysisType", "Peak Direction");
            }
            else if (Project.DirectionAnalysisMode == DirectionType.BothDirections)
            {
                xtw.WriteElementString("AnalysisType", "Peak and Off-Peak Directions");
            }

            if (Project.Period == StudyPeriod.StandardK)
            {
                xtw.WriteElementString("PeriodID", "Standard K");
            }
            else if (Project.Period == StudyPeriod.Kother)
            {
                xtw.WriteElementString("PeriodID", "Kother");
            }
            else if (Project.Period == StudyPeriod.PeakHour)
            {
                xtw.WriteElementString("PeriodID", "Dir Hr Demand Vol");
            }

            xtw.WriteElementString("Program", "ARTPLAN 2012");
            xtw.WriteElementString("Version", FDOTplanning_ParmRanges.VersionDate);

            xtw.WriteEndElement();  //close the <PROJECT> tag

            //write <AnalysisParamters> information
            //** maybe not include since this information is never used (maybe by HCS)

            //write <ARTERIAL> information
            xtw.WriteStartElement("ARTERIAL");
            xtw.WriteAttributeString("id", "1");
            //write <ARTERIALINFO> information
            xtw.WriteStartElement("ARTERIALINFO");
            xtw.WriteElementString("ArterialName", Art.ArtName);
            xtw.WriteElementString("From", Art.From);
            xtw.WriteElementString("To", Art.To);

            if (Art.AnalysisTravelDir == TravelDirection.Northbound)
            {
                xtw.WriteElementString("FwdDirection", "Northbound");
            }
            else if (Art.AnalysisTravelDir == TravelDirection.Southbound)
            {
                xtw.WriteElementString("FwdDirection", "Southbound");
            }
            else if (Art.AnalysisTravelDir == TravelDirection.Westbound)
            {
                xtw.WriteElementString("FwdDirection", "Westbound");
            }
            else if (Art.AnalysisTravelDir == TravelDirection.Eastbound)
            {
                xtw.WriteElementString("FwdDirection", "Eastbound");
            }

            if (Art.Area == AreaType.LargeUrbanized)
            {
                xtw.WriteElementString("AreaType", "Large Urbanized");
            }
            else if (Art.Area == AreaType.OtherUrbanized)
            {
                xtw.WriteElementString("AreaType", "Other Urbanized");
            }
            else if (Art.Area == AreaType.Transitioning)
            {
                xtw.WriteElementString("AreaType", "Transitioning/Urban");
            }
            else if (Art.Area == AreaType.RuralDeveloped)
            {
                xtw.WriteElementString("AreaType", "Rural Developed");
            }

            xtw.WriteElementString("ArterialClass_HCM", Art.Classification.ToString());
            xtw.WriteElementString("KFactor_PLN", Art.Kfactor.ToString());
            xtw.WriteElementString("DFactor_PLN", Art.Dfactor.ToString());
            //xtw.WriteElementString("PHF", Art.PHF.ToString());
            //xtw.WriteElementString("BaseSatFlowPerLane", Art.Segments[0].Intersection.Approaches[0].LaneGroups[0].BaseSaturationFlowRate.ToString());
            xtw.WriteElementString("NumberOfIntersections", Convert.ToString(Art.TotalInts - 1));
            if (Project.Mode != ModeType.SignalOnly)
            {
                xtw.WriteElementString("ArtLength", Art.LengthMiles.ToString("0.0000"));
            }
            else
            {
                xtw.WriteElementString("ArtLength", "N/A");
            }
            xtw.WriteElementString("MaxSerVol", Art.MaxSerVol.ToString());
            xtw.WriteEndElement();  //close the <ARTERIALINFO> tag

            //write <APPROACH> information
            xtw.WriteStartElement("ARTERIALDIR");
            xtw.WriteAttributeString("id", "forward");
            //xtw.WriteElementString("NumberOfLanes", Art.);
            //xtw.WriteElementString("HVPct", Art.PctHeavyVeh.ToString());

            //only write results to file if results are currently displayed
            if (writeResults == true)
            {
                //write <MOEGROUP> information
                xtw.WriteStartElement("MOEGROUP");
                if (Project.Mode != ModeType.SignalOnly)
                {
                    xtw.WriteElementString("TotalTravelTime", Art.Results.TravelTime.ToString("0.00"));
                    //if (Art.WtdgC <= 0.50)
                    //    xtw.WriteElementString("WtdgC", Art.WtdgC.ToString("0.00"));
                    //else
                    //    xtw.WriteElementString("WtdgC", "##");
                    //xtw.WriteElementString("FFSDelay", Art.Results.FFSdelay.ToString("0.00"));
                    //xtw.WriteElementString("ThresholdDelay", Art.Results.ThreshDelay.ToString("0.00"));
                    if (overVCMessage == false)
                    {
                        xtw.WriteElementString("AvgTravelSpeed", Art.Results.AverageSpeed.ToString("0.00"));
                        //xtw.WriteElementString("BaseFreeFlowSpeed", Art.Results.BaseFreeFlowSpeed.ToString("0.00"));
                        xtw.WriteElementString("ArtLOS", Art.Results.LOS.ToString());
                    }
                    else
                    {
                        xtw.WriteElementString("AvgTravelSpeed", "###");
                        xtw.WriteElementString("BaseFreeFlowSpeed", "###");
                        xtw.WriteElementString("ArtLOS", "###");
                    }
                }
                else  //signal only
                {
                    xtw.WriteElementString("TotalTravelTime", "N/A");
                    xtw.WriteElementString("WtdgC", "N/A");
                    xtw.WriteElementString("AvgTravelSpeed", "N/A");
                    xtw.WriteElementString("FFSDelay", "N/A");
                    xtw.WriteElementString("ThresholdDelay", "N/A");
                    xtw.WriteElementString("ArtLOS", "N/A");
                }
                xtw.WriteEndElement();  //close the <MOEGROUP> tag
            }

            xtw.WriteEndElement();  //close the <APPROACH> tag

            if (Project.DirectionAnalysisMode == DirectionType.BothDirections)
            {
                //write <APPROACH> information
                xtw.WriteStartElement("APPROACH");
                xtw.WriteAttributeString("id", "reverse");
                //xtw.WriteElementString("NumberOfLanes", Art.);
                //xtw.WriteElementString("HVPct", Art[1].PctHeavyVeh.ToString());

                //write <MOEGROUP> information
                //xtw.WriteStartElement("MOEGROUP");

                xtw.WriteEndElement();  //close the <Approach> tag
            }

            //write <INTERSECTIONS> information
            xtw.WriteStartElement("INTERSECTIONS");
            for (int id = 1; id <= Art.TotalInts; id++)
            {
                //write a new <INTERSECTION id="nnn"> element
                xtw.WriteStartElement("INTERSECTION");
                xtw.WriteAttributeString("id", id.ToString());

                //write <INTERSECTIONINFO> information
                xtw.WriteStartElement("INTERSECTIONINFO");
                xtw.WriteElementString("CrossStreetName", Int[id].CrossStreetName);
                xtw.WriteEndElement();  //close the <INTERSECTIONINFO> tag

                //write <CONTROLLER> information
                xtw.WriteStartElement("CONTROLLER");
                //if (Art.SigControl == SigControlType.Pretimed)
                //    xtw.WriteElementString("ControlMode", "Pretimed");
                //else if (Art.SigControl == SigControlType.CoordinatedActuated)
                //    xtw.WriteElementString("ControlMode", "CoordinatedActuated");
                //else if (Art.SigControl == SigControlType.FullyActuated)
                //    xtw.WriteElementString("ControlMode", "FullyActuated");
                //xtw.WriteElementString("CycleLength", Int[id].CycleLen.ToString());
                //if (Int[id].LTphasing == PhasingType.Protect)
                //    xtw.WriteElementString("LeftTurnPhasing", "Protected");
                //else if (Int[id].LTphasing == PhasingType.ProtPerm)
                //    xtw.WriteElementString("LeftTurnPhasing", "ProtPerm");
                //else
                //    xtw.WriteElementString("LeftTurnPhasing", "None");
                xtw.WriteEndElement();                                                       //close the <CONTROLLER> tag

                if (id == 1 && Project.DirectionAnalysisMode == DirectionType.PeakDirection) // && Project.Mode != ModeType.SignalOnly)  //if peak direction analysis and not signal-only analysis, do not write remaining items for 1st intersection
                {
                    xtw.WriteEndElement();                                                   //close the <INTERSECTION> tag
                    continue;
                }

                //write <APPROACH> information
                xtw.WriteStartElement("APPROACH");
                xtw.WriteAttributeString("id", "forward");

                //write <LANEGROUP> information
                xtw.WriteStartElement("LANEGROUP");     //do not include id info, as all lane group info is currently grouped together

                xtw.WriteElementString("Section", Convert.ToString(id - 1));
                //Intersection Data
                //unit extension
                //xtw.WriteElementString("GCRatio", Int[id].gCthru.ToString());
                //if (Int[id].isLTbay == true)
                //{
                //    xtw.WriteElementString("LeftTurnBayYN", "Yes");
                //    xtw.WriteElementString("NumberLTlanes", Int[id].NumLTlanes.ToString());
                //    xtw.WriteElementString("LTBayLength", Int[id].LTbayLen.ToString());
                //    xtw.WriteElementString("GCRatioLT", Int[id].gClt.ToString("0.00"));
                //}
                //else  //false
                //{
                //    xtw.WriteElementString("LeftTurnBayYN", "No");
                //    xtw.WriteElementString("NumberLTlanes", "N/A");
                //    xtw.WriteElementString("LTBayLength", "N/A");
                //    xtw.WriteElementString("GCRatioLT", "N/A");
                //}

                //if (Int[id].isRTbay == true)
                //    xtw.WriteElementString("RightTurnBayYN", "Yes");
                //else  //false
                //    xtw.WriteElementString("RightTurnBayYN", "No");
                //xtw.WriteElementString("PctTurn_Left", Int[id].PctLT.ToString());
                //xtw.WriteElementString("PctTurn_Right", Int[id].PctRT.ToString());
                //xtw.WriteElementString("ArrivalType", Int[id].ArvType.ToString());
                //xtw.WriteElementString("NumberOfLanes_INT", Int[id].NumThLanes.ToString());
                //Segment Data
                //float SegLengthMiles = Convert.ToDouble(Seg[id - 1].Length) / 5280;
                if (Project.Mode != ModeType.SignalOnly)
                {
                    xtw.WriteElementString("LinkLength", Seg[id - 1].LengthFt.ToString());
                    xtw.WriteElementString("NumberOfLanes_SEG", Seg[id - 1].NumLanes.ToString());
                    xtw.WriteElementString("PostedSpeed", Seg[id - 1].PostSpeedMPH.ToString());
                    xtw.WriteElementString("FreeFlowSpeed", Seg[id - 1].Results.FreeFlowSpeedMPH.ToString());
                    if (Seg[id - 1].MedType == MedianType.None)
                    {
                        xtw.WriteElementString("MedianType", "None");
                    }
                    else if (Seg[id - 1].MedType == MedianType.Nonrestrictive)
                    {
                        xtw.WriteElementString("MedianType", "Non-Restrictive");
                    }
                    else if (Seg[id - 1].MedType == MedianType.Restrictive)
                    {
                        xtw.WriteElementString("MedianType", "Restrictive");
                    }

                    if (Seg[id - 1].OnStreetParkingExists == false)
                    {
                        xtw.WriteElementString("OnStreetParkingYN", "No");
                    }
                    else  //true
                    {
                        xtw.WriteElementString("OnStreetParkingYN", "Yes");
                    }

                    if (Seg[id - 1].ParkingActivity == ParkingActivityLevel.Low)
                    {
                        xtw.WriteElementString("ParkingActivity", "Low");
                    }
                    else if (Seg[id - 1].ParkingActivity == ParkingActivityLevel.Medium)
                    {
                        xtw.WriteElementString("ParkingActivity", "Medium");
                    }
                    else if (Seg[id - 1].ParkingActivity == ParkingActivityLevel.High)
                    {
                        xtw.WriteElementString("ParkingActivity", "High");
                    }
                    else if (Seg[id - 1].ParkingActivity == ParkingActivityLevel.NotApplicable)
                    {
                        xtw.WriteElementString("ParkingActivity", "N/A");
                    }
                }
                else
                {
                    xtw.WriteElementString("LinkLength", "N/A");
                    xtw.WriteElementString("NumberOfLanes_SEG", "N/A");
                    xtw.WriteElementString("FreeFlowSpeed", "N/A");
                    xtw.WriteElementString("MedianType", "N/A");
                }

                xtw.WriteElementString("AADT", Seg[id - 1].AADT.ToString());
                xtw.WriteElementString("DDHV", Seg[id - 1].DDHV.ToString("0"));
                //Calculated Values
                //xtw.WriteElementString("ThruMvmtFlowRate", Int[id].ThruVol.ToString("0"));
                //xtw.WriteElementString("AdjSatFlowRate", (Int[id].AdjSatFlow * Int[id].NumThLanes).ToString("0"));
                //xtw.WriteElementString("Cap", Int[id].Capacity.ToString("0"));

                if (Seg[id - 1].OutsideLaneWidth == OutLaneWidth.Narrow)
                {
                    xtw.WriteElementString("OutsideLnWidth", "Narrow");
                }
                else if (Seg[id - 1].OutsideLaneWidth == OutLaneWidth.Typical)
                {
                    xtw.WriteElementString("OutsideLnWidth", "Typical");
                }
                else if (Seg[id - 1].OutsideLaneWidth == OutLaneWidth.Wide)
                {
                    xtw.WriteElementString("OutsideLnWidth", "Wide");
                }
                //else if (Seg[id - 1].OutsideLaneWidth == OutLaneWidth.Custom)
                //    xtw.WriteElementString("OutsideLnWidth", Seg[id - 1].NumOutsideLaneWidth.ToString());

                //if (Seg[id - 1].PaveCond == PavementCondition.Desirable)
                //    xtw.WriteElementString("PavementCondition", "Desirable");
                //else if (Seg[id - 1].PaveCond == PavementCondition.Typical)
                //    xtw.WriteElementString("PavementCondition", "Typical");
                //else if (Seg[id - 1].PaveCond == PavementCondition.Undesirable)
                //    xtw.WriteElementString("PavementCondition", "Undesirable");

                //if (Seg[id - 1].BikeLaneExists == false)
                //    xtw.WriteElementString("BikeLnYN", "No");
                //else  //true
                //    xtw.WriteElementString("BikeLnYN", "Yes");

                //if (Seg[id - 1].SidewalkExists == false)
                //    xtw.WriteElementString("SidewalkYN", "No");
                //else  //true
                //    xtw.WriteElementString("SidewalkYN", "Yes");


                //only write results to file if results are currently displayed
                if (writeResults == true)
                {
                    //write <MOEGROUP> information
                    //xtw.WriteStartElement("MOEGROUP");
                    if (Project.Mode != ModeType.SignalOnly)
                    {
                        xtw.WriteElementString("VCRatio", Int[id].Results.vcRatio.ToString("0.000"));
                        xtw.WriteElementString("ControlDelay", Int[id].Results.ControlDelay.ToString("0.00"));
                        xtw.WriteElementString("IntLOS", Int[id].Results.LOS);
                        //if (Int[id].Approaches[0].LaneGroups[0].AnalysisResults.QueStorageRatio <= 1.0)
                        //    xtw.WriteElementString("QueueStorageRatio", Int[id].Results.QueStorageRatio.ToString("0.00"));
                        //else
                        //    xtw.WriteElementString("QueueStorageRatio", "#");
                        xtw.WriteElementString("BaseFreeFlowSpeed", Seg[id - 1].Results.BaseFreeFlowSpeed.ToString("0.00"));
                        //xtw.WriteElementString("SectAverageTravelSpeed", Seg[id - 1].Results.AverageSpeed.ToString("0.00"));
                        xtw.WriteElementString("SectLOS", Seg[id - 1].Results.LOS);
                    }
                    else  //signal-only analysis
                    {
                        xtw.WriteElementString("VCRatio", Int[2].Results.vcRatio.ToString("0.000"));
                        xtw.WriteElementString("ControlDelay", Int[2].Results.ControlDelay.ToString("0.00"));
                        xtw.WriteElementString("IntLOS", Int[2].Results.LOS);
                        //if (Int[2].Results.QueStorageRatio <= 1.0)
                        //    xtw.WriteElementString("QueueStorageRatio", Int[2].Results.QueStorageRatio.ToString("0.00"));
                        //else
                        //    xtw.WriteElementString("QueueStorageRatio", "#");
                        xtw.WriteElementString("BaseFreeFlowSpeed", "N/A");
                        xtw.WriteElementString("SectAverageTravelSpeed", "N/A");
                        xtw.WriteElementString("SectLOS", "N/A");
                    }
                    //xtw.WriteEndElement();  //close the <MOEGROUP> tag
                }

                xtw.WriteEndElement(); //close the <LANEGROUP> tag

                xtw.WriteEndElement(); //close the <APPROACH> tag
                xtw.WriteEndElement(); //close the <INTERSECTION> tag
            }
            xtw.WriteEndElement();     //close the <INTERSECTIONS> tag

            //only write service volume tables to file if results are currently displayed
            bool WriteServiceVols = false; //temp

            if (WriteServiceVols == true)  //(writeResults == true)
            {
                xtw.WriteStartElement("LOSTABLES");
                xtw.WriteAttributeString("Mode", "Auto");

                for (int lanes = 1; lanes <= 5; lanes++)      //2,4,6,8,*
                {
                    xtw.WriteStartElement("CROSSSECTION");
                    xtw.WriteAttributeString("Lanes", (lanes * 2).ToString());

                    for (int LOS = 1; LOS <= 5; LOS++)      //LOS A-E
                    {
                        xtw.WriteStartElement("SERVICEVOL");
                        xtw.WriteAttributeString("LOS", LOS.ToString());

                        if (SerVol.PkDirVol[lanes, LOS] > 0)
                        {
                            xtw.WriteElementString("PeakDirection", SerVol.PkDirVol[lanes, LOS].ToString());
                            if (Project.Period != StudyPeriod.PeakHour)     // Dir Pk Hr Demand study period
                            {
                                xtw.WriteElementString("BothDirections", SerVol.BothDirVol[lanes, LOS].ToString());
                                xtw.WriteElementString("AADT", SerVol.AADT[lanes, LOS].ToString());
                            }
                            else
                            {
                                xtw.WriteElementString("BothDirections", "N/A");
                                xtw.WriteElementString("AADT", "N/A");
                            }
                        }
                        else if (SerVol.PkDirVol[lanes, LOS] == -2)
                        {
                            xtw.WriteElementString("PeakDirection", "**");
                            if (Project.Period != StudyPeriod.PeakHour)     // Dir Pk Hr Demand study period
                            {
                                xtw.WriteElementString("BothDirections", "**");
                                xtw.WriteElementString("AADT", "**");
                            }
                            else
                            {
                                xtw.WriteElementString("BothDirections", "N/A");
                                xtw.WriteElementString("AADT", "N/A");
                            }
                        }
                        else if (SerVol.PkDirVol[lanes, LOS] == -3)
                        {
                            xtw.WriteElementString("PeakDirection", "***");
                            if (Project.Period != StudyPeriod.PeakHour)     // Dir Pk Hr Demand study period
                            {
                                xtw.WriteElementString("BothDirections", "***");
                                xtw.WriteElementString("AADT", "***");
                            }
                            else
                            {
                                xtw.WriteElementString("BothDirections", "N/A");
                                xtw.WriteElementString("AADT", "N/A");
                            }
                        }
                        xtw.WriteEndElement(); //close the <SERVICEVOL> tag
                    }
                    xtw.WriteEndElement();     //close the <CROSSSECTION> tag
                }
                xtw.WriteEndElement();         //close the <LOSTABLES> tag
            }

            xtw.WriteEndElement();  //close the <ARTERIAL> tag
            xtw.WriteEndDocument(); //close the <TMML> tag
            xtw.Close();
        }
コード例 #3
0
        /// <summary>
        /// Creates the Service Volumes for an arterial based on input parameters.
        /// </summary>
        /// <param name="Project"></param>
        /// <param name="SerVol"></param>
        /// <param name="inputsOneLane"></param>
        /// <param name="inputsMultiLane"></param>

        /*public static void ServiceVolsAuto(ProjectData Project, ServiceVolumes SerVol, ServiceVolumeArterialInputs
         * inputsOneLane, ServiceVolumeArterialInputs inputsMultiLane)
         * {
         *
         *  float NumberOfLoops = 5 * 5;  //This accounts for LOS and Lanes, does not account for volume increments; Type is float just to avoid extra cast in calculations below
         *  int LoopCounter = 0;
         *  frmMain.bgwRunServiceVolsCalcs.ReportProgress(0);
         *
         *  ArterialData Arterial = new ArterialData();
         *  for (int lanes = 0; lanes < 5; lanes++) // 2,4,6,8,*
         *  {
         *      int vol = 40; // Starting volume (volume entering upstream of first intersection)
         *      bool threshExceeded = false;
         *
         *      // Variable access points
         *
         *      ServiceVolumeArterialInputs inputsForArterialCreation = inputsOneLane;
         *      if (lanes > 0)
         *          inputsForArterialCreation = inputsMultiLane;
         *
         *      if (lanes != 4)
         *          Arterial = CreateArterial_FDOTSerVols.NewArterial(inputsForArterialCreation, vol, lanes + 1);
         *      else
         *          Arterial = CreateArterial_FDOTSerVols.NewArterial(inputsForArterialCreation, vol);
         *
         *      for (int LOSlevel = 0; LOSlevel < 5; LOSlevel++) // LOS A-E
         *      {
         *          LoopCounter++;
         *
         *          int[] ServiceVolsArray;
         *          do
         *          {
         *              CreateArterial_FDOTSerVols.ChangeArterialVolume(ref Arterial, vol);
         *              Arterial.TestSerVol = vol;
         *              CalcsArterial.CalcResults(Project, ref Arterial);
         *
         *              if (!Arterial.OverCapacity)
         *              {
         *                  // Check whether LOS speed threshold has been exceeded
         *                  if (Arterial.Results.AverageSpeed < Arterial.Thresholds.Speed[LOSlevel])  // Avg. speed below LOS threshold speed
         *                  {
         *                      vol -= 10;
         *                      threshExceeded = true;
         *                      if (vol <= 0)
         *                      {
         *                          vol = 10;
         *                          SerVol.PkDirVol[lanes, LOSlevel] = -1;
         *                          SerVol.BothDirVol[lanes, LOSlevel] = -1;
         *                          SerVol.AADT[lanes, LOSlevel] = -1;
         *                          SerVol.Found[lanes, LOSlevel] = true;
         *                      }
         *                  }
         *                  else
         *                  {
         *                      if (threshExceeded == false) // Threshold not exceeded, increment volume
         *                      {
         *                          if ((Arterial.Results.AverageSpeed - Arterial.Thresholds.Speed[LOSlevel]) > 5)
         *                              vol += (30 * (lanes + 1) * (LOSlevel + 1));
         *                          else
         *                              vol += 10;
         *                      }
         *                      else // Threshold exceeded, record volume for LOS level
         *                      {
         *                          if (LOSlevel > 0)
         *                              ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, SerVol.PkDirVol[lanes, LOSlevel - 1]);
         *                          else
         *                              ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, -1);
         *                          SerVol.PkDirVol[lanes, LOSlevel] = ServiceVolsArray[0];
         *                          SerVol.BothDirVol[lanes, LOSlevel] = ServiceVolsArray[1];
         *                          SerVol.AADT[lanes, LOSlevel] = ServiceVolsArray[2];
         *                          SerVol.Found[lanes, LOSlevel] = true;
         *                          vol += 10; // Increment volume for start of next LOS level
         *                          threshExceeded = false;
         *                      }
         *                  }
         *              }
         *              else  // Check to see if there is a constraining intersection due to (v/c * PHF) > 1
         *              {
         *                  vol -= 10; // Return to the previous non-capacity-constrained volume
         *                  for (int capCheckLOSlevel = LOSlevel + 1; capCheckLOSlevel < 5; capCheckLOSlevel++) // LOS A-E
         *                  {
         *                      SerVol.PkDirVol[lanes, capCheckLOSlevel] = -2;
         *                      SerVol.BothDirVol[lanes, capCheckLOSlevel] = -2;
         *                      SerVol.AADT[lanes, capCheckLOSlevel] = -2;
         *                      SerVol.Found[lanes, capCheckLOSlevel] = true;
         *                  }
         *                  if (LOSlevel > 0)
         *                      ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, SerVol.PkDirVol[lanes, LOSlevel - 1]);
         *                  else
         *                      ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, -1);
         *                  SerVol.PkDirVol[lanes, LOSlevel] = ServiceVolsArray[0];
         *                  SerVol.BothDirVol[lanes, LOSlevel] = ServiceVolsArray[1];
         *                  SerVol.AADT[lanes, LOSlevel] = ServiceVolsArray[2];
         *                  SerVol.Found[lanes, LOSlevel] = true;
         *              }
         *          }
         *          while (SerVol.Found[lanes, LOSlevel] == false);     //loop until service vol reached for given LOS
         *          if (Arterial.OverCapacity)
         *          {
         *              LoopCounter = 5 * (lanes + 1);
         *              frmMain.bgwRunServiceVolsCalcs.ReportProgress((int)(Math.Round(LoopCounter / NumberOfLoops * 100, 0, MidpointRounding.AwayFromZero)));
         *              break;
         *          }
         *          frmMain.bgwRunServiceVolsCalcs.ReportProgress((int)(Math.Round(LoopCounter / NumberOfLoops * 100, 0, MidpointRounding.AwayFromZero)));
         *      } // BP here to view service volumes by LOS
         *  } // BP here to view service volumes by number of lanes
         * } // BP here to view all service volumes*/

        public static void ServiceVolsAutoNew(ProjectData Project, ServiceVolumes SerVol, ServiceVolumeTableFDOT inputsOneLane, ServiceVolumeTableFDOT inputsMultiLane)
        {
            float NumberOfLoops = 5 * 5;  //This accounts for LOS and Lanes, does not account for volume increments; Type is float just to avoid extra cast in calculations below
            int   LoopCounter   = 0;

            frmMain.bgwRunServiceVolsCalcs.ReportProgress(0);

            ArterialData Arterial = new ArterialData();

            for (int lanes = 0; lanes < 5; lanes++) // 2,4,6,8,*
            {
                int  vol            = 40;           // Starting volume (volume entering upstream of first intersection)
                bool threshExceeded = false;

                // Variable access points

                ServiceVolumeTableFDOT inputsForArterialCreation = inputsOneLane;
                if (lanes > 0)
                {
                    inputsForArterialCreation = inputsMultiLane;
                }

                if (lanes != 4)
                {
                    Arterial = CreateArterial_FDOTSerVols.NewArterial(inputsForArterialCreation, Project.AnalMode, vol, lanes + 1);
                }
                else
                {
                    Arterial = CreateArterial_FDOTSerVols.NewArterial(inputsForArterialCreation, Project.AnalMode, vol);
                }

                for (int LOSlevel = 0; LOSlevel < 5; LOSlevel++) // LOS A-E
                {
                    LoopCounter++;

                    int[] ServiceVolsArray;
                    do
                    {
                        CreateArterial_FDOTSerVols.ChangeArterialVolume(ref Arterial, vol);
                        Arterial.TestSerVol = vol;
                        CalcsArterial.CalcResults(Project, ref Arterial);

                        if (!Arterial.OverCapacity)
                        {
                            // Check whether LOS speed threshold has been exceeded
                            if (Arterial.Results.AverageSpeed < Arterial.Thresholds.Speed[LOSlevel])  // Avg. speed below LOS threshold speed
                            {
                                vol           -= 10;
                                threshExceeded = true;
                                if (vol <= 0)
                                {
                                    vol = 10;
                                    SerVol.PkDirVol[lanes, LOSlevel]   = -1;
                                    SerVol.BothDirVol[lanes, LOSlevel] = -1;
                                    SerVol.AADT[lanes, LOSlevel]       = -1;
                                    SerVol.Found[lanes, LOSlevel]      = true;
                                }
                            }
                            else
                            {
                                if (threshExceeded == false) // Threshold not exceeded, increment volume
                                {
                                    if ((Arterial.Results.AverageSpeed - Arterial.Thresholds.Speed[LOSlevel]) > 5)
                                    {
                                        vol += (30 * (lanes + 1) * (LOSlevel + 1));
                                    }
                                    else
                                    {
                                        vol += 10;
                                    }
                                }
                                else // Threshold exceeded, record volume for LOS level
                                {
                                    //vol += 10;
                                    if (LOSlevel > 0)
                                    {
                                        ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, SerVol.PkDirVol[lanes, LOSlevel - 1]);
                                    }
                                    else
                                    {
                                        ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, -1);
                                    }
                                    SerVol.PkDirVol[lanes, LOSlevel]   = ServiceVolsArray[0];
                                    SerVol.BothDirVol[lanes, LOSlevel] = ServiceVolsArray[1];
                                    SerVol.AADT[lanes, LOSlevel]       = ServiceVolsArray[2];
                                    SerVol.Found[lanes, LOSlevel]      = true;
                                    vol           += 10; // Increment volume for start of next LOS level
                                    threshExceeded = false;
                                }
                            }
                        }
                        else  // Check to see if there is a constraining intersection due to (v/c * PHF) > 1
                        {
                            vol -= 10; // Return to the previous non-capacity-constrained volume
                            for (int capCheckLOSlevel = LOSlevel + 1; capCheckLOSlevel < 5; capCheckLOSlevel++) // LOS A-E
                            {
                                SerVol.PkDirVol[lanes, capCheckLOSlevel]   = -2;
                                SerVol.BothDirVol[lanes, capCheckLOSlevel] = -2;
                                SerVol.AADT[lanes, capCheckLOSlevel]       = -2;
                                SerVol.Found[lanes, capCheckLOSlevel]      = true;
                            }
                            if (LOSlevel > 0)
                            {
                                ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, SerVol.PkDirVol[lanes, LOSlevel - 1]);
                            }
                            else
                            {
                                ServiceVolsArray = SetServiceVolumes(vol, Project.Period, Arterial.Dfactor, Arterial.Kfactor, LOSlevel, -1);
                            }
                            SerVol.PkDirVol[lanes, LOSlevel]   = ServiceVolsArray[0];
                            SerVol.BothDirVol[lanes, LOSlevel] = ServiceVolsArray[1];
                            SerVol.AADT[lanes, LOSlevel]       = ServiceVolsArray[2];
                            SerVol.Found[lanes, LOSlevel]      = true;
                        }
                    }while (SerVol.Found[lanes, LOSlevel] == false);     //loop until service vol reached for given LOS
                    threshExceeded = false;
                    if (Arterial.OverCapacity)
                    {
                        LoopCounter = 5 * (lanes + 1);
                        frmMain.bgwRunServiceVolsCalcs.ReportProgress((int)(Math.Round(LoopCounter / NumberOfLoops * 100, 0, MidpointRounding.AwayFromZero)));
                        break;
                    }
                    frmMain.bgwRunServiceVolsCalcs.ReportProgress((int)(Math.Round(LoopCounter / NumberOfLoops * 100, 0, MidpointRounding.AwayFromZero)));
                } // BP here to view service volumes by LOS
            }     // BP here to view service volumes by number of lanes
        }         // BP here to view all service volumes
コード例 #4
0
        /*public static void WriteServiceVolResultsData(string filename, List<ServiceVolumes> serVolResults)
         * {
         *  try
         *  {
         *      //bool DoesFileCurrentlyExist = File.Exists(filename);
         *
         *      StreamWriter swLinkResults = new StreamWriter(filename, true);
         *
         *      /*if (DoesFileCurrentlyExist == false)
         *      {
         *          //WriteLinkResultsDataHeader(Filename);
         *          swLinkResults.Write("Scenario, SubScenario, Replication, Link Id, Link Type, Density (veh/mi/ln), Avg. Speed (mi/h), Avg. Travel Time (s), Accel Noise-Mean Zero (ft/s2), Accel Noise-Mean NonZero (ft/s2), Flow Rate (veh/h/ln), Num PC, % PC, Num SUT, % SUT, Num IMST");
         *          swLinkResults.WriteLine();
         *      }*
         *
         *      swLinkResults.Write(",,Volumes by LOS");
         *      if (serVolResults.Count > 1)
         *          swLinkResults.Write(",,,,,,,% Difference Between Ranges,,,,,");
         *      swLinkResults.WriteLine();
         *      if (serVolResults.Count > 1)
         *          swLinkResults.Write(serVolResults[0].TestParameterLabel + ",");
         *      swLinkResults.Write("Lanes,");
         *      swLinkResults.Write("LOS A,");
         *      swLinkResults.Write("LOS B,");
         *      swLinkResults.Write("LOS C,");
         *      swLinkResults.Write("LOS D,");
         *      swLinkResults.Write("LOS E,");
         *      swLinkResults.Write(",");
         *      if (serVolResults.Count > 1)
         *      {
         *          swLinkResults.Write("Range,");
         *          swLinkResults.Write("Lanes,");
         *          swLinkResults.Write("LOS A,");
         *          swLinkResults.Write("LOS B,");
         *          swLinkResults.Write("LOS C,");
         *          swLinkResults.Write("LOS D,");
         *          swLinkResults.Write("LOS E,");
         *      }
         *      swLinkResults.Write(",Legend");
         *      swLinkResults.WriteLine();
         *
         *      foreach (ServiceVolumes serVolResult in serVolResults)
         *      {
         *          for (int lanes = 0; lanes < 5; lanes++)
         *          {
         *              // Service Volumes by LOS
         *              if (serVolResult.TestParameterLabel != "None")
         *                  swLinkResults.Write(Math.Round(serVolResult.TestParameterValue,2) + ",");
         *              else if (serVolResults.Count > 1)
         *                  swLinkResults.Write(",");
         *              swLinkResults.Write((lanes+1) + ",");
         *              for (int LOSLevel = 0; LOSLevel < 5; LOSLevel++)
         *              {
         *                  if (serVolResult.PkDirVol[lanes, LOSLevel] >= 0)
         *                      swLinkResults.Write(serVolResult.PkDirVol[lanes, LOSLevel] + ",");
         *                  else if (serVolResult.PkDirVol[lanes, LOSLevel] == -1)
         *                      swLinkResults.Write("a*,");
         *                  else if (serVolResult.PkDirVol[lanes, LOSLevel] == -2)
         *                      swLinkResults.Write("b*,");
         *                  else if (serVolResult.PkDirVol[lanes, LOSLevel] == -3)
         *                      swLinkResults.Write("c*,");
         *              }
         *              swLinkResults.Write(",");
         *
         *              // % Difference Between Highest and Lowest Values
         *              if (serVolResults.IndexOf(serVolResult) == 0 && serVolResults.Count > 1)
         *              {
         *                  if (serVolResults.Count > 1)
         *                      swLinkResults.Write("Min to Max,");
         *                  swLinkResults.Write((lanes + 1) + ",");
         *                  for (int LOSLevel = 0; LOSLevel < 5; LOSLevel++)
         *                  {
         *                      float lowestValue = 9999999;
         *                      float highestValue = 0;
         *                      foreach (ServiceVolumes serVolResultCheckValues in serVolResults)
         *                      {
         *                          if (serVolResultCheckValues.PkDirVol[lanes, LOSLevel] > 0)
         *                          {
         *                              lowestValue = Math.Min(serVolResultCheckValues.PkDirVol[lanes, LOSLevel], lowestValue);
         *                              highestValue = Math.Max(serVolResultCheckValues.PkDirVol[lanes, LOSLevel], highestValue);
         *                          }
         *                      }
         *                      if (highestValue == 0 && lowestValue == 9999999)
         *                          swLinkResults.Write("N/A,");
         *                      else
         *                          swLinkResults.Write(Math.Round((highestValue - lowestValue) * 100 / lowestValue, 2) + "%,");
         *                  }
         *              }
         *              else if (serVolResults.IndexOf(serVolResult) > 0) // % Difference Between Bound Iterations
         *              {
         *                  if (serVolResults.Count > 1)
         *                      swLinkResults.Write(Math.Round(serVolResults[serVolResults.IndexOf(serVolResult) - 1].TestParameterValue,2) + " to " + Math.Round(serVolResult.TestParameterValue,2) + ",");
         *                  swLinkResults.Write((lanes + 1) + ",");
         *                  for (int LOSLevel = 0; LOSLevel < 5; LOSLevel++)
         *                  {
         *                      if (serVolResults.IndexOf(serVolResult) == 0)
         *                          swLinkResults.Write("N/A,");
         *                      else
         *                      {
         *                          if (serVolResult.PkDirVol[lanes, LOSLevel] > 0 && serVolResults[serVolResults.IndexOf(serVolResult) - 1].PkDirVol[lanes, LOSLevel] > 0)
         *                              swLinkResults.Write(Math.Round((float)(serVolResult.PkDirVol[lanes, LOSLevel] - serVolResults[serVolResults.IndexOf(serVolResult) - 1].PkDirVol[lanes, LOSLevel]) * 100 / (float)serVolResults[serVolResults.IndexOf(serVolResult) - 1].PkDirVol[lanes, LOSLevel], 2) + "%,");
         *                          else
         *                              swLinkResults.Write("N/A,");
         *                      }
         *                  }
         *
         *              }
         *              if (serVolResults.IndexOf(serVolResult)==0)
         *              {
         *                  if (lanes == 0)
         *                      swLinkResults.Write(",a*,LOS Level cannot be achieved");
         *                  else if (lanes == 1)
         *                      swLinkResults.Write(",b*,Service volume is constrained by capacity");
         *                  else if (lanes == 2)
         *                      swLinkResults.Write(",c*,Service volume same for previous LOS level");
         *              }
         *              swLinkResults.WriteLine();
         *          }
         *      }
         *      swLinkResults.Close();
         *  }
         *  catch //(IOException ex)
         *  {
         *      //ex.Message
         *  }
         * }*/

        public static void WriteLOSHeaders(StreamWriter swLinkResults, ServiceVolumes serVolResult, List <ServiceVolumes> serVolResults)
        {
            swLinkResults.WriteLine();

            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(",");
            }
            swLinkResults.Write(serVolResult.SerVolAreaType);
            if (serVolResult.SerVolAreaType != AreaType.RuralDeveloped)
            {
                swLinkResults.Write(",," + serVolResult.Class + ",,");
            }
            else
            {
                swLinkResults.Write(",,,,");
            }
            swLinkResults.Write("Peak Hour Dir. Vol,,,");

            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(",");
            }
            swLinkResults.Write(serVolResult.SerVolAreaType);
            if (serVolResult.SerVolAreaType != AreaType.RuralDeveloped)
            {
                swLinkResults.Write(",," + serVolResult.Class + ",,");
            }
            else
            {
                swLinkResults.Write(",,,,");
            }
            swLinkResults.Write("Peak Hour Both. Vol,,,");

            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(",");
            }
            swLinkResults.Write(serVolResult.SerVolAreaType);
            if (serVolResult.SerVolAreaType != AreaType.RuralDeveloped)
            {
                swLinkResults.Write(",," + serVolResult.Class + ",,");
            }
            else
            {
                swLinkResults.Write(",,,,");
            }
            swLinkResults.Write("AADT");
            if (serVolResult.TestParameterLabel != "None")
            {
                swLinkResults.Write(",,,," + serVolResult.SerVolAreaType);
                if (serVolResult.SerVolAreaType != AreaType.RuralDeveloped)
                {
                    swLinkResults.Write(",," + serVolResult.Class + ",,");
                }
                else
                {
                    swLinkResults.Write(",,,,");
                }
                swLinkResults.Write("% Difference Pk. Dir");
            }
            swLinkResults.WriteLine();
            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(serVolResults[0].TestParameterLabel + ",");
            }
            swLinkResults.Write("Lanes,");
            swLinkResults.Write("LOS A,");
            swLinkResults.Write("LOS B,");
            swLinkResults.Write("LOS C,");
            swLinkResults.Write("LOS D,");
            swLinkResults.Write("LOS E,");
            swLinkResults.Write(",");
            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(serVolResults[0].TestParameterLabel + ",");
            }
            swLinkResults.Write("Lanes,");
            swLinkResults.Write("LOS A,");
            swLinkResults.Write("LOS B,");
            swLinkResults.Write("LOS C,");
            swLinkResults.Write("LOS D,");
            swLinkResults.Write("LOS E,");
            swLinkResults.Write(",");
            if (serVolResults[0].TestParameterLabel != "None")
            {
                swLinkResults.Write(serVolResults[0].TestParameterLabel + ",");
            }
            swLinkResults.Write("Lanes,");
            swLinkResults.Write("LOS A,");
            swLinkResults.Write("LOS B,");
            swLinkResults.Write("LOS C,");
            swLinkResults.Write("LOS D,");
            swLinkResults.Write("LOS E,");
            if (serVolResult.TestParameterLabel != "None")
            {
                swLinkResults.Write(",");
                swLinkResults.Write("Range,");
                swLinkResults.Write("Lanes,");
                swLinkResults.Write("LOS A,");
                swLinkResults.Write("LOS B,");
                swLinkResults.Write("LOS C,");
                swLinkResults.Write("LOS D,");
                swLinkResults.Write("LOS E,");
            }
            swLinkResults.WriteLine();
        }