当前位置: 首页>>代码示例>>C#>>正文


C# MamaMsg.getMsg方法代码示例

本文整理汇总了C#中Wombat.MamaMsg.getMsg方法的典型用法代码示例。如果您正苦于以下问题:C# MamaMsg.getMsg方法的具体用法?C# MamaMsg.getMsg怎么用?C# MamaMsg.getMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Wombat.MamaMsg的用法示例。


在下文中一共展示了MamaMsg.getMsg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getEntries

        private void getEntries(
            MamdaOrderBookPriceLevel level,
            MamaMsg plMsg)
        {
            /* Entries may or may not exist in the message.  If they do exist,
             * they exist as a vector of submessages, separate submessages, or
             * (if there is only one entry in the message) in the price level
             * message itself. */

            /* Optional order book fields: */
            MamaMsg[] msgEntries = null;
            /*We won't have PL_ENTRIES if FieldAttrsOrderBookWombatMsg
             is not specified in the data dictionary*/
            if (MamdaOrderBookFields.PL_ENTRIES != null)
            {
                /* null is passed as default value otherwise
                    getVectorMsg throws an exception if not found*/
                msgEntries = plMsg.getVectorMsg(MamdaOrderBookFields.PL_ENTRIES, null);
            }
            if (msgEntries != null)
            {
                MamdaOrderBookEntry[] entries = new MamdaOrderBookEntry[msgEntries.Length];
                for (int j = 0; j < msgEntries.Length; j++)
                {
                    MamaMsg entMsg = msgEntries[j];
                    if (entMsg != null)
                    {
                        MamdaOrderBookEntry entry = new MamdaOrderBookEntry();
                        getEntryInfo(entry, entMsg, level);
                        level.addEntry(entry);
                    }
                }
                return;
            }

            /* Second, try the list of entries. */
            int maxEntryFields = MamdaOrderBookFields.PL_ENTRY.Length;

            // Get the number of attached sub messages
            int numEntryAttached = plMsg.getI32(MamdaOrderBookFields.PL_NUM_ATTACH, 0);

            // If there are no sub messages attempt to get the entry Id from this price level message
            if (0 == numEntryAttached)
            {
                string entID = null;
                // Check for the entry Id
                if (plMsg.tryString(MamdaOrderBookFields.ENTRY_ID, ref entID))
                {
                    // Add a new entry to the level
                    MamdaOrderBookEntry entry = new MamdaOrderBookEntry();
                    getEntryInfo(entry, plMsg, level);
                    level.addEntry(entry);
                }
            }

            else
            {
                // Ensure we dont' enumerate beyond the maximum number of entries
                if (numEntryAttached < maxEntryFields)
                {
                    maxEntryFields = numEntryAttached;
                }

                // Enumerate all the entries
                for (int j = 1; j <= maxEntryFields; j++)
                {
                    // Get the sub message
                    MamaMsg entMsg = plMsg.getMsg(MamdaOrderBookFields.PL_ENTRY[j], null);
                    if (entMsg != null)
                    {
                        // Add an entry for this level
                        MamdaOrderBookEntry entry = new MamdaOrderBookEntry();
                        getEntryInfo(entry, entMsg, level);
                        level.addEntry(entry);
                    }
                }
            }
        }
开发者ID:jacobraj,项目名称:MAMA,代码行数:78,代码来源:MamdaOrderBookListener.cs

示例2: getLevelInfoAndEntries


//.........这里部分代码省略.........
            // price level action is an add should the number of
            // entries match.
            //

            if (mLevelEntryHandler!=null)
            {
                // clear entry cache
                clearLevelEntryFields();

                // First try a single vector.
                int  numEntriesInMsg = 0;
                MamaMsg[] msgEntries = null;

                /* We won't have PL_ENTRIES if FieldAttrsOrderBookWombatMsg
                * is not specified in the data dictionary */
                if (MamdaOrderBookFields.PL_ENTRIES != null)
                {
                    /* null is passed as default value otherwise
                    * getVectorMsg throws an exception if not found */
                    msgEntries = plMsg.getVectorMsg(MamdaOrderBookFields.PL_ENTRIES, null);
                    if (msgEntries != null)
                    {
                        numEntriesInMsg = msgEntries.Length;
                    }
                }

                if (numEntriesInMsg > 0)
                {
                    mPriceLevelActNumEntries = numEntriesInMsg;

                    for (int j = 0; j < numEntriesInMsg; j++)
                    {
                        entMsg = msgEntries[j];

                        getEntriesInfo(entMsg);
                        if (isRecap)
                        {
                            mLevelEntryHandler.onBookAtomicLevelEntryRecap (
                                        subscription, this, msg, this);
                        }
                        else
                        {
                            mLevelEntryHandler.onBookAtomicLevelEntryDelta (
                                        subscription, this, msg, this);
                        }
                    }
                }
                else
                {
                    // Second, try the list of entries.
                    int maxEntryFields = MamdaOrderBookFields.getNumEntryFields ();

                    // getNumEntryFields() defaults to 0 but we want to go into the
                    // below loop at least once for flattened messages scenario
                    if (maxEntryFields == 0)
                    {
                        maxEntryFields = 1;
                    }

                    int numEntryAttached = plMsg.getI32(MamdaOrderBookFields.PL_NUM_ATTACH, 1);
                    if (numEntryAttached < maxEntryFields)
                    {
                        maxEntryFields = numEntryAttached;
                    }
                    mPriceLevelActNumEntries = maxEntryFields;
                    for (int j = 1; j <= maxEntryFields; j++)
                    {

                        if (MamdaOrderBookFields.PL_ENTRY.Length > 1)
                        {
                            entMsg = plMsg.getMsg(MamdaOrderBookFields.PL_ENTRY[j], null);
                        }

                        if ((entMsg == null) && (numEntryAttached == 1))
                        {
                            // Price level fields are probably be in the main message.
                            entMsg = plMsg;
                        }
                        if (entMsg != null)
                        {
                            if (!getEntriesInfo(entMsg))
                            {
                                return;
                            }

                            if (isRecap)
                            {
                                mLevelEntryHandler.onBookAtomicLevelEntryRecap (
                                    subscription, this, msg, this);
                            }
                            else
                            {
                                mLevelEntryHandler.onBookAtomicLevelEntryDelta (
                                    subscription, this, msg, this);
                            }
                        }
                    }
                }
            }
        }
开发者ID:jacobraj,项目名称:MAMA,代码行数:101,代码来源:MamdaBookAtomicListener.cs

示例3: createDeltaFromMamaMsgWithoutVectorFields

        /// <summary>
        /// Returns whether a complete book delta was received.
        /// 
        /// Books without vector fields (i.e. fixed field layout) might
        /// come in multiple MamaMsgs.  The MdMsgNum and MdTotalNum
        /// fields can be used to determine which message is which.
        /// 
        /// When a single price level is present, it may or may not be
        /// encapsulated in a nested message field.  Similarly, with single
        /// entries in a price level.
        /// </summary>
        /// <param name="delta"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        private bool createDeltaFromMamaMsgWithoutVectorFields(
			MamdaOrderBook delta,
			MamaMsg msg)
        {
            int msgNum   = 1;
            int msgTotal = 1;

            if (msg.tryI32(MamaReservedFields.MsgNum, ref mMsgNum))
            {
                msgNum = mMsgNum.Value;
            }
            if (msg.tryI32(MamaReservedFields.MsgTotal, ref mMsgTotal))
            {
                msgTotal = mMsgTotal.Value;
            }

            if (msgNum == 1)
            {
                // Only clear the book if this is the first message in the
                // set of updates.
                delta.clear();
            }

            if (!mHaveSanityCheckedBookDict)
            {
                mHaveSanityCheckedBookDict = true;
                if (MamdaOrderBookFields.PRICE_LEVEL.Length == 0)
                {
                    throw new MamdaOrderBookException (
                        "data dictionary error: cannot find price level fields");
                }
            }

            //for optimised feed date, wNumLevels should be assumed = 1 if not sent
            int numLevelFieldInMsg = 1;
            if (msg.tryI32(MamdaOrderBookFields.NUM_LEVELS, ref mNumLevelFields))
            {
                numLevelFieldInMsg = mNumLevelFields.Value;
            }

            int maxLevelFields = MamdaOrderBookFields.PRICE_LEVEL.Length;
            if (numLevelFieldInMsg < maxLevelFields)
            {
                maxLevelFields = numLevelFieldInMsg;
            }

            for (int i = 1; i <= maxLevelFields; i++)
            {
                MamaMsg plMsg = msg.getMsg(MamdaOrderBookFields.PRICE_LEVEL[i], null);

                if (plMsg == null)
                {
                    if (numLevelFieldInMsg == 1)
                    {
                        /* Price level fields are probably be in the main
                         * message. */
                        plMsg = msg;
                    }
                    else
                    {
                        throw new MamdaDataException (
                            "cannot find price level fields in MamaMsg");
                    }
                }

                MamdaOrderBookPriceLevel level = new MamdaOrderBookPriceLevel();
                getLevelInfo(level, plMsg, delta);
                getEntries(level, plMsg);
                delta.addLevel (level);
            }
            return msgNum == msgTotal;
        }
开发者ID:jacobraj,项目名称:MAMA,代码行数:86,代码来源:MamdaOrderBookListener.cs

示例4: createDeltaFromMamaMsgWithoutVectorFields

        private void createDeltaFromMamaMsgWithoutVectorFields(
                                                MamdaSubscription subscription,
                                                MamaMsg msg,
                                                bool isRecap)
        {
            NullableInt numLevelFields_ = new NullableInt();

            int numLevelFieldInMsg = 1;

            if (msg.tryI32 (MamdaOrderBookFields.NUM_LEVELS, ref numLevelFields_))
            {
                numLevelFieldInMsg = numLevelFields_.Value;
            }

            int maxLevelFields = MamdaOrderBookFields.getNumLevelFields();

            // getNumLevelFields() defaults to 0 but we want to go into the
            // below loop at least once for flattened messages scenario
            if (maxLevelFields == 0)
            {
                maxLevelFields = 1;
            }

            if (numLevelFieldInMsg < maxLevelFields)
            {
                maxLevelFields = numLevelFieldInMsg;
            }
            mPriceLevels = maxLevelFields;

            for (int i = 1; i <= maxLevelFields; i++)
            {
                clearLevelFields();
                mPriceLevel = i;
                MamaMsg plMsg = null;

                if (MamdaOrderBookFields.PRICE_LEVEL.Length > 1)
                {
                    plMsg = msg.getMsg(MamdaOrderBookFields.PRICE_LEVEL[i], null);
                }

                if (plMsg == null)
                {
                    if (numLevelFieldInMsg == 1)
                    {
                        // Price level fields are probably be in the main message.
                        plMsg = msg;
                    }
                    else
                    {
                         throw new MamdaDataException (
                            "cannot find price level fields in MamaMsg");
                    }
                }
                getLevelInfoAndEntries(subscription, msg, plMsg, isRecap);
            }
        }
开发者ID:jacobraj,项目名称:MAMA,代码行数:56,代码来源:MamdaBookAtomicListener.cs


注:本文中的Wombat.MamaMsg.getMsg方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。