public Read GetReadFromGraphTime(double pGraphTime) { double min = 9999, difference; double otherGraphTime; Read minRead = null; foreach (Read read in _DataReads) { otherGraphTime = InterruptionCycle.GetGraphTime(GraphStart, read.UTCTime, mNumCycles); difference = Math.Abs(otherGraphTime - pGraphTime); if (difference < min) { minRead = read; min = difference; } } return(minRead); }
public void CreateGraphReads() { if (!mIsMidCycleStartAllowed) { GraphStart = InterruptionCycle.GetNextCycleStart(_DataReads[0].UTCTime); } else { GraphStart = _DataReads[0].UTCTime; } GraphEnd = GraphStart.AddSeconds(InterruptionCycle.Length.TotalSeconds * mNumCycles); int setPosition; DateTime time, lastAdded = new DateTime(); double readValue; bool hasReachedEnd = false; bool repeatToFill = false; TimeSpan offset = new TimeSpan(); do { for (int i = 0; i < _DataReads.Count; ++i) { time = _DataReads[i].UTCTime.Add(offset); readValue = _DataReads[i].Value; if (time >= GraphStart && time <= GraphEnd && time > lastAdded) { setPosition = InterruptionCycle.GetSetPosition(time); mGraphReads[setPosition].Add(new GraphRead(readValue, InterruptionCycle.GetGraphTime(GraphStart, time, mNumCycles))); lastAdded = time; } if (time > GraphEnd) { hasReachedEnd = true; } } offset = offset.Add(InterruptionCycle.Length); } while (!hasReachedEnd && repeatToFill); }
public RISDataSet(string pFilePath, InterruptionCycle pInterruptionCycle) { if (!File.Exists(pFilePath)) { throw new ArgumentException("File does not exist!\n" + pFilePath); } InterruptionCycle = pInterruptionCycle; if (InterruptionCycle is MultiSetInterruptionCycle) { mNumCycles = 1; } else { mNumCycles = 20; } mIsMidCycleStartAllowed = true; mGraphReads = new Dictionary <int, List <GraphRead> >(); for (int i = 0; i < InterruptionCycle.Sets.Length; ++i) { mGraphReads.Add(i, new List <GraphRead>()); } FileName = Path.GetFileNameWithoutExtension(pFilePath); _DataReads = new List <Read>(); MaxValueData = float.MinValue; MinValueData = float.MaxValue; switch (Path.GetExtension(pFilePath)) { case ".csv": ReadMcMilleriBTVMFile(pFilePath); break; default: break; } }