Please note that System Parameter RS7 may need to be set to 2 to allow writing of variables outside of remote mode.
Name | Type | Description |
---|---|---|
ByteVariable | ByteVariableInterface* | Reads and writes byte(B) variables. |
IntegerVariable | IntegerVariableInterface* | Reads and writes Integer(I) variables. |
DoubleIntVariable | DoubleIntVariableInterface* | Reads and writes Double(D) variables. |
RealVariable | RealVariableInterface* | Reads and writes Real(R) variables. |
StringVariable | StringVariableInterface* | Reads and writes String(S) variables. |
RobotPositionVariable | RobotPositionVariableInterface* | Reads and writes Robot Position(P) variables. |
BasePositionVariable | BaseAxisPositionVariableInterface* | Reads and writes Base Position variables. |
StationPositionVariable | StationPositionVariableInterface* | Reads and writes Station Position variables. |
Reads a byte (B) variable from the controller.
StatusInfo Read(UINT16 variableIndex, ByteVariableData& byteVariableDataObject)
variableIndex
[in] The index of the variable to read.
byteVariableDataObject
[out] The byte variable data object to store the read data. See ByteVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
ByteVariableData byteVariableData{};
status = c->Variables->ByteVariable->Read(1, byteVariableData);
std::cout << status << std::endl;
std::cout << byteVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
B001=2
Writes a byte (B) variable to the controller.
StatusInfo Write(const ByteVariableData& byteVariableDataObject)
byteVariableDataObject
[in] The byte variable data object to write. See ByteVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
ByteVariableData byteVariableData{1, 1};
status = c->Variables->ByteVariable->Write(byteVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads an integer (I) variable from the controller.
StatusInfo Read(UINT16 variableIndex, IntegerVariableData& integerVariableDataObject)
variableIndex
[in] The index of the variable to read.
integerVariableDataObject
[out] The integer variable data object to store the read data. See IntegerVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IntegerVariableData integerVariableData{};
status = c->Variables->IntegerVariable->Read(1, integerVariableData);
std::cout << status << std::endl;
std::cout << integerVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
I001=2
Writes an integer (I) variable to the controller.
StatusInfo Write(const IntegerVariableData& integerVariableDataObject)
integerVariableDataObject
[in] The integer variable data object to write. See IntegerVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IntegerVariableData integerVariableData{1, 1};
status = c->Variables->IntegerVariable->Write(integerVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads a double integer (D) variable from the controller.
StatusInfo Read(UINT16 variableIndex, DoubleIntVariableData& doubleIntVariableDataObject)
variableIndex
[in] The index of the variable to read.
doubleIntVariableDataObject
[out] The double integer variable data object to store the read data. See DoubleIntVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
DoubleIntVariableData doubleIntVariableData{};
status = c->Variables->DoubleIntVariable->Read(1, doubleIntVariableData);
std::cout << status << std::endl;
std::cout << doubleIntVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
D001=2
Writes a double integer (D) variable to the controller.
StatusInfo Write(const DoubleIntVariableData& doubleIntVariableDataObject)
doubleIntVariableDataObject
[in] The double integer variable data object to write. See DoubleIntVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
DoubleIntVariableData doubleIntVariableData{1, 1};
status = c->Variables->DoubleIntVariable->Write(doubleIntVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads a real (R) variable from the controller.
StatusInfo Read(UINT16 variableIndex, RealVariableData& realVariableDataObject)
variableIndex
[in] The index of the variable to read.
realVariableDataObject
[out] The real variable data object to store the read data. See RealVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RealVariableData realVariableData{};
status = c->Variables->RealVariable->Read(1, realVariableData);
std::cout << status << std::endl;
std::cout << realVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
R001=2
Writes a real (R) variable to the controller.
StatusInfo Write(const RealVariableData& realVariableDataObject)
realVariableDataObject
[in] The real variable data object to write. See RealVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RealVariableData realVariableData{1, 1};
status = c->Variables->RealVariable->Write(realVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads a string (S) variable from the controller.
StatusInfo Read(UINT16 variableIndex, StringVariableData& stringVariableDataObject)
variableIndex
[in] The index of the variable to read.
stringVariableDataObject
[out] The string variable data object to store the read data. See StringVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
StringVariableData stringVariableData{};
status = c->Variables->StringVariable->Read(1, stringVariableData);
std::cout << status << std::endl;
std::cout << stringVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
S001=A STRING VARIABLE
Writes a string (S) variable to the controller. Max length is 32 characters.
StatusInfo Write(const StringVariableData& stringVariableDataObject)
stringVariableDataObject
[in] The string variable data object to write. See StringVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
StringVariableData stringVariableData{"ITS A STRING", 1};
status = c->Variables->StringVariable->Write(stringVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads a robot position (P) variable from the controller.
StatusInfo Read(UINT16 variableIndex, RobotPositionVariableData& robotPositionVariableDataObject)
variableIndex
[in] The index of the variable to read.
robotPositionVariableDataObject
[out] The robot position variable data object to store the read data. See RobotPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RobotPositionVariableData robotPositionVariableData{};
status = c->Variables->RobotPositionVariable->Read(1, robotPositionVariableData);
std::cout << status << std::endl;
std::cout << robotPositionVariableData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
P001:
Coordinate Type: ToolCoordinate
Figure:
Front, Upper, Flip, S<180, L<180, U<180, R<180, B<180, T<180, E<180, W<180
Tool Number: 1
User Coordinate Number: 0
Axes:
Axis X : 0.1 millimeters.
Axis Y : 0 millimeters.
Axis Z : 0 millimeters.
Axis Rx : 0 degrees.
Axis Ry : 0 degrees.
Axis Rz : 0 degrees.
Axis Re : 0 degrees.
Axis Rw : 0 degrees.
Writes a robot position (P) variable to the controller.
StatusInfo Write(const RobotPositionVariableData& robotPositionVariableDataObject)
robotPositionVariableDataObject
[in] The robot position variable data object to write. See RobotPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
RobotPositionVariableData robotPositionVariableData{};
status = c->Variables->RobotPositionVariable->Read(1, robotPositionVariableData);
status = c->Variables->RobotPositionVariable->Write(robotPositionVariableData);
robotPositionVariableData.variableIndex = 2;
status = c->Variables->RobotPositionVariable->Write(robotPositionVariableData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Reads a base axis position (BP) variable from the controller.
StatusInfo Read(UINT16 variableIndex, BaseAxisPositionVariableData& baseAxisPositionVariableDataObject)
variableIndex
[in] The index of the variable to read.
baseAxisPositionVariableDataObject
[out] The base axis position variable data object to store the read data. See BaseAxisPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status;
BaseAxisPositionVariableData data{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Variables->BasePositionVariable->Read(0, data);
std::cout << status << std::endl;
std::cout << data << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Variable Index: 0
Coordinate Type: Base
X: 100
Y: 0
Z: 0
Writes a base axis position (BP) variable to the controller.
StatusInfo Write(const BaseAxisPositionVariableData& basePositionVariableDataObject)
baseAxisPositionVariableDataObject
[in] Data to set. See BaseAxisPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status;
BaseAxisPositionVariableData data{};
data.X = 100;
data.coordinateType = CoordinateType::BaseCoordinate;
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Variables->BasePositionVariable->Read(0, data);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Get variable data at the specified variable index.
StatusInfo Read(UINT16 variableIndex, StationPositionVariableData& stationPositionVariableDataObject)
variableIndex
[in] The index of the variable to read.
stationPositionVariableDataObject
[out] The base axis position variable data object to store the read data. See StationPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status;
StationPositionVariableData stationPositionData;
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Variables->StationPositionVariable->Read(0, stationPositionData);
std::cout << status << std::endl;
std::cout << stationPositionData << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
VariableIndex: 0
Coordinates: 0, 100, 0, 0, 0, 0, 0, 0,
Set variable data at the specified variable index. System Parameter at RS7 may need to be set to 2 to allow writing outside of REMOTE mode.
StatusInfo Write(const StationPositionVariableData& stationPositionVariableDataObject)
baseAxisPositionVariableDataObject
[in] Data to set. See StationPositionVariableData.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status;
StationPositionVariableData stationPositionData;
auto c = YMConnect::OpenConnection("192.168.1.31", status);
stationPositionData.positionData.axisData[1] = 100;
stationPositionData.variableIndex = 0;
status = c->Variables->StationPositionVariable->Write(stationPositionData);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK