Exemple #1
0
		protected void RxCallback(MessageIfc messsage)
		{
			// new data in the connected state. Find the request handler by message ID
			// and forward the data
		}
Exemple #2
0
        /// <summary>
        /// ieMap[0] is TICK_PRICE (1)
        /// </summary>
        public static bool Parser_TICK_PRICE(byte[] data, System.Collections.Generic.List<Utils.IEIndex> ieMap, out MessageIfc message, out int ieCount)
        {
            bool res = false;
            message = null;
            Utils.IEIndex ieIndex;
            ieCount = 6;
            do
            {
                if (ieMap.Count < ieCount)
                {
                    System.Console.Out.WriteLine ("Not enough ies. Expected "+ieCount+", actual "+ieMap.Count);
                    break;
                }

                // get version
                string ieStr;
                int version;
                int id;
                TickType tickType;
                double price;
                int size;

                ieIndex = ieMap[1];
                res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out version, out ieStr);
                if (!res) {
                    System.Console.Out.WriteLine ("Failed to parse version (" + ieStr + ")");
                    break;
                }

                ieIndex = ieMap[2];
                res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out id, out ieStr);
                if (!res) {
                    System.Console.Out.WriteLine ("Failed to parse id (" + ieStr + ")");
                    break;
                }

                ieIndex = ieMap[3];
                int tickTypeValue;
                res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out tickTypeValue, out ieStr);
                if (!res) {
                    System.Console.Out.WriteLine ("Failed to parse tickType (" + ieStr + ")");
                    break;
                }
                tickType = getTickType(tickTypeValue);

                ieIndex = ieMap[4];
                res = Utils.GetIEValueDouble (data, 0, ieIndex.firstByte, ieIndex.lastByte, out price, out ieStr);
                if (!res) {
                    System.Console.Out.WriteLine ("Failed to parse price (" + ieStr + ")");
                    break;
                }

                ieIndex = ieMap[5];
                res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out size, out ieStr);
                if (!res) {
                    System.Console.Out.WriteLine ("Failed to parse tickType (" + ieStr + ")");
                    break;
                }

                message = new Message_TickPrice(id, tickType, price, size);

                res = true;
            }
            while (false);

            return res;
        }
Exemple #3
0
		/// <summary>
		/// ieMap[0] is TICK_PRICE (1)
		/// </summary>
		public static bool Parser_TICK_PRICE (byte[] data, System.Collections.Generic.List<Utils.IEIndex> ieMap, out MessageIfc message, out int ieCount)
		{
			bool res = false;
			message = null;
			Utils.IEIndex ieIndex;
			ieCount = 6;
			do
			{
				if (ieMap.Count < ieCount)
				{
					System.Console.Out.WriteLine ("Not enough ies. Expected "+ieCount+", actual "+ieMap.Count);
					break;
				}
				
				// get version
				string ieStr;
				int version; 
				int id; 
				TickType tickType;
				double price;
				int size;
				
				ieIndex = ieMap[1];
				res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out version, out ieStr);
				if (!res) {
					System.Console.Out.WriteLine ("Failed to parse version (" + ieStr + ")");
					break;
				}
				
				ieIndex = ieMap[2];
				res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out id, out ieStr);
				if (!res) {
					System.Console.Out.WriteLine ("Failed to parse id (" + ieStr + ")");
					break;
				}
				
				ieIndex = ieMap[3];
				int tickTypeValue;
				res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out tickTypeValue, out ieStr);
				if (!res) {
					System.Console.Out.WriteLine ("Failed to parse tickType (" + ieStr + ")");
					break;
				}
				tickType = getTickType(tickTypeValue);
				
				ieIndex = ieMap[4];
				res = Utils.GetIEValueDouble (data, 0, ieIndex.firstByte, ieIndex.lastByte, out price, out ieStr);
				if (!res) {
					System.Console.Out.WriteLine ("Failed to parse price (" + ieStr + ")");
					break;
				}
				
				ieIndex = ieMap[5];
				res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out size, out ieStr);
				if (!res) {
					System.Console.Out.WriteLine ("Failed to parse tickType (" + ieStr + ")");
					break;
				}
				
				message = new Message_TickPrice(id, tickType, price, size);
				
				res = true;
			}
			while (false);
			
			return res;
		}
Exemple #4
0
        /// <summary>
        /// Methos assumes that array data contains message ID. The method will call 
        /// appropriate parser and return array of information elements
        /// </summary>
        public static bool Parse(byte[] data, System.Collections.Generic.List<Utils.IEIndex> ieMap, out MessageIfc message, out int ieCount)
        {
            bool res = true;
            message = null;
            ieCount = 0;
            do
            {
                // get first IE - message ID
                int ieMessageId;
                string ieMessageIdStr;
                Utils.IEIndex ieIndex = ieMap[0];
                res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out ieMessageId, out ieMessageIdStr);
                if (!res)
                {
                    System.Console.Out.WriteLine("Failed to parse message ID ("+ieMessageIdStr+")");
                    break;
                }

                MessageParser messageParser = MessageParser.Find(ieMessageId);
                res = (messageParser != null);
                if (!res)
                {
                    System.Console.Out.WriteLine("Failed to find message ID ("+ieMessageId+")");
                    break;
                }

                res = messageParser.parser(data, ieMap, out message, out ieCount);
                if (!res)
                {
                    break;
                }
            }
            while (false);

            return res;
        }
Exemple #5
0
		/// <summary>
		/// Methos assumes that array data contains message ID. The method will call 
		/// appropriate parser and return array of information elements
		/// </summary>
		public static bool Parse(byte[] data, System.Collections.Generic.List<Utils.IEIndex> ieMap, out MessageIfc message, out int ieCount)
		{
			bool res = true;
			message = null;
			ieCount = 0;
			do
			{
				// get first IE - message ID
				int ieMessageId;
				string ieMessageIdStr;
				Utils.IEIndex ieIndex = ieMap[0];
				res = Utils.GetIEValueInt (data, 0, ieIndex.firstByte, ieIndex.lastByte, out ieMessageId, out ieMessageIdStr);
				if (!res)
				{
					System.Console.Out.WriteLine("Failed to parse message ID ("+ieMessageIdStr+")");
					break;
				}
				
				MessageParser messageParser = MessageParser.Find(ieMessageId);
				res = (messageParser != null);
				if (!res)
				{
					System.Console.Out.WriteLine("Failed to find message ID ("+ieMessageId+")");
					break;
				}
				
				res = messageParser.parser(data, ieMap, out message, out ieCount);
				if (!res)
				{
					break;
				}
			}
			while (false);
			
			return res;
		}