Used to read and write IO. Each IO read and write provides four ways to perform the operation.
The IOData structure is a type alias of a bitset. This allows you to access the bits by treating it like an array.
Writable addresses are network input on all controllers. Interface Panel and General Output are writable on YRC1000 and newer.
Name | Description |
---|---|
ConvertIOGroupToBitAddress | Conversion of IOGroup to bit address. |
ReadBit | Read a bit from the controller using the specified IO type, group, and bit position. |
ReadBit | Read a bit from the controller using the specified address. |
ReadByte | Read a byte from the controller using the specified IO type and group. Reads the value as IOByteData. |
ReadByte | Read a byte from the controller using the specified address. Gets value as IOByteData. |
ReadByte | Read a byte from the controller using the specified IO type and group. Reads the value as UINT8. |
ReadByte | Read a byte from the controller using the specified address. Gets value as UINT8 |
ReadWord | Read a word from the controller using the specified IO type and group. Reads the value as IOWordData. |
ReadWord | Read a word from the controller using the specified address. Gets value as IOWordData. |
ReadWord | Read a word from the controller using the specified IO type and group. Reads the value as UINT16. |
ReadWord | Read a word from the controller using the specified address. Reads the value as UINT16 |
WriteBit | Write a bit from the controller using the specified IO type and group. |
WriteBit | Write a bit from the controller using the specified address. |
WriteByte | Write a byte to the controller using the specified IO type and group. Writes the value as IOByteData. |
WriteByte | Write a byte to the controller using the specified address. Writes the value as IOByteData. |
WriteByte | Write a byte to the controller using the specified IO type and group. Writes the value as UINT8. |
WriteByte | Write a byte to the controller using the specified address. Writes the value as UINT8 |
WriteWord | Write a word to the controller using the specified IO type and group. Writes the value as IOWordData. |
WriteWord | Write a word to the controller using the specified address. Writes the value as IOWordData. |
WriteWord | Write a word to the controller using the specified IO type and group. Writes the value as UINT16. |
WriteWord | Write a word to the controller using the specified address. Writes the value as UINT16 |
ReadRegister | Read a register as a register object. |
ReadRegister | Read a register as a bitset<16> object. |
WriteRegister | Write a register as a register object. |
WriteRegister | Write a register as a bitset<16> object. |
Conversion of IOGroup to bit address.
If a bit address is required, this function can be used to convert the IOType, Group and bit index to a bit address.
Useful for IO operations.
ConvertIOGroupToBitAddress(IOType type, UINT16 group, UINT8 bitIndex, StatusInfo& statusInfo)
type
[in] The type of IO to convert. See IOType.
group
[in] The group of IO to convert.
bitIndex
[in] The bit index of the IO to convert.
statusInfo
[out] 0 if successful, otherwise a StatusInfo object with a description of error.
The bit address.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
UINT32 bitAddress = c->Io->ConvertIOGroupToBitAddress(IOType::GeneralOutput, 0, 0, status);
std::cout << status << std::endl;
std::cout << bitAddress << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
10000
Read a bit from the controller using the specified IO type, group, and bit position.
StatusInfo ReadBit(IOType ioType, UINT16 group, UINT32 bitPosition, bool& value);
ioType
[in] The type of IO to read. See IOType.
group
[in] The group of IO to read.
bitPosition
[in] The bit position of the IO to read.
value
[out] The value of the bit.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
bool value{};
status = c->Io->ReadBit(IOType::GeneralOutput, 0, 0, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a bit from the controller using the specified address.
StatusInfo ReadBit(UINT32 address, bool& value);
address
[in] The address of the IO to read.
value
[out] The value of the bit.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31, status);
bool value{};
status = c->Io->ReadBit(10010, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a byte from the controller using the specified IO type, group, and byte position. Gets value as IOByteData.
StatusInfo ReadByte(IOType ioType, UINT16 group, IOByteData& value);
ioType
[in] The type of IO to read. See IOType.
group
[in] The group of IO to read.
value
[out] The value of the byte represented as an IOByteData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOByteData value{};
status = c->Io->ReadByte(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
for (int i = 0; i < 8; i++)
{
std::cout << value[i];
}
YMConnect::CloseConnection(c);
Output
Code (0): OK
00000000
Read a byte from the controller using the specified address. Gets value as IOByteData.
StatusInfo ReadByte(UINT32 address, IOByteData& value);
address
[in] The address of the IO to read.
value
[out] The value of the byte represented as an IOByteData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOByteData value{};
status = c->Io->ReadByte(10010, value);
std::cout << status << std::endl;
for (int i = 0; i < 8; i++)
{
std::cout << value[i];
}
YMConnect::CloseConnection(c);
Output
Code (0): OK
00000000
Read a byte from the controller using the specified IO type, group, and byte position. Reads the value as UINT8.
StatusInfo ReadByte(IOType type, UINT16 group, UINT8& io)
ioType
[in] The type of IO to read. See IOType.
group
[in] The group of IO to read.
io
[out] The value of the byte represented as a UINT8.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
UINT8 value{};
status = c->Io->ReadByte(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a byte from the controller using the specified address. Reads the value as UINT8.
StatusInfo ReadByte(UINT32 address, UINT8& value);
address
[in] The address of the IO to read.
value
[out] The value of the byte represented as a UINT8.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
UINT8 value{};
status = c->Io->ReadByte(10010, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a word from the controller using the specified IO type, group, and byte position. Gets value as IOWordData.
StatusInfo ReadWord(IOType ioType, UINT16 group, IOWordData& value);
ioType
[in] The type of IO to read. See IOType.
group
[in] The group of IO to read.
value
[out] The value of the word represented as an IOWordData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOWordData value{};
status = c->Io->ReadWord(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
for (int i = 0; i < 16; i++)
{
std::cout << value[i];
}
YMConnect::CloseConnection(c);
Output
Code (0): OK
0000000000000000
Read a word from the controller using the specified address. Gets value as IOWordData.
StatusInfo ReadWord(UINT32 address, IOWordData& value);
address
[in] The address of the IO to read.
value
[out] The value of the word represented as an IOWordData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOWordData value{};
status = c->Io->ReadWord(10010, value);
std::cout << status << std::endl;
for (int i = 0; i < 16; i++)
{
std::cout << value[i];
}
YMConnect::CloseConnection(c);
Output
Code (0): OK
0000000000000000
Read a word from the controller using the specified IO type, group, and byte position. Reads the value as UINT16.
StatusInfo ReadWord(IOType ioType, UINT16 group, UINT16& value);
ioType
[in] The type of IO to read. See IOType.
group
[in] The group of IO to read.
value
[out] The value of the word represented as a UINT16.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
UINT16 value{};
status = c->Io->ReadWord(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a word from the controller using the specified address. Reads the value as UINT16.
StatusInfo ReadWord(UINT32 address, UINT16& value);
address
[in] The address of the IO to read.
value
[out] The value of the word represented as a UINT16.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
UINT16 value{};
status = c->Io->ReadWord(10010, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Write a bit to the controller using the specified IO type, group, and bit position.
StatusInfo WriteBit(IOType ioType, UINT16 group, UINT32 bitPosition, bool value);
ioType
[in] The type of IO to write. See IOType.
group
[in] The group of IO to write.
bitPosition
[in] The bit position of the IO to write.
value
[in] The value of the bit.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->WriteBit(IOType::GeneralOutput, 0, 0, true);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a bit to the controller using the specified address.
StatusInfo WriteBit(UINT32 address, bool value);
address
[in] The address of the IO to write.
value
[in] The value of the bit.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31, status);
status = c->Io->WriteBit(10010, true);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a byte to the controller using the specified IO type, group, and byte position. Writes the value as IOByteData.
StatusInfo WriteByte(IOType ioType, UINT16 group, IOByteData& value);
ioType
[in] The type of IO to write. See IOType.
group
[in] The group of IO to write.
value
[in] The value of the byte represented as an IOByteData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOByteData value{};
value[0] = true;
value[1] = true;
status = c->Io->WriteByte(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a byte to the controller using the specified address. Writes the value as IOByteData.
StatusInfo WriteByte(UINT32 address, IOByteData& value);
address
[in] The address of the IO to write.
value
[in] The value of the byte represented as an IOByteData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOByteData value{};
value[0] = true;
value[1] = true;
status = c->Io->WriteByte(10010, value);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a byte to the controller using the specified IO type, group, and byte position. Writes the value as UINT8.
StatusInfo WriteByte(IOType ioType, UINT16 group, UINT8 value);
ioType
[in] The type of IO to write. See IOType.
group
[in] The group of IO to write.
value
[in] The value of the byte represented as a UINT8.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->WriteByte(IOType::GeneralOutput, 0, 0xFF);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a byte to the controller using the specified address. Writes the value as UINT8.
StatusInfo WriteByte(UINT32 address, UINT8 value);
address
[in] The address of the IO to write.
value
[in] The value of the byte represented as a UINT8.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->WriteByte(10010, 0xFF);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a word to the controller using the specified IO type, group, and byte position. Writes the value as IOWordData.
StatusInfo WriteWord(IOType ioType, UINT16 group, IOWordData& value);
ioType
[in] The type of IO to write. See IOType.
group
[in] The group of IO to write.
value
[in] The value of the word represented as an IOWordData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOWordData value{};
value[0] = true;
value[1] = true;
status = c->Io->WriteWord(IOType::GeneralOutput, 0, value);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a word to the controller using the specified address. Writes the value as IOWordData.
StatusInfo WriteWord(UINT32 address, IOWordData& value);
address
[in] The address of the IO to write.
value
[in] The value of the word represented as an IOWordData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
IOWordData value{};
value[0] = true;
value[1] = true;
status = c->Io->WriteWord(10010, value);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a word to the controller using the specified IO type, group, and byte position. Writes the value as UINT16.
StatusInfo WriteWord(IOType ioType, UINT16 group, UINT16 value);
ioType
[in] The type of IO to write. See IOType.
group
[in] The group of IO to write.
value
[in] The value of the word represented as a UINT16.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->WriteWord(IOType::GeneralOutput, 0, 0xFFFF);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a word to the controller using the specified address. Writes the value as UINT16.
StatusInfo WriteWord(UINT32 address, UINT16 value);
address
[in] The address of the IO to write.
value
[in] The value of the word represented as a UINT16.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->WriteWord(10010, 0xFFFF);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Read a register as a register object.
StatusInfo ReadRegister(UINT32 address, RegisterData& value);
address
[in] The address of the register to read.
value
[out] The value of the register represented as a RegisterData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
RegisterData value{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->ReadRegister(6, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0
Read a register as a bitset<16> object.
StatusInfo ReadRegister(UINT32 address, std::bitset<16>& value);
address
[in] The address of the register to read.
value
[out] The value of the register represented as a bitset<16> object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
std::bitset<16> value{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
status = c->Io->ReadRegister(6, value);
std::cout << status << std::endl;
std::cout << value << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
0000000000000000
Write a register as a register object. Note that if the register value is controlled by an application running on the controller, the register value that you send will be overwritten by the application. This function will still return ok, but the register value will not be changed.
StatusInfo WriteRegister(UINT32 address, const RegisterData& value);
address
[in] The address of the register to write.
value
[in] The value of the register represented as a RegisterData object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
c->Io->WriteRegister(6, 0xFFFF);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK
Write a register as a bitset<16> object. Note that if the register value is controlled by an application running on the controller, the register value that you send will be overwritten by the application. This function will still return ok, but the register value will not be changed.
StatusInfo WriteRegister(UINT32 address, const std::bitset<16>& value);
address
[in] The address of the register to write.
value
[in] The value of the register represented as a bitset<16> object.
0 if successful, otherwise a StatusInfo object with a description of error.
StatusInfo status{};
std::bitset<16> value{};
auto c = YMConnect::OpenConnection("192.168.1.31", status);
value[0] = true;
value[1] = true;
status = c->Io->WriteRegister(6, value);
std::cout << status << std::endl;
YMConnect::CloseConnection(c);
Output
Code (0): OK