EPLAN Remoting is a part of API which enables user to connect to an EPLAN Platform variant and control it in remote way.
Internally it uses gRPC and protocol buffers (protobuf) technology.
The connection is established form client application (a .NET program written by API user) to existing EPLAN instance which is available in network.
The condition is that the EPLAN variant is started as a remoting server (without the /NoRemoting parameter).
EPLAN Remoting consist of following internal libraries:
external libraries:
and .NET System libraries
The – Grpc_csharp_ext.x64.dll – is a runtime dll that is used by the Grpc.Core and it is necessary to integrate it to the project.
There are two ways to integrate it correctly. Either you copy it into the build folder or it is added to the project as an "existing item".
Add -> Existing item… (Shift + Alt + A)
When added, please set the property “Copy to Output Directory” to “Copy always”:
All the dlls are stored in EPLAN Platform BIN folder. Below are examples how to use it.
EPLAN Remoting allows you to execute actions and some P8 operations in the remote way.
To open a new session, you have to connect your client to one of the existing P8 instance (the gRPC server that is embedded inside it).
The server could run locally or remotely.
After that, you can run P8 actions synchronously or asynchronously.
You can also pass or get parameters using action contex.
Finally, to close your remote session, you have to disconnect.
Below examples show how to use EPLAN Remoting:
C# |
Copy Code
|
---|---|
List<EplanServerData> oInstalledEplanVersions = new List<EplanServerData>(); oClient.GetInstalledEplanVersionsOnLocalMachine(out oInstalledEplanVersions); foreach (EplanServerData oVersion in oInstalledEplanVersions) Console.WriteLine(oVersion.EplanVariant + "," + oVersion.EplanVersion + "," + (oVersion.Is64Bit ? "64" : "32"); |
C# |
Copy Code
|
---|---|
List<EplanServerData> oActiveEplanVersions = new List<EplanServerData>(); oClient.GetActiveEplanServersOnLocalMachine(out oActiveEplanVersions); foreach (EplanServerData oVersion in oActiveEplanVersions) Console.WriteLine(oVersion.EplanVariant + "," + oVersion.EplanVersion + "," + oVersion.ServerPort); |
C# |
Copy Code
|
---|---|
List<EplanServerData> oInstalledEplanVersions = new List<EplanServerData>(); oClient.GetInstalledEplanVersionsOnLocalMachine(out oInstalledEplanVersions); EplanServerData oConnected = oClient.StartEplan(oInstalledEplanVersions[0].EplanPath); |
To make sure that the EPLAN server was started, please check the registry key HKEY_CURRENT_USER\Software\EPLAN\RemoteServer\<port_number>.
C# |
Copy Code
|
---|---|
EplanRemoteClient oClient = new EplanRemoteClient(); bool bConnected = oClient.Connect("localhost", "49155"); // Default port for EPLAN instance is 49155 |
C# |
Copy Code
|
---|---|
EplanRemoteClient oClient = new EplanRemoteClient(); bool bConnected = oClient.Connect("remote_server", "49155", new TimeSpan(0, 0, 0, 5)); // Wait 5 seconds |
C# |
Copy Code
|
---|---|
bool oResp = oClient.ExecuteAction("XPartsManagementStart"); |
C# |
Copy Code
|
---|---|
oClient.SynchronousMode = false; oClient.ResponseArrivedFromEplanServer += onCallbackArrivedFromEplan; oClient.ExecuteAction("XPartsManagementStart"); |
In this case, the program starts an action and continues running. onCallbackArrivedFromEplan method is called after action finished.
This example shows how to get input from a user using context:
C# |
Copy Code
|
---|---|
oClient.SynchronousMode = true; CallingContext oCallingContext = new CallingContext(); oClient.ExecuteAction("XPamSelectPart", ref oCallingContext); |
In this case, the program waits until the action execution is finished.
C# |
Copy Code
|
---|---|
StringCollection oObjects = new StringCollection(); oObjects.Add(@"17/688"); EplanResponse oResponse = oClient.SelectEplanObjects(@"$(MD_PROJECTS)\EPLAN_Sample_Project.elk", oObjects, true); |
C# |
Copy Code
|
---|---|
oClient.Disconnect(); |
It is important to close the connection when operations are finished.