public void TestDecodeMessageWithAllFieldTypes()
        {
            //               --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6---
            const string msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010";
            Stream input = ByteUtil.CreateByteStream(msgstr);

            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("4", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.ASCII, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("6", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false),
                });
            var context = new Context();
            context.RegisterTemplate(113, template);

            GroupValue message = new Message(template);
            message.SetString(1, "H");
            message.SetByteVector(2, new[] { (byte)0xFF });
            message.SetDecimal(3, 1.201);
            message.SetInteger(4, -1);
            message.SetString(5, "abc");
            message.SetInteger(6, 2);
            Assert.AreEqual(message, new FastDecoder(context, input).ReadMessage());
        }
        public void TestEncodeMessageWithAllFieldTypes()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.BYTE_VECTOR, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.DECIMAL, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("4", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.STRING, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("6", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false),
                });
            var context = new Context();
            context.RegisterTemplate(113, template);

            var message = new Message(template);
            message.SetString(1, "H");
            message.SetByteVector(2, new[] { (byte)0xFF });
            message.SetDecimal(3, 1.201);
            message.SetInteger(4, -1);
            message.SetString(5, "abc");
            message.SetInteger(6, 2);

            //               --PMAP-- --TID--- ---#1--- -------#2-------- ------------#3------------ ---#4--- ------------#5------------ ---#6---
            const string msgstr = "11111111 11110001 11001000 10000001 11111111 11111101 00001001 10110001 11111111 01100001 01100010 11100011 10000010";
            AssertEquals(msgstr, new FastEncoder(context).Encode(message));
        }
예제 #3
0
 public void SendMessage(string symbol)
 {
     var message = new Message(ses.MessageOutputStream.GetTemplateRegistry().get_Renamed("Arbitry"));
     message.SetInteger(1, rnd.Next()%1000);
     message.SetInteger(2, rnd.Next() % 1000);
     message.SetInteger(3, rnd.Next() % 1000);
     message.SetInteger(4, rnd.Next() % 1000);
     message.SetInteger(6, rnd.Next() % 1000);
     ses.MessageOutputStream.WriteMessage(message);
 }
예제 #4
0
        public void TestEquals()
        {
            var template = new MessageTemplate("",
                new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false)
                });
            GroupValue message = new Message(template);
            message.SetInteger(1, 1);

            GroupValue other = new Message(template);
            other.SetInteger(1, 1);

            Assert.AreEqual(message, other);
        }
