Skip to content

Commit

Permalink
+Separate Intel.Realsense.Net library for network devices. It is bein…
Browse files Browse the repository at this point in the history
…g created on BUILD_NETWORK_DEVICE=ON cmake flag as well as cs-tutorial-7-net-dev example tutorial tha uses this library.
  • Loading branch information
Andrey Uzbekov authored and Nir-Az committed Sep 29, 2021
1 parent e8bf11e commit e06191b
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 10 deletions.
7 changes: 5 additions & 2 deletions wrappers/csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ add_subdirectory(tutorial/depth)
add_subdirectory(tutorial/capture)
add_subdirectory(tutorial/processing)
add_subdirectory(tutorial/software-dev)
add_subdirectory(tutorial/pose)
add_subdirectory(tutorial/d400-occ)
add_subdirectory(tutorial/load-json)
add_subdirectory(tutorial/net-dev)

if(BUILD_NETWORK_DEVICE)
add_subdirectory(Intel.RealSense.Net)
add_subdirectory(tutorial/net-dev)
endif()
16 changes: 16 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/.nuget/Intel.RealSense.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(Platform)' == 'x64' ">
<NativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\*.dll" />
<None Include="@(NativeLibs)">
<Link>%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'x86' OR '$(Platform)' == 'AnyCPU' ">
<NativeLibs Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\*.dll" />
<None Include="@(NativeLibs)">
<Link>%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
46 changes: 46 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required( VERSION 3.8.0 )

project(Intel.RealSense.Net)

set(LRS_DOTNET_TARGET ${PROJECT_NAME})

add_library(${PROJECT_NAME}
NativeMethods.cs
.nuget/Intel.RealSense.targets
GlobalSuppressions.cs
Properties/AssemblyInfo.cs
packages.config
stylecop.json
)

include(Devices/CMakeLists.txt)

csharp_set_designer_cs_properties(
.nuget/Intel.RealSense.Net.targets
)


set_property(SOURCE App.xaml PROPERTY VS_XAML_TYPE "ApplicationDefinition")

set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v${DOTNET_VERSION_LIBRARY}")

add_dependencies(${PROJECT_NAME} Intel.RealSense)

set_target_properties (${PROJECT_NAME} PROPERTIES
FOLDER Wrappers/csharp
)

set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
"System"
)

target_compile_options(${PROJECT_NAME} PRIVATE /define:${CMAKE_SYSTEM_NAME})

set_source_files_properties(stylecop.json PROPERTIES VS_TOOL_OVERRIDE "AdditionalFiles")

install(TARGETS ${PROJECT_NAME}
EXPORT realsense2Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
#ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
4 changes: 4 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/Devices/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target_sources(${LRS_DOTNET_TARGET}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/NetDevice.cs"
)
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

namespace Intel.RealSense
namespace Intel.RealSense.Net
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Intel.RealSense;


public class NetDevice : Device
public class NetDevice : ProxyDevice
{
public NetDevice(string address) : base(init(address))
{
Expand Down
8 changes: 8 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Pending")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1201:Elements must appear in the correct order", Justification = "Pending")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1202:Elements must be ordered by access", Justification = "Pending")]
42 changes: 42 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#pragma warning disable SA1600 // Elements must be documented
#pragma warning disable SA1124 // Do not use regions

namespace Intel.RealSense.Net
{
using System;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;

[SuppressUnmanagedCodeSecurity]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
internal static class NativeMethods
{

#if DEBUG
private const string dllName = "realsense2d";
private const string dllNetName = "realsense2-netd";
#else
private const string dllName = "realsense2";
private const string dllNetName = "realsense2-net";
#endif

[DllImport(dllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void rs2_context_add_software_device(ContextHandle ctx, IntPtr device, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ErrorMarshaler))] out object error);

[DllImport(dllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern int rs2_get_api_version([MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ErrorMarshaler))] out object error);

#region rs_net_device
[DllImport(dllNetName, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr rs2_create_net_device(int api_version, string address, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ErrorMarshaler))] out object error);
#endregion
}
}

#pragma warning restore SA1600 // Elements must be documented
#pragma warning restore SA1124 // Do not use regions
36 changes: 36 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Intel(R) RealSense(TM) SDK C# Net Wrapper")]
[assembly: AssemblyDescription("Intel(R) RealSense(TM) SDK C# Net Wrapper")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Intel(R) Corporation")]
[assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK C# Net Wrapper")]
[assembly: AssemblyCopyright("Copyright © 2021, Intel Corporation. All rights reserved")]
[assembly: AssemblyTrademark("Intel(R) RealSense(TM)")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("71c85ee0-c7c2-4e2e-8020-6af818537a15")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
4 changes: 4 additions & 0 deletions wrappers/csharp/Intel.RealSense.Net/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net35" developmentDependency="true" />
</packages>
2 changes: 1 addition & 1 deletion wrappers/csharp/Intel.RealSense/Devices/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ target_sources(${LRS_DOTNET_TARGET}
"${CMAKE_CURRENT_LIST_DIR}/UpdatableDevice.cs"
"${CMAKE_CURRENT_LIST_DIR}/UpdateDevice.cs"
"${CMAKE_CURRENT_LIST_DIR}/FirmwareLogsDevice.cs"
"${CMAKE_CURRENT_LIST_DIR}/NetDevice.cs"
"${CMAKE_CURRENT_LIST_DIR}/ProxyDevice.cs"
)
22 changes: 22 additions & 0 deletions wrappers/csharp/Intel.RealSense/Devices/ProxyDevice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.
//
// This proxy device is for accessing Device constructor that is internal, by successors in different namespaces and assemblies
// This way is more controllable for accessing base Device object instead of making it's constructors public
// Example of usage: NetDevice in Intel.Realsense.Net.dll that is a successor of ProxyDevice

namespace Intel.RealSense
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;


public class ProxyDevice : Device
{
public ProxyDevice(IntPtr ptr) : base(ptr)
{
}
}
}
1 change: 1 addition & 0 deletions wrappers/csharp/cs-tutorial-7-net-dev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION
# set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE TRUE)

add_dependencies(${PROJECT_NAME} Intel.RealSense)
add_dependencies(${PROJECT_NAME} Intel.RealSense.Net)

set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES
"System"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Intel(R) RealSense(TM) SDK C# Wrapper Tutorial-7")]
[assembly: AssemblyDescription("Intel(R) RealSense(TM) SDK C# Wrapper Examples")]
[assembly: AssemblyTitle("Intel(R) RealSense(TM) SDK C# Net Wrapper Tutorial-7")]
[assembly: AssemblyDescription("Intel(R) RealSense(TM) SDK C# Net Wrapper Examples")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Intel(R) Corporation")]
[assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK C# Wrapper")]
[assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK C# Net Wrapper Tutorial-7")]
[assembly: AssemblyCopyright("Copyright © 2021, Intel Corporation. All rights reserved")]
[assembly: AssemblyTrademark("Intel(R) RealSense(TM)")]
[assembly: AssemblyCulture("")]
Expand All @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("71c85ee0-c7c2-4e2e-8020-6af818537a14")]
[assembly: Guid("71c85ee0-c7c2-4e2e-8020-6af818537a16")]

// Version information for an assembly consists of the following four values:
//
Expand Down
1 change: 1 addition & 0 deletions wrappers/csharp/cs-tutorial-7-net-dev/Window.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Intel.RealSense.Net;

namespace Intel.RealSense
{
Expand Down

0 comments on commit e06191b

Please sign in to comment.