private void AddIndexRange(string mnemonic, AbstractIndexValue start, AbstractIndexValue end, Dictionary <string, Range <double?> > ranges) { double?startValue = null; double?endValue = null; if (start is TimeIndexValue) { var startTime = (TimeIndexValue)start; if (startTime.Time.HasValue) { startValue = startTime.Time.ToUnixTimeMicroseconds(); } var endTime = end as TimeIndexValue; if (endTime?.Time.HasValue ?? false) { endValue = endTime.Time.ToUnixTimeMicroseconds(); } } else if (start is DepthIndexValue) { var startDepth = (DepthIndexValue)start; if (startDepth.Depth.HasValue) { startValue = startDepth.Depth.Value; } var endDepth = end as DepthIndexValue; if (endDepth?.Depth.HasValue ?? false) { endValue = endDepth.Depth.Value; } } else { var startPass = start as PassIndexedDepth; if (startPass?.Depth.HasValue ?? false) { startValue = startPass.Depth.Value; } var endPass = end as PassIndexedDepth; if (endPass?.Depth.HasValue ?? false) { endValue = endPass.Depth.Value; } } ranges.Add(mnemonic, new Range <double?>(startValue, endValue)); }
private AbstractIndexValue UpdateIndexValue(ChannelIndexType?indexType, AbstractIndexValue current, double value) { AbstractIndexValue indexValue; if (indexType == ChannelIndexType.datetime || indexType == ChannelIndexType.elapsedtime) { indexValue = current ?? new TimeIndexValue(); ((TimeIndexValue)indexValue).Time = DateTimeExtensions.FromUnixTimeMicroseconds((long)value); } else if (indexType == ChannelIndexType.passindexeddepth) { indexValue = current ?? new PassIndexedDepth(); ((PassIndexedDepth)indexValue).Depth = (float)value; } else { indexValue = current ?? new DepthIndexValue(); ((DepthIndexValue)indexValue).Depth = (float)value; } return(indexValue); }