예제 #5
0
        public void TestNotEquals()
        {
            var template = new MessageTemplate("",
                new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false)
                });
            var message = new Message(template);
            message.SetInteger(1, 2);

            var other = new Message(template);
            Assert.IsFalse(message.equals(other));
            Assert.IsFalse(other.equals(message));
            other.SetInteger(1, 1);

            Assert.IsFalse(message.equals(other));
            Assert.IsFalse(other.equals(message));
        }
        public void NewSession(Session session)
        {
            //session.Listening = true;
            session.ErrorHandler = new TCPServer.FASTServer.ServerErrorHandler();
            session.MessageHandler = new FASTMessageListener();
            //register a template
            TemplateRegistry registry = new BasicTemplateRegistry();
            var template = new MessageTemplate("Arbitry",
               new Field[] {
                    new Scalar("1", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.I32, Operator.DELTA, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.I32, Operator.INCREMENT,
                        new IntegerValue(10), false),
                    new Scalar("4", FASTType.I32, Operator.INCREMENT,
                        ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.I32, Operator.CONSTANT,
                        new IntegerValue(1), false), /* NON-TRANSFERRABLE */
                new Scalar("6", FASTType.I32, Operator.DEFAULT,
                        new IntegerValue(2), false)
                });
            registry.Register(24, template);

            session.MessageInputStream.RegisterTemplate(24, template);
            //send that template
            session.SendTemplates(registry);

            while (true)
            {
                DateTime startTime = DateTime.Now;
                for (int i = 0; i < 64000; i++)
                {
                    //make a message
                    var message = new Message(template);
                    message.SetInteger(1, 109);
                    message.SetInteger(2, 29470);
                    message.SetInteger(3, 10);
                    message.SetInteger(4, 3);
                    message.SetInteger(5, 1);
                    message.SetInteger(6, 2);

                    //send it to client
                    session.MessageOutputStream.WriteMessage(message);
                }
                double seconds = (DateTime.Now - startTime).TotalSeconds;
                Console.WriteLine(seconds);
                Console.WriteLine("MSG/S:" + (64000 / seconds).ToString("0"));
            }
        }
        public void TestConstantOperatorWithMandatoryField()
        {
            var field = new Scalar("", FASTType.U32, Operator.CONSTANT, new IntegerValue(16), false);
            MessageTemplate template = registerTemplate(field);

            var msg1 = new Message(template);
            //        msg1.setInteger(1, 16);

            var msg2 = new Message(template);
            msg2.SetInteger(1, 16);

            //                 --PMAP-- --TID---
            encodeAndAssertEquals("11000000 11110001", msg1);

            //                     --PMAP--
            encodeAndAssertEquals("10000000", msg2);

            GroupValue readMessage = decoder.ReadMessage();
            Assert.AreEqual(msg1, readMessage);
            readMessage = decoder.ReadMessage();
            Assert.AreEqual(msg2, readMessage);
        }
        public void TestConstantOperatorWithOptionalField()
        {
            var field = new Scalar("", FASTType.U32, Operator.CONSTANT, new IntegerValue(16), true);
            MessageTemplate template = registerTemplate(field);

            var msg1 = new Message(template);

            var msg2 = new Message(template);
            msg2.SetInteger(1, 16);

            //                     --PMAP-- --TID---
            encodeAndAssertEquals("11000000 11110001", msg1);

            //                     --PMAP--
            encodeAndAssertEquals("10100000", msg2);

            readMessageAndAssertEquals(msg1);
            readMessageAndAssertEquals(msg2);
        }
        public void TestIncrementOperatorWithMandatoryField()
        {
            var field = new Scalar("", FASTType.U32,
                    Operator.INCREMENT, new IntegerValue(16), false);
            MessageTemplate template = registerTemplate(field);

            var msg1 = new Message(template);
            msg1.SetInteger(1, 16);

            var msg2 = new Message(template);
            msg2.SetInteger(1, 17);

            var msg3 = new Message(template);
            msg3.SetInteger(1, 20);

            //                     --PMAP-- --TID---
            encodeAndAssertEquals("11000000 11110001", msg1);

            //                     --PMAP-- ---#1---
            encodeAndAssertEquals("10000000", msg2);

            //                     --PMAP--
            encodeAndAssertEquals("10100000 10010100", msg3);

            readMessageAndAssertEquals(msg1);
            readMessageAndAssertEquals(msg2);
            readMessageAndAssertEquals(msg3);
        }
        public void TestEmptyOperatorWithSequenceOfMessages()
        {
            var field = new Scalar("", FASTType.U32, Operator.NONE,
                    ScalarValue.UNDEFINED, true);
            MessageTemplate template = registerTemplate(field);

            var msg1 = new Message(template);

            var msg2 = new Message(template);
            msg2.SetInteger(1, 15);

            //                 --PMAP-- --TID--- ---#1---
            String encoding = "11000000 11110001 10000000";
            encodeAndAssertEquals(encoding, msg1);

            //          --PMAP-- ---#1---
            encoding = "10000000 10010000";
            byte[] encodedMessage = encoder.Encode(msg2);
            TestUtil.AssertBitVectorEquals(encoding, encodedMessage);
            output.Write(encodedMessage);

            GroupValue readMessage = decoder.ReadMessage();
            Assert.AreEqual(msg1, readMessage);
            readMessage = decoder.ReadMessage();
            Assert.AreEqual(msg2, readMessage);
        }
