diff --git a/.github/workflows/ci_standard.yaml b/.github/workflows/ci_standard.yaml
index 9b9f9bc3..f17f8dac 100644
--- a/.github/workflows/ci_standard.yaml
+++ b/.github/workflows/ci_standard.yaml
@@ -80,16 +80,12 @@ jobs:
if: steps.opendds-libraries-windows.outputs.cache-hit != 'true'
run: ${{ github.workspace }}/Build/OpenDDSharp.Build.ps1 --BuildConfiguration=${{ matrix.BuildConfiguration }} --BuildPlatform=${{ matrix.BuildPlatform }} --OpenDdsVersion=${{ env.OpenDdsVersion }} --IgnoreThirdPartySetup=False --IgnoreThirdPartyBuild=False --VisualStudioVersion=VS2022
working-directory: ${{ github.workspace }}/Build
- env:
- _NO_DEBUG_HEAP: 1
- name: Build & Test with Cake (Cached)
shell: pwsh
if: steps.opendds-libraries-windows.outputs.cache-hit == 'true'
run: ${{ github.workspace }}/Build/OpenDDSharp.Build.ps1 --BuildConfiguration=${{ matrix.BuildConfiguration }} --BuildPlatform=${{ matrix.BuildPlatform }} --OpenDdsVersion=${{ env.OpenDdsVersion }} --IgnoreThirdPartySetup=True --IgnoreThirdPartyBuild=True --VisualStudioVersion=VS2022
working-directory: ${{ github.workspace }}/Build
- env:
- _NO_DEBUG_HEAP: 1
- name: Test Report
uses: dorny/test-reporter@v1
diff --git a/Build/OpenDDSharp.Build/OpenDDSharp.Build.csproj b/Build/OpenDDSharp.Build/OpenDDSharp.Build.csproj
index b0708690..a437ad4e 100644
--- a/Build/OpenDDSharp.Build/OpenDDSharp.Build.csproj
+++ b/Build/OpenDDSharp.Build/OpenDDSharp.Build.csproj
@@ -24,12 +24,12 @@
-
+
all
-
+
all
@@ -39,7 +39,7 @@
all
-
+
all
diff --git a/Build/OpenDDSharp.Build/Tasks/TestTask.cs b/Build/OpenDDSharp.Build/Tasks/TestTask.cs
index 34b24bb7..21f15cfc 100644
--- a/Build/OpenDDSharp.Build/Tasks/TestTask.cs
+++ b/Build/OpenDDSharp.Build/Tasks/TestTask.cs
@@ -38,7 +38,7 @@ public override void Run(BuildContext context)
context.Log.Information("Starting test task...");
var solutionFullPath = Path.GetFullPath(BuildContext.OPENDDSHARP_SOLUTION_FOLDER);
- var path = Path.Combine(solutionFullPath, $"Tests/OpenDDSharp.UnitTest/bin/{context.BuildConfiguration}/net6.0/{context.RunTime}");
+ var path = Path.Combine(solutionFullPath, $"Tests/OpenDDSharp.UnitTest/bin/{context.BuildConfiguration}/net8.0/{context.RunTime}");
context.Log.Information($"Unit test path: {path}");
var testAdapterPath = Path.Combine(BuildContext.OPENDDSHARP_SOLUTION_FOLDER, "packages/coverlet.collector/6.0.2/build/netstandard2.0");
var settingsFile = Path.Combine(solutionFullPath, "Tests.runsettings");
diff --git a/Examples/ConsoleDemoCore/ConsoleDemoCore.csproj b/Examples/ConsoleDemoCore/ConsoleDemoCore.csproj
index b07ad62b..17fce79e 100644
--- a/Examples/ConsoleDemoCore/ConsoleDemoCore.csproj
+++ b/Examples/ConsoleDemoCore/ConsoleDemoCore.csproj
@@ -15,12 +15,12 @@
-
+
all
-
+
all
@@ -30,7 +30,7 @@
all
-
+
all
diff --git a/Native/CSharpCDRImplTemplate.txt b/Native/CSharpCDRImplTemplate.txt
index 42d9ba92..42d8163b 100644
--- a/Native/CSharpCDRImplTemplate.txt
+++ b/Native/CSharpCDRImplTemplate.txt
@@ -71,7 +71,7 @@
[SuppressUnmanagedCodeSecurity]
internal static partial class <%TYPE%>TypeSupportNative
{
-#if NET7_0_OR_GREATER
+#if NET8_0_OR_GREATER
[SuppressUnmanagedCodeSecurity]
[LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>TypeSupport_new", StringMarshalling = StringMarshalling.Utf8)]
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
@@ -307,7 +307,7 @@
public static partial class <%TYPE%>DataWriterNative
{
-#if NET7_0_OR_GREATER
+#if NET8_0_OR_GREATER
[SuppressUnmanagedCodeSecurity]
[LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataWriter_Narrow")]
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
@@ -452,40 +452,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadWithCondition(_native, ref rd, ref ri, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -501,40 +501,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.Read(_native, ref rd, ref ri, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.Read(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -565,40 +565,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeWithCondition(_native, ref rd, ref ri, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -614,40 +614,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.Take(_native, ref rd, ref ri, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.Take(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -678,40 +678,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadInstanceWithCondition(_native, ref rd, ref ri, (int)handle, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadInstanceWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, (int)handle, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -727,40 +727,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadInstance(_native, ref rd, ref ri, handle, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadInstance(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, handle, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -791,40 +791,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeInstanceWithCondition(_native, ref rd, ref ri, (int)handle, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeInstanceWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, (int)handle, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -840,40 +840,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeInstance(_native, ref rd, ref ri, handle, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeInstance(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, handle, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -904,40 +904,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextInstanceWithCondition(_native, ref rd, ref ri, previousHandle, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextInstanceWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, previousHandle, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -953,40 +953,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextInstance(_native, ref rd, ref ri, previousHandle, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextInstance(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, previousHandle, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -1017,40 +1017,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextInstanceWithCondition(_native, ref rd, ref ri, previousHandle, maxSamples, condition.ToNative());
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextInstanceWithCondition(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, previousHandle, maxSamples, condition.ToNative());
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -1066,40 +1066,40 @@
receivedData.Clear();
receivedInfo.Clear();
- IntPtr rd = IntPtr.Zero;
- IntPtr ri = IntPtr.Zero;
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
ReturnCode ret = ReturnCode.Error;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextInstance(_native, ref rd, ref ri, previousHandle, maxSamples, sampleStates, viewStates, instanceStates);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextInstance(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo, previousHandle, maxSamples, sampleStates, viewStates, instanceStates);
- if (ret == ReturnCode.Ok && !rd.Equals(IntPtr.Zero) && !ri.Equals(IntPtr.Zero))
+ if (ret == ReturnCode.Ok && !ptrData.Equals(IntPtr.Zero) && !ptrInfo.Equals(IntPtr.Zero))
{
- IList data = new List();
- IList info = new List();
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- MarshalHelper.PtrToUTF8StringSequence(rd, ref data);
- MarshalHelper.PtrToSequence(ri, ref info);
+ OpenDDSharp.Marshaller.Cdr.CdrReader reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(dataArray);
+ var total = reader.ReadUInt32();
- if (data != null)
+ for (int i = 0; i < total; i++)
{
- foreach (var d in data)
- {
- receivedData.Add(_typeSupport.DecodeFromString(d));
- }
+ var sample = new <%TYPE%>();
+ sample.FromCDR(reader);
+ receivedData.Add(sample);
}
- if (info != null && info.Count > 0)
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+ reader = new OpenDDSharp.Marshaller.Cdr.CdrReader(infoArray);
+ total = reader.ReadUInt32();
+
+ for (int i = 0; i < total; i++)
{
- foreach (var i in info)
- {
- SampleInfo aux = new SampleInfo();
- aux.FromNative(i);
- receivedInfo.Add(aux);
- }
+ var sampleInfo = new SampleInfo();
+ sampleInfo.FromCDR(reader);
+ receivedInfo.Add(sampleInfo);
}
-
- MarshalHelper.ReleaseNativeStringSequence(rd);
- MarshalHelper.ReleaseNativePointer(ri);
}
return ret;
@@ -1113,21 +1113,25 @@
}
ReturnCode ret = ReturnCode.Error;
- IntPtr ptr = IntPtr.Zero;
- SampleInfoWrapper infoWrapper = new SampleInfoWrapper();
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
- UIntPtr size = UIntPtr.Zero;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextSample(_native, ref ptr, ref size, ref infoWrapper);
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.ReadNextSample(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo);
if (ret == ReturnCode.Ok)
{
- byte[] managedArray = new byte[(int)size];
- Marshal.Copy(ptr, managedArray, 0, (int)size);
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- var sample = _typeSupport.DecodeFromBytes(managedArray);
+ var sample = _typeSupport.DecodeFromBytes(dataArray);
data.MemberwiseCopy(sample);
- sampleInfo.FromNative(infoWrapper);
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+
+ sampleInfo.FromCDR(infoArray);
}
return ret;
@@ -1141,19 +1145,25 @@
}
ReturnCode ret = ReturnCode.Error;
- var ptr = IntPtr.Zero;
- var infoWrapper = new SampleInfoWrapper();
- var size = UIntPtr.Zero;
- ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextSample(_native, ref ptr, ref size, ref infoWrapper);
+ IntPtr ptrData = IntPtr.Zero;
+ IntPtr ptrInfo = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
+ UIntPtr sizeInfo = UIntPtr.Zero;
+
+ ret = (ReturnCode)<%TYPE%>DataReaderNative.TakeNextSample(_native, ref ptrData, ref sizeData, ref ptrInfo, ref sizeInfo);
+
if (ret == ReturnCode.Ok)
{
- byte[] managedArray = new byte[(int)size];
- Marshal.Copy(ptr, managedArray, 0, (int)size);
+ byte[] dataArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, dataArray, 0, (int)sizeData);
- var sample = _typeSupport.DecodeFromBytes(managedArray);
+ var sample = _typeSupport.DecodeFromBytes(dataArray);
data.MemberwiseCopy(sample);
- sampleInfo.FromNative(infoWrapper);
+ byte[] infoArray = new byte[(int)sizeInfo];
+ Marshal.Copy(ptrInfo, infoArray, 0, (int)sizeInfo);
+
+ sampleInfo.FromCDR(infoArray);
}
return ret;
@@ -1171,23 +1181,18 @@
return ReturnCode.BadParameter;
}
- var str = _typeSupport.EncodeToString(data);
- var ptr = MarshalHelper.NativeUtf8FromString(str);
+ IntPtr ptrData = IntPtr.Zero;
+ UIntPtr sizeData = UIntPtr.Zero;
- var ret = (ReturnCode)<%TYPE%>DataReaderNative.GetKeyValue(_native, ref ptr, handle);
+ var ret = (ReturnCode)<%TYPE%>DataReaderNative.GetKeyValue(_native, ref ptrData, ref sizeData, handle);
if (ret == ReturnCode.Ok)
{
- var json_data = MarshalHelper.StringFromNativeUtf8(ptr) ?? string.Empty;
-
- if (!string.IsNullOrWhiteSpace(json_data))
- {
- var sample = _typeSupport.DecodeFromString(json_data);
+ byte[] managedArray = new byte[(int)sizeData];
+ Marshal.Copy(ptrData, managedArray, 0, (int)sizeData);
- data.MemberwiseCopy(sample);
- }
-
- MarshalHelper.ReleaseNativeStringPointer(ptr);
+ var sample = _typeSupport.DecodeFromBytes(managedArray);
+ data.MemberwiseCopy(sample);
}
return ret;
@@ -1197,9 +1202,9 @@
{
InstanceHandle ret = InstanceHandle.HandleNil;
- var json_data = _typeSupport.EncodeToString(instance);
+ var bytes = _typeSupport.EncodeToBytes(instance);
- ret = <%TYPE%>DataReaderNative.LookupInstance(_native, json_data);
+ ret = <%TYPE%>DataReaderNative.LookupInstance(_native, bytes, (UIntPtr)bytes.Length);
return ret;
}
@@ -1208,158 +1213,158 @@
internal static partial class <%TYPE%>DataReaderNative
{
-#if NET7_0_OR_GREATER
+#if NET8_0_OR_GREATER
[SuppressUnmanagedCodeSecurity]
[LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Narrow")]
[UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
internal static partial IntPtr Narrow(IntPtr dr);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Read_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int Read(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Read_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int Read(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int ReadWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Take_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int Take(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Take_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int Take(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int TakeWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstance_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int ReadInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstance_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int ReadInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstance_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int TakeInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstance_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int TakeInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstance_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int ReadNextInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstance_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadNextInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int ReadNextInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadNextInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstance_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int TakeNextInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstance_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeNextInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int TakeNextInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeNextInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [SuppressGCTransition]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadNextSample(IntPtr dr, [In, Out] ref IntPtr cdr_data, [In, Out] ref UIntPtr size, [In, Out] ref SampleInfoWrapper sampleInfo);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int ReadNextSample(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo);
[SuppressUnmanagedCodeSecurity]
- [SuppressGCTransition]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeNextSample(IntPtr dr, [In, Out] ref IntPtr cdr_data, [In, Out] ref UIntPtr size, [In, Out] ref SampleInfoWrapper sampleInfo);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int TakeNextSample(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_LookupInstance_Json", StringMarshalling = StringMarshalling.Utf8)]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int LookupInstance(IntPtr dr, string jsonData);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_LookupInstance_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int LookupInstance(IntPtr dr, byte[] cdrData, UIntPtr sizeData);
[SuppressUnmanagedCodeSecurity]
- [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_GetKeyValue_Json")]
- [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
- internal static partial int GetKeyValue(IntPtr dr, ref IntPtr data, int handle);
+ [LibraryImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_GetKeyValue_Cdr")]
+ [UnmanagedCallConv(CallConvs = new[] { typeof(System.Runtime.CompilerServices.CallConvSuppressGCTransition) })]
+ internal static partial int GetKeyValue(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, int handle);
#else
[SuppressUnmanagedCodeSecurity]
[DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Narrow", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr Narrow(IntPtr dr);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Read_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Read(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Read_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Read(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int ReadWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Take_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int Take(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_Take_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int Take(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int TakeWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstance_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstance_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int ReadInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int ReadInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstance_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstance_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int TakeInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int TakeInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstance_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadNextInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstance_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int ReadNextInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadNextInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int ReadNextInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstance_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeNextInstance(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstance_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int TakeNextInstance(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, uint sampleStates, uint viewStates, uint instanceStates);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeNextInstanceWithCondition(IntPtr dr, ref IntPtr receivedData, ref IntPtr receivedInfo, int handle, int maxSamples, IntPtr condition);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int TakeNextInstanceWithCondition(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo, int handle, int maxSamples, IntPtr condition);
[SuppressUnmanagedCodeSecurity]
[DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int ReadNextSample(IntPtr dr, [In, Out] ref IntPtr json_data, [In, Out] ref UIntPtr size, [In, Out] ref SampleInfoWrapper sampleInfo);
+ internal static extern int ReadNextSample(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo);
[SuppressUnmanagedCodeSecurity]
[DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int TakeNextSample(IntPtr dr, [In, Out] ref IntPtr cdr_data, [In, Out] ref UIntPtr size, [In, Out] ref SampleInfoWrapper sampleInfo);
+ internal static extern int TakeNextSample(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, ref IntPtr cdrInfo, ref UIntPtr sizeInfo);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_LookupInstance_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int LookupInstance(IntPtr dr, [MarshalAs(UnmanagedType.LPStr), In]string jsonData);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_LookupInstance_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int LookupInstance(IntPtr dr, byte[] cdrData, UIntPtr sizeData);
[SuppressUnmanagedCodeSecurity]
- [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_GetKeyValue_Json", CallingConvention = CallingConvention.Cdecl)]
- internal static extern int GetKeyValue(IntPtr dr, [In, Out] ref IntPtr data, int handle);
+ [DllImport(<%TYPE%>.API_DLL, EntryPoint = "<%SCOPED_METHOD%>DataReader_GetKeyValue_Cdr", CallingConvention = CallingConvention.Cdecl)]
+ internal static extern int GetKeyValue(IntPtr dr, ref IntPtr cdrData, ref UIntPtr sizeData, int handle);
#endif
}
\ No newline at end of file
diff --git a/Native/CWrapperHeaderTemplate.txt b/Native/CWrapperHeaderTemplate.txt
index 84f32f76..d7c13d42 100644
--- a/Native/CWrapperHeaderTemplate.txt
+++ b/Native/CWrapperHeaderTemplate.txt
@@ -62,43 +62,71 @@ EXTERN_METHOD_EXPORT <%SCOPED%>DataReader_ptr <%SCOPED_METHOD%>DataReader_Narrow
EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_ReadNextSample_Json(<%SCOPED%>DataReader_ptr dr, char* & json_data, ::DDS::SampleInfo* sampleInfo);
-EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, ::DDS::SampleInfo* sampleInfo);
+EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, char* & cdr_info, size_t & size_info);
EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_TakeNextSample_Json(<%SCOPED%>DataReader_ptr dr, char* & json_data, ::DDS::SampleInfo* sampleInfo);
-EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, ::DDS::SampleInfo* sampleInfo);
+EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, char* & cdr_info, size_t & size_info);
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Read_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Read_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Take_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Take_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr, const char* json_data);
+EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_LookupInstance_Cdr(<%SCOPED%>DataReader_ptr dr, const char* cdr_data, size_t size);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates);
+
EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+EXTERN_METHOD_EXPORT ::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition);
+
EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_GetKeyValue_Json(<%SCOPED%>DataReader_ptr dr, char* & json_data, int handle);
+EXTERN_METHOD_EXPORT int <%SCOPED_METHOD%>DataReader_GetKeyValue_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, int handle);
+
/*
#include
- using std::ofstream;
+using std::ofstream;
#include
using std::cout;
using std::endl;
@@ -156,13 +184,45 @@ void <%SCOPED_METHOD%>_serialize_to_bytes(const <%SCOPED%>& idl_value, char* &da
ACE_Message_Block mb(xcdr_size);
OpenDDS::DCPS::Serializer serializer(&mb, encoding);
if (!(serializer << idl_value)) {
- throw std::runtime_error("failed to serialize");
+ throw std::runtime_error("Failed to serialize sample of type <%SCOPED%>.");
}
data = (char*)malloc(xcdr_size);
memcpy(data, mb.base(), xcdr_size);
size = xcdr_size;
}
+void <%SCOPED_METHOD%>Seq_serialize_to_bytes(const <%SCOPED%>Seq& seq_data, char* &data, size_t &size)
+{
+ const OpenDDS::DCPS::Encoding encoding(OpenDDS::DCPS::Encoding::KIND_XCDR1, OpenDDS::DCPS::ENDIAN_LITTLE);
+
+ size_t total_size = 0;
+ OpenDDS::DCPS::primitive_serialized_size(encoding, total_size, seq_data.length());
+
+ for (CORBA::ULong i = 0; i < seq_data.length(); i++) {
+ total_size += OpenDDS::DCPS::serialized_size(encoding, seq_data[i]);
+ }
+
+ // Ensure extra space for struct alignment
+ total_size += seq_data.length() * 8;
+
+ ACE_Message_Block mb(total_size);
+ OpenDDS::DCPS::Serializer serializer(&mb, encoding);
+
+ if (!(serializer << ACE_CDR::ULong(seq_data.length()))) {
+ throw std::runtime_error("Failed to serialize sequence length.");
+ }
+
+ for (CORBA::ULong i = 0; i < seq_data.length(); i++) {
+ if (!(serializer << seq_data[i])) {
+ throw std::runtime_error("Failed to serialize sequence of type <%SCOPED%>." + std::to_string(i));
+ }
+ }
+
+ data = (char*)malloc(total_size);
+ memcpy(data, mb.base(), total_size);
+ size = total_size;
+}
+
<%SCOPED%> <%SCOPED_METHOD%>_deserialize_from_bytes(const char* xcdr, size_t size)
{
const OpenDDS::DCPS::Encoding encoding(OpenDDS::DCPS::Encoding::KIND_XCDR1, OpenDDS::DCPS::ENDIAN_LITTLE);
diff --git a/Native/CWrapperImplTemplate.txt b/Native/CWrapperImplTemplate.txt
index 158e2677..6b832154 100644
--- a/Native/CWrapperImplTemplate.txt
+++ b/Native/CWrapperImplTemplate.txt
@@ -251,14 +251,16 @@ int <%SCOPED_METHOD%>DataReader_ReadNextSample_Json(<%SCOPED%>DataReader_ptr dr,
return (int)ret;
}
-int <%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, ::DDS::SampleInfo* sampleInfo)
+int <%SCOPED_METHOD%>DataReader_ReadNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, char* & cdr_info, size_t & size_info)
{
<%SCOPED%> sample;
- ::DDS::ReturnCode_t ret = dr->read_next_sample(sample, *sampleInfo);
+ ::DDS::SampleInfo sampleInfo;
+ ::DDS::ReturnCode_t ret = dr->read_next_sample(sample, sampleInfo);
if (ret == ::DDS::RETCODE_OK)
{
<%SCOPED_METHOD%>_serialize_to_bytes(sample, cdr_data, size);
+ marshal::dds_sample_info_serialize_to_bytes(sampleInfo, cdr_info, size_info);
}
return (int)ret;
@@ -277,14 +279,16 @@ int <%SCOPED_METHOD%>DataReader_TakeNextSample_Json(<%SCOPED%>DataReader_ptr dr,
return (int)ret;
}
-int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size, ::DDS::SampleInfo* sampleInfo)
+int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size_data, char* & cdr_info, size_t & size_info)
{
<%SCOPED%> sample;
- ::DDS::ReturnCode_t ret = dr->take_next_sample(sample, *sampleInfo);
+ ::DDS::SampleInfo sampleInfo;
+ ::DDS::ReturnCode_t ret = dr->take_next_sample(sample, sampleInfo);
if (ret == ::DDS::RETCODE_OK)
{
- <%SCOPED_METHOD%>_serialize_to_bytes(sample, cdr_data, size);
+ <%SCOPED_METHOD%>_serialize_to_bytes(sample, cdr_data, size_data);
+ marshal::dds_sample_info_serialize_to_bytes(sampleInfo, cdr_info, size_info);
}
return (int)ret;
@@ -313,6 +317,24 @@ int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Read_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+
+ ::DDS::ReturnCode_t ret = dr->read(received_data, info_seq, maxSamples, sampleStates, viewStates, instanceStates);
+
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -336,6 +358,23 @@ int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+
+ ::DDS::ReturnCode_t ret = dr->read_w_condition(received_data, info_seq, maxSamples, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Take_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
{
<%SCOPED%>Seq received_data;
@@ -358,6 +397,22 @@ int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_Take_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->take(received_data, info_seq, maxSamples, sampleStates, viewStates, instanceStates);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -381,6 +436,23 @@ int <%SCOPED_METHOD%>DataReader_TakeNextSample_Cdr(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+
+ ::DDS::ReturnCode_t ret = dr->take_w_condition(received_data, info_seq, maxSamples, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr, const char* json_data)
{
<%SCOPED%>_var samplev = <%SCOPED_METHOD%>_DecodeJsonSample(json_data);
@@ -393,6 +465,14 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return dr->lookup_instance(sample);
}
+
+int <%SCOPED_METHOD%>DataReader_LookupInstance_Cdr(<%SCOPED%>DataReader_ptr dr, const char* cdr_data, size_t size)
+{
+ <%SCOPED%> sample = <%SCOPED_METHOD%>_deserialize_from_bytes(cdr_data, size);
+
+ return dr->lookup_instance(sample);
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
{
<%SCOPED%>Seq received_data;
@@ -415,6 +495,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->read_instance(received_data, info_seq, maxSamples, handle, sampleStates, viewStates, instanceStates);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -438,6 +534,23 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+
+ ::DDS::ReturnCode_t ret = dr->read_instance_w_condition(received_data, info_seq, maxSamples, handle, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
{
<%SCOPED%>Seq received_data;
@@ -460,6 +573,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->take_instance(received_data, info_seq, maxSamples, handle, sampleStates, viewStates, instanceStates);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -483,6 +612,23 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+
+ ::DDS::ReturnCode_t ret = dr->take_instance_w_condition(received_data, info_seq, maxSamples, handle, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
{
<%SCOPED%>Seq received_data;
@@ -505,6 +651,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->read_next_instance(received_data, info_seq, maxSamples, handle, sampleStates, viewStates, instanceStates);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -527,6 +689,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_ReadNextInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->read_next_instance_w_condition(received_data, info_seq, maxSamples, handle, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstance_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
{
<%SCOPED%>Seq received_data;
@@ -549,6 +727,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstance_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::SampleStateMask sampleStates, ::DDS::ViewStateMask viewStates, ::DDS::InstanceStateMask instanceStates)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->take_next_instance(received_data, info_seq, maxSamples, handle, sampleStates, viewStates, instanceStates);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Json(<%SCOPED%>DataReader_ptr dr, void*& receivedData, void*& receivedInfo, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
{
<%SCOPED%>Seq received_data;
@@ -571,6 +765,22 @@ int <%SCOPED_METHOD%>DataReader_LookupInstance_Json(<%SCOPED%>DataReader_ptr dr,
return ret;
}
+::DDS::ReturnCode_t <%SCOPED_METHOD%>DataReader_TakeNextInstanceWithCondition_Cdr(<%SCOPED%>DataReader_ptr dr, char*& cdr_data, size_t & size_data, char*& cdr_info, size_t & size_info, ::DDS::InstanceHandle_t handle, CORBA::Long maxSamples, ::DDS::ReadCondition_ptr condition)
+{
+ <%SCOPED%>Seq received_data;
+ ::DDS::SampleInfoSeq info_seq;
+ ::DDS::ReturnCode_t ret = dr->take_next_instance_w_condition(received_data, info_seq, maxSamples, handle, condition);
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED_METHOD%>Seq_serialize_to_bytes(received_data, cdr_data, size_data);
+ marshal::dds_sample_info_seq_serialize_to_bytes(info_seq, cdr_info, size_info);
+ }
+
+ dr->return_loan(received_data, info_seq);
+
+ return ret;
+}
+
int <%SCOPED_METHOD%>DataReader_GetKeyValue_Json(<%SCOPED%>DataReader_ptr dr, char* & json_data, int handle)
{
<%SCOPED%> sample_key;
@@ -585,3 +795,18 @@ int <%SCOPED_METHOD%>DataReader_GetKeyValue_Json(<%SCOPED%>DataReader_ptr dr, ch
return ret;
}
+
+int <%SCOPED_METHOD%>DataReader_GetKeyValue_Cdr(<%SCOPED%>DataReader_ptr dr, char* & cdr_data, size_t & size_data, int handle)
+{
+ <%SCOPED%> sample_key;
+ ::DDS::ReturnCode_t ret = dr->get_key_value(sample_key, handle);
+
+ if (ret == ::DDS::RETCODE_OK)
+ {
+ <%SCOPED%> sample;
+ <%SCOPED_METHOD%>_CopyKeys(&sample_key, &sample);
+ <%SCOPED_METHOD%>_serialize_to_bytes(sample, cdr_data, size_data);
+ }
+
+ return ret;
+}
diff --git a/Native/marshal.h b/Native/marshal.h
index a05c0e8f..4c6b66e3 100644
--- a/Native/marshal.h
+++ b/Native/marshal.h
@@ -509,21 +509,195 @@ class marshal {
return ptr;
}
- static DDS::Time_t dds_time_deserialize_from_bytes(const char *bytes, size_t size) {
+ static DDS::Time_t dds_time_deserialize_from_bytes(const char *bytes, size_t size)
+ {
const OpenDDS::DCPS::Encoding encoding(OpenDDS::DCPS::Encoding::KIND_XCDR1, OpenDDS::DCPS::ENDIAN_LITTLE);
+
ACE_Message_Block mb(size);
mb.copy(bytes, size);
+
OpenDDS::DCPS::Serializer serializer(&mb, encoding);
+
DDS::Time_t time_value;
if (!(serializer >> time_value.sec)) {
throw std::runtime_error("Failed to deserialize DDS::Time_t seconds from bytes");
}
if (!(serializer >> time_value.nanosec)) {
- throw std::runtime_error("Failed to deserialize DDS::Time_t nanoseconds from bytes");
+ throw std::runtime_error("Failed to deserialize DDS::Time_t nanosec from bytes");
}
return time_value;
}
+
+ static void dds_sample_info_serialize_to_bytes(DDS::SampleInfo& sample_info, char* &data, size_t &size)
+ {
+ const OpenDDS::DCPS::Encoding encoding(OpenDDS::DCPS::Encoding::KIND_XCDR1, OpenDDS::DCPS::ENDIAN_LITTLE);
+
+ size_t xcdr_size = 0;
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.valid_data);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.sample_state, 1);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.view_state);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.instance_state);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.source_timestamp.sec);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.source_timestamp.nanosec);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.instance_handle);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.publication_handle);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.disposed_generation_count);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.no_writers_generation_count);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.sample_rank);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.generation_rank);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, sample_info.absolute_generation_rank);
+
+ ACE_Message_Block mb(xcdr_size);
+
+ OpenDDS::DCPS::Serializer serializer(&mb, encoding);
+
+ if (!(serializer << sample_info.valid_data)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo valid_data to bytes");
+ }
+
+ if (!(serializer << sample_info.sample_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo sample_state to bytes");
+ }
+
+ if (!(serializer << sample_info.view_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo view_state to bytes");
+ }
+
+ if (!(serializer << sample_info.instance_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo instance_state to bytes");
+ }
+
+ if (!(serializer << sample_info.source_timestamp.sec)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo source_timestamp.sec to bytes");
+ }
+
+ if (!(serializer << sample_info.source_timestamp.nanosec)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo source_timestamp.nanosec to bytes");
+ }
+
+ if (!(serializer << sample_info.instance_handle)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo instance_handle to bytes");
+ }
+
+ if (!(serializer << sample_info.publication_handle)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo publication_handle to bytes");
+ }
+
+ if (!(serializer << sample_info.disposed_generation_count)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo disposed_generation_count to bytes");
+ }
+
+ if (!(serializer << sample_info.no_writers_generation_count)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo no_writers_generation_count to bytes");
+ }
+
+ if (!(serializer << sample_info.sample_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo sample_rank to bytes");
+ }
+
+ if (!(serializer << sample_info.generation_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo generation_rank to bytes");
+ }
+
+ if (!(serializer << sample_info.absolute_generation_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo absolute_generation_rank to bytes");
+ }
+
+ data = (char*)malloc(xcdr_size);
+ memcpy(data, mb.base(), xcdr_size);
+ size = xcdr_size;
+ }
+
+ static void dds_sample_info_seq_serialize_to_bytes(::DDS::SampleInfoSeq& seq_info, char* &data, size_t &size)
+ {
+ const OpenDDS::DCPS::Encoding encoding(OpenDDS::DCPS::Encoding::KIND_XCDR1, OpenDDS::DCPS::ENDIAN_LITTLE);
+
+ size_t xcdr_size = 0;
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].valid_data);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].sample_state, 1);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].view_state);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].instance_state);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].source_timestamp.sec);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].source_timestamp.nanosec);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].instance_handle);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].publication_handle);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].disposed_generation_count);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].no_writers_generation_count);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].sample_rank);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].generation_rank);
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info[0].absolute_generation_rank);
+
+ xcdr_size*=seq_info.length();
+
+ OpenDDS::DCPS::primitive_serialized_size(encoding, xcdr_size, seq_info.length());
+
+ ACE_Message_Block mb(xcdr_size);
+
+ OpenDDS::DCPS::Serializer serializer(&mb, encoding);
+
+ if (!(serializer << ACE_CDR::ULong(seq_info.length()))) {
+ throw std::runtime_error("Failed to serialize sequence length.");
+ }
+
+ for (int i = 0; i < seq_info.length(); i++) {
+ if (!(serializer << seq_info[i].valid_data)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo valid_data to bytes");
+ }
+
+ if (!(serializer << seq_info[i].sample_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo sample_state to bytes");
+ }
+
+ if (!(serializer << seq_info[i].view_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo view_state to bytes");
+ }
+
+ if (!(serializer << seq_info[i].instance_state)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo instance_state to bytes");
+ }
+
+ if (!(serializer << seq_info[i].source_timestamp.sec)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo source_timestamp.sec to bytes");
+ }
+
+ if (!(serializer << seq_info[i].source_timestamp.nanosec)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo source_timestamp.nanosec to bytes");
+ }
+
+ if (!(serializer << seq_info[i].instance_handle)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo instance_handle to bytes");
+ }
+
+ if (!(serializer << seq_info[i].publication_handle)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo publication_handle to bytes");
+ }
+
+ if (!(serializer << seq_info[i].disposed_generation_count)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo disposed_generation_count to bytes");
+ }
+
+ if (!(serializer << seq_info[i].no_writers_generation_count)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo no_writers_generation_count to bytes");
+ }
+
+ if (!(serializer << seq_info[i].sample_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo sample_rank to bytes");
+ }
+
+ if (!(serializer << seq_info[i].generation_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo generation_rank to bytes");
+ }
+
+ if (!(serializer << seq_info[i].absolute_generation_rank)) {
+ throw std::runtime_error("Failed to serialize DDS::SampleInfo absolute_generation_rank to bytes");
+ }
+ }
+
+ data = (char*)malloc(xcdr_size);
+ memcpy(data, mb.base(), xcdr_size);
+ size = xcdr_size;
+ }
};
#endif
\ No newline at end of file
diff --git a/Sources/OpenDDSharp.BuildTasks/OpenDDSharp.BuildTasks.csproj b/Sources/OpenDDSharp.BuildTasks/OpenDDSharp.BuildTasks.csproj
index 0d67fa19..cc2195e0 100644
--- a/Sources/OpenDDSharp.BuildTasks/OpenDDSharp.BuildTasks.csproj
+++ b/Sources/OpenDDSharp.BuildTasks/OpenDDSharp.BuildTasks.csproj
@@ -10,16 +10,16 @@
-
-
+
+
-
+
all
-
+
all
diff --git a/Sources/OpenDDSharp.Marshaller/OpenDDSharp.Marshaller.csproj b/Sources/OpenDDSharp.Marshaller/OpenDDSharp.Marshaller.csproj
index 1cfd169c..78e07323 100644
--- a/Sources/OpenDDSharp.Marshaller/OpenDDSharp.Marshaller.csproj
+++ b/Sources/OpenDDSharp.Marshaller/OpenDDSharp.Marshaller.csproj
@@ -34,18 +34,18 @@
-
+
-
+
all
-
+
all
diff --git a/Sources/OpenDDSharp/DDS/SampleInfo.cs b/Sources/OpenDDSharp/DDS/SampleInfo.cs
index d39cc013..96cca7b6 100644
--- a/Sources/OpenDDSharp/DDS/SampleInfo.cs
+++ b/Sources/OpenDDSharp/DDS/SampleInfo.cs
@@ -151,7 +151,7 @@ public void FromNative(SampleInfoWrapper wrapper)
/// Converts the time value to a CDR representation.
///
/// The byte span serialized.
- internal ReadOnlySpan ToCDR()
+ public ReadOnlySpan ToCDR()
{
var writer = new Marshaller.Cdr.CdrWriter();
writer.WriteBool(ValidData);
@@ -174,7 +174,7 @@ internal ReadOnlySpan ToCDR()
/// Updates the time value from a CDR representation.
///
/// The byte span serialized.
- internal void FromCDR(ReadOnlySpan data)
+ public void FromCDR(ReadOnlySpan data)
{
var reader = new Marshaller.Cdr.CdrReader(data.ToArray());
ValidData = reader.ReadBool();
@@ -194,6 +194,26 @@ internal void FromCDR(ReadOnlySpan data)
GenerationRank = reader.ReadInt32();
AbsoluteGenerationRank = reader.ReadInt32();
}
+
+ public void FromCDR(Marshaller.Cdr.CdrReader reader)
+ {
+ ValidData = reader.ReadBool();
+ SampleState = reader.ReadUInt32();
+ ViewState = reader.ReadUInt32();
+ InstanceState = reader.ReadUInt32();
+ SourceTimestamp = new Timestamp
+ {
+ Seconds = reader.ReadInt32(),
+ NanoSeconds = reader.ReadUInt32(),
+ };
+ InstanceHandle = reader.ReadInt32();
+ PublicationHandle = reader.ReadInt32();
+ DisposedGenerationCount = reader.ReadInt32();
+ NoWritersGenerationCount = reader.ReadInt32();
+ SampleRank = reader.ReadInt32();
+ GenerationRank = reader.ReadInt32();
+ AbsoluteGenerationRank = reader.ReadInt32();
+ }
#endregion
#region IEquatable Members
diff --git a/Sources/OpenDDSharp/DDS/WaitSet.cs b/Sources/OpenDDSharp/DDS/WaitSet.cs
index ac9031c6..4bf0c5f4 100644
--- a/Sources/OpenDDSharp/DDS/WaitSet.cs
+++ b/Sources/OpenDDSharp/DDS/WaitSet.cs
@@ -112,17 +112,19 @@ public ReturnCode Wait(ICollection activeConditions, Duration timeout
var seq = IntPtr.Zero;
var ret = UnsafeNativeMethods.Wait(_native, ref seq, timeout);
- if (ret == ReturnCode.Ok && !seq.Equals(IntPtr.Zero))
+ if (ret != ReturnCode.Ok || seq.Equals(IntPtr.Zero))
{
- ICollection lst = new Collection();
- seq.PtrToSequence(ref lst);
+ return ret;
+ }
+
+ ICollection lst = new List();
+ seq.PtrToSequence(ref lst);
- foreach (var ptr in lst)
+ foreach (var ptr in lst)
+ {
+ if (_conditions.TryGetValue(ptr, out var condition))
{
- if (_conditions.TryGetValue(ptr, out var condition))
- {
- activeConditions.Add(condition);
- }
+ activeConditions.Add(condition);
}
}
@@ -146,7 +148,7 @@ public ReturnCode AttachCondition(Condition cond)
return ReturnCode.BadParameter;
}
- ReturnCode ret = UnsafeNativeMethods.AttachCondition(_native, cond.ToNative());
+ var ret = UnsafeNativeMethods.AttachCondition(_native, cond.ToNative());
if (ret == ReturnCode.Ok)
{
@@ -171,7 +173,7 @@ public ReturnCode DetachCondition(Condition cond)
return ReturnCode.BadParameter;
}
- ReturnCode ret = UnsafeNativeMethods.DetachCondition(_native, cond.ToNative());
+ var ret = UnsafeNativeMethods.DetachCondition(_native, cond.ToNative());
if (ret == ReturnCode.Ok)
{
@@ -194,8 +196,8 @@ public ReturnCode GetConditions(ICollection attachedConditions)
}
attachedConditions.Clear();
- IntPtr seq = IntPtr.Zero;
- ReturnCode ret = UnsafeNativeMethods.GetConditions(_native, ref seq);
+ var seq = IntPtr.Zero;
+ var ret = UnsafeNativeMethods.GetConditions(_native, ref seq);
if (ret == ReturnCode.Ok && !seq.Equals(IntPtr.Zero))
{
diff --git a/Sources/OpenDDSharp/OpenDDSharp.csproj b/Sources/OpenDDSharp/OpenDDSharp.csproj
index eaa7c7b8..eca726bd 100644
--- a/Sources/OpenDDSharp/OpenDDSharp.csproj
+++ b/Sources/OpenDDSharp/OpenDDSharp.csproj
@@ -42,12 +42,12 @@
-
+
all
-
+
all
@@ -57,7 +57,7 @@
all
-
+
all
diff --git a/Tests/BenchmarkPerformance/PerformanceTests/OpenDDSharpLatencyTest.cs b/Tests/BenchmarkPerformance/PerformanceTests/OpenDDSharpLatencyTest.cs
index 1de03081..706ea248 100644
--- a/Tests/BenchmarkPerformance/PerformanceTests/OpenDDSharpLatencyTest.cs
+++ b/Tests/BenchmarkPerformance/PerformanceTests/OpenDDSharpLatencyTest.cs
@@ -118,12 +118,16 @@ private void InitializeDDSEntities()
var dwQos = new DataWriterQos
{
- Reliability = { Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos },
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
History =
{
Kind = HistoryQosPolicyKind.KeepLastHistoryQos,
Depth = 1,
},
+ Durability = { Kind = DurabilityQosPolicyKind.VolatileDurabilityQos}
};
var dw = _publisher.CreateDataWriter(_topic, dwQos);
_dataWriter = new KeyedOctetsDataWriter(dw);
@@ -136,24 +140,28 @@ private void InitializeDDSEntities()
var drQos = new DataReaderQos
{
- Reliability = { Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos },
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
History =
{
Kind = HistoryQosPolicyKind.KeepLastHistoryQos,
Depth = 1,
},
+ Durability = { Kind = DurabilityQosPolicyKind.VolatileDurabilityQos}
};
var dr = _subscriber.CreateDataReader(_topic, drQos);
_dataReader = new KeyedOctetsDataReader(dr);
- _dataWriter.Enable();
- _dataReader.Enable();
-
_waitSet = new WaitSet();
_statusCondition = _dataReader.StatusCondition;
_statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
_waitSet.AttachCondition(_statusCondition);
+ _dataWriter.Enable();
+ _dataReader.Enable();
+
_readerThread = new Thread(ReaderThreadProc)
{
IsBackground = true,
@@ -172,7 +180,9 @@ private void ReaderThreadProc()
var sample = new KeyedOctets();
var sampleInfo = new SampleInfo();
+
_dataReader.TakeNextSample(sample, sampleInfo);
+
_count += 1;
_evt.Set();
diff --git a/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs b/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs
new file mode 100644
index 00000000..5b6d70c9
--- /dev/null
+++ b/Tests/OpenDDSharp.UnitTest/DataReaderCDRTest.cs
@@ -0,0 +1,2426 @@
+/*********************************************************************
+This file is part of OpenDDSharp.
+
+OpenDDSharp is a .NET wrapper for OpenDDS.
+Copyright (C) 2018 Jose Morato
+
+OpenDDSharp is free software: you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+OpenDDSharp is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License
+along with OpenDDSharp. If not, see .
+**********************************************************************/
+using System;
+using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Threading;
+using CdrWrapper;
+using CdrWrapperInclude;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using OpenDDSharp.DDS;
+using OpenDDSharp.UnitTest.Helpers;
+using OpenDDSharp.UnitTest.Listeners;
+
+namespace OpenDDSharp.UnitTest
+{
+ ///
+ /// unit test class.
+ ///
+ [TestClass]
+ public class DataReaderCDRTest
+ {
+ #region Constants
+ private const string TEST_CATEGORY = "DataReader";
+ #endregion
+
+ #region Fields
+ private DomainParticipant _participant;
+ private Publisher _publisher;
+ private Subscriber _subscriber;
+ private Topic _topic;
+ #endregion
+
+ #region Properties
+ ///
+ /// Gets or sets the property.
+ ///
+ [SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Global", Justification = "Required by MSTest")]
+ public TestContext TestContext { get; set; }
+ #endregion
+
+ #region Initialization/Cleanup
+ ///
+ /// The test initializer method.
+ ///
+ [TestInitialize]
+ public void TestInitialize()
+ {
+ _participant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);
+ Assert.IsNotNull(_participant);
+ _participant.BindRtpsUdpTransportConfig();
+
+ _publisher = _participant.CreatePublisher();
+ Assert.IsNotNull(_publisher);
+
+ _subscriber = _participant.CreateSubscriber();
+ Assert.IsNotNull(_subscriber);
+
+ var typeSupport = new TestIncludeTypeSupport();
+ var typeName = typeSupport.GetTypeName();
+ var ret = typeSupport.RegisterType(_participant, typeName);
+ Assert.AreEqual(ReturnCode.Ok, ret);
+
+ _topic = _participant.CreateTopic(TestContext.TestName, typeName);
+ Assert.IsNotNull(_topic);
+ }
+
+ ///
+ /// The test cleanup method.
+ ///
+ [TestCleanup]
+ public void TestCleanup()
+ {
+ _publisher?.DeleteContainedEntities();
+ _subscriber?.DeleteContainedEntities();
+ _participant?.DeletePublisher(_publisher);
+ _participant?.DeleteSubscriber(_subscriber);
+ _participant?.DeleteTopic(_topic);
+ _participant?.DeleteContainedEntities();
+ AssemblyInitializer.Factory?.DeleteParticipant(_participant);
+
+ _participant = null;
+ _publisher = null;
+ _subscriber = null;
+ _topic = null;
+ }
+ #endregion
+
+ #region Test Methods
+ ///
+ /// Test the properties.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestProperties()
+ {
+ // Create a DataReader and check the TopicDescription and Subscriber properties
+ var reader = _subscriber.CreateDataReader(_topic);
+
+ Assert.IsNotNull(reader);
+ Assert.IsNotNull(reader.TopicDescription);
+ Assert.AreSame(_topic, reader.TopicDescription);
+ Assert.AreEqual(_topic.Name, reader.TopicDescription.Name);
+ Assert.AreSame(_topic.Participant, reader.TopicDescription.Participant);
+ Assert.AreEqual(_topic.TypeName, reader.TopicDescription.TypeName);
+ Assert.AreSame(_subscriber, reader.Subscriber);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ }
+
+ ///
+ /// Test the constructor.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestNewDataReaderQos()
+ {
+ var qos = new DataReaderQos();
+ TestHelper.TestDefaultDataReaderQos(qos);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetQos()
+ {
+ // Create a non-default QoS and create a datareader with it.
+ var qos = TestHelper.CreateNonDefaultDataReaderQos();
+
+ var dataReader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(dataReader);
+
+ // Call GetQos and check the values received.
+ qos = new DataReaderQos();
+ var result = dataReader.GetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ TestHelper.TestNonDefaultDataReaderQos(qos);
+
+ // Call GetQos with null parameter.
+ result = dataReader.GetQos(null);
+ Assert.AreEqual(ReturnCode.BadParameter, result);
+
+ dataReader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(dataReader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestSetQos()
+ {
+ // Create a new DataReader using the default QoS.
+ var dataReader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(dataReader);
+
+ // Get the qos to ensure that is using the default properties
+ var qos = new DataReaderQos();
+ var result = dataReader.GetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ TestHelper.TestDefaultDataReaderQos(qos);
+
+ // Try to change an immutable property
+ qos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
+ result = dataReader.SetQos(qos);
+ Assert.AreEqual(ReturnCode.ImmutablePolicy, result);
+
+ // Change some mutable properties and check them.
+ qos = new DataReaderQos
+ {
+ UserData =
+ {
+ Value = new List { 0x42 },
+ },
+ };
+
+ result = dataReader.SetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ qos = new DataReaderQos();
+ result = dataReader.GetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(qos.UserData);
+ Assert.IsNotNull(qos.UserData.Value);
+ Assert.AreEqual(1, qos.UserData.Value.Count);
+ Assert.AreEqual(0x42, qos.UserData.Value[0]);
+
+ // Try to set immutable QoS properties before enable the datareader.
+ var subQos = new SubscriberQos
+ {
+ EntityFactory =
+ {
+ AutoenableCreatedEntities = false,
+ },
+ };
+ result = _subscriber.SetQos(subQos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ var otherDataReader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(otherDataReader);
+
+ qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ result = otherDataReader.SetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ qos = new DataReaderQos();
+ result = otherDataReader.GetQos(qos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(ReliabilityQosPolicyKind.ReliableReliabilityQos, qos.Reliability.Kind);
+
+ result = otherDataReader.Enable();
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Set back the default subscriber QoS
+ subQos = new SubscriberQos();
+ _subscriber.SetQos(subQos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Call SetQos with null parameter
+ result = dataReader.SetQos(null);
+ Assert.AreEqual(ReturnCode.BadParameter, result);
+
+ dataReader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(dataReader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetListener()
+ {
+ // Create a new DataReader with a listener
+ var listener = new MyDataReaderListener();
+ var dataReader = _subscriber.CreateDataReader(_topic, null, listener);
+ Assert.IsNotNull(dataReader);
+
+ // Call to GetListener and check the listener received
+#pragma warning disable CS0618 // Type or member is obsolete
+ var received = (MyDataReaderListener)dataReader.GetListener();
+#pragma warning restore CS0618 // Type or member is obsolete
+ Assert.IsNotNull(received);
+ Assert.AreEqual(listener, received);
+
+ Assert.AreEqual(ReturnCode.Ok, dataReader.SetListener(null, StatusMask.NoStatusMask));
+ listener.Dispose();
+
+ Assert.AreEqual(ReturnCode.Ok, dataReader.DeleteContainedEntities());
+ Assert.AreEqual(ReturnCode.Ok, _subscriber.DeleteDataReader(dataReader));
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestSetListener()
+ {
+ // Create a new DataReader without listener
+ var dataReader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(dataReader);
+
+ Assert.IsNull((MyDataReaderListener)dataReader.Listener);
+
+ // Create a listener, set it and check that is correctly set
+ using (var listener = new MyDataReaderListener())
+ {
+ var result = dataReader.SetListener(listener, StatusMask.AllStatusMask);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ var received = (MyDataReaderListener)dataReader.Listener;
+ Assert.IsNotNull(received);
+ Assert.AreEqual(listener, received);
+
+ // Remove the listener calling SetListener with null and check it
+ result = dataReader.SetListener(null, StatusMask.NoStatusMask);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ received = (MyDataReaderListener)dataReader.Listener;
+ Assert.IsNull(received);
+ }
+
+ dataReader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(dataReader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestCreateReadCondition()
+ {
+ // Initialize entities
+ var reader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(reader);
+
+ // Create a read condition with the simplest overload
+ var condition = reader.CreateReadCondition();
+ Assert.IsNotNull(condition);
+ Assert.AreSame(reader, condition.DataReader);
+ Assert.AreEqual(InstanceStateMask.AnyInstanceState, condition.InstanceStateMask);
+ Assert.AreEqual(SampleStateMask.AnySampleState, condition.SampleStateMask);
+ Assert.AreEqual(ViewStateMask.AnyViewState, condition.ViewStateMask);
+ Assert.IsFalse(condition.TriggerValue);
+
+ // Create a read condition with the full parameters overload
+ condition = reader.CreateReadCondition(
+ SampleStateKind.ReadSampleState,
+ ViewStateKind.NotNewViewState,
+ InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState);
+
+ Assert.IsNotNull(condition);
+ Assert.AreSame(reader, condition.DataReader);
+ Assert.AreEqual(InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState, condition.InstanceStateMask);
+ Assert.AreEqual(SampleStateKind.ReadSampleState, condition.SampleStateMask);
+ Assert.AreEqual(ViewStateKind.NotNewViewState, condition.ViewStateMask);
+ Assert.IsFalse(condition.TriggerValue);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestCreateQueryCondition()
+ {
+ // Initialize entities
+ var reader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(reader);
+
+ const string expression = "Id > %0 AND Id < %1";
+ const string parameter1 = "1";
+ const string parameter2 = "5";
+
+ // Create a QueryCondition with the simplest overload
+ var condition = reader.CreateQueryCondition(expression, parameter1, parameter2);
+ Assert.IsNotNull(condition);
+ Assert.AreEqual(InstanceStateMask.AnyInstanceState, condition.InstanceStateMask);
+ Assert.AreEqual(SampleStateMask.AnySampleState, condition.SampleStateMask);
+ Assert.AreEqual(ViewStateMask.AnyViewState, condition.ViewStateMask);
+ Assert.IsFalse(condition.TriggerValue);
+ Assert.AreEqual(expression, condition.QueryExpression);
+
+ var parameters = new List();
+ var result = condition.GetQueryParameters(parameters);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(parameters);
+ Assert.AreEqual(2, parameters.Count);
+ Assert.AreEqual(parameter1, parameters[0]);
+ Assert.AreEqual(parameter2, parameters[1]);
+
+ // Create a QueryCondition with the full parameters overload
+ condition = reader.CreateQueryCondition(
+ SampleStateKind.ReadSampleState,
+ ViewStateKind.NotNewViewState,
+ InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState,
+ expression, parameter1, parameter2);
+
+ Assert.IsNotNull(condition);
+ Assert.AreEqual(InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState, condition.InstanceStateMask);
+ Assert.AreEqual(SampleStateKind.ReadSampleState, condition.SampleStateMask);
+ Assert.AreEqual(ViewStateKind.NotNewViewState, condition.ViewStateMask);
+ Assert.IsFalse(condition.TriggerValue);
+ Assert.AreEqual(expression, condition.QueryExpression);
+
+ parameters = new List();
+ result = condition.GetQueryParameters(parameters);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(parameters);
+ Assert.AreEqual(2, parameters.Count);
+ Assert.AreEqual(parameter1, parameters[0]);
+ Assert.AreEqual(parameter2, parameters[1]);
+
+ // Create a QueryCondition with an invalid number of parameters
+ condition = reader.CreateQueryCondition(expression, parameter1);
+ Assert.IsNull(condition);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestDeleteReadCondition()
+ {
+ // Initialize entities
+ var reader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(reader);
+
+ const string expression = "Id > %0 AND Id < %1";
+ const string parameter1 = "1";
+ const string parameter2 = "5";
+
+ // Create a read condition with the simplest overload
+ var readCondition = reader.CreateReadCondition();
+ Assert.IsNotNull(readCondition);
+ Assert.AreEqual(reader, readCondition.DataReader);
+ Assert.AreEqual(InstanceStateMask.AnyInstanceState, readCondition.InstanceStateMask);
+ Assert.AreEqual(SampleStateMask.AnySampleState, readCondition.SampleStateMask);
+ Assert.AreEqual(ViewStateMask.AnyViewState, readCondition.ViewStateMask);
+ Assert.IsFalse(readCondition.TriggerValue);
+
+ // Create a QueryCondition with the simplest overload
+ var queryCondition = reader.CreateQueryCondition(expression, parameter1, parameter2);
+ Assert.IsNotNull(queryCondition);
+ Assert.AreEqual(InstanceStateMask.AnyInstanceState, queryCondition.InstanceStateMask);
+ Assert.AreEqual(SampleStateMask.AnySampleState, queryCondition.SampleStateMask);
+ Assert.AreEqual(ViewStateMask.AnyViewState, queryCondition.ViewStateMask);
+ Assert.IsFalse(queryCondition.TriggerValue);
+ Assert.AreEqual(expression, queryCondition.QueryExpression);
+
+ var parameters = new List();
+ var result = queryCondition.GetQueryParameters(parameters);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(parameters);
+ Assert.AreEqual(2, parameters.Count);
+ Assert.AreEqual(parameter1, parameters[0]);
+ Assert.AreEqual(parameter2, parameters[1]);
+
+ // Create other reader
+ var otherReader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(otherReader);
+
+ // Delete read condition with null
+ result = otherReader.DeleteReadCondition(null);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Delete the previous conditions with the other reader
+ result = otherReader.DeleteReadCondition(queryCondition);
+ Assert.AreEqual(ReturnCode.PreconditionNotMet, result);
+
+ result = otherReader.DeleteReadCondition(readCondition);
+ Assert.AreEqual(ReturnCode.PreconditionNotMet, result);
+
+ // Delete the query condition with the correct reader
+ result = reader.DeleteReadCondition(queryCondition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Delete the read condition with the correct reader
+ result = reader.DeleteReadCondition(readCondition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ reader.DeleteContainedEntities();
+ otherReader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _subscriber.DeleteDataReader(otherReader);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestDeleteContainedEntities()
+ {
+ // Initialize entities
+ var reader = _subscriber.CreateDataReader(_topic);
+ Assert.IsNotNull(reader);
+
+ // Call DeleteContainedEntities in an empty DataReader
+ var result = reader.DeleteContainedEntities();
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Create a ReadCondition and a QueryCondition in the datareader
+ var readCondition = reader.CreateReadCondition();
+ Assert.IsNotNull(readCondition);
+
+ var queryCondition = reader.CreateQueryCondition("Id > 1");
+ Assert.IsNotNull(queryCondition);
+
+ // Try to delete the DataReader without delete the ReadCondition
+ result = _subscriber.DeleteDataReader(reader);
+ Assert.AreEqual(ReturnCode.PreconditionNotMet, result);
+
+ // Call DeleteContainedEntities and remove the DataReader again
+ result = reader.DeleteContainedEntities();
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = _subscriber.DeleteDataReader(reader);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetSampleRejectedStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ ResourceLimits =
+ {
+ MaxInstances = 1,
+ MaxSamples = 1,
+ MaxSamplesPerInstance = 1,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.SampleRejectedStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var dwQos = new DataWriterQos();
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ Assert.IsTrue(reader.WaitForPublications(1, 5_000));
+ Assert.IsTrue(writer.WaitForSubscriptions(1, 5_000));
+
+ // Call sample rejected status
+ SampleRejectedStatus status = default;
+ var result = reader.GetSampleRejectedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(status);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+ Assert.AreEqual(SampleRejectedStatusKind.NotRejected, status.LastReason);
+ Assert.AreEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);
+
+ // Write two samples of the same instances
+ for (var i = 1; i <= 2; i++)
+ {
+ result = dataWriter.Write(new TestInclude
+ {
+ Id = "1",
+ });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+ }
+
+ Assert.IsTrue(evt.Wait(5_000));
+
+ // Call sample rejected status
+ result = reader.GetSampleRejectedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(status);
+ Assert.AreEqual(1, status.TotalCount);
+ Assert.AreEqual(1, status.TotalCountChange);
+ Assert.AreEqual(SampleRejectedStatusKind.RejectedBySamplesPerInstanceLimit, status.LastReason);
+ Assert.AreNotEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetLivelinessChangedStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Check the status when no writers are matched
+ var drQos = new DataReaderQos
+ {
+ Liveliness =
+ {
+ LeaseDuration = new Duration { Seconds = 1 },
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.LivelinessChangedStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ LivelinessChangedStatus status = default;
+ var result = reader.GetLivelinessChangedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.AliveCount);
+ Assert.AreEqual(0, status.AliveCountChange);
+ Assert.AreEqual(0, status.NotAliveCount);
+ Assert.AreEqual(0, status.NotAliveCountChange);
+ Assert.AreEqual(InstanceHandle.HandleNil, status.LastPublicationHandle);
+
+ // Creates a datawriter
+ var dwQos = new DataWriterQos
+ {
+ Liveliness =
+ {
+ Kind = LivelinessQosPolicyKind.ManualByTopicLivelinessQos,
+ LeaseDuration = new Duration { Seconds = 1 },
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+ Assert.IsNotNull(dataWriter);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Assert liveliness in the writer
+ result = writer.AssertLiveliness();
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Receive the first alive event
+ Assert.IsTrue(evt.Wait(1_500));
+
+ status = default;
+ result = reader.GetLivelinessChangedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, status.AliveCount);
+ Assert.AreEqual(1, status.AliveCountChange);
+ Assert.AreEqual(0, status.NotAliveCount);
+ Assert.AreEqual(0, status.NotAliveCountChange);
+ Assert.AreEqual(writer.InstanceHandle, status.LastPublicationHandle);
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // After one second and a half one liveliness should be lost
+ Assert.IsTrue(evt.Wait(1_500));
+
+ result = reader.GetLivelinessChangedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.AliveCount);
+ Assert.AreEqual(-1, status.AliveCountChange);
+ Assert.AreEqual(1, status.NotAliveCount);
+ Assert.AreEqual(1, status.NotAliveCountChange);
+ Assert.AreEqual(writer.InstanceHandle, status.LastPublicationHandle);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetRequestedDeadlineMissedStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataWriterQos
+ {
+ Deadline =
+ {
+ Period = new Duration { Seconds = 1 },
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, qos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ var drQos = new DataReaderQos
+ {
+ Deadline =
+ {
+ Period = new Duration { Seconds = 1 },
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.RequestedDeadlineMissedStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // Wait for discovery and write an instance
+ var found = writer.WaitForSubscriptions(1, 1000);
+ Assert.IsTrue(found);
+
+ found = reader.WaitForPublications(1, 1000);
+ Assert.IsTrue(found);
+
+ dataWriter.Write(new TestInclude { Id = "1" });
+
+ // After half second deadline should not be lost yet
+ Assert.IsFalse(evt.Wait(500));
+
+ RequestedDeadlineMissedStatus status = default;
+ var result = reader.GetRequestedDeadlineMissedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+ Assert.AreEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);
+
+ // After one second and a half one deadline should be lost
+ Assert.IsTrue(evt.Wait(1_500));
+
+ result = reader.GetRequestedDeadlineMissedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, status.TotalCount);
+ Assert.AreEqual(1, status.TotalCountChange);
+ Assert.AreNotEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetRequestedIncompatibleQosStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.RequestedIncompatibleQosStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // If not matched writers should return the default status
+ RequestedIncompatibleQosStatus status = default;
+ var result = reader.GetRequestedIncompatibleQosStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+ Assert.IsNotNull(status.Policies);
+ Assert.AreEqual(0, status.Policies.Count);
+ Assert.AreEqual(0, status.LastPolicyId);
+
+ // Create a not compatible writer
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ status = default;
+ result = reader.GetRequestedIncompatibleQosStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, status.TotalCount);
+ Assert.AreEqual(1, status.TotalCountChange);
+ Assert.AreEqual(11, status.LastPolicyId);
+ Assert.IsNotNull(status.Policies);
+ Assert.AreEqual(1, status.Policies.Count);
+ Assert.AreEqual(1, status.Policies.First().Count);
+ Assert.AreEqual(11, status.Policies.First().PolicyId);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetSubscriptionMatchedStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.SubscriptionMatchedStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // If not DataWriters are created should return the default status
+ SubscriptionMatchedStatus status = default;
+ var result = reader.GetSubscriptionMatchedStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.CurrentCount);
+ Assert.AreEqual(0, status.CurrentCountChange);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+ Assert.AreEqual(InstanceHandle.HandleNil, status.LastPublicationHandle);
+
+ // Create a not compatible writer
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+
+ // Wait for discovery and check the status
+ Assert.IsFalse(evt.Wait(1_500));
+ result = reader.GetSubscriptionMatchedStatus(ref status);
+
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, status.CurrentCount);
+ Assert.AreEqual(0, status.CurrentCountChange);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+ Assert.AreEqual(InstanceHandle.HandleNil, status.LastPublicationHandle);
+
+ // Create a compatible writer
+ var otherWriter = _publisher.CreateDataWriter(_topic);
+ Assert.IsNotNull(otherWriter);
+
+ // Wait for discovery and check the status
+ Assert.IsTrue(evt.Wait(1_500));
+ result = reader.GetSubscriptionMatchedStatus(ref status);
+
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, status.CurrentCount);
+ Assert.AreEqual(1, status.CurrentCountChange);
+ Assert.AreEqual(1, status.TotalCount);
+ Assert.AreEqual(1, status.TotalCountChange);
+ Assert.AreEqual(otherWriter.InstanceHandle, status.LastPublicationHandle);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ _publisher.DeleteDataWriter(otherWriter);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetSampleLostStatus()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos,
+ },
+ DestinationOrder =
+ {
+ Kind = DestinationOrderQosPolicyKind.BySourceTimestampDestinationOrderQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepLastHistoryQos,
+ Depth = 1,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.SampleLostStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var dwQos = new DataWriterQos();
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ Assert.IsTrue(reader.WaitForPublications(1, 5_000));
+ Assert.IsTrue(writer.WaitForSubscriptions(1, 5_000));
+
+ // Call sample lost status
+ SampleLostStatus status = default;
+ var result = reader.GetSampleLostStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(status);
+ Assert.AreEqual(0, status.TotalCount);
+ Assert.AreEqual(0, status.TotalCountChange);
+
+ // Write two samples of the same instances
+ var handle = dataWriter.RegisterInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ var time = DateTime.Now.ToTimestamp();
+ result = dataWriter.Write(new TestInclude { Id = "1" }, handle, time);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsFalse(evt.Wait(500));
+
+ time = DateTime.Now.Subtract(TimeSpan.FromSeconds(10)).ToTimestamp();
+ result = dataWriter.Write(new TestInclude { Id = "1" }, handle, time);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Call sample lost status
+ result = reader.GetSampleLostStatus(ref status);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(status);
+ Assert.AreEqual(1, status.TotalCount);
+ Assert.AreEqual(1, status.TotalCountChange);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestWaitForHistoricalData()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ Durability =
+ {
+ Kind = DurabilityQosPolicyKind.TransientLocalDurabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Writes an instance
+ var result = dataWriter.Write(new TestInclude { Id = "1" });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ // Create a DataReader
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ Durability =
+ {
+ Kind = DurabilityQosPolicyKind.TransientLocalDurabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // OpenDDS Issue: Wait for historical data is not actually implemented. It returns always ReturnCode.Ok
+ result = dataReader.WaitForHistoricalData(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Read the previous published instance
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.Read(data, sampleInfos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.IsTrue(sampleInfos[0].ValidData);
+ Assert.AreEqual(0, sampleInfos[0].AbsoluteGenerationRank);
+ Assert.AreEqual(0, sampleInfos[0].DisposedGenerationCount);
+ Assert.AreEqual(0, sampleInfos[0].GenerationRank);
+ Assert.AreNotEqual(InstanceHandle.HandleNil, sampleInfos[0].InstanceHandle);
+ Assert.AreEqual(InstanceStateKind.AliveInstanceState, sampleInfos[0].InstanceState);
+ Assert.AreEqual(0, sampleInfos[0].NoWritersGenerationCount);
+ Assert.AreNotEqual(InstanceHandle.HandleNil, sampleInfos[0].PublicationHandle);
+ Assert.AreEqual(0, sampleInfos[0].SampleRank);
+ Assert.AreEqual(SampleStateKind.NotReadSampleState, sampleInfos[0].SampleState);
+ Assert.AreEqual(ViewStateKind.NewViewState, sampleInfos[0].ViewState);
+ Assert.IsNotNull(sampleInfos[0].SourceTimestamp);
+ Assert.IsTrue(sampleInfos[0].SourceTimestamp.Seconds > 0);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetMatchedPublications()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.SubscriptionMatchedStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ // Test matched publications without any match
+ var list = new List { InstanceHandle.HandleNil };
+ var result = reader.GetMatchedPublications(list);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, list.Count);
+
+ // Test matched publications with null
+ result = reader.GetMatchedPublications(null);
+ Assert.AreEqual(ReturnCode.BadParameter, result);
+
+ // Create a not compatible writer
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+
+ // Wait for discovery and check the matched subscriptions
+ Assert.IsFalse(evt.Wait(1_500));
+
+ result = reader.GetMatchedPublications(list);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(0, list.Count);
+
+ // Create a compatible writer
+ var otherWriter = _publisher.CreateDataWriter(_topic);
+ Assert.IsNotNull(otherWriter);
+
+ // Wait for discovery and check the matched subscriptions
+ Assert.IsTrue(evt.Wait(1_500));
+ result = reader.GetMatchedPublications(list);
+
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, list.Count);
+ Assert.AreEqual(otherWriter.InstanceHandle, list[0]);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ _publisher.DeleteDataWriter(otherWriter);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetMatchedPublicationData()
+ {
+ // Initialize entities
+ var drQos = TestHelper.CreateNonDefaultDataReaderQos();
+ drQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
+
+ // OPENDDS ISSUE: Cannot use ExclusiveOwnership for the test because when calling delete_datareader
+ // the BitPubListenerImpl::on_data_available take_next_sample method enter an infinite loop if we already called
+ // the GetMatchedPublicationData. It tries to take a not_read_sample, but it doesn't exist because it is already marked
+ // as read in the GetMatchedPublicationData call.
+ drQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ // DCPSInfoRepo-based discovery generates Built-In Topic data once (inside the
+ // info repo process) and therefore all known entities in the domain are
+ // reflected in the Built-In Topics. RTPS discovery, on the other hand, follows
+ // the DDS specification and omits "local" entities from the Built-In Topics.
+ // The definition of "local" means those entities belonging to the same Domain
+ // Participant as the given Built-In Topic Subscriber.
+ // https://github.com/OpenDDS/OpenDDS/blob/master/docs/design/RTPS
+
+ // OPENDDS ISSUE: GetMatchedSubscriptions returns local entities but GetMatchedSubscriptionData doesn't
+ // because it is looking in the Built-in topic. If not found in the built-in, shouldn't try to look locally?
+ // WORKAROUND: Create another participant for the DataReader.
+ var otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);
+ Assert.IsNotNull(otherParticipant);
+ otherParticipant.BindRtpsUdpTransportConfig();
+
+ var support = new TestIncludeTypeSupport();
+ var typeName = support.GetTypeName();
+ var result = support.RegisterType(otherParticipant, typeName);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ var otherTopic = otherParticipant.CreateTopic(nameof(TestGetMatchedPublicationData), typeName);
+ Assert.IsNotNull(otherTopic);
+
+ var publisher = otherParticipant.CreatePublisher();
+ Assert.IsNotNull(publisher);
+
+ var dwQos = TestHelper.CreateNonDefaultDataWriterQos();
+ dwQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
+ var writer = publisher.CreateDataWriter(otherTopic, dwQos);
+ Assert.IsNotNull(writer);
+
+ // Wait for publications
+ var found = reader.WaitForPublications(1, 5000);
+ Assert.IsTrue(found);
+
+ // Get the matched subscriptions
+ var list = new List();
+ result = reader.GetMatchedPublications(list);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, list.Count);
+
+ // Get the matched publication data
+ PublicationBuiltinTopicData data = default;
+ result = reader.GetMatchedPublicationData(list[0], ref data);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ TestHelper.TestNonDefaultPublicationData(data);
+
+ // Destroy the other participant
+ result = otherParticipant.DeleteContainedEntities();
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ publisher.DeleteDataWriter(writer);
+ publisher.DeleteContainedEntities();
+ otherParticipant.DeletePublisher(publisher);
+ otherParticipant.DeleteTopic(otherTopic);
+ AssemblyInitializer.Factory.DeleteParticipant(otherParticipant);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestRead()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Write an instance a wait for acknowledgment
+ var result = dataWriter.Write(new TestInclude { Id = "1" });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Read the data with the simplest overload
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.Read(data, sampleInfos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+
+ // Write another sample of the same instance
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+ result = dataWriter.Write(new TestInclude { Id = "1", ShortField = 2, IncludeField = new IncludeStruct { Message = "Test"} });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Read the data limiting the max samples
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.Read(data, sampleInfos, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.Read(data, sampleInfos, 2);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("1", data[1].Id);
+ Assert.AreEqual(2, data[1].ShortField);
+
+ // Read the data with a QueryCondition
+ var condition = reader.CreateQueryCondition("ShortField = 2");
+ Assert.IsNotNull(condition);
+
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.Read(data, sampleInfos, ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(2, data[0].ShortField);
+
+ // Read the data with mask parameters
+ result = dataReader.Read(data, sampleInfos, ResourceLimitsQosPolicy.LengthUnlimited, SampleStateKind.NotReadSampleState, ViewStateMask.AnyViewState, InstanceStateMask.AnyInstanceState);
+ Assert.AreEqual(ReturnCode.NoData, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(0, data.Count);
+ Assert.AreEqual(0, sampleInfos.Count);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestTake()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Write an instance a wait for acknowledgment
+ var result = dataWriter.Write(new TestInclude { Id = "1" });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Take the data with the simplest overload
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.Take(data, sampleInfos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+
+ // Take again to test NoData
+ result = dataReader.Take(data, sampleInfos);
+ Assert.AreEqual(ReturnCode.NoData, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(0, data.Count);
+ Assert.AreEqual(0, sampleInfos.Count);
+
+ // Write three samples
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = "2", ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Take the data limiting the max samples
+ result = dataReader.Take(data, sampleInfos, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(1, data[0].ShortField);
+
+ // Take all the remaining samples
+ result = dataReader.Take(data, sampleInfos, ResourceLimitsQosPolicy.LengthUnlimited);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(2, data[0].ShortField);
+ Assert.AreEqual("2", data[1].Id);
+ Assert.AreEqual(3, data[1].ShortField);
+
+ // Write three samples more
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = "3", ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Take the data with a QueryCondition
+ var condition = reader.CreateQueryCondition("ShortField = 2");
+ Assert.IsNotNull(condition);
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.Take(data, sampleInfos, ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(2, data[0].ShortField);
+
+ // Take the data with mask parameters
+ result = dataReader.Take(data, sampleInfos, ResourceLimitsQosPolicy.LengthUnlimited,
+ SampleStateKind.NotReadSampleState, ViewStateMask.AnyViewState, InstanceStateMask.AnyInstanceState);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(1, data[0].ShortField);
+ Assert.AreEqual("3", data[1].Id);
+ Assert.AreEqual(3, data[1].ShortField);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestReadInstance()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Write two samples of three different instances
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Read instance with the simplest overload
+ var handle = dataReader.LookupInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.ReadInstance(data, sampleInfos, handle);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("1", data[1].Id);
+ Assert.AreEqual(1, data[1].ShortField);
+
+ // Read instance limiting the max samples
+ result = dataReader.ReadInstance(data, sampleInfos, handle, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ // Read instance with a QueryCondition
+ var condition = reader.CreateQueryCondition("ShortField = 1");
+ Assert.IsNotNull(condition);
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.ReadInstance(data, sampleInfos, handle, ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(1, data[0].ShortField);
+
+ // Read instance with mask parameters
+ result = dataReader.ReadInstance(data, sampleInfos, handle,
+ ResourceLimitsQosPolicy.LengthUnlimited,
+ SampleStateKind.NotReadSampleState,
+ ViewStateKind.NewViewState | ViewStateKind.NotNewViewState,
+ InstanceStateKind.AliveInstanceState | InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState);
+ Assert.AreEqual(ReturnCode.NoData, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(0, data.Count);
+ Assert.AreEqual(0, sampleInfos.Count);
+
+ handle = dataReader.LookupInstance(new TestInclude { Id = "2" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ result = dataReader.ReadInstance(data, sampleInfos, handle,
+ ResourceLimitsQosPolicy.LengthUnlimited,
+ SampleStateKind.NotReadSampleState,
+ ViewStateMask.AnyViewState,
+ InstanceStateMask.AnyInstanceState);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("2", data[1].Id);
+ Assert.AreEqual(2, data[1].ShortField);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestTakeInstance()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Write two samples of three different instances
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Take instance with the simplest overload
+ var handle = dataReader.LookupInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.TakeInstance(data, sampleInfos, handle);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("1", data[1].Id);
+ Assert.AreEqual(1, data[1].ShortField);
+
+ // Take again to ensure NoData is received
+ result = dataReader.TakeInstance(data, sampleInfos, handle);
+ Assert.AreEqual(ReturnCode.NoData, result);
+
+ // Take instance limiting the max samples
+ handle = dataReader.LookupInstance(new TestInclude { Id = "2" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ result = dataReader.TakeInstance(data, sampleInfos, handle, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ result = dataReader.TakeInstance(data, sampleInfos, handle,
+ ResourceLimitsQosPolicy.LengthUnlimited);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(2, data[0].ShortField);
+
+ // Take instance with a QueryCondition
+ handle = dataReader.LookupInstance(new TestInclude { Id = "3" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ var condition = reader.CreateQueryCondition("ShortField = 3");
+ Assert.IsNotNull(condition);
+
+ data = new List();
+ sampleInfos = new List();
+ result = dataReader.ReadInstance(data, sampleInfos, handle,
+ ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(3, data[0].ShortField);
+
+ // Take instance with mask parameters
+ result = dataReader.ReadInstance(data, sampleInfos, handle,
+ ResourceLimitsQosPolicy.LengthUnlimited,
+ SampleStateKind.NotReadSampleState,
+ ViewStateMask.AnyViewState,
+ InstanceStateMask.AnyInstanceState);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestReadNextInstance()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+
+ var dataReader = new TestIncludeDataReader(reader);
+ Assert.IsNotNull(dataReader);
+
+ var statusCondition = dataReader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+
+ var dataWriter = new TestIncludeDataWriter(writer);
+ Assert.IsNotNull(dataWriter);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Write two samples of three different instances
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+ // Thread.Sleep(1_000);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+ // Thread.Sleep(1_000);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Read next instance with the simplest overload
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.ReadNextInstance(data, sampleInfos, InstanceHandle.HandleNil);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("1", data[1].Id);
+ Assert.AreEqual(1, data[1].ShortField);
+
+ // Read next instance limiting the max samples
+ result = dataReader.ReadNextInstance(data, sampleInfos, InstanceHandle.HandleNil, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ // Read next instance with QueryCondition
+ var condition = reader.CreateQueryCondition("ShortField = 3");
+ Assert.IsNotNull(condition);
+
+ result = dataReader.ReadNextInstance(data, sampleInfos, InstanceHandle.HandleNil, ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(3, data[0].ShortField);
+
+ // Read next instance with mask parameters
+ var handle = dataReader.LookupInstance(new TestInclude { Id = "2" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ result = dataReader.ReadNextInstance(data, sampleInfos, handle, ResourceLimitsQosPolicy.LengthUnlimited, SampleStateKind.NotReadSampleState, ViewStateMask.AnyViewState, InstanceStateKind.AliveInstanceState);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestTakeNextInstance()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5000);
+ Assert.IsTrue(found);
+
+ // Write two samples of three different instances
+ for (short i = 1; i <= 3; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Take next instance with the simplest overload
+ var data = new List();
+ var sampleInfos = new List();
+ result = dataReader.TakeNextInstance(data, sampleInfos, InstanceHandle.HandleNil);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(2, data.Count);
+ Assert.AreEqual(2, sampleInfos.Count);
+ Assert.AreEqual("1", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+ Assert.AreEqual("1", data[1].Id);
+ Assert.AreEqual(1, data[1].ShortField);
+
+ // Read next instance limiting the max samples
+ result = dataReader.TakeNextInstance(data, sampleInfos, InstanceHandle.HandleNil, 1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("2", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ // Read next instance with QueryCondition
+ var condition = reader.CreateQueryCondition("ShortField = 3");
+ Assert.IsNotNull(condition);
+
+ result = dataReader.TakeNextInstance(data, sampleInfos, InstanceHandle.HandleNil, ResourceLimitsQosPolicy.LengthUnlimited, condition);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(3, data[0].ShortField);
+
+ // Read next instance with mask parameters
+ var handle = dataReader.LookupInstance(new TestInclude { Id = "2" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ result = dataReader.TakeNextInstance(data, sampleInfos, handle, ResourceLimitsQosPolicy.LengthUnlimited, SampleStateKind.NotReadSampleState, ViewStateMask.AnyViewState, InstanceStateKind.AliveInstanceState);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(sampleInfos);
+ Assert.AreEqual(1, data.Count);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreEqual("3", data[0].Id);
+ Assert.AreEqual(0, data[0].ShortField);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestReadNextSample()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5000);
+ Assert.IsTrue(found);
+
+ // Write two samples of two different instances
+ for (short i = 1; i <= 2; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Read next samples
+ var data = new TestInclude();
+ var info = new SampleInfo();
+
+ for (short i = 1; i <= 4; i++)
+ {
+ result = dataReader.ReadNextSample(data, info);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsTrue(info.ValidData);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(info);
+ if (i < 3)
+ {
+ Assert.AreEqual("1", data.Id);
+ Assert.AreEqual(i % 2 == 0 ? 1 : 0, data.ShortField);
+ }
+ else
+ {
+ Assert.AreEqual("2", data.Id);
+ Assert.AreEqual(i % 2 == 0 ? 2 : 0, data.ShortField);
+ }
+ }
+
+ // Read next sample to check NoData
+ result = dataReader.ReadNextSample(data, info);
+ Assert.AreEqual(ReturnCode.NoData, result);
+
+ // Read samples
+ var samples = new List();
+ var sampleInfos = new List();
+ result = dataReader.Read(samples, sampleInfos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(4, samples.Count);
+ Assert.AreEqual(4, sampleInfos.Count);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestTakeNextSample()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ ReturnCode result;
+ var drQos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ History =
+ {
+ Kind = HistoryQosPolicyKind.KeepAllHistoryQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, drQos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5000);
+ Assert.IsTrue(found);
+
+ // Write two samples of two different instances
+ for (short i = 1; i <= 2; i++)
+ {
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString() });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ evt.Reset();
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ result = dataWriter.Write(new TestInclude { Id = i.ToString(), ShortField = i });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+ }
+
+ // Take next samples
+ var data = new TestInclude();
+ var info = new SampleInfo();
+
+ for (short i = 1; i <= 4; i++)
+ {
+ result = dataReader.TakeNextSample(data, info);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.IsTrue(info.ValidData);
+ Assert.IsNotNull(data);
+ Assert.IsNotNull(info);
+ if (i < 3)
+ {
+ Assert.AreEqual("1", data.Id);
+ Assert.AreEqual(i % 2 == 0 ? 1 : 0, data.ShortField);
+ }
+ else
+ {
+ Assert.AreEqual("2", data.Id);
+ Assert.AreEqual(i % 2 == 0 ? 2 : 0, data.ShortField);
+ }
+ }
+
+ // Take next sample to check NoData
+ result = dataReader.TakeNextSample(data, info);
+ Assert.AreEqual(ReturnCode.NoData, result);
+
+ // Take samples
+ var samples = new List();
+ var sampleInfos = new List();
+ result = dataReader.Take(samples, sampleInfos);
+ Assert.AreEqual(ReturnCode.NoData, result);
+ Assert.AreEqual(0, samples.Count);
+ Assert.AreEqual(0, sampleInfos.Count);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestGetKeyValue()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var dwQos = new DataWriterQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var writer = _publisher.CreateDataWriter(_topic, dwQos);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ Assert.IsTrue(writer.WaitForSubscriptions(1, 5_000));
+ Assert.IsTrue(reader.WaitForPublications(1, 5_000));
+
+ // Register an instance and write it
+ var handle1 = dataWriter.RegisterInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle1);
+
+ var result = dataWriter.Write(new TestInclude { Id = "1" }, handle1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Get the for an existing instance
+ var structs = new List();
+ var sampleInfos = new List();
+ result = dataReader.Read(structs, sampleInfos);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual(1, sampleInfos.Count);
+ Assert.AreNotEqual(InstanceHandle.HandleNil, sampleInfos[0].InstanceHandle);
+
+ var data = new TestInclude();
+ result = dataReader.GetKeyValue(data, sampleInfos[0].InstanceHandle);
+ Assert.AreEqual(ReturnCode.Ok, result);
+ Assert.AreEqual("1", data.Id);
+
+ // Call GetKeyValue with HandleNil
+ data = new TestInclude();
+ result = dataReader.GetKeyValue(data, InstanceHandle.HandleNil);
+ Assert.AreEqual(ReturnCode.BadParameter, result);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+
+ ///
+ /// Test the method.
+ ///
+ [TestMethod]
+ [TestCategory(TEST_CATEGORY)]
+ public void TestLookupInstance()
+ {
+ using var evt = new ManualResetEventSlim(false);
+
+ // Initialize entities
+ var qos = new DataReaderQos
+ {
+ Reliability =
+ {
+ Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos,
+ },
+ };
+ var reader = _subscriber.CreateDataReader(_topic, qos);
+ Assert.IsNotNull(reader);
+ var dataReader = new TestIncludeDataReader(reader);
+
+ var statusCondition = reader.StatusCondition;
+ statusCondition.EnabledStatuses = StatusKind.DataAvailableStatus;
+ TestHelper.CreateWaitSetThread(evt, statusCondition);
+
+ var writer = _publisher.CreateDataWriter(_topic);
+ Assert.IsNotNull(writer);
+ var dataWriter = new TestIncludeDataWriter(writer);
+
+ // Wait for discovery
+ var found = reader.WaitForPublications(1, 5_000);
+ Assert.IsTrue(found);
+ found = writer.WaitForSubscriptions(1, 5_000);
+ Assert.IsTrue(found);
+
+ // Lookup for a non-existing instance
+ var handle = dataReader.LookupInstance(new TestInclude { Id = "1" });
+ Assert.AreEqual(InstanceHandle.HandleNil, handle);
+
+ // Register an instance and write it
+ var handle1 = dataWriter.RegisterInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle1);
+
+ var result = dataWriter.Write(new TestInclude { Id = "1" }, handle1);
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ result = dataWriter.WaitForAcknowledgments(new Duration { Seconds = 5 });
+ Assert.AreEqual(ReturnCode.Ok, result);
+
+ Assert.IsTrue(evt.Wait(1_500));
+
+ // Lookup for an existing instance
+ handle = dataReader.LookupInstance(new TestInclude { Id = "1" });
+ Assert.AreNotEqual(InstanceHandle.HandleNil, handle);
+
+ reader.DeleteContainedEntities();
+ _subscriber.DeleteDataReader(reader);
+ _publisher.DeleteDataWriter(writer);
+ }
+ #endregion
+ }
+}
diff --git a/Tests/OpenDDSharp.UnitTest/DataReaderTest.cs b/Tests/OpenDDSharp.UnitTest/DataReaderTest.cs
index 7f78031b..09b554d4 100644
--- a/Tests/OpenDDSharp.UnitTest/DataReaderTest.cs
+++ b/Tests/OpenDDSharp.UnitTest/DataReaderTest.cs
@@ -329,7 +329,7 @@ public void TestCreateReadCondition()
Assert.AreEqual(InstanceStateMask.AnyInstanceState, condition.InstanceStateMask);
Assert.AreEqual(SampleStateMask.AnySampleState, condition.SampleStateMask);
Assert.AreEqual(ViewStateMask.AnyViewState, condition.ViewStateMask);
- Assert.AreEqual(false, condition.TriggerValue);
+ Assert.IsFalse(condition.TriggerValue);
// Create a read condition with the full parameters overload
condition = reader.CreateReadCondition(
@@ -342,7 +342,7 @@ public void TestCreateReadCondition()
Assert.AreEqual(InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState, condition.InstanceStateMask);
Assert.AreEqual(SampleStateKind.ReadSampleState, condition.SampleStateMask);
Assert.AreEqual(ViewStateKind.NotNewViewState, condition.ViewStateMask);
- Assert.AreEqual(false, condition.TriggerValue);
+ Assert.IsFalse(condition.TriggerValue);
reader.DeleteContainedEntities();
_subscriber.DeleteDataReader(reader);
@@ -369,7 +369,7 @@ public void TestCreateQueryCondition()
Assert.AreEqual(InstanceStateMask.AnyInstanceState, condition.InstanceStateMask);
Assert.AreEqual(SampleStateMask.AnySampleState, condition.SampleStateMask);
Assert.AreEqual(ViewStateMask.AnyViewState, condition.ViewStateMask);
- Assert.AreEqual(false, condition.TriggerValue);
+ Assert.IsFalse(condition.TriggerValue);
Assert.AreEqual(expression, condition.QueryExpression);
var parameters = new List();
@@ -391,7 +391,7 @@ public void TestCreateQueryCondition()
Assert.AreEqual(InstanceStateKind.NotAliveDisposedInstanceState | InstanceStateKind.NotAliveNoWritersInstanceState, condition.InstanceStateMask);
Assert.AreEqual(SampleStateKind.ReadSampleState, condition.SampleStateMask);
Assert.AreEqual(ViewStateKind.NotNewViewState, condition.ViewStateMask);
- Assert.AreEqual(false, condition.TriggerValue);
+ Assert.IsFalse(condition.TriggerValue);
Assert.AreEqual(expression, condition.QueryExpression);
parameters = new List();
@@ -432,7 +432,7 @@ public void TestDeleteReadCondition()
Assert.AreEqual(InstanceStateMask.AnyInstanceState, readCondition.InstanceStateMask);
Assert.AreEqual(SampleStateMask.AnySampleState, readCondition.SampleStateMask);
Assert.AreEqual(ViewStateMask.AnyViewState, readCondition.ViewStateMask);
- Assert.AreEqual(false, readCondition.TriggerValue);
+ Assert.IsFalse(readCondition.TriggerValue);
// Create a QueryCondition with the simplest overload
var queryCondition = reader.CreateQueryCondition(expression, parameter1, parameter2);
@@ -440,7 +440,7 @@ public void TestDeleteReadCondition()
Assert.AreEqual(InstanceStateMask.AnyInstanceState, queryCondition.InstanceStateMask);
Assert.AreEqual(SampleStateMask.AnySampleState, queryCondition.SampleStateMask);
Assert.AreEqual(ViewStateMask.AnyViewState, queryCondition.ViewStateMask);
- Assert.AreEqual(false, queryCondition.TriggerValue);
+ Assert.IsFalse(queryCondition.TriggerValue);
Assert.AreEqual(expression, queryCondition.QueryExpression);
var parameters = new List();
@@ -1178,7 +1178,7 @@ public void TestGetMatchedPublicationData()
// OPENDDS ISSUE: Cannot use ExclusiveOwnership for the test because when calling delete_datareader
// the BitPubListenerImpl::on_data_available take_next_sample method enter in a infinite loop if we already called
- // the GetMatchedPublicationData. It tries to take a not_read_sample but it doesn't exists because it is already marked
+ // the GetMatchedPublicationData. It tries to take a not_read_sample but it doesn't exist because it is already marked
// as read in the GetMatchedPublicationData call.
drQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
var reader = _subscriber.CreateDataReader(_topic, drQos);
@@ -1193,7 +1193,7 @@ public void TestGetMatchedPublicationData()
// https://github.com/OpenDDS/OpenDDS/blob/master/docs/design/RTPS
// OPENDDS ISSUE: GetMatchedSubscriptions returns local entities but GetMatchedSubscriptionData doesn't
- // because is looking in the Built-in topic. If not found in the built-in, shouldn't try to look locally?
+ // because it is looking in the Built-in topic. If not found in the built-in, shouldn't try to look locally?
// WORKAROUND: Create another participant for the DataReader.
var otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);
Assert.IsNotNull(otherParticipant);
diff --git a/Tests/OpenDDSharp.UnitTest/OpenDDSharp.UnitTest.csproj b/Tests/OpenDDSharp.UnitTest/OpenDDSharp.UnitTest.csproj
index ac15fbc7..a41cf7c9 100644
--- a/Tests/OpenDDSharp.UnitTest/OpenDDSharp.UnitTest.csproj
+++ b/Tests/OpenDDSharp.UnitTest/OpenDDSharp.UnitTest.csproj
@@ -61,9 +61,9 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
+
+
+
@@ -73,7 +73,7 @@
-
+
all
@@ -85,7 +85,7 @@
all
-
+
all
diff --git a/Tests/TestIdlCdr/IDL/Test.idl b/Tests/TestIdlCdr/IDL/Test.idl
index 017fcbea..59b8063e 100644
--- a/Tests/TestIdlCdr/IDL/Test.idl
+++ b/Tests/TestIdlCdr/IDL/Test.idl
@@ -154,6 +154,7 @@ module CdrWrapper {
@topic
struct TestInclude {
@key string Id;
+ int16 ShortField;
CdrWrapperInclude::IncludeStruct IncludeField;
};
diff --git a/Tests/TestSupportProcessCore/TestSupportProcessCore.csproj b/Tests/TestSupportProcessCore/TestSupportProcessCore.csproj
index 5d4d6f41..a6e087b4 100644
--- a/Tests/TestSupportProcessCore/TestSupportProcessCore.csproj
+++ b/Tests/TestSupportProcessCore/TestSupportProcessCore.csproj
@@ -36,10 +36,10 @@
-
+
all
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -52,7 +52,7 @@
all
-
+
all
diff --git a/global.json b/global.json
index f202156d..42f2b948 100644
--- a/global.json
+++ b/global.json
@@ -1,6 +1,6 @@
{
"sdk": {
- "version": "8.0.401",
+ "version": "8.0.404",
"rollForward": "latestFeature",
"allowPrerelease": false
}