Exemplo n.º 1
0
        //=========================================================================
        /// <summary>
        /// Initialise with an incoming msg. This interpreter now has a copy of the message.
        /// </summary>
        /// <param name="inMsg"></param>
        /// <returns></returns>
        //=========================================================================
        public bool loadMessage(TMsgHeader inMsg)
        {
            int  iFld;
            bool result;

            if (!inMsg.Equals(null))  //if there is a message header
            {
                //need to do a cleanup in case the interpreter has any existing msg's
                for (iFld = 1; (iFld <= Msgs.MAX_FLDS) && (initArray[iFld - 1].fieldType != TTypedValue.TBaseType.ITYPE_EMPTY); iFld++)
                {
                    if (initArray[iFld - 1].size > 0)
                    {
                        freeInitArrayItem(iFld);
                    }
                }
                //take ownership of the msg header and data block
                msg    = inMsg;   //now I own the msg because I will delete it later
                result = true;
            }
            else
            {
                result = false;
            }

            return(result);
        }
Exemplo n.º 2
0
        //=========================================================================
        /// <summary>
        /// Determines the offset for a particular field in the msg data block. Adds
        /// all the item sizes and uses the char[] block information to determine the
        /// size of the char[] strings.
        /// </summary>
        /// <param name="fieldID">Field ID e.g. 14001</param>
        /// <returns>The offset count from the start of the data block to find the
        /// field data.</returns>
        //=========================================================================
        private uint calcOffset(int fieldID)
        {
            int  iFieldNo;
            int  iFld;       //field number along the block
            int  iFldType;
            uint offset = 0; //ptr offset counter
            int  strSize;

            if ((!msg.Equals(null)) && (msg.dataPtr.Length > 0))
            {        //check that a message and data block exist
                iFieldNo = fieldID % 1000;

                for (iFld = 1; iFld < iFieldNo; iFld++)
                {
                    iFldType = msgSpec[msg.msgType - 1].fld[iFld - 1];
                    if (iFldType == (int)TTypedValue.TBaseType.ITYPE_STR)
                    {
                        strSize = BitConverter.ToInt32(msg.dataPtr, (int)offset);                              //get the size of the char string
                        offset += TTypedValue.typeSize[(int)TTypedValue.TBaseType.ITYPE_INT4] + (uint)strSize; //add 4byte size DIM + length of string
                    }
                    else
                    {
                        offset += TTypedValue.typeSize[iFldType];
                    }
                }
            }
            if (msg.nDataBytes < offset)
            {
                string errorMsg = string.Format("Error determining offset of field {0} from msg {1}", fieldID, msg.msgType);
                throw (new ApplicationException(errorMsg));
            }
            return(offset);
        }
Exemplo n.º 3
0
 //============================================================================
 /// <summary>
 /// Test if the msg is defined.
 /// </summary>
 /// <param name="msg"></param>
 /// <returns>True if msg == TMessageHdrList.Null</returns>
 //============================================================================
 public Boolean IsNull(TMsgHeader msg)
 {
     return(msg.Equals(Null));
 }