set_output_register_int

This function writes an integer value to the controller output register using the specified register address and value. It is typically used for PLC I/O register control in Ethernet-based environments.

Definition
DRFLEx.h within class CDRFLEx, public section

bool set_output_register_int(unsigned short address, int val) {
    return _set_output_register_int(_rbtCtrl, address, val);
};

Parameter

Parameter Name

Data Type

Default Value

Description

address

unsigned short

Output register address (int type, 0~23)

val

int

Integer value to write

Return

Value

Description

0

Error: failed to write output register int

1

Success: output register int written

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 int and read back (timeout 300 ms)
    // Initialize to 0 to indicate “not read yet” if the call fails.
    int out_int = 0;
    robot.set_output_register_int(0, 1);
    robot.get_output_register_int(0, out_int, 300);
    std::cout << "addr=0, out_int=" << out_int << std::endl;

    robot.close_connection();
    return 0;
}

This example writes an integer value to the output register at address 0 (Int_Output_Register[0]) and reads it back.