protected int GetUDTArrayTypeMappingCount(ArrayMapping arrayMapping) { // UDT[] where each array element is the same mapping, but represent different times if (arrayMapping.WindowSize != 0.0M) { MeasurementKey[] keys; AlignmentCoordinator.SampleWindow sampleWindow = GetSampleWindow(arrayMapping, out keys); m_lastKeyIndex = m_keyIndex; m_cachedMapping = GetTypeMapping(arrayMapping); m_cachedFrames = AlignmentCoordinator.GetFrames(keys, CurrentFrameTime, sampleWindow); return(m_cachedFrames.Count); } // UDT[] where each array element is the same time (relative to now), but represent different mappings if (arrayMapping.RelativeTime != 0.0M) { MeasurementKey[] keys; AlignmentCoordinator.SampleWindow sampleWindow = GetSampleWindow(arrayMapping, out keys); CurrentFrame = AlignmentCoordinator.GetFrame(keys, CurrentFrameTime, sampleWindow); m_cachedMappings = MappingCompiler.EnumerateTypeMappings(arrayMapping.Expression).ToArray(); return(m_cachedMappings.Length); } // UDT[] where each array element is the same time, but represent different mappings m_cachedMappings = MappingCompiler.EnumerateTypeMappings(arrayMapping.Expression).ToArray(); return(m_cachedMappings.Length); }
protected List <MetaValues> CreateMetaValues(ArrayMapping arrayMapping) { MeasurementKey[] keys = m_keys[m_keyIndex++]; if (arrayMapping.WindowSize != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); MeasurementKey key = keys.Single(); return(AlignmentCoordinator.CreateMetaValues(key, m_currentFrameTime, sampleWindow)); } if (arrayMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); return(keys .Select(key => AlignmentCoordinator.CreateMetaValue(key, m_currentFrameTime, sampleWindow)) .ToList()); } return(keys .Select(key => new MetaValues() { ID = key.SignalID, Timestamp = m_currentFrameTime, Flags = MeasurementFlags.CalculatedValue }) .ToList()); }
protected IMeasurement GetMeasurement(FieldMapping fieldMapping) { IMeasurement measurement; if (fieldMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); MeasurementKey key = m_keys[m_keyIndex++].Single(); measurement = AlignmentCoordinator.GetMeasurement(key, CurrentFrameTime, sampleWindow); } else { measurement = SignalLookup.GetMeasurement(m_keys[m_keyIndex++].Single()); } // Set OverRangeError flag if the value of the measurement is NaN and the // destination field's type does not support NaN; this will set the UnreasonableValue // flag in the ECA MeasurementFlags of the MetaValues structure if (IsNaNOrInfinity(measurement.Value) && s_nonNanTypes.Contains($"{fieldMapping.Field.Type.Category}.{fieldMapping.Field.Type.Identifier}")) { measurement = new Measurement() { Metadata = measurement.Metadata, Timestamp = measurement.Timestamp, Value = 0.0D, StateFlags = measurement.StateFlags | MeasurementStateFlags.OverRangeError }; } return(measurement); }
protected Ticks GetRelativeFrameTime(FieldMapping fieldMapping) { IEnumerable <FieldMapping> signalMappings = m_mappingCompiler.TraverseSignalMappings(fieldMapping); MeasurementKey[] keys = signalMappings.SelectMany(mapping => SignalLookup.GetMeasurementKeys(mapping.Expression)).ToArray(); AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); return(sampleWindow.GetTimestamps(CurrentFrameTime).FirstOrDefault()); }
protected IDictionary <MeasurementKey, IMeasurement> GetRelativeFrame(FieldMapping fieldMapping) { IEnumerable <FieldMapping> signalMappings = MappingCompiler.TraverseSignalMappings(fieldMapping); MeasurementKey[] keys = signalMappings.SelectMany(mapping => SignalLookup.GetMeasurementKeys(mapping.Expression)).ToArray(); AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); return(AlignmentCoordinator.GetFrame(keys, CurrentFrameTime, sampleWindow)); }
protected int GetArrayMeasurementCount(ArrayMapping arrayMapping) { MeasurementKey[] keys = m_keys[m_keyIndex++]; if (arrayMapping.WindowSize != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); return(sampleWindow.GetTimestamps(m_currentFrameTime).Count); } return(keys.Length); }
protected IMeasurement GetMeasurement(FieldMapping fieldMapping) { if (fieldMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); MeasurementKey key = Keys[m_keyIndex++].Single(); return(AlignmentCoordinator.GetMeasurement(key, CurrentFrameTime, sampleWindow)); } return(SignalLookup.GetMeasurement(Keys[m_keyIndex++].Single())); }
protected int GetArrayMeasurementCount(ArrayMapping arrayMapping) { Lazy <bool> isNanType = new Lazy <bool>(() => { DataType underlyingType = (arrayMapping.Field.Type as ArrayType)?.UnderlyingType; return(!s_nonNanTypes.Contains($"{underlyingType?.Category}.{underlyingType?.Identifier}")); }); // Set OverRangeError flag if the value of the measurement is NaN and the // destination field's type does not support NaN; this will set the UnreasonableValue // flag in the ECA MeasurementFlags of the MetaValues structure Func <IMeasurement, IMeasurement> toNotNan = measurement => new Measurement() { Metadata = measurement.Metadata, Timestamp = measurement.Timestamp, Value = 0.0D, StateFlags = measurement.StateFlags | MeasurementStateFlags.OverRangeError }; if (arrayMapping.WindowSize != 0.0M) { // native[] where each array element is the same mapping, but represent different times AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); m_cachedMeasurements = AlignmentCoordinator .GetMeasurements(m_keys[m_keyIndex++].Single(), CurrentFrameTime, sampleWindow) .Select(measurement => (!IsNaNOrInfinity(measurement.Value) || isNanType.Value) ? measurement : toNotNan(measurement)) .ToArray(); } else if (arrayMapping.RelativeTime != 0.0M) { // native[] where each array element is the same time (relative to now), but represent different mappings AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); m_cachedMeasurements = m_keys[m_keyIndex++] .Select(key => AlignmentCoordinator.GetMeasurement(key, CurrentFrameTime, sampleWindow)) .Select(measurement => (!IsNaNOrInfinity(measurement.Value) || isNanType.Value) ? measurement : toNotNan(measurement)) .ToArray(); } else { // native[] where each array element is the same time, but represent different mappings m_cachedMeasurements = SignalLookup.GetMeasurements(m_keys[m_keyIndex++]) .Select(measurement => (!IsNaNOrInfinity(measurement.Value) || isNanType.Value) ? measurement : toNotNan(measurement)) .ToArray(); } return(m_cachedMeasurements.Length); }
protected MetaValues CreateMetaValues(FieldMapping fieldMapping) { if (fieldMapping.RelativeTime != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); MeasurementKey key = m_keys[m_keyIndex++].Single(); return(AlignmentCoordinator.CreateMetaValue(key, CurrentFrameTime, sampleWindow)); } return(new MetaValues() { ID = m_keys[m_keyIndex++].Single().SignalID, Timestamp = m_currentFrameTime, Flags = MeasurementFlags.CalculatedValue }); }
protected void PushWindowFrameTime(ArrayMapping arrayMapping) { if (arrayMapping.WindowSize != 0.0M) { AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); m_lastKeyIndex = m_keyIndex; m_cachedFrameTime = CurrentFrameTime; m_cachedFrameTimes = sampleWindow.GetTimestamps(m_currentFrameTime).ToArray(); m_cachedMapping = GetTypeMapping(arrayMapping); } else if (arrayMapping.RelativeTime != 0.0M) { m_cachedFrameTime = CurrentFrameTime; CurrentFrameTime = GetRelativeFrameTime(arrayMapping); m_cachedMappings = m_mappingCompiler.EnumerateTypeMappings(arrayMapping.Expression).ToArray(); } else { m_cachedMappings = m_mappingCompiler.EnumerateTypeMappings(arrayMapping.Expression).ToArray(); } }
protected int GetArrayMeasurementCount(ArrayMapping arrayMapping) { if (arrayMapping.WindowSize != 0.0M) { // native[] where each array element is the same mapping, but represent different times AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); m_cachedMeasurements = AlignmentCoordinator.GetMeasurements(Keys[m_keyIndex++].Single(), CurrentFrameTime, sampleWindow).ToArray(); } else if (arrayMapping.RelativeTime != 0.0M) { // native[] where each array element is the same time (relative to now), but represent different mappings AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); m_cachedMeasurements = Keys[m_keyIndex++].Select(key => AlignmentCoordinator.GetMeasurement(key, CurrentFrameTime, sampleWindow)).ToArray(); } else { // native[] where each array element is the same time, but represent different mappings m_cachedMeasurements = SignalLookup.GetMeasurements(Keys[m_keyIndex++]); } return(m_cachedMeasurements.Length); }
protected IDictionary <MeasurementKey, IMeasurement> GetRelativeFrame(FieldMapping fieldMapping) { MeasurementKey[] keys = m_timeWindowKeys[m_timeWindowKeyIndex++]; AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(fieldMapping); return(AlignmentCoordinator.GetFrame(keys, CurrentFrameTime, sampleWindow)); }
protected List <IDictionary <MeasurementKey, IMeasurement> > GetWindowFrames(ArrayMapping arrayMapping) { MeasurementKey[] keys = m_timeWindowKeys[m_timeWindowKeyIndex++]; AlignmentCoordinator.SampleWindow sampleWindow = CreateSampleWindow(arrayMapping); return(AlignmentCoordinator.GetFrames(keys, CurrentFrameTime, sampleWindow)); }