private void tsbAddLink_Click(object sender, EventArgs e) { /* * int NumLinks = dgvLinkData.Rows.Count; //get number of entered links * if (NumLinks == 1000) //maximum, based on 500 nodes (roughly nodes * 2) * { * MessageBox.Show("The number of entered links is limited to a maximum of 1000.", "XXE", MessageBoxButtons.OK, MessageBoxIcon.Information); * return; * } */ dgvLinkData.Rows.Add(1); for (int i = 0; i < dgvLinkData.Columns.Count; i++) { dgvLinkData.Rows[dgvLinkData.Rows.Count - 1].Cells[i].Style.BackColor = Color.Yellow; } if (dgvLinkData.Rows.Count > 1) { tsbDeleteLink.Enabled = true; } if (Project.Type == ProjectType.BPRlinks) { LinkData NewLink = new LinkData(); Links.Add(NewLink); } else { FreewayData NewFreewayFacility = new FreewayData(); FreewayFacilities.Add(NewFreewayFacility); } }
private void dgvResults_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (WithFreewayFacilityFiles == true) { if (e.ColumnIndex > 0 && e.RowIndex >= 0) { int link = Convert.ToInt32(dgvResults.Rows[e.RowIndex].Cells[colID.Name].Value); int tp = Convert.ToInt32(dgvResults.Rows[e.RowIndex].Cells[colTimePeriod.Name].Value); if (e.ColumnIndex == 7) // Load in FreewawFacilities program { int freewayID = (int)dgvResults.Rows[e.RowIndex].Cells[colID.Name].Value; GetLinkIndex(freewayID); int numTPs = myResults.Count; //numTPs-1: the last time period results contains them all FreewayData fwy = myFreewayFacilities[GetFacilityID(freewayID)]; List <List <SegmentData> > tpsegs = fwy.TPsegs; int NumOfLanes = tpsegs[0][0].NumThruLanes; HCMCalc_Definitions.ProjectData FFproject = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); HCMCalc_Calculations.CalculationsMain.CalcResults(FFproject, NumOfLanes, ref fwy, ref tpsegs); HCMCalc_FreewayFacility.mdiMain MDIform = new HCMCalc_FreewayFacility.mdiMain(FFproject, fwy, tpsegs); MDIform.Show(); } } } }
public FreewayFacility(FreewayData fwyImport) { InitializeComponent(); panelChartControl.Controls.Add(ctrlDistributionDisplay1); ChartResizing(); GetMainlineInputSettings(); Fwy = fwyImport; TPSegs = Fwy.TPsegs; updnTimePeriod.Maximum = Fwy.TotalTimePeriods; GenerateInitialRampProportionTimePeriodList(); //btnCreateChart_Click(null,null); }
public void FileOpen(object sender, EventArgs e) { string FileName = Main.GetFilename(FileListingTitle, RegistryDirectory, RegistryPathForStoredFilenames, Filter, InitialDirectory); if (Project.Type == ProjectType.BPRlinks) { if (FileName != "") { this.CloseAllToolStripMenuItem_Click(this, e); //close currently active child forms Project.FileName = FileName; tstxtFilename.Text = Project.FileName; //XXE_Calculations.FileInputOutput FileIO = new XXE_Calculations.FileInputOutput(); XXE_Calculations.FileInputOutput.ReadXmlFile(Project.FileName, Project, Network, Links, OrigDestPairs); //string ShortFileName = System.IO.Path.GetFileName(ProjectData.FileName); this.Text = "XXE"; OpenAllDataForms(); } } else { if (FileName != "") { this.CloseAllToolStripMenuItem_Click(this, e); //close currently active child forms Project.FileName = FileName; tstxtFilename.Text = Project.FileName; //read proejct file XXE_Calculations.FileInputOutput.ReadFreewayFacilitiesProjectFile(FileName, Project, Network); //read freeway facilities network file HCMCalc_Definitions.ProjectData ProjectFF = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); FreewayFacilityIO FileIOFF = new FreewayFacilityIO(); FreewayFacilities.Clear(); FileIOFF.ReadFreewaysFile(Project.NetworkFileName, ref ProjectFF, FreewayFacilities); //test for (int fwy = 0; fwy < FreewayFacilities.Count; fwy++) { List <List <SegmentData> > tpsegs = FreewayFacilities[fwy].TPsegs; FreewayData Freeway = FreewayFacilities[fwy]; HCMCalc_Definitions.ProjectData FFproject = new HCMCalc_Definitions.ProjectData("Freeway Facility", AnalysisMode.HCM2016); HCMCalc_Calculations.CalculationsMain.CalcResults(FFproject, FreewayFacilities[fwy].TPsegs[0][0].NumThruLanes, ref Freeway, ref tpsegs); } //read od data file XXE_Calculations.FileInputOutput.ReadODxmlFile(Project.ODfileName, Network, OrigDestPairs); tsConvCrit.Text = Network.ConvCrit.ToString(); tsMaxIter.Text = Network.MaxIterations.ToString(); this.Text = "XXE"; OpenAllDataForms(); } } }
private FreewayData InitializeFreewayData() { FreewayData fwy = new FreewayData(); fwy.TPsegs = new List <List <SegmentData> >(); List <SegmentData> SegData; //------------ From HCM-CALC; eventually replace with call to method in HCM-CALC -----------------------// //time period zero MainlineOutputs newTimePeriodFreewayResults = new MainlineOutputs(); fwy.Results.Add(newTimePeriodFreewayResults); SegData = new List <SegmentData>(); //add first dummy segment SegData.Add(new SegmentData(SegmentType.Basic)); //add first real segment SegData.Add(new SegmentData(SegmentType.Basic)); SegData[1].isZero = true; //add last dummy segment; currently needed for oversaturated analysis SegData.Add(new SegmentData(SegmentType.Basic)); fwy.TPsegs.Add(SegData); //adding zero time period //time period 1 newTimePeriodFreewayResults = new MainlineOutputs(); fwy.Results.Add(newTimePeriodFreewayResults); SegData = new List <SegmentData>(); //add first dummy segment SegData.Add(new SegmentData(SegmentType.Basic)); //add first real segment SegData.Add(new SegmentData(SegmentType.Basic)); //add last dummy segment; currently needed for oversaturated analysis SegData.Add(new SegmentData(SegmentType.Basic)); fwy.TPsegs.Add(SegData); //adding first time period fwy.TotalTimePeriods = 1; fwy.TotalSegs = 1; //------------------------------------------------------------------------------------------// return(fwy); }
private void tsbInsertLink_Click(object sender, EventArgs e) { /* * int NumLinks = dgvLinkData.Rows.Count; //get number of entered links * if (NumLinks == 1000) //maximum, based on 500 nodes (roughly nodes * 2) * { * MessageBox.Show("The number of entered links is limited to a maximum of 1000.", "XXE", MessageBoxButtons.OK, MessageBoxIcon.Information); * return; * } */ try { //insert a new link between two current links int SelectedRow = dgvLinkData.SelectedRows[0].Index; dgvLinkData.Rows.Insert(SelectedRow, 1); if (dgvLinkData.Rows.Count > 1) { tsbDeleteLink.Enabled = true; } for (int i = 0; i < dgvLinkData.Columns.Count; i++) { dgvLinkData.Rows[SelectedRow].Cells[i].Style.BackColor = Color.Yellow; } if (Project.Type == ProjectType.BPRlinks) { LinkData NewLink = new LinkData(); Links.Insert(SelectedRow, NewLink); } else { FreewayData NewFreewayFacility = new FreewayData(); FreewayFacilities.Insert(SelectedRow, NewFreewayFacility); } } catch { MessageBox.Show("To insert a row, you must select a row by clicking on the row number on the left-hand side of the grid. The new row will be inserted above this row selection.", "Row Insert Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static double TravTimeFcnFreewayFacilities(List <List <double> > ProportionTimePeriodList, FreewayData fwy, int tp, double flowImport) { int flow = (int)flowImport; if (fwy.PhysicalLinkXXE == false) { tp = 1; } //Calculate travel time through HCM-CALC Freeway Facilities module ApplyVolumeSteps(fwy.TPsegs, flow, ProportionTimePeriodList, tp); List <List <SegmentData> > tpsegs = fwy.TPsegs; ProjectData FFproject = new ProjectData("Freeway Facility", AnalysisMode.HCM2016); HCMCalc_Calculations.CalculationsMain.CalcResults(FFproject, fwy.TPsegs[0][0].NumThruLanes, ref fwy, ref tpsegs); //Fcn = fwy.Results[tp].TravTimeAvg; double facilityTravTimeAvg = 0; ////Save to 0.1 minute if (flow == 0) { facilityTravTimeAvg = Math.Round(fwy.Results[tp].TravTimeFreeFlow, 1); } else if (flow > 0) { facilityTravTimeAvg = Math.Round(fwy.Results[tp].TravTimeAvg, 1); } //int numSegments = fwy.TPsegs[0].Count - 2; ////Save to 0.1 minute //if (flow == 0) //{ // for(int seg =1; seg<=numSegments; seg++) // { // facilityTravTimeAvg = facilityTravTimeAvg + Math.Round(fwy.TPsegs[tp][seg].Results.TravTimeFreeFlow, 1); // } //} //else if (flow > 0) //{ // for (int seg = 1; seg <= numSegments; seg++) // { // facilityTravTimeAvg = facilityTravTimeAvg + Math.Round(fwy.TPsegs[tp][seg].Results.TravTimeAvg, 1); // } //} return(facilityTravTimeAvg); }
private Boolean LoadLinkData() { if (Project.Type == ProjectType.BPRlinks) { if ((Links == null) || (Network.TotalLinks == 0)) { LinkData NewLink = new LinkData(); Links.Add(NewLink); dgvLinkData.Rows.Add(1); //for (int i = 0; i < dgvLinkData.Columns.Count; i++) // dgvLinkData.Rows[0].Cells[i].Style.BackColor = Color.Yellow; return(false); } else { try { dgvLinkData.Rows.Add(Network.TotalLinks); for (int i = 1; i <= Network.TotalLinks; i++) { dgvLinkData.Rows[i - 1].Cells[0].Value = Links[i].FromNode.ToString(); dgvLinkData.Rows[i - 1].Cells[1].Value = Links[i].ToNode.ToString(); dgvLinkData.Rows[i - 1].Cells[2].Value = Links[i].Capacity[0].ToString(); dgvLinkData.Rows[i - 1].Cells[3].Value = Links[i].Length.ToString(); if (Links[i].FreeFlowSpeed > 4) { dgvLinkData.Rows[i - 1].Cells[4].Value = Links[i].FreeFlowSpeed.ToString(); } else //pedestrian speeds are being used { dgvLinkData.Rows[i - 1].Cells[4].Value = Links[i].FreeFlowSpeed.ToString("0.00"); } dgvLinkData.Rows[i - 1].Cells[5].Value = (Convert.ToDouble(dgvLinkData.Rows[i - 1].Cells[3].Value) / Convert.ToDouble(dgvLinkData.Rows[i - 1].Cells[4].Value)).ToString("0.0000"); dgvLinkData.Rows[i - 1].Cells[6].Value = Links[i].Description; if (Network.TimePeriodType == TimePeriod.Multiple) { dgvLinkData.Rows[i - 1].Cells[7].Value = Links[i].PrintTimePerResults; dgvLinkData.Rows[i - 1].Cells[8].Value = Links[i].TimePerData; } } tsFirstNode.Text = Network.FirstNetworkNode.ToString(); tsTotNodes.Text = Network.NumNodes.ToString(); //set cell background colors to white for valid data tsFirstNode.BackColor = Color.White; tsTotNodes.BackColor = Color.White; dgvLinkData.DefaultCellStyle.BackColor = Color.White; dgvLinkData.AlternatingRowsDefaultCellStyle.BackColor = Color.White; DataSaved = true; DataCurrent = true; return(true); } catch { MessageBox.Show("Invalid Input Data. Check your saved data file for invalid entries and try again.", "Input Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } } else { if (FreewayFacilities == null || FreewayFacilities.Count == 0) { FreewayData NewFreewayFacility = InitializeFreewayData(); FreewayFacilities.Add(NewFreewayFacility); dgvLinkData.Rows.Add(1); return(false); } else { try { dgvLinkData.Rows.Clear(); Network.TotalLinks = FreewayFacilities.Count; dgvLinkData.Rows.Add(Network.TotalLinks); for (int i = 0; i < Network.TotalLinks; i++) { dgvLinkData.Rows[i].Cells[0].Value = FreewayFacilities[i].FromNode.ToString(); dgvLinkData.Rows[i].Cells[1].Value = FreewayFacilities[i].ToNode.ToString(); if (FreewayFacilities[i].PhysicalLinkXXE == true) { dgvLinkData.Rows[i].Cells[colPhysicalLink.Name].Value = "Yes"; } else { dgvLinkData.Rows[i].Cells[colPhysicalLink.Name].Value = "No"; } } tsFirstNode.Text = Network.FirstNetworkNode.ToString(); tsTotNodes.Text = Network.NumNodes.ToString(); //set cell background colors to white for valid data tsFirstNode.BackColor = Color.White; tsTotNodes.BackColor = Color.White; dgvLinkData.DefaultCellStyle.BackColor = Color.White; dgvLinkData.AlternatingRowsDefaultCellStyle.BackColor = Color.White; DataSaved = true; DataCurrent = true; return(true); } catch { MessageBox.Show("Invalid Input Data. Check your saved data file for invalid entries and try again.", "Input Data Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } } }