get_output_register_float
This function reads a float value from the controller output register using the specified register address. It is typically used for PLC I/O register monitoring in Ethernet-based environments.
Definition
DRFLEx.h within class CDRFLEx, public section
bool get_output_register_float(unsigned short address, float& out_val, int timeout_ms = 300) {
return _get_output_register_float(_rbtCtrl, address, &out_val, timeout_ms);
};
Parameter
Parameter Name |
Data Type |
Default Value |
Description |
|---|---|---|---|
address |
unsigned short |
Output register address (float type, 0~23) |
|
out_val |
float& |
Output float value to read |
|
timeout_ms |
int |
300 |
Timeout in milliseconds |
Return
Value |
Description |
|---|---|
0 |
Error: failed to read output register float |
1 |
Success: output register float read |
Example
#include "DRFLEx.h"
#include <iostream>
using namespace DRAFramework;
int main() {
CDRFLEx robot;
const char* ip = "192.168.137.100";
if (!robot.open_connection(ip)) {
std::cout << "Failed to connect: " << ip << std::endl;
return 1;
}
// Write float and read back (timeout 300 ms)
// Initialize to 0.0f to indicate “not read yet” if the call fails.
float out_float = 0.0f;
robot.set_output_register_float(0, 2.0f);
robot.get_output_register_float(0, out_float, 300);
std::cout << "addr=0, out_float=" << out_float << std::endl;
robot.close_connection();
return 0;
}
This example writes a float value to the output register at address 0 (Float_Output_Register[0]) and reads it back.