private void readString(string datastring) { //Keep a datapoint DataPoint dp = new DataPoint(); //split string into words array string[] words = datastring.Split(new char[] { ' ', '\n' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < words.Length; i++) { switch (words[i].Trim()) { //time case "{\"ts\":": i++; string strq = words[i]; string strReplaceq = strq.Replace("\"", "").Trim(); string strReplace1q = strReplaceq.Replace(",", "").Trim(); dp.setTime(strReplace1q); //Debug.Log(strReplace1q); break; //resouces case "\"resources\":": bool done = false; while (!done) { i++; switch (words[i].Trim()) { //1st tag case TAG_SOURCE_ID: i += 3; string tag1 = parseTag(words, i); i += 15; dp.setFirstId(tag1); //Debug.Log(tag1); break; //2nd tag case TAG_DEST_ID: i += 3; string tag2 = parseTag(words, i); i += 15; dp.setSecondId(tag2); //Debug.Log(tag2); break; //distance case DIST_VAL_ID: i += 2; string dist = words[i].Trim(); //Debug.Log(dist); string strReplacew = dist.Replace("}", "").Trim(); string strReplace1w = strReplacew.Replace(",", "").Trim(); dp.setDistance(strReplace1w); //Debug.Log(distNum); break; //unit case DIST_UNITS_ID: done = true; break; } } break; //all other symbols default: break; } //If we have all four necessary pieces of data if (dp.hasAllExceptTime()) { //Debug.Log("Adding new DataPoint"); //Add this DataPoint to the queue dataQueue.Enqueue(dp); //Reset the one we're currently working on dp = new DataPoint(); } } firstTime = dataQueue.Peek().getTime(); startTime = DateTime.Now; //Debug.Log("Finished enqueuing data"); }