RMCLink.Interop .NET Assembly RMCLink.Disconnect Method |
Closes the connection, if one has been established, associated with this RMCLink object.
Visual Basic (Declaration) |
Public Sub Disconnect |
Visual Basic (Usage) |
Dim instance As RMCLink
instance.Disconnect() |
C# |
public void Disconnect () |
Visual C++/CLI |
public: void Disconnect () |
On serial connections, the serial port will be released for use by other applications. On Ethernet connection, the TCP/IP connection will be closed.
This method is synchronous, which means that it will not return until the link is disconnected. However, disconnecting generally takes only a fraction of a second.
WARNING: For Ethernet connections, it is highly recommended that the connection not be disconnected and re-connected between transactions. Doing so will have lower performance, and more importantly, each call to Connect() will consume a TCP connection in the Windows operating system. This TCP connection will not be fully released by the operating system until typically 2 minutes after Disconnect() is called. Therefore, it is possible to consume all available TCP connections by repeated calls to Connect()/Disconnect() and as a result be unable to re-connect over RMCLink or even adversely affect other applications running on the same PC.
Exception Type |
Condition |
This link was already disconnected. |
The following code example illustrates the use of the Disconnect method.
Visual Basic |
Imports RMCLinkNET
Module Example
Sub Main()
' Create the object itself.
Dim rmc As RMCLink = RMCLink.CreateSerialLink(DeviceType.RMC70, "COM1")
' Connect to the controller.
rmc.Connect()
' Read and display Axis 0's Actual Position (F8:8).
Dim data() As Single = New Single(0) {}
rmc.ReadFFile(FileNumber70.fn70StatusAxis0,8,data,0,1)
Console.WriteLine("Axis0 Actual Position = " & data(0) & " inches")
' Disconnect from the controller.
rmc.Disconnect()
End Sub
End Module
|
C# |
using System;
using RMCLinkNET;
namespace Example
{
public class Program
{
static void Main()
{
// Create the object itself.
RMCLink rmc = RMCLink.CreateSerialLink(DeviceType.RMC70, "COM1");
// Connect to the controller.
rmc.Connect();
// Read and display Axis 0's Actual Position.
float[] data = new float[1];
rmc.ReadFFile(FileNumber70.fn70StatusAxis0,8,data,0,1);
Console.WriteLine("Axis0 Actual Position = " + data[0] + " inches");
// Disconnect from the controller.
rmc.Disconnect();
}
}
}
|
Visual C++/CLI |
using namespace System;
using namespace RMCLinkNET;
int main()
{
// Create the object itself.
RMCLink^ rmc = RMCLink::CreateSerialLink(DeviceType::RMC70, "COM1");
// Connect to the controller.
rmc->Connect();
// Read and display Axis 0's Actual Position.
array<float>^ data = gcnew array<float>(1);
rmc->ReadFFile(FileNumber70::fn70StatusAxis0,8,data,0,1);
Console::WriteLine("Axis0 Actual Position = " + data[0] + " inches");
// Disconnect from the controller.
rmc->Disconnect();
return 0;
}
|
See Also
RMCLink.Interop .NET Assembly | RMCLinkNET Namespace | RMCLink Class
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion