Beispiel #1
0
        private void BuildMeasurementKeys(TypeMapping inputMapping)
        {
            foreach (FieldMapping fieldMapping in inputMapping.FieldMappings)
            {
                DataType fieldType      = fieldMapping.Field.Type;
                DataType underlyingType = (fieldType as ArrayType)?.UnderlyingType;

                // ReSharper disable once PossibleNullReferenceException
                if (fieldType.IsArray && underlyingType.IsUserDefined)
                {
                    m_mappingCompiler.EnumerateTypeMappings(fieldMapping.Expression).ToList().ForEach(BuildMeasurementKeys);
                }
                else if (fieldType.IsUserDefined)
                {
                    BuildMeasurementKeys(m_mappingCompiler.GetTypeMapping(fieldMapping.Expression));
                }
                else if (fieldType.IsArray)
                {
                    m_keys.Add(m_signalLookup.GetMeasurementKeys(fieldMapping.Expression));
                }
                else
                {
                    m_keys.Add(new[] { m_signalLookup.GetMeasurementKey(fieldMapping.Expression) });
                }
            }
        }
Beispiel #2
0
        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);
        }
        // Recursively traverses all referenced types and mappings from the source mapping and stores them in the given hash sets.
        private void GetReferencedTypesAndMappings(TypeMapping sourceMapping, HashSet <UserDefinedType> referencedTypes, HashSet <TypeMapping> referencedMappings)
        {
            // Add the type of the source mapping to the collection of referenced types
            referencedTypes.Add(sourceMapping.Type);

            // Add the source mapping to the collection of referenced
            // mappings and quit if we've already done so before
            if (!referencedMappings.Add(sourceMapping))
            {
                return;
            }

            // Get a collection of all field mappings of the source mapping where the
            // field's type is either a user-defined type or an array of user-defined types
            IEnumerable <FieldMapping> udtFields = sourceMapping.FieldMappings
                                                   .Where(fieldMapping =>
            {
                DataType fieldType      = fieldMapping.Field.Type;
                DataType underlyingType = (fieldType as ArrayType)?.UnderlyingType ?? fieldType;
                return(underlyingType.IsUserDefined);
            });

            // Recursively search all fields that reference user-defined types
            foreach (FieldMapping fieldMapping in udtFields)
            {
                foreach (TypeMapping typeMapping in m_compiler.EnumerateTypeMappings(fieldMapping.Expression))
                {
                    GetReferencedTypesAndMappings(typeMapping, referencedTypes, referencedMappings);
                }
            }
        }
Beispiel #4
0
 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();
     }
 }
Beispiel #5
0
        private void BuildMappingCollections(TypeMapping inputMapping)
        {
            foreach (FieldMapping fieldMapping in inputMapping.FieldMappings)
            {
                ArrayMapping arrayMapping   = fieldMapping as ArrayMapping;
                DataType     fieldType      = fieldMapping.Field.Type;
                DataType     underlyingType = (fieldType as ArrayType)?.UnderlyingType;

                // ReSharper disable once PossibleNullReferenceException
                if (fieldType.IsArray && underlyingType.IsUserDefined && arrayMapping.WindowSize == 0.0M)
                {
                    m_mappingCollections.Add(MappingCompiler.EnumerateTypeMappings(arrayMapping.Expression).ToArray());
                }

                if (fieldType.IsArray && underlyingType.IsUserDefined)
                {
                    m_mappingCompiler.EnumerateTypeMappings(fieldMapping.Expression).ToList().ForEach(BuildMappingCollections);
                }
                else if (fieldType.IsUserDefined)
                {
                    BuildMappingCollections(m_mappingCompiler.GetTypeMapping(fieldMapping.Expression));
                }
            }
        }