Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isoHeader"></param>
        /// <param name="packedBytes"></param>
        /// <param name="index"></param>
        public override void Pack(ISOHeader isoHeader, byte[] packedBytes, ref int index)
        {
            ISOHeaderVisa visaHeader = (ISOHeaderVisa)isoHeader;

            ISOUtils.Hex2Bytes(isoHeader.Length().ToString("X2"), packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h02_HeaderFlagAndFormat, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h03_TextFormat, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h04_TotalMessageLength, packedBytes, ref index);

            ISOUtils.Ascii2Bcd(visaHeader.h05_DestinationStationId, packedBytes, ref index, ISOFieldPadding.LEFT);

            ISOUtils.Ascii2Bcd(visaHeader.h06_SourceStationId, packedBytes, ref index, ISOFieldPadding.LEFT);

            ISOUtils.Hex2Bytes(visaHeader.h07_RoundTripControlInformation, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h08_BaseIFlag, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h09_MessageStatusFlag, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h10_BatchNumber, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h11_Reserved, packedBytes, ref index);

            ISOUtils.Hex2Bytes(visaHeader.h12_UserInformation, packedBytes, ref index);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isoHeader"></param>
        /// <param name="packedBytes"></param>
        /// <param name="index"></param>
        public override void Pack(ISOHeader isoHeader, byte[] packedBytes, ref int index)
        {
            ISOHeaderTITP terminalHeader = (ISOHeaderTITP)isoHeader;

            terminalHeader.Payload.CopyTo(packedBytes, index);
            index += terminalHeader.Payload.Length;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isoHeader"></param>
        /// <param name="packedBytes"></param>
        /// <param name="index"></param>
        public override void UnPack(ISOHeader isoHeader, ReadOnlySpan <byte> packedBytes, ref int index)
        {
            if (Logger.IsEnabled(LogLevel.Information))
            {
                Logger.LogInformation("Unpacking TITP Header");
            }
            ISOHeaderTITP terminalHeader = (ISOHeaderTITP)isoHeader;
            int           length         = terminalHeader.Payload.Length;

            packedBytes.Slice(index, length).CopyTo(terminalHeader.Payload);
            index += length;
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="isoMessagePackager"></param>
        public ISOMessage(ILogger logger, ISOMessagePackager isoMessagePackager) : base(logger, 0)
        {
            m_isoMesssagePackager = isoMessagePackager;

            m_isoMessageFields = new ISOMessageFields(Logger, m_isoMesssagePackager.GetISOMessageFieldsPackager(), 0);

            m_isoHeaderPackager = new ISOHeaderVisaPackager(Logger);

            // based on isoHeaderPackager storage class initialize the correct ISOHeader
            m_isoHeader = new ISOHeaderVisa(Logger, m_isoHeaderPackager);

            m_totalFields = ((ISOMessagePackager)m_isoMesssagePackager).GetTotalFields();
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="messagePackager"></param>
        /// <param name="isoHeaderPackager"></param>
        //public ISOMessage(ILogger logger, ISOMessagePackager messagePackager, ISOHeaderPackager isoHeaderPackager) : base(logger, 0)
        //{
        //    m_isoMesssagePackager = messagePackager;

        //    m_isoMessageFields = new ISOMessageFields(Logger, m_isoMesssagePackager.GetISOMessageFieldsPackager(), 0);

        //    m_isoHeader = ISOPackagerLoader.GetMessageHeader(m_isoMesssagePackager.GetISOMessageFieldsPackager().HeaderPackager, logger);
        //    // based on isoHeaderPackager storage class initialize the correct ISOHeader
        //    //m_isoHeaderPackager = isoHeaderPackager;
        //    //m_isoHeader = new ISOHeaderVisa(Logger, m_isoHeaderPackager);

        //    m_totalFields = ((ISOMessagePackager)m_isoMesssagePackager).GetTotalFields();
        //}
        /// <summary>
        ///
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="isoMessagePackager"></param>
        public ISOMessage(ILogger logger, ISOMessagePackager isoMessagePackager) : base(logger, 0)
        {
            m_isoMesssagePackager = isoMessagePackager;

            m_isoMessageFields = new ISOMessageFields(Logger, m_isoMesssagePackager.GetISOMessageFieldsPackager(), 0);

            var headerResult = ISOPackagerLoader.GetMessageHeaderAndPackager(isoMessagePackager.GetISOMessageFieldsPackager().HeaderPackager, Logger);

            m_isoHeader         = headerResult.Header;
            m_isoHeaderPackager = headerResult.Packager;

            //m_isoHeaderPackager =  new ISOHeaderVisaPackager(Logger);
            // based on isoHeaderPackager storage class initialize the correct ISOHeader
            //m_isoHeader = new ISOHeaderVisa(Logger, m_isoHeaderPackager);

            m_totalFields = (m_isoMesssagePackager).GetTotalFields();
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="isoHeader"></param>
        /// <param name="packedBytes"></param>
        /// <param name="index"></param>
        public override void UnPack(ISOHeader isoHeader, byte[] packedBytes, ref int index)
        {
            // Unpack should check for existense of Header Field 13 always

            ISOHeaderVisa visaHeader = (ISOHeaderVisa)isoHeader;

            if (Logger.IsEnabled(LogLevel.Information))
            {
                Logger.LogInformation("Unpacking VISA Header");
            }

            string lenHex = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);

            visaHeader.m_length = ISOUtils.Hex2Bytes(lenHex)[0];

            visaHeader.h02_HeaderFlagAndFormat = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);

            visaHeader.h03_TextFormat = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);


            visaHeader.h04_TotalMessageLength = ISOUtils.Bytes2Hex(packedBytes, ref index, 2);


            visaHeader.h05_DestinationStationId = ISOUtils.Bcd2Ascii(packedBytes, ref index, ISOFieldPadding.LEFT, 6);

            visaHeader.h06_SourceStationId = ISOUtils.Bcd2Ascii(packedBytes, ref index, ISOFieldPadding.LEFT, 6);


            visaHeader.h07_RoundTripControlInformation = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);

            visaHeader.h08_BaseIFlag = ISOUtils.Bytes2Hex(packedBytes, ref index, 2);

            visaHeader.h09_MessageStatusFlag = ISOUtils.Bytes2Hex(packedBytes, ref index, 3);

            visaHeader.h10_BatchNumber = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);

            visaHeader.h11_Reserved = ISOUtils.Bytes2Hex(packedBytes, ref index, 3);

            visaHeader.h12_UserInformation = ISOUtils.Bytes2Hex(packedBytes, ref index, 1);
        }
Ejemplo n.º 7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="isoHeader"></param>
 /// <param name="packedBytes"></param>
 /// <param name="index"></param>
 public abstract void UnPack(ISOHeader isoHeader, byte[] packedBytes, ref int index);
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="isoHeader"></param>
 /// <param name="packedBytes"></param>
 /// <param name="index"></param>
 public abstract void UnPack(ISOHeader isoHeader, ReadOnlySpan <byte> packedBytes, ref int index);