RMCLink.Interop .NET Assembly RMCLink.ReadBit Method |
Reads a single bit from an integer (L) register in the RMC. ReadBit is typically used to read the value of a status bit in the RMC.
Visual Basic (Declaration) |
Public Function ReadBit ( _ file As Integer, _ element As Integer, _ bit As Integer _ ) As Boolean |
Visual Basic (Usage) |
Dim instance As RMCLink Dim file As Integer Dim element As Integer Dim bit As Integer Dim returnValue As Boolean
returnValue = instance.ReadBit(file, element, bit) |
C# |
public bool ReadBit ( int file, int element, int bit ) |
Visual C++/CLI |
public: bool ReadBit ( int file, int element, int bit ) |
file
File number of the register with the bit to be read. See the RMCLink Register Reference for details.
element
Element number of the register with the bit to be read. See the RMCLink Register Reference for details.
bit
Number of the bit (0-31) to read in the register. Bits are numbered from least to most significant.
If the bit that was read was 1, then true (True in Visual Basic) is returned, otherwise false (False in Visual Basic) is returned.
This method is synchronous, which means that it will not return until the read is completed, which may take several seconds. If this method is called on the main thread, then the application will likely be unresponsive until this method completes. For applications where this is not acceptable, this and other synchronous methods should be called from a worker thread, and may use the CancelRequest method to cancel an in progress request.
Exception Type |
Condition |
One of the file, element, and bit parameters is out of range. Ensure that file and element are between 0 and 65535, and that bit is between 0 and 31. |
|
This read was cancelled by a call on another thread to one of the Disconnect and CancelRequest methods. |
|
The link is not currently connected. The Connect method must be called before attempting to read from the controller. |
|
The read failed due to a communication failure. Check that the remote device is powered up, check the communication wiring, and check the communication configuration of both the local and remote devices. Check the Message property of the exception for a description of the communication failure. |
The following code example illustrates the use of the ReadBit 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 In Position Bit (L8:0/0).
Dim inPosition As Boolean = rmc.ReadBit(FileNumber70.fn70StatusAxis0,0,0)
Console.WriteLine("Axis0 In Position? " & inPosition)
' 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 In Position Bit (L8:0/0).
bool inPosition = rmc.ReadBit(FileNumber70.fn70StatusAxis0,0,0);
Console.WriteLine("Axis0 In Position? " + inPosition);
// 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 In Position Bit (L8:0/0).
bool inPosition = rmc->ReadBit(FileNumber70::fn70StatusAxis0,0,0);
Console::WriteLine("Axis0 In Position? " + inPosition);
// 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