Example #1
1
        public Decoder(string astm_message)
            : this()
        {
            log.Debug("Decoder:ctor(string)");

            try
            {
                _astm_message = astm_message;
                _parser = new Parser();
                _nodes = _parser.CreateNode((int)ParseTreeLevel.Message);
                string msg = _parser.RemoveDelimiter(_astm_message);
                _parser.Parse(_nodes, msg, "\r|\\^", (int)ParseTreeLevel.Message);
                _parser.ProcessItems(_nodes);
                _message = Mapper.MapToMessage(_nodes);
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Dekodira poruku - vrace Message objekt
        /// </summary>
        /// <param name="astm_message"></param>
        /// <returns></returns>
        public Message DecodeMessage(string astm_message)
        {
            log.Debug(String.Format("Decoder:DecodeMessage: astm_message={0}", astm_message));

            try
            {
                Parser parser = new Parser();
                IParseTree nodes = parser.CreateNode((int)ParseTreeLevel.Message);
                string msg = parser.RemoveDelimiter(astm_message);
                parser.Parse(nodes, msg, "\r|\\^", (int)ParseTreeLevel.Message);
                parser.ProcessItems(nodes);
                return Mapper.MapToMessage(nodes);
            }
            catch(Exception ex)
            {
                log.Error(ex.ToString());
                throw new DecoderException("DecodeMessage",ex);
            }
        }
Example #3
0
        /// <summary>
        /// Dekkodira rekord, vraca Record objekt
        /// </summary>
        /// <param name="astm_record"></param>
        /// <returns></returns>
        public Record DecodeRecord(string astm_record)
        {
            log.Debug("Decoder:DecodeRecord");

            try
            {
                Parser parser = new Parser();
                IParseTree nodes = parser.CreateNode((int)ParseTreeLevel.Record);
                string msg = parser.RemoveDelimiter(astm_record);
                parser.Parse(nodes, msg, "\r|\\^", (int)ParseTreeLevel.Record);
                parser.ProcessItems(nodes);
                return Mapper.MapToRecord(nodes);
            }
            catch(Exception ex)
            {
                log.Error(ex.ToString());
                throw;
            }
        }