Esempio n. 1
0
        void IMessagePool.AddMessage(Message message)
        {
            if (!(message is T))
            {
                throw new System.ArgumentException($"MessagePool<{MessageRegistry.GetRosMessageName<T>()}> can't store a \"{message.RosMessageName}\" message.");
            }

            AddMessage((T)message);
        }
Esempio n. 2
0
        public void RegisterAndGet_OneMessage_ReturnsMessageNameAndDeserialize()
        {
            const string rosMessageName = "testmessage";
            Func <MessageDeserializer, TestMessage> deserializer = des => new TestMessage();

            MessageRegistry.Register(rosMessageName, deserializer);

            Assert.AreEqual(rosMessageName, MessageRegistry.GetRosMessageName <TestMessage>());
            Assert.AreEqual(deserializer, MessageRegistry.GetDeserializeFunction <TestMessage>());
            Assert.AreEqual(deserializer, MessageRegistry.GetDeserializeFunction(rosMessageName));
        }
Esempio n. 3
0
        public void RegisterAndGet_Subtopics_ReturnCorrectDeserializers()
        {
            const string rosMessageName = "testmessage";
            Func <MessageDeserializer, TestMessage>  deserializer  = des => new TestMessage();
            Func <MessageDeserializer, TestResponse> deserializer2 = des => new TestResponse();

            MessageRegistry.Register(rosMessageName, deserializer, MessageSubtopic.Default);
            MessageRegistry.Register(rosMessageName, deserializer2, MessageSubtopic.Response);

            Assert.AreEqual(rosMessageName, MessageRegistry.GetRosMessageName <TestMessage>());
            Assert.AreEqual(rosMessageName, MessageRegistry.GetRosMessageName <TestResponse>());
            Assert.AreEqual(MessageSubtopic.Default, MessageRegistry.GetSubtopic <TestMessage>());
            Assert.AreEqual(MessageSubtopic.Response, MessageRegistry.GetSubtopic <TestResponse>());
            Assert.AreEqual(deserializer, MessageRegistry.GetDeserializeFunction <TestMessage>());
            Assert.AreEqual(deserializer, MessageRegistry.GetDeserializeFunction(rosMessageName, MessageSubtopic.Default));
            Assert.AreEqual(deserializer2, MessageRegistry.GetDeserializeFunction <TestResponse>());
            Assert.AreEqual(deserializer2, MessageRegistry.GetDeserializeFunction(rosMessageName, MessageSubtopic.Response));
            Assert.IsNull(MessageRegistry.GetDeserializeFunction(rosMessageName, MessageSubtopic.Goal));
        }
 public static void RegisterTypeVisualizer <MsgType>(IVisualFactory visualFactory, int priority = 0) where MsgType : Message
 {
     RegisterTypeVisualizer(MessageRegistry.GetRosMessageName <MsgType>(), visualFactory, priority, MessageRegistry.GetSubtopic <MsgType>());
 }