RMCLink COM Component RMCLinkServer.CreateSerialLink Method |
Creates an RMCLink object for communicating with a controller (either RMC70 or RMC100) over a serial port.
Visual Basic (Declaration) |
Function CreateSerialLink ( _ devType As DeviceType, _ portName As String _ ) As RMCLink |
Visual Basic (Usage) |
Dim instance As RMCLinkServer Dim devType As DeviceType Dim portName As String Dim returnValue As RMCLink
returnValue = instance.CreateSerialLink(devType, portName) |
devType
Specifies which type of RMC will be linked to. It must be either dtRMC70 or dtRMC100.
portName
Specifies the serial port to use for communicating with the device. Typical names include "COM1" and "COM2".
Returns a reference to a new RMCLink object created for communicating with the specified device type on the specified serial port.
Notice that this method does not in any way try to connect to the controller. This method simply creates the RMCLink object. To connect to the device, you will need to call the RMCLink.Connect instance method. This method will support any com port on the PC.
Because the object is only created and the connection is not made, this method returns immediately.
Error Code |
Description |
rmcEOutOfMemory = 5 |
Out of memory. |
rmcEInvalidArg = 7 |
Invalid argument. Ensure that devType was either dtRMC70 or dtRMC100 and that portName had a serial port name. |
The following code example illustrates the use of the CreateSerialLink method.
Visual Basic 6 / VBA |
Option Explicit
Public Sub Sample()
' Declare and create the RMCLinkServer COM object.
Dim srv As New RMCLinkServer
' Use our RMCLinkServer to create the correct type of RMCLink object.
Dim rmc As RMCLink
Set rmc = srv.CreateSerialLink(dtRMC70, "COM1")
' Establish the connection.
rmc.Connect
' Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
Dim data As Variant
data = rmc.ReadFFile(fn70StatusAxis0, 8, 2)
resultText = "Actual Position = " & data(0) & ", Actual Velocity = " & data(1)
' Close the connection.
rmc.Disconnect
End Sub
|
VBScript |
Option Explicit
Dim srv, rmc, data
' First we need to create the RMCLinkServer COM object.
Set srv = CreateObject("RMCLink.RMCLinkServer")
' Use our RMCLinkServer to create the correct type of RMCLink object.
' NOTE: VBScript does not support enumerations, so we use the literal value (dtRMC70=2).
Set rmc = srv.CreateSerialLink(2, "COM1")
' Establish the connection.
rmc.Connect
' Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
data = rmc.ReadFFile_Script(8,8,2)
WScript.Echo "Actual Position = " & data(0) & ", Actual Velocity = " & data(1)
' Close the connection.
rmc.Disconnect
|
JScript |
// First we need to create the RMCLinkServer COM object.
var srv = new ActiveXObject("RMCLink.RMCLinkServer");
// Use our RMCLinkServer to create the correct type of RMCLink object.
// NOTE: JScript does not support enumerations, so we use the literal value (dtRMC70=2).
var rmc = srv.CreateSerialLink(2, "COM1");
// Establish the connection.
rmc.Connect();
// Read F8:8 and F8:9 (Axis 0 Actual Position and Velocity)
var data = rmc.ReadFFile_Script(8,8,2).toArray();
WScript.echo("Actual Position = " + data[0] + ", Actual Velocity = " + data[1]);
// Close the connection.
rmc.Disconnect();
|
See Also
RMCLinkServer Class | RMCLink Class | RMCLink COM Component
Copyright (c) 2024 Delta Computer Systems, Inc. dba Delta Motion