Ejemplo n.º 1
0
        public string UpdateMapping(string udtFileContents, string mappingFileContents, string identifier, string newident)
        {
            StringReader udtsr     = new StringReader(udtFileContents);
            StringReader mappingsr = new StringReader(mappingFileContents);

            UDTCompiler udtCompiler = new UDTCompiler();

            udtCompiler.Compile(udtsr);

            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            mappingCompiler.Compile(mappingsr);

            foreach (TypeMapping tm in mappingCompiler.DefinedMappings)
            {
                if (tm.Identifier == identifier)
                {
                    tm.Identifier = newident;
                }
            }

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings);

            StringBuilder sb = new StringBuilder();

            mappingWriter.Write(new StringWriter(sb));

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public string UpdateUDT(string udtFileContents, string category, string identifier, string newcat, string newident)
        {
            StringReader udtsr = new StringReader(udtFileContents);

            UDTCompiler udtCompiler = new UDTCompiler();

            udtCompiler.Compile(udtsr);

            foreach (DataType dt in udtCompiler.DefinedTypes)
            {
                if (dt.Category == category && dt.Identifier == identifier)
                {
                    if (newcat != null)
                    {
                        dt.Category = newcat;
                    }
                    if (newident != null)
                    {
                        dt.Identifier = newident;
                    }
                }
            }

            UDTWriter udtWriter = new UDTWriter();

            udtWriter.Types.AddRange(udtCompiler.DefinedTypes.OfType <UserDefinedType>());

            StringBuilder sb = new StringBuilder();

            udtWriter.Write(new StringWriter(sb));

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new <see cref="MapperBase"/>.
        /// </summary>
        /// <param name="framework">Container object for framework elements.</param>
        /// <param name="unmapper">Object that handles conversion of data from data structures into measurements.</param>
        /// <param name="inputMapping">Input mapping name.</param>
        protected MapperBase(Framework framework, string inputMapping)
        {
            m_framework             = framework;
            m_minimumRetentionLock  = new object();
            m_minimumRetentionTimes = new Dictionary <MeasurementKey, TimeSpan>();
            m_mappingRetentionTimes = new Dictionary <MeasurementKey, TimeSpan>();
            m_retentionTimes        = new Dictionary <MeasurementKey, TimeSpan>();

            UDTCompiler udtCompiler = new UDTCompiler();

            m_mappingCompiler = new MappingCompiler(udtCompiler);

            string udtPath     = Path.Combine("Model", "UserDefinedTypes.ecaidl");
            string mappingPath = Path.Combine("Model", "UserDefinedMappings.ecamap");

            udtCompiler.Compile(udtPath);
            m_mappingCompiler.Compile(mappingPath);

            m_keys               = new List <MeasurementKey[]>();
            m_timeWindowKeys     = new List <MeasurementKey[]>();
            m_mappingCollections = new List <TypeMapping[]>();
            m_inputMapping       = inputMapping;

            if ((object)m_mappingCompiler.GetTypeMapping(inputMapping) == null)
            {
                throw new InvalidOperationException($"Unable to find input mapping \"{inputMapping}\" in mapping file ({mappingPath})!");
            }
        }
Ejemplo n.º 4
0
        public List <DataType> ReadUDTFile(string udtfileContents)
        {
            StringReader udtsr = new StringReader(udtfileContents);


            UDTCompiler compiler = new UDTCompiler();

            compiler.Compile(udtsr);

            return(compiler.DefinedTypes.Where(x => x.IsUserDefined).ToList());
        }
Ejemplo n.º 5
0
        public List <TypeMapping> ReadMappingFile(string udtfileContents, string mappingFileContents)
        {
            StringReader udtsr     = new StringReader(udtfileContents);
            StringReader mappingsr = new StringReader(mappingFileContents);

            UDTCompiler comp = new UDTCompiler();

            comp.Compile(udtsr);
            MappingCompiler compiler = new MappingCompiler(comp);

            compiler.Compile(mappingsr);

            return(compiler.DefinedMappings);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a new <see cref="MapperBase"/>.
        /// </summary>
        /// <param name="framework">Container object for framework elements.</param>
        /// <param name="inputMapping">Input mapping name.</param>
        protected MapperBase(Framework framework, string inputMapping)
        {
            m_signalLookup         = framework.SignalLookup;
            m_alignmentCoordinator = framework.AlignmentCoordinator;
            m_signalBuffers        = framework.SignalBuffers;

            UDTCompiler udtCompiler = new UDTCompiler();

            m_mappingCompiler = new MappingCompiler(udtCompiler);
            udtCompiler.Compile(Path.Combine("Model", "UserDefinedTypes.ecaidl"));
            m_mappingCompiler.Compile(Path.Combine("Model", "UserDefinedMappings.ecamap"));

            m_keys         = new List <MeasurementKey[]>();
            m_readonlyKeys = m_keys.AsReadOnly();
            m_inputMapping = inputMapping;
        }
Ejemplo n.º 7
0
        public string UpdateMappingForUDT(string udtFileContents, string mappingFileContents, string category, string identifier, string newcat, string newident)
        {
            StringReader udtsr     = new StringReader(udtFileContents);
            StringReader mappingsr = new StringReader(mappingFileContents);

            UDTCompiler udtCompiler = new UDTCompiler();

            udtCompiler.Compile(udtsr);
            MappingCompiler mappingCompiler = new MappingCompiler(udtCompiler);

            mappingCompiler.Compile(mappingsr);

            foreach (DataType dt in udtCompiler.DefinedTypes)
            {
                if (dt.Category == category && dt.Identifier == identifier)
                {
                    if (newcat != null)
                    {
                        dt.Category = newcat;
                    }
                    if (newident != null)
                    {
                        dt.Identifier = newident;
                    }
                }
            }

            MappingWriter mappingWriter = new MappingWriter();

            mappingWriter.Mappings.AddRange(mappingCompiler.DefinedMappings);

            StringBuilder sb = new StringBuilder();

            mappingWriter.Write(new StringWriter(sb));

            return(sb.ToString());
        }