//private List<Closure> downloadCurrentINCIXMLFromWeb(double pollingOrRequestFrequency)//download current INCI XML data from NextBus with processing for INCITime //{ // List<Closure> downloadedINCIXML = new List<Closure>(); // Uri uriToDownload = new Uri("http://www1.toronto.ca/transportation/roadrestrictions/RoadRestrictions.xml"); // repeatWebDownload: // try // { // using (WebClient client = new WebClient()) // { // //download string and write to file // string xml = client.DownloadString(uriToDownload); // string xmlString = Convert.ToString(xml); // using (StringReader reader = new StringReader(xmlString)) // { // XmlSerializer serializer = new XmlSerializer(typeof(Closures)); // string headerString = reader.ReadLine(); // string currentVehString = reader.ReadToEnd(); // MemoryStream memStream = new MemoryStream(Encoding.UTF8.GetBytes(currentVehString)); // Closures currentXMLINCIPoints = (Closures)serializer.Deserialize(memStream); // downloadedINCIXML.AddRange(currentXMLINCIPoints.Closure); // }//end using reader // }//end using cilent // } // catch (Exception e) // { // //sleep to aviod too many requests // Thread.Sleep(Convert.ToInt32(1000 * pollingOrRequestFrequency / 2));//check delay at "half of" polling frequency (minute), until it is time for download // goto repeatWebDownload; // } // return downloadedINCIXML; //} /// <summary> /// /// </summary> /// <param name="RouteTags"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public List <SSIncidentDataTable> RetriveINCIData(DateTime startTime, DateTime endTime, List <string> RouteTags = null) { List <SSIncidentDataTable> finalPackageOfINCIDataAllRoutes = new List <SSIncidentDataTable>(); List <SSIncidentDataTable> allDataInTheINCIDataFile = new List <SSIncidentDataTable>(); //For incident and weather data, saves are daily startTime = startTime.Date; //beginning of first day endTime = endTime.Date.AddDays(1).AddSeconds(-1); //end of second day DateTime lastIntermediateTime = startTime; //intermediate time 59:59 (min:sec) from start DateTime intermediateTime = startTime.Date.AddHours(startTime.Hour).AddSeconds(fileSaveFreq - 1); //intermediate time 59:59 (min:sec) from start while (intermediateTime.DateTimeToEpochTime() <= endTime.DateTimeToEpochTime()) { string currentfilename = string.Format(xmlINCIFilenameFormat, lastIntermediateTime.ToUniversalTime().DateTimeNamingFormat(), intermediateTime.ToUniversalTime().DateTimeNamingFormat()); allDataInTheINCIDataFile.AddRange(convertRawINCIToSSFormat(SSUtil.DeSerializeXMLObject <List <Closure> >(xmlINCIFolderPath + currentfilename))); //increment to read next file foreach (SSIncidentDataTable aINCIPoint in allDataInTheINCIDataFile) { //identify any filtering needed - none to start with finalPackageOfINCIDataAllRoutes.Add(aINCIPoint); } lastIntermediateTime = lastIntermediateTime.AddSeconds(fileSaveFreq); intermediateTime = intermediateTime.AddSeconds(fileSaveFreq); } allDataInTheINCIDataFile.Clear(); //clear Temp list return(finalPackageOfINCIDataAllRoutes); //return result list }
public static void Execute() { SSUtil.Log("executing {0}", typeof(T06_matrix_caching).Name); Matrix4x4 ret = Matrix4x4.zero; ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_caching: no caching_")) { for (int i = 0; i < NUM; i++) { ret = Camera.main.worldToCameraMatrix * _inputMat; } } ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_caching: cached_")) { Matrix4x4 cached = Camera.main.worldToCameraMatrix; for (int i = 0; i < NUM; i++) { ret = cached * _inputMat; } } }
public static string Execute() { SSUtil.Log("executing {0}", typeof(T03_enum_string).Name); using (SSTimer t = new SSTimer("_test_enum_to_string")) { for (int i = 0; i < NUM; i++) { for (int k = 0; k < (int)FooTypes.Max; k++) { foo = ((FooTypes)k).ToString(); } } } foo = ""; using (SSTimer t = new SSTimer("_test_enum_get_name")) { for (int i = 0; i < NUM; i++) { for (int k = 0; k < (int)FooTypes.Max; k++) { foo = Enum.GetName(typeof(FooTypes), (FooTypes)k); } } } foo = ""; return(foo); // prevent 'foo' from being optimized out }
void Start() { SSUtil.Log("high-res: {0}, freq: {1}, timestamp: {2}", Stopwatch.IsHighResolution, Stopwatch.Frequency, Stopwatch.GetTimestamp()); T01_foreach.Execute(); T03_enum_string.Execute(); T04_typecast.Execute(); T05_matrix.Execute(); T06_matrix_caching.Execute(); }
/// <summary> /// /// </summary> /// <param name="RouteTags"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public List <SSVehGPSDataTable> RetriveGPSData(List <string> RouteTags, DateTime startTime, DateTime endTime) { List <SSVehGPSDataTable> finalPackageOfGPSDataAllRoutes = new List <SSVehGPSDataTable>(); //List<SSVehGPSDataTable> allDataInTheGPSDataFile = new List<SSVehGPSDataTable>(); Dictionary <string, List <SSVehGPSDataTable> > allDataInGPSDataFile = new Dictionary <string, List <SSVehGPSDataTable> >(); List <string> gpsDataFilenames = new List <string>(); //in order DateTime lastIntermediateTime = startTime; //intermediate time 59:59 (min:sec) from start DateTime intermediateTime = startTime.Date.AddHours(startTime.Hour).AddSeconds(fileSaveFreq - 1); //intermediate time 59:59 (min:sec) from start //initiate filenames while (intermediateTime.DateTimeToEpochTime() <= endTime.DateTimeToEpochTime()) { string currentfilename = string.Format(xmlGPSFilenameFormat, lastIntermediateTime.ToUniversalTime().DateTimeNamingFormat(), intermediateTime.ToUniversalTime().DateTimeNamingFormat()); gpsDataFilenames.Add(currentfilename); //increment to read next file lastIntermediateTime = lastIntermediateTime.AddSeconds(fileSaveFreq); intermediateTime = intermediateTime.AddSeconds(fileSaveFreq); } //load all files in parallel ParallelOptions pOptions = new ParallelOptions(); pOptions.MaxDegreeOfParallelism = Environment.ProcessorCount; Parallel.For(0, gpsDataFilenames.Count, pOptions, i => { string currentfilename = gpsDataFilenames[i]; allDataInGPSDataFile.Add(currentfilename, (convertRawGPSToSSFormat(SSUtil.DeSerializeXMLObject <List <Vehicle> >(xmlGPSFolderPath + currentfilename)))); }); //add each file, then each gps point, in order foreach (string currentfilename in gpsDataFilenames) { //filter by routeTag foreach (SSVehGPSDataTable aGPSPoint in allDataInGPSDataFile[currentfilename]) { string aGPSPointRouteTag = aGPSPoint.TripCode == "NULL" ? "" : aGPSPoint.TripCode.Split('_')[0]; if (RouteTags.Contains(aGPSPointRouteTag)) { finalPackageOfGPSDataAllRoutes.Add(aGPSPoint); } } //List<SSVehGPSDataTable> filteredData = allDataInGPSDataFile[currentfilename].Where(v => RouteTags.Contains(v.TripCode.Split('_')[0])).ToList(); //finalPackageOfGPSDataAllRoutes.AddRange(filteredData); } allDataInGPSDataFile.Clear(); gpsDataFilenames.Clear(); return(finalPackageOfGPSDataAllRoutes);//return result list }
public static void Execute() { SSUtil.Log("executing {0}", typeof(T01_foreach).Name); for (int i = 0; i < NUM; i++) { _testArray[i] = i; } for (int i = 0; i < NUM; i++) { _testList.Add(i); } for (int i = 0; i < NUM; i++) { _testDict[i] = i; } int sum = 0; using (SSTimer t = new SSTimer("_testArray")) { foreach (var item in _testArray) { sum += item; } } using (SSTimer t = new SSTimer("_testList")) { foreach (var item in _testList) { sum += item; } } using (SSTimer t = new SSTimer("_testDict")) { foreach (var item in _testList) { sum += item; } } }
public static void Execute() { SSUtil.Log("executing {0}", typeof(T04_typecast).Name); Foo f = new Bar(); using (SSTimer t = new SSTimer("_test_as_cast_")) { for (int i = 0; i < NUM; i++) { Bar b = f as Bar; b.dummy_derived = 1; } } using (SSTimer t = new SSTimer("_test_c_style_cast_")) { for (int i = 0; i < NUM; i++) { Bar b = (Bar)f; b.dummy_derived = 1; } } }
/// <summary> /// B: Pull records within a given period - download any missing data from CVST /// DATA INFO: Records for specific route in a given period: /// http://portal.cvst.ca/api/0.1/ttc/name/<route_name>?starttime=<ts1>&endtime=<ts2> /// <ts> could be epoch time or string type with<YYYY><MM><DD>T<HH><MM><time-zone> /// </summary> /// <param name="RouteTags"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public List <SSVehGPSDataTable> RetriveGPSData(List <string> RouteTags, DateTime startTime, DateTime endTime) { List <JSONVehLoc> finalPackageOfGPSDataForRoutes = new List <JSONVehLoc>(); List <JSONVehLoc> packageOfGPSDataForRoutes = new List <JSONVehLoc>(); List <JSONVehLoc> packetsOfGPSDataForRoutes = new List <JSONVehLoc>(); string json = null; string filepath = jsonfolderpath + RouteTags[0] + "-" + SSUtil.DateTimeNamingFormat(startTime.ToLocalTime()) + "-" + SSUtil.DateTimeNamingFormat(endTime.ToLocalTime()) + @".json"; //URI format: ("http://portal.cvst.ca/api/0.1/ttc/name/<route_name>?starttime=<ts1>&endtime=<ts2>") //Uri uriToDownload = new Uri("http://portal.cvst.ca/api/0.1/ttc/name/100-Flemingdon%20Park?starttime=1451779200&endtime=1451779900"); string baseGPSURI = "tag/" + RouteTags[0]; string appendURI = baseGPSURI + @"?starttime=" + SSUtil.DateTimeToEpochTime(startTime.ToUniversalTime()) + @"&endtime=" + SSUtil.DateTimeToEpochTime(endTime.ToUniversalTime()); Uri uriToDownload = new Uri(uri_CVSTbase, appendURI); JsonSerializer serializer; //now log-in process is finished, start download specified routes in list for (int i = 0; i < RouteTags.Count; i++) { //Defining JSON file names for route data - initial filepath = jsonfolderpath + RouteTags[i] + "-" + SSUtil.DateTimeNamingFormat(startTime.ToLocalTime()) + "-" + SSUtil.DateTimeNamingFormat(endTime.ToLocalTime()) + @".json"; if (!(File.Exists(filepath) && !online)) // skip download if in offline mode, and file does exist { //if download is needed, and username hasn't been inputted, asks for user info if (usernameCVST == "" || usernameCVST == null || passwordCVST == "" || passwordCVST == null) { bool userFlag = true; while (userFlag) { userFlag = !userAccessCVST(); } } //0. check if cd is already open, if not, open it as it will be needed if (cd_closed) { //Run selenium only if online mode is on or file does not exist //web driver will open once, until quitWebCrawler() is called cd = new ChromeDriver(); //must have installed chrome driver via nuget // log-in process cd.Url = @"http://portal.cvst.ca/login"; cd.Navigate(); IWebElement e = cd.FindElementByName("username"); e.SendKeys(usernameCVST); e = cd.FindElementByName("password"); e.SendKeys(passwordCVST); //e.SendKeys(Keys.Enter);//workaround if below line doesn't work e = cd.FindElementByXPath("/html/body/div/div/div/div/div[2]/form/fieldset/input");//can inspect and copy the element xpath in chrome e.Click(); cd_closed = false; //cd is now open, it'll remain open until uitWebCrawler() is called. } // 1. Download json file from web webCrawlerRepeatRequest: try { long timeDifference = SSUtil.DateTimeToEpochTime(endTime) - SSUtil.DateTimeToEpochTime(startTime); int num_packets = (int)Math.Ceiling((double)timeDifference / (double)timeIncre); DateTime intermediateStartTime = startTime; DateTime intermediateEndTime = endTime.AddSeconds(-(num_packets - 1) * timeIncre); for (int n = 0; n < num_packets; n++) { // 1. Download json file from web baseGPSURI = "tag/" + RouteTags[i]; appendURI = baseGPSURI + @"?starttime=" + SSUtil.DateTimeToEpochTime(intermediateStartTime.ToUniversalTime()) + @"&endtime=" + SSUtil.DateTimeToEpochTime(intermediateEndTime.ToUniversalTime()); uriToDownload = new Uri(uri_CVSTbase, appendURI); cd.Url = Convert.ToString(uriToDownload); json = cd.PageSource; json = json.Substring(121, json.Length - 121); //get rid of extra characters at the front json = json.Substring(0, json.Length - 22); //get rid of extra characters at the end packetsOfGPSDataForRoutes.AddRange(JsonConvert.DeserializeObject <List <JSONVehLoc> >(json)); intermediateStartTime = intermediateEndTime; intermediateEndTime = intermediateEndTime.AddSeconds(timeIncre); } serializer = new JsonSerializer(); using (StreamWriter sw = new StreamWriter(filepath)) { using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; serializer.Serialize(writer, packetsOfGPSDataForRoutes); packetsOfGPSDataForRoutes = null;//clear list packetsOfGPSDataForRoutes = new List <JSONVehLoc>(); } } } catch (WebDriverException e1)//bad request, try again { goto webCrawlerRepeatRequest; } catch (JsonSerializationException e2)//bad string, try again { goto webCrawlerRepeatRequest; } } // 3. Deserialize json data from local and append to master GPS data object // read directly from file, no string used //StreamReader file = File.OpenText(filepath); //serializer = new JsonSerializer(); //packageOfGPSDataForRoutes.AddRange((List<JSONVehLoc>)serializer.Deserialize(file, typeof(List<JSONVehLoc>))); string jsonString = File.ReadAllText(filepath); packageOfGPSDataForRoutes.AddRange((List <JSONVehLoc>)JsonConvert.DeserializeObject(jsonString, typeof(List <JSONVehLoc>))); /* post-process for GPS data that are outside of city area - uses TorontoCentroid and a radius*/ /* Toronto Centroid: 43.7, -79.4 */ foreach (JSONVehLoc aPoint in packageOfGPSDataForRoutes) { double distFromTorontoCentroid = SSUtil.GetGlobeDistance(TorontoCentroid.Latitude, TorontoCentroid.Longitude, aPoint.coordinates[1], aPoint.coordinates[0]); if (distFromTorontoCentroid < TorontoRadius) { finalPackageOfGPSDataForRoutes.Add(aPoint); } } } return(convertRawGPSToSSFormat(finalPackageOfGPSDataForRoutes)); }
public int startLiveDownloadTask(DateTime pollingStart, DateTime pollingEnd, double pollingFrequency) { lasttimeTimeURLField = 0; int downloadState = 0; //NOTE: polling freq: 19s < bk freq: 60s < save freq: 3600s downloadedGPSXMLData_UNSAVED = new ConcurrentDictionary <Tuple <long, string>, Vehicle>(); //GPSTime & VehID as tuple index DateTime nextDownloadTime; // = DateTime.Now.ToLocalTime().AddSeconds(pollingFrequency); DateTime nextBackupTime; // = DateTime.Now.ToLocalTime().AddSeconds(bkSaveFreq); //DateTime nextSaveTime = DateTime.Now.ToLocalTime().AddSeconds(fileSaveFreq); DateTime nextSaveTime; // = pollingStart.Date.AddSeconds(pollingStart.Hour * 3600 - 1 + fileSaveFreq);//save on the last second of the next hour long lastLogUpdatedSave = 0; string bkfilename = "current-GPSXML-bk.xml"; ////load last saved backup, if it is from within the last 5 minutes //if ((DateTime.Now.DateTimeToEpochTime() - File.GetLastWriteTime(bkfilename).DateTimeToEpochTime()) < (5 * 60)) //{ // List<Vehicle> bkGPSPoints = new List<Vehicle>(); // bkGPSPoints = DeSerializeXMLObject<List<Vehicle>>(xmlGPSFolderPath + bkfilename); // foreach (Vehicle aGPSPoint in bkGPSPoints) // { // downloadedGPSXMLData_UNSAVED.AddOrUpdate(new Tuple<long, string>(aGPSPoint.GPStime, aGPSPoint.Id), aGPSPoint, (k, v) => aGPSPoint);//replaces existing if it exists // } //} if (pollingStart.DateTimeToEpochTime() >= DateTime.Now.ToLocalTime().DateTimeToEpochTime())//future download - put thread to sleep until start - proper state { //return pollingStart.DateTimeToEpochTime() - downloadStartTime.DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * (pollingStart.DateTimeToEpochTime() - DateTime.Now.ToLocalTime().DateTimeToEpochTime() - 1))); nextDownloadTime = pollingStart.AddSeconds(0); nextBackupTime = pollingStart.AddSeconds(0); nextSaveTime = pollingStart.Date.AddSeconds(pollingStart.Hour * 3600 - 1 + fileSaveFreq); //assume file save frequency is at the hour } else if ((pollingStart.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) && (pollingEnd.DateTimeToEpochTime() > DateTime.Now.ToLocalTime().DateTimeToEpochTime())) //some missing downloads - start period is before download can take place { //polling reschedule message LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("NextBus Polling to Start at: {0}.", DateTime.Now.ToLocalTime().Date.AddSeconds(DateTime.Now.ToLocalTime().Hour * 3600 + fileSaveFreq).DateTimeISO8601Format()); OnLogUpdate(args); Thread.Sleep(Convert.ToInt32(1000 * (3600 - (DateTime.Now.ToLocalTime().Minute * 60 + DateTime.Now.ToLocalTime().Second - 1)))); downloadState = -1; nextDownloadTime = DateTime.Now.ToLocalTime(); nextBackupTime = DateTime.Now.ToLocalTime(); nextSaveTime = DateTime.Now.ToLocalTime().Date.AddSeconds(DateTime.Now.ToLocalTime().Hour * 3600 - 1 + fileSaveFreq);//assume file save frequency is at the hour } else //if (pollingEnd.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime())//nothing to download - end period is before download can take place { nextDownloadTime = new DateTime(); nextBackupTime = new DateTime(); nextSaveTime = new DateTime(); downloadState = -2; return(downloadState); } //initial save message if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("NextBus Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } //download started after a proper wait - proper state, or start immediate if some data can be downloaded (state: -1) while (pollingEnd.DateTimeToEpochTime() >= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { List <long> nextOpTime = new List <long>(); nextOpTime.Add(nextDownloadTime.DateTimeToEpochTime()); nextOpTime.Add(nextBackupTime.DateTimeToEpochTime()); nextOpTime.Add(nextSaveTime.DateTimeToEpochTime()); nextOpTime.Sort(); if ((nextOpTime[0] > DateTime.Now.ToLocalTime().DateTimeToEpochTime())) { if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("NextBus Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } long sleepTime = nextOpTime[0] - DateTime.Now.ToLocalTime().DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * sleepTime));//brief sleep in between operations } //this condition structure prioritize download to mem, then backup, then save if (nextDownloadTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextDownloadTime = nextDownloadTime.AddSeconds(pollingFrequency); downloadCurrentGPSXMLFromWeb(pollingFrequency); //List<Vehicle> newGPSPoints = downloadCurrentGPSXMLFromWeb(pollingFrequency); //foreach (Vehicle aGPSPoint in newGPSPoints) //{ // downloadedGPSXMLData_UNSAVED.AddOrUpdate(new Tuple<long, string>(aGPSPoint.GPStime, aGPSPoint.Id), aGPSPoint, (k, v) => aGPSPoint);//replaces existing if it exists //} } else if (nextBackupTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextBackupTime = nextBackupTime.AddSeconds(bkSaveFreq); SSUtil.SerializeXMLObject(downloadedGPSXMLData_UNSAVED.Values.ToList(), xmlGPSFolderPath + bkfilename); } else if (nextSaveTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { if (downloadedGPSXMLData_UNSAVED.Values.Count > 0)//avoid saving empty file { string newfilename = string.Format(xmlGPSFilenameFormat, nextSaveTime.AddSeconds(-fileSaveFreq + 1).ToUniversalTime().DateTimeNamingFormat(), nextSaveTime.ToUniversalTime().DateTimeNamingFormat()); SSUtil.SerializeXMLObject(downloadedGPSXMLData_UNSAVED.Values.ToList(), xmlGPSFolderPath + newfilename); downloadedGPSXMLData_UNSAVED.Clear();//clear mem } nextSaveTime = nextSaveTime.AddSeconds(fileSaveFreq); } } return(downloadState); //downloadState = -2;//no download has taken place, date out of range //downloadState = -1;//download completed with some error - some missing data //downloadState = 0;//download completed with no error }
public int startLiveDownloadTask(DateTime pollingStart, DateTime pollingEnd, double pollingFrequency) { //fileSaveFreq must be 1 day, otherwise, needs to modify nextSaveTime int downloadState = 0; //NOTE: polling freq: 60s < bk freq: 120s < save freq: 3600s * 24 = 1 day downloadedINCIXMLData_UNSAVED = new ConcurrentDictionary <string, Closure>(); //INCITime & VehID as tuple index DateTime nextDownloadTime; // = DateTime.Now.ToLocalTime().AddSeconds(pollingFrequency); DateTime nextBackupTime; // = DateTime.Now.ToLocalTime().AddSeconds(bkSaveFreq); //DateTime nextSaveTime = DateTime.Now.ToLocalTime().AddSeconds(fileSaveFreq); DateTime nextSaveTime; // = pollingStart.Date.AddSeconds(pollingStart.Hour * 3600 - 1 + fileSaveFreq);//save on the last second of the next hour long lastLogUpdatedSave = 0; string bkfilename = "current-RRXML-bk.xml"; //load last saved backup, if it is from within the last 5 minutes if ((DateTime.Now.DateTimeToEpochTime() - File.GetLastWriteTime(bkfilename).DateTimeToEpochTime()) < (5 * 60)) { List <Closure> bkINCIPoints = new List <Closure>(); bkINCIPoints = SSUtil.DeSerializeXMLObject <List <Closure> >(xmlINCIFolderPath + bkfilename); foreach (Closure aINCIPoint in bkINCIPoints) { downloadedINCIXMLData_UNSAVED.AddOrUpdate(aINCIPoint.Id, aINCIPoint, (k, v) => aINCIPoint);//replaces existing if it exists } } if (pollingStart.DateTimeToEpochTime() >= DateTime.Now.ToLocalTime().DateTimeToEpochTime())//future download - put thread to sleep until start - proper state { //return pollingStart.DateTimeToEpochTime() - downloadStartTime.DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * (pollingStart.DateTimeToEpochTime() - DateTime.Now.ToLocalTime().DateTimeToEpochTime() - 1))); nextDownloadTime = pollingStart.AddSeconds(0); nextBackupTime = pollingStart.AddSeconds(0); nextSaveTime = DateTime.Now.ToLocalTime().Date.AddSeconds(-1 + fileSaveFreq); //asume save frequencies are in the scale of days, save at midnighht } else if ((pollingStart.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) && (pollingEnd.DateTimeToEpochTime() > DateTime.Now.ToLocalTime().DateTimeToEpochTime())) //some missing downloads - start period is before download can take place { //download at next hour, catch whatever data can be retrived. //Thread.Sleep(Convert.ToInt32(1000 * (3600 - (DateTime.Now.ToLocalTime().Minute * 60 + DateTime.Now.ToLocalTime().Second) - 1))); downloadState = -1; nextDownloadTime = DateTime.Now.ToLocalTime().AddSeconds(0); //no delay for download nextBackupTime = DateTime.Now.ToLocalTime().AddSeconds(0); //no delay for backup nextSaveTime = DateTime.Now.ToLocalTime().Date.AddSeconds(-1 + fileSaveFreq); //asume save frequencies are in the scale of days, save at midnighht } else //if (pollingEnd.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime())//nothing to download - end period is before download can take place { nextDownloadTime = new DateTime(); nextBackupTime = new DateTime(); nextSaveTime = new DateTime(); downloadState = -2; return(downloadState); } //initial save message if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("Rd Closures Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } //download started after a proper wait - proper state, or start immediate if some data can be downloaded (state: -1) while (pollingEnd.DateTimeToEpochTime() >= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { List <long> nextOpTime = new List <long>(); nextOpTime.Add(nextDownloadTime.DateTimeToEpochTime()); nextOpTime.Add(nextBackupTime.DateTimeToEpochTime()); nextOpTime.Add(nextSaveTime.DateTimeToEpochTime()); nextOpTime.Sort(); if ((nextOpTime[0] > DateTime.Now.ToLocalTime().DateTimeToEpochTime())) { if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("Rd Closures Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } long sleepTime = nextOpTime[0] - DateTime.Now.ToLocalTime().DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * sleepTime));//brief sleep in between operations } //this condition structure prioritize download to mem, then backup, then save if (nextDownloadTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextDownloadTime = nextDownloadTime.AddSeconds(pollingFrequency); downloadCurrentINCIXMLFromWeb(pollingFrequency); //List < Closure > newINCIPoints = downloadCurrentINCIXMLFromWeb(pollingFrequency); //foreach (Closure aINCIPoint in downloadedINCIXML) //{ // downloadedINCIXMLData_UNSAVED.AddOrUpdate(aINCIPoint.Id, aINCIPoint, (k, v) => aINCIPoint);//replaces existing if it exists //} } else if (nextBackupTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextBackupTime = nextBackupTime.AddSeconds(bkSaveFreq); SSUtil.SerializeXMLObject(downloadedINCIXMLData_UNSAVED.Values.ToList(), xmlINCIFolderPath + bkfilename); } else if (nextSaveTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { if (downloadedINCIXMLData_UNSAVED.Values.Count > 0)//avoid saving empty file { string newfilename = string.Format(xmlINCIFilenameFormat, nextSaveTime.AddSeconds(-fileSaveFreq + 1).ToUniversalTime().DateTimeNamingFormat(), nextSaveTime.ToUniversalTime().DateTimeNamingFormat()); SSUtil.SerializeXMLObject(downloadedINCIXMLData_UNSAVED.Values.ToList(), xmlINCIFolderPath + newfilename); downloadedINCIXMLData_UNSAVED.Clear();//clear mem } nextSaveTime = nextSaveTime.AddSeconds(fileSaveFreq); } } return(downloadState); //downloadState = -2;//no download has taken place, date out of range //downloadState = -1;//download completed with some error - some missing data //downloadState = 0;//download completed with no error }
public static void Execute() { SSUtil.Log("executing {0}", typeof(T05_matrix).Name); // testing correctness ResetRandomly(); Matrix4x4 r0 = _m1 * _m2; Matrix4x4 r1 = SSMatrix.Mul_v1_naive(_m1, _m2); Matrix4x4 r2 = SSMatrix.Mul_v2_naive_expanded(_m1, _m2); Matrix4x4 r3 = Matrix4x4.zero; SSMatrix.Mul_v3_ref(ref r3, ref _m1, ref _m2); SSUtil.Assert(r0 == r1, "matrix r1 bad result."); SSUtil.Assert(r0 == r2, "matrix r2 bad result."); SSUtil.Assert(r0 == r3, "matrix r3 bad result."); // 'Mul_v4_for_3d_trans' always produce the same 4th row Matrix4x4 r4 = Matrix4x4.zero; SSMatrix.Mul_v4_for_3d_trans(ref r4, ref _m1, ref _m2); Matrix4x4 r4_target = r0; r4_target.SetRow(3, new Vector4(0.0f, 0.0f, 0.0f, 1.0f)); SSUtil.Assert(r4 == r4_target, "matrix r4 bad result."); // testing performances Matrix4x4 ret = Matrix4x4.zero; ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_mul: Unity Built-In_")) { for (int i = 0; i < NUM; i++) { ret = _m1 * _m2; } } ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_mul: v1 - Naive Implementation_")) { for (int i = 0; i < NUM; i++) { ret = SSMatrix.Mul_v1_naive(_m1, _m2); } } ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_mul: v2 - Naive (Expanded)_")) { for (int i = 0; i < NUM; i++) { ret = SSMatrix.Mul_v2_naive_expanded(_m1, _m2); } } ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_mul: v3 - ref passed & returned_")) { for (int i = 0; i < NUM; i++) { SSMatrix.Mul_v3_ref(ref ret, ref _m1, ref _m2); } } ResetRandomly(); using (SSTimer t = new SSTimer("_test_mat_mul: v4 - for 3d transform only_")) { for (int i = 0; i < NUM; i++) { SSMatrix.Mul_v4_for_3d_trans(ref ret, ref _m1, ref _m2); } } }
public int startLiveDownloadTask(DateTime pollingStart, DateTime pollingEnd, double pollingFrequency) { int downloadState = 0; //NOTE: polling freq: 60s < bk freq: 120s < save freq: 3600s * 24 = 1 day downloadedWeatherJSONData_UNSAVED = new ConcurrentDictionary <Tuple <int, long>, List>(); //INCITime & VehID as tuple index downloadedForecastWeatherJSONData_UNSAVED = new ConcurrentDictionary <Tuple <int, long>, List>(); //INCITime & VehID as tuple index List <List> lastDownloadedData = new List <List>(); //check actual data downloaded - a package of last downloaded data long currentServerDelay; //lastDownloadedData.list[1].dt DateTime currentServerDownloadTime; DateTime nextDownloadTime; // = DateTime.Now.ToLocalTime().AddSeconds(pollingFrequency); DateTime nextForecastDownloadTime; // = DateTime.Now.ToLocalTime().AddSeconds(pollingFrequency); double forecast_pollingFrequency = 10 * 60; //poll every hour DateTime nextBackupTime; // = DateTime.Now.ToLocalTime().AddSeconds(bkSaveFreq); //DateTime nextSaveTime = DateTime.Now.ToLocalTime().AddSeconds(fileSaveFreq); DateTime nextSaveTime; // = pollingStart.Date.AddSeconds(pollingStart.Hour * 3600 - 1 + fileSaveFreq);//save on the last second of the next hour - time stamp save DateTime nextActualSaveTime; // = pollingStart.Date.AddSeconds(pollingStart.Hour * 3600 - 1 + fileSaveFreq);//appropriate save time based on server delay! long lastLogUpdatedSave = 0; string bkfilename = "current-WeatherJSON-bk.json"; //load last saved backup, if it is from within the last 5 minutes if (File.Exists(jsonWeatherFolderPath + bkfilename) && File.Exists(jsonForecastWeatherFolderPath + bkfilename)) { if ((DateTime.Now.DateTimeToEpochTime() - File.GetLastWriteTime(jsonWeatherFolderPath + bkfilename).DateTimeToEpochTime()) < (5 * 60)) { List <List> bkWeatherPoints = new List <List>(); bkWeatherPoints = DeSerializeJSONObject <List <List> >(jsonWeatherFolderPath + bkfilename); foreach (List aWeatherPoint in bkWeatherPoints) { downloadedWeatherJSONData_UNSAVED.AddOrUpdate(new Tuple <int, long>(aWeatherPoint.id, aWeatherPoint.dt), aWeatherPoint, (k, v) => aWeatherPoint);//replaces existing if it exists } bkWeatherPoints = DeSerializeJSONObject <List <List> >(jsonForecastWeatherFolderPath + bkfilename); foreach (List aWeatherPoint in bkWeatherPoints) { downloadedForecastWeatherJSONData_UNSAVED.AddOrUpdate(new Tuple <int, long>(aWeatherPoint.id, aWeatherPoint.dt), aWeatherPoint, (k, v) => aWeatherPoint);//replaces existing if it exists } } } downloadCurrentWeatherJSONFromWeb(); currentServerDownloadTime = downloadedWeatherJSONData_UNSAVED.Count == 0 ? DateTime.Now : SSUtil.EpochTimeToLocalDateTime(downloadedWeatherJSONData_UNSAVED.Values.Select(c => c.dt).ToList().Max()); currentServerDelay = DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDownloadTime.DateTimeToEpochTime(); //in secs //server delay will be accounted for, in the next polling request --> a delay results in later start and later stop download time if (pollingStart.DateTimeToEpochTime() >= (DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDelay)) //future download - put thread to sleep until start - proper state { while (pollingStart.DateTimeToEpochTime() >= (DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDelay)) { //return pollingStart.DateTimeToEpochTime() - downloadStartTime.DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * pollingFrequency)); //check delay at polling frequency (minute), until it is time for download downloadCurrentWeatherJSONFromWeb(); //lastDownloadedData = currentServerDownloadTime = downloadedWeatherJSONData_UNSAVED.Count == 0 ? DateTime.Now : SSUtil.EpochTimeToLocalDateTime(downloadedWeatherJSONData_UNSAVED.Values.Select(c => c.dt).ToList().Max()); currentServerDelay = DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDownloadTime.DateTimeToEpochTime(); //in secs } //start late as per server delays nextDownloadTime = pollingStart.AddSeconds(0 + currentServerDelay); nextForecastDownloadTime = pollingStart.AddSeconds(0); nextBackupTime = pollingStart.AddSeconds(0); //no delay for backup nextActualSaveTime = pollingStart.Date.AddSeconds(-1 + fileSaveFreq + currentServerDelay); //assume file save frequency is at the hour nextSaveTime = DateTime.Now.ToLocalTime().Date.AddSeconds(-1 + fileSaveFreq); //asume save frequencies are in the scale of days } else if ((pollingStart.DateTimeToEpochTime() <= (DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDelay)) && (pollingEnd.DateTimeToEpochTime() > (DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDelay))) //some missing downloads - start period is before download can take place { //start late as per server delays - save at the hour, polling appropriately downloadState = -1; nextDownloadTime = DateTime.Now.ToLocalTime().AddSeconds(0); //no delay for download nextForecastDownloadTime = DateTime.Now.ToLocalTime().AddSeconds(0); //no delay for download nextBackupTime = DateTime.Now.ToLocalTime().AddSeconds(0); //no delay for backup nextSaveTime = DateTime.Now.ToLocalTime().Date.AddSeconds(-1 + fileSaveFreq); //asume save frequencies are in the scale of days nextActualSaveTime = nextSaveTime.AddSeconds(currentServerDelay); //assume file save frequency is at the hour } else //if (pollingEnd.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime())//nothing to download - end period is before download can take place { downloadState = -2; return(downloadState); } //initial save message if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("Weather Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } //download started after a proper wait - proper state, or start immediate if some data can be downloaded (state: -1) while (pollingEnd.DateTimeToEpochTime() >= (DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDelay))//delay completion of survey as per server delay { List <long> nextOpTime = new List <long>(); nextOpTime.Add(nextDownloadTime.DateTimeToEpochTime()); nextOpTime.Add(nextForecastDownloadTime.DateTimeToEpochTime()); nextOpTime.Add(nextBackupTime.DateTimeToEpochTime()); //nextOpTime.Add(nextSaveTime.DateTimeToEpochTime()); nextOpTime.Add(nextActualSaveTime.DateTimeToEpochTime()); nextOpTime.Sort();//ascending if ((nextOpTime[0] > DateTime.Now.ToLocalTime().DateTimeToEpochTime())) { if (lastLogUpdatedSave != nextSaveTime.DateTimeToEpochTime()) { lastLogUpdatedSave = nextSaveTime.DateTimeToEpochTime(); LogUpdateEventArgs args = new LogUpdateEventArgs(); args.logMessage = String.Format("Weather Upcoming Save: {0}.", nextSaveTime.DateTimeISO8601Format()); OnLogUpdate(args); } long sleepTime = nextOpTime[0] - DateTime.Now.ToLocalTime().DateTimeToEpochTime(); Thread.Sleep(Convert.ToInt32(1000 * sleepTime));//brief sleep in between operations } //this condition structure prioritize download to mem, then backup, then save //Download - current weather if (nextDownloadTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextDownloadTime = DateTime.Now.AddSeconds(pollingFrequency); //nextDownloadTime.AddSeconds(pollingFrequency); downloadCurrentWeatherJSONFromWeb(); //List<List> newWeatherPoints = currentServerDownloadTime = downloadedWeatherJSONData_UNSAVED.Count == 0 ? DateTime.Now : SSUtil.EpochTimeToLocalDateTime(downloadedWeatherJSONData_UNSAVED.Values.Select(c => c.dt).ToList().Max()); if ((DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDownloadTime.DateTimeToEpochTime()) > 0) //data cannot be from the future { currentServerDelay = DateTime.Now.ToLocalTime().DateTimeToEpochTime() - currentServerDownloadTime.DateTimeToEpochTime(); //in secs } else { currentServerDelay = 0; } //update next save time based on server delay nextActualSaveTime = nextSaveTime.AddSeconds(currentServerDelay);//approximated next actual save time } //Download - Forecast weather if (nextForecastDownloadTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextForecastDownloadTime = DateTime.Now.AddSeconds(forecast_pollingFrequency); //nextDownloadTime.AddSeconds(pollingFrequency); downloadCurrentWeatherJSONFromWeb(true); //List<List> newWeatherPoints = } //Backup if (nextBackupTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { nextBackupTime = DateTime.Now.Subtract(nextBackupTime).TotalSeconds > bkSaveFreq?DateTime.Now.AddSeconds(bkSaveFreq) : nextBackupTime.AddSeconds(bkSaveFreq); SerializeJSONObject(downloadedWeatherJSONData_UNSAVED.Values.ToList(), jsonWeatherFolderPath + bkfilename); SerializeJSONObject(downloadedForecastWeatherJSONData_UNSAVED.Values.ToList(), jsonForecastWeatherFolderPath + bkfilename); } //Save if (nextActualSaveTime.DateTimeToEpochTime() <= DateTime.Now.ToLocalTime().DateTimeToEpochTime()) { if (downloadedWeatherJSONData_UNSAVED.Values.Count > 0)//avoid saving empty file { string newfilename = string.Format(jsonWeatherFilenameFormat, nextSaveTime.AddSeconds(-fileSaveFreq + 1).ToUniversalTime().DateTimeNamingFormat(), nextSaveTime.ToUniversalTime().DateTimeNamingFormat()); SerializeJSONObject(downloadedWeatherJSONData_UNSAVED.Values.ToList(), jsonWeatherFolderPath + newfilename); SerializeJSONObject(downloadedForecastWeatherJSONData_UNSAVED.Values.ToList(), jsonForecastWeatherFolderPath + newfilename); downloadedWeatherJSONData_UNSAVED.Clear(); //clear mem downloadedForecastWeatherJSONData_UNSAVED.Clear(); //clear mem } nextSaveTime = nextSaveTime.AddSeconds(fileSaveFreq); //next save time stamp nextActualSaveTime = nextSaveTime.AddSeconds(currentServerDelay); //approximated next actual save time } } //clear backupFiles return(downloadState); //downloadState = -2;//no download has taken place, date out of range //downloadState = -1;//download completed with some error - some missing data //downloadState = 0;//download completed with no error }
public ConcurrentDictionary <int, SSINTNXSignalDataTable> getCombinedIntxnData() { ConcurrentDictionary <int, SSINTNXSignalDataTable> combinedTable = new ConcurrentDictionary <int, SSINTNXSignalDataTable>(); //try //{ //read all Intxn data sheets from xml //traffic_signals.xml if (trafficSignalsFilePath != null) { Traffic_signals trafficSignalData = SSUtil.DeSerializeXMLObject <Traffic_signals>(trafficSignalsFilePath); foreach (RecordTrafficSignals records in trafficSignalData.Record) { int pxID = Convert.ToInt32(records.Px); SSINTNXSignalDataTable commonData = combinedTable.ContainsKey(pxID) ? combinedTable[pxID] : new SSINTNXSignalDataTable(); commonData.pxID = pxID; commonData.mainStreet = records.Main; commonData.midblockStreet = records.Mid_block; commonData.sideStreet1 = records.Side1; commonData.sideStreet2 = records.Side2; commonData.Latitude = Convert.ToDouble(records.Lat); commonData.Longitude = Convert.ToDouble(records.Long); commonData.signal_system = records.Signal_system; commonData.mode_of_control = records.Mode_of_control; commonData.isNotFXT = records.Mode_of_control.Contains("FXT") ? false : true; commonData.transit_preempt = records.Transit_preempt.Contains("1") ? true : false; commonData.fire_preempt = records.Fire_preempt.Contains("1") ? true : false; commonData.Rail_preempt = records.Rail_preempt.Contains("1") ? true : false; int noOfApproaches = records.No_of_signalized_approaches.Length == 1 ? Convert.ToInt32(records.No_of_signalized_approaches) : 0; commonData.vehVol = -1; //no volume default commonData.pedVol = -1; //no volume default commonData.no_of_signalized_approaches = noOfApproaches; commonData.isSignalizedIntxn = true; commonData.isPedCross = false; commonData.isFlasingBeacons = false; combinedTable.AddOrUpdate(pxID, commonData, (k, v) => v); } } //pedestrian_crossovers.xml if (pedCrossoverFilePath != null) { Pedestrian_crossovers pedCrossData = SSUtil.DeSerializeXMLObject <Pedestrian_crossovers>(pedCrossoverFilePath); foreach (RecordPedCross records in pedCrossData.Record) { int pxID = Convert.ToInt32(records.Px); SSINTNXSignalDataTable commonData; if (combinedTable.ContainsKey(pxID)) { commonData = combinedTable[pxID]; } else { commonData = new SSINTNXSignalDataTable(); commonData.pxID = pxID; commonData.mainStreet = records.Main; commonData.midblockStreet = records.Midblock; commonData.sideStreet1 = records.Side1; commonData.sideStreet2 = records.Side2; commonData.Latitude = Convert.ToDouble(records.Lat); commonData.Longitude = Convert.ToDouble(records.Long); commonData.no_of_signalized_approaches = 2; commonData.vehVol = -1; //no volume default commonData.pedVol = -1; //no volume default } commonData.isSignalizedIntxn = false; commonData.isPedCross = true; commonData.isFlasingBeacons = false; combinedTable.AddOrUpdate(pxID, commonData, (k, v) => v); } } //flashing_beacons.xml if (flashingBeaconFilePath != null) { Flashing_beacons flashingBeaconData = SSUtil.DeSerializeXMLObject <Flashing_beacons>(flashingBeaconFilePath); foreach (RecordFlashingBeacons records in flashingBeaconData.Record) { int pxID = Convert.ToInt32(records.Px); SSINTNXSignalDataTable commonData; if (combinedTable.ContainsKey(pxID)) { commonData = combinedTable[pxID]; } else { commonData = new SSINTNXSignalDataTable(); commonData.pxID = pxID; commonData.mainStreet = records.Main; commonData.midblockStreet = records.Midblock; commonData.sideStreet1 = records.Side1; commonData.sideStreet2 = records.Side2; commonData.Latitude = Convert.ToDouble(records.Lat); commonData.Longitude = Convert.ToDouble(records.Long); commonData.no_of_signalized_approaches = 2; commonData.vehVol = -1; //no volume default commonData.pedVol = -1; //no volume default } commonData.isSignalizedIntxn = false; commonData.isPedCross = false; commonData.isFlasingBeacons = true; combinedTable.AddOrUpdate(pxID, commonData, (k, v) => v); } } //traffic_vols.xml if (trafficVolFilePath != null) { Traffic_vols trafficVolData = SSUtil.DeSerializeXMLObject <Traffic_vols>(trafficVolFilePath); foreach (RecordTrafficVols records in trafficVolData.Record) { int pxID = Convert.ToInt32(records.Px); SSINTNXSignalDataTable commonData; if (combinedTable.ContainsKey(pxID)) { commonData = combinedTable[pxID]; } else { commonData = new SSINTNXSignalDataTable(); commonData.pxID = pxID; commonData.mainStreet = records.Main; commonData.midblockStreet = records.Midblock; commonData.sideStreet1 = records.Side1; commonData.sideStreet2 = records.Side2; commonData.Latitude = Convert.ToDouble(records.Lat); commonData.Longitude = Convert.ToDouble(records.Long); commonData.signal_system = "unknownFromVolFile"; commonData.mode_of_control = "unknownFromVolFile"; commonData.isNotFXT = false; commonData.transit_preempt = false; commonData.fire_preempt = false; commonData.Rail_preempt = false; int noOfApproaches = (commonData.midblockStreet.Length > 0) ? 2 : ((commonData.sideStreet2.Contains("PRIVATE ACCESS")) ? 3 : 4); //estimates commonData.no_of_signalized_approaches = noOfApproaches; commonData.isSignalizedIntxn = true; //assumes only signalized intersection has volume measurements commonData.isPedCross = false; commonData.isFlasingBeacons = false; } commonData.countDate = DateTime.ParseExact(records.CountDate, "M-d-yyyy", System.Globalization.CultureInfo.InvariantCulture); string vehVol = Regex.Replace(records.VehVol8Hr, @"\s+", ""); commonData.vehVol = Convert.ToInt32(vehVol); string pedVol = Regex.Replace(records.PedVol8Hr, @"\s+", ""); commonData.pedVol = Convert.ToInt32(pedVol); combinedTable.AddOrUpdate(pxID, commonData, (k, v) => v); } } //} //catch (Exception e) //{ // return null; //} return(combinedTable); }
public void Dispose() { _stopWatch.Stop(); SSUtil.Log("'{0}' exec time: {1:0.000} (ms)", _tag, ((double)_stopWatch.ElapsedTicks / (double)Stopwatch.Frequency) * 1000); }