예제 #11
0
        public void TestEncodeSimpleMessage()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false)
                });
            var context = new Context();
            context.RegisterTemplate(113, template);

            var message = new Message(template);
            message.SetInteger(1, 1);

            var encoder = new FastEncoder(context);
            AssertEquals("11100000 11110001 10000001", encoder.Encode(message));
        }
        public void TestDeltaOperatorWithOptionalField()
        {
            var field = new Scalar("", FASTType.U32, Operator.DELTA,
                    new IntegerValue(16), true);
            MessageTemplate template = registerTemplate(field);

            var msg1 = new Message(template);
            msg1.SetInteger(1, 16);

            var msg2 = new Message(template);
            msg2.SetInteger(1, 17);

            var msg3 = new Message(template);

            var msg4 = new Message(template);
            msg4.SetInteger(1, 20);

            //                     --PMAP-- --TID--- ---#1---
            encodeAndAssertEquals("11000000 11110001 10000001", msg1);

            //                     --PMAP-- ---#1---
            encodeAndAssertEquals("10000000 10000010", msg2);

            //                     --PMAP-- ---#1---
            encodeAndAssertEquals("10000000 10000000", msg3);

            //                     --PMAP-- ---#1---
            encodeAndAssertEquals("10000000 10000100", msg4);

            readMessageAndAssertEquals(msg1);
            readMessageAndAssertEquals(msg2);
            readMessageAndAssertEquals(msg3);
            readMessageAndAssertEquals(msg4);
        }
예제 #13
0
        public void TestDecodeMessageWithSignedIntegerFieldTypesAndAllOperators()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.I32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.I32, Operator.DELTA, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.I32, Operator.INCREMENT,
                        new IntegerValue(10), false),
                    new Scalar("4", FASTType.I32, Operator.INCREMENT,
                        ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.I32, Operator.CONSTANT,
                        new IntegerValue(1), false), /* NON-TRANSFERRABLE */
                new Scalar("6", FASTType.I32, Operator.DEFAULT,
                        new IntegerValue(2), false)
                });

            GroupValue message = new Message(template);
            message.SetInteger(1, 109);
            message.SetInteger(2, 29470);
            message.SetInteger(3, 10);
            message.SetInteger(4, 3);
            message.SetInteger(5, 1);
            message.SetInteger(6, 2);

            //             --PMAP-- --TID--- --------#1------- ------------#2------------ ---#4---
            const string msg1 = "11101000 11110001 00000000 11101101 00000001 01100110 10011110 10000011";

            //             --PMAP-- ---#2--- ---#6---
            const string msg2 = "10000100 11111111 10000011";

            //             --PMAP-- --------#1------- --------#2------- ---#4--- ---#6---
            const string msg3 = "10101100 00000000 11100000 00001000 10000111 10000001 10000011";

            Stream input = ByteUtil.CreateByteStream(msg1 + ' ' + msg2 + ' ' +
                    msg3);
            var context = new Context();
            context.RegisterTemplate(113, template);

            var decoder = new FastDecoder(context, input);

            Message readMessage = decoder.ReadMessage();
            Assert.AreEqual(message, readMessage);

            message.SetInteger(2, 29469);
            message.SetInteger(3, 11);
            message.SetInteger(4, 4);
            message.SetInteger(6, 3);

            readMessage = decoder.ReadMessage();
            Assert.AreEqual(message, readMessage);

            message.SetInteger(1, 96);
            message.SetInteger(2, 30500);
            message.SetInteger(3, 12);
            message.SetInteger(4, 1);

            readMessage = decoder.ReadMessage();
            Assert.AreEqual(message, readMessage);
        }
예제 #14
0
        public void testDecodeSimpleMessage()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false)
                });
            Stream input = ByteUtil.CreateByteStream("11100000 11110001 10000001");
            var context = new Context();
            context.RegisterTemplate(113, template);

            var message = new Message(template);
            message.SetInteger(1, 1);

            var decoder = new FastDecoder(context, input);
            GroupValue readMessage = decoder.ReadMessage();
            Assert.AreEqual(message, readMessage);
            Assert.AreEqual(readMessage, message);
        }
예제 #15
0
        public void TestEncodeMessageWithOverlongPmap()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false),
                    new Scalar("1", FASTType.U32, Operator.COPY, new IntegerValue(1), false)
                });

            var context = new Context();
            context.RegisterTemplate(113, template);

            var message = new Message(template);
            message.SetInteger(1, 1);
            message.SetInteger(2, 1);
            message.SetInteger(3, 1);
            message.SetInteger(4, 1);
            message.SetInteger(5, 1);
            message.SetInteger(6, 1);
            message.SetInteger(7, 1);

            //               --PMAP-- --PMAP-- --PMAP-- --TID---
            //WHAT IT THINKS 01000000 00000000 10000000 11110001
            const string msgstr = "11000000 11110001";

            AssertEquals(msgstr, new FastEncoder(context).Encode(message));
        }
        public void TestEmptyOperatorWithOptionalField()
        {
            var field = new Scalar("", FASTType.U32, Operator.NONE,
                    ScalarValue.UNDEFINED, true);
            MessageTemplate template = registerTemplate(field);

            var message = new Message(template);
            message.SetInteger(1, 126);

            //                 --PMAP-- --TID--- ---#1---
            const string encoding = "11000000 11110001 11111111";

            encodeAndAssertEquals(encoding, message);

            GroupValue readMessage = decoder.ReadMessage();

            Assert.AreEqual(message, readMessage);
        }
예제 #17
0
        public void TestEncodeMessageWithUnsignedIntegerFieldTypesAndAllOperators()
        {
            var template = new MessageTemplate("",
                    new Field[] {
                    new Scalar("1", FASTType.U32, Operator.COPY, ScalarValue.UNDEFINED, false),
                    new Scalar("2", FASTType.U32, Operator.DELTA, ScalarValue.UNDEFINED, false),
                    new Scalar("3", FASTType.I32, Operator.INCREMENT, new IntegerValue(10), false),
                    new Scalar("4", FASTType.I32, Operator.INCREMENT, ScalarValue.UNDEFINED, false),
                    new Scalar("5", FASTType.I32, Operator.CONSTANT, new IntegerValue(1), false), /* NON-TRANSFERRABLE */
                    new Scalar("6", FASTType.I32, Operator.DEFAULT, new IntegerValue(2), false)
                });
            var context = new Context();
            context.RegisterTemplate(113, template);

            var encoder = new FastEncoder(context);

            var message = new Message(template);
            message.SetInteger(1, 109);
            message.SetInteger(2, 29470);
            message.SetInteger(3, 10);
            message.SetInteger(4, 3);
            message.SetInteger(5, 1);
            message.SetInteger(6, 2);

            //             --PMAP-- --TID--- ---#1--- ------------#2------------ ---#4---
            const string msg1 = "11101000 11110001 11101101 00000001 01100110 10011110 10000011";
            AssertEquals(msg1, encoder.Encode(message));

            message.SetInteger(2, 29471);
            message.SetInteger(3, 11);
            message.SetInteger(4, 4);
            message.SetInteger(6, 3);

            //             --PMAP-- ---#2--- ---#6---
            const string msg2 = "10000100 10000001 10000011";
            AssertEquals(msg2, encoder.Encode(message));

            message.SetInteger(1, 96);
            message.SetInteger(2, 30500);
            message.SetInteger(3, 12);
            message.SetInteger(4, 1);

            //             --PMAP-- ---#1--- --------#2------- ---#4--- ---#6---
            const string msg3 = "10101100 11100000 00001000 10000101 10000001 10000011";
            AssertEquals(msg3, encoder.Encode(message));
        }