Ejemplo n.º 1
0
        public void TestAssertLiveliness()
        {
            // Initialize entities
            DataWriterQos qos = new DataWriterQos();

            qos.Liveliness.Kind          = LivelinessQosPolicyKind.ManualByTopicLivelinessQos;
            qos.Liveliness.LeaseDuration = new Duration
            {
                Seconds = 1,
            };
            DataWriter writer = _publisher.CreateDataWriter(_topic, qos);

            Assert.IsNotNull(writer);

            // Manually assert liveliness
            for (int i = 0; i < 5; i++)
            {
                ReturnCode assertResult = writer.AssertLiveliness();
                Assert.AreEqual(ReturnCode.Ok, assertResult);
                System.Threading.Thread.Sleep(500);
            }

            //// Check that no liveliness has been lost
            LivelinessLostStatus status = default;
            ReturnCode           result = writer.GetLivelinessLostStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);
        }
Ejemplo n.º 2
0
        public void TestGetLivelinessLostStatus()
        {
            // Initialize entities
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Liveliness.Kind          = LivelinessQosPolicyKind.ManualByTopicLivelinessQos;
            dwQos.Liveliness.LeaseDuration = new Duration
            {
                Seconds = 1,
            };
            DataWriter writer = _publisher.CreateDataWriter(_topic, dwQos);

            Assert.IsNotNull(writer);
            TestStructDataWriter dataWriter = new TestStructDataWriter(writer);

            Assert.IsNotNull(dataWriter);

            // After half second liveliness should not be lost yet
            System.Threading.Thread.Sleep(500);

            LivelinessLostStatus status = default;
            ReturnCode           result = writer.GetLivelinessLostStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);

            // After one second and a half one liveliness should be lost
            System.Threading.Thread.Sleep(1000);

            result = writer.GetLivelinessLostStatus(ref status);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(1, status.TotalCount);
            Assert.AreEqual(1, status.TotalCountChange);
        }
Ejemplo n.º 3
0
        public ReturnCode GetLivelinessLostStatus(
            ref LivelinessLostStatus status)
        {
            ReturnCode result;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                if (status == null)
                {
                    status = new LivelinessLostStatus();
                }
                GCHandle statusGCHandle = GCHandle.Alloc(status, GCHandleType.Normal);
                result = uResultToReturnCode(
                    User.Writer.GetLivelinessLostStatus(
                        rlReq_UserPeer, 1, LivelinessLostStatusMarshaler.CopyOut, GCHandle.ToIntPtr(statusGCHandle)));
                status = statusGCHandle.Target as LivelinessLostStatus;
                statusGCHandle.Free();
            }
            else
            {
                result = DDS.ReturnCode.AlreadyDeleted;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
 private void PrivateLivelinessLost(IntPtr entityData, IntPtr writerPtr, LivelinessLostStatus status)
 {
     if (listener != null)
     {
         IDataWriter dataWriter = (IDataWriter)OpenSplice.SacsSuperClass.fromUserData(writerPtr);
         listener.OnLivelinessLost(dataWriter, status);
     }
 }
 private void PrivateLivelinessLost(IntPtr entityData, IntPtr writerPtr, LivelinessLostStatus status)
 {
     if (listener != null)
     {
         IDataWriter dataWriter = (IDataWriter)OpenSplice.SacsSuperClass.fromUserData(writerPtr);
         listener.OnLivelinessLost(dataWriter, status);
     }
 }
Ejemplo n.º 6
0
 public ReturnCode GetLivelinessLostStatus(
     ref LivelinessLostStatus status)
 {
     if (status == null)
     {
         status = new LivelinessLostStatus();
     }
     return(Gapi.DataWriter.get_liveliness_lost_status(GapiPeer, status));
 }
Ejemplo n.º 7
0
        internal static V_RESULT CopyOut(IntPtr fromPtr, IntPtr toPtr)
        {
            v_livelinessLostInfo from = (v_livelinessLostInfo)Marshal.PtrToStructure(fromPtr, type);

            GCHandle             toGCHandle = GCHandle.FromIntPtr(toPtr);
            LivelinessLostStatus to         = toGCHandle.Target as LivelinessLostStatus;

            V_RESULT result = CopyOut(ref from, to);

            toGCHandle.Target = to;
            return(result);
        }
Ejemplo n.º 8
0
 public override void OnLivelinessLost(DataWriter writer, LivelinessLostStatus status)
 {
     LivelinessLost?.Invoke(writer, status);
 }
Ejemplo n.º 9
0
 /*! This event is raised when the DataWriter failed to signal its liveliness
  * within the time specified by the LivelinessQosPolicy */
 public void OnLivelinessLostHendler(DataWriter dataWriter, LivelinessLostStatus status)
 {
     Console.WriteLine("Liveliness Lost on DataWriter: " + dataWriter.Name);
 }
Ejemplo n.º 10
0
 public static extern ReturnCode get_liveliness_lost_status(
     IntPtr _this,
     LivelinessLostStatus status
     );
Ejemplo n.º 11
0
 public static extern ReturnCode get_liveliness_lost_status(
     IntPtr _this,
     LivelinessLostStatus status
     );
Ejemplo n.º 12
0
 internal static V_RESULT CopyOut(ref v_livelinessLostInfo from, LivelinessLostStatus to)
 {
     to.TotalCount       = from.totalCount;
     to.TotalCountChange = from.totalChanged;
     return(V_RESULT.OK);
 }