コード例 #1
0
 public void OnReceiveHlaGenericInteraction(HlaGenericInteractionMessage msg)
 {
     message = msg;
     if (log.IsDebugEnabled)
     {
         log.Debug("Received LastMessage =  " + msg.ToString());
     }
     PulseMonitor();
 }
コード例 #2
0
        public void TestHlaGenericInteractionMessage()
        {
            lock (syncObject)
            {
                long ticks = System.DateTime.Now.Ticks;
                HlaGenericInteractionMessage msg = new HlaGenericInteractionMessage();
                msg.UserSuppliedTag = System.Text.UnicodeEncoding.Unicode.GetBytes("Sample user data Generic");
                msg.ParameterList   = new HLAparameterHandleValuePair[2];

                msg.ParameterList[0] = new HLAparameterHandleValuePair();
                msg.ParameterList[0].ParameterHandle = 1;
                msg.ParameterList[0].ParameterValue  = BitConverter.GetBytes(Math.PI);

                msg.ParameterList[1] = new HLAparameterHandleValuePair();
                msg.ParameterList[1].ParameterHandle = 2;
                msg.ParameterList[1].ParameterValue  = BitConverter.GetBytes(ticks);

                channel.OutputStream.Position = 0;
                helper.SendInteraction(msg);

                channel.InputStream.Position = 0;
                myListener.LastMessage       = null;
                reliableChannel.ReliableRead();

                System.Threading.Monitor.Wait(syncObject, milliSeconds);
                if (!(myListener.LastMessage is HlaGenericInteractionMessage))
                {
                    throw new RTIexception("Error reading HlaGenericInteractionMessage");
                }
                else
                {
                    HlaGenericInteractionMessage lastMsg = myListener.LastMessage as HlaGenericInteractionMessage;

                    Assert.AreEqual(lastMsg.FederationExecutionHandle, msg.FederationExecutionHandle);
                    Assert.AreEqual(lastMsg.InteractionClassHandle, msg.InteractionClassHandle);
                    Assert.AreEqual(lastMsg.UserSuppliedTag, msg.UserSuppliedTag);
                    Assert.AreEqual(lastMsg.ParameterList.Length, msg.ParameterList.Length);
                    Assert.AreEqual(lastMsg.ParameterList[0].ParameterValue, msg.ParameterList[0].ParameterValue);
                    Assert.AreEqual(lastMsg.ParameterList[1].ParameterValue, msg.ParameterList[1].ParameterValue);
                    Assert.AreEqual(Math.PI, BitConverter.ToDouble(msg.ParameterList[0].ParameterValue, 0));
                    Assert.AreEqual(ticks, BitConverter.ToInt64(msg.ParameterList[1].ParameterValue, 0));
                }
            }
        }
コード例 #3
0
ファイル: InteractionTests.cs プロジェクト: superliujian/Sxta
 public void OnReceiveHlaGenericInteraction(HlaGenericInteractionMessage msg)
 {
     message = msg;
     if (log.IsDebugEnabled) log.Debug("Received LastMessage =  " + msg.ToString());
     PulseMonitor();
 }
コード例 #4
0
ファイル: InteractionTests.cs プロジェクト: superliujian/Sxta
        public void TestHlaGenericInteractionMessage()
        {
            lock (syncObject)
            {
                long ticks = System.DateTime.Now.Ticks;
                HlaGenericInteractionMessage msg = new HlaGenericInteractionMessage();
                msg.UserSuppliedTag = System.Text.UnicodeEncoding.Unicode.GetBytes("Sample user data Generic");
                msg.ParameterList = new HLAparameterHandleValuePair[2];

                msg.ParameterList[0] = new HLAparameterHandleValuePair();
                msg.ParameterList[0].ParameterHandle = 1;
                msg.ParameterList[0].ParameterValue = BitConverter.GetBytes(Math.PI);

                msg.ParameterList[1] = new HLAparameterHandleValuePair();
                msg.ParameterList[1].ParameterHandle = 2;
                msg.ParameterList[1].ParameterValue = BitConverter.GetBytes(ticks);

                channel.OutputStream.Position = 0;
                helper.SendInteraction(msg);

                channel.InputStream.Position = 0;
                myListener.LastMessage = null;
                reliableChannel.ReliableRead();

                System.Threading.Monitor.Wait(syncObject, milliSeconds);
                if (!(myListener.LastMessage is HlaGenericInteractionMessage))
                {
                    throw new RTIexception("Error reading HlaGenericInteractionMessage");
                }
                else
                {
                    HlaGenericInteractionMessage lastMsg = myListener.LastMessage as HlaGenericInteractionMessage;

                    Assert.AreEqual(lastMsg.FederationExecutionHandle, msg.FederationExecutionHandle);
                    Assert.AreEqual(lastMsg.InteractionClassHandle, msg.InteractionClassHandle);
                    Assert.AreEqual(lastMsg.UserSuppliedTag, msg.UserSuppliedTag);
                    Assert.AreEqual(lastMsg.ParameterList.Length, msg.ParameterList.Length);
                    Assert.AreEqual(lastMsg.ParameterList[0].ParameterValue, msg.ParameterList[0].ParameterValue);
                    Assert.AreEqual(lastMsg.ParameterList[1].ParameterValue, msg.ParameterList[1].ParameterValue);
                    Assert.AreEqual(Math.PI, BitConverter.ToDouble(msg.ParameterList[0].ParameterValue, 0));
                    Assert.AreEqual(ticks, BitConverter.ToInt64(msg.ParameterList[1].ParameterValue, 0));
                }
            }
        }