Direct Variable Manager
Direct variable can read and write directly to each type of memory through shared memory within STEP. Direct variables are accessible not only in shared memory, but also in Conty and other communications, and since direct variables at the same address are shared with each other, they have the same value and can be used in various ways.
Direct Variable Manager is a class contains functions that provide easy access to direct variables through shared memory in STEP.
-
Namespace : NRMKIndy::SharedData
-
Header : NRMKFramework/Indy/SharedMemory/DirectVariable.h
Type and Address
There are seven types of direct variables(Byte, Word, DWord, LWord, Flot, DFloat and Modbus). The Modbus Type is a direct variable used in ModbusTCP communication, which is accessible through Modbus Master (Client), rather than through shared memory. So it is ignored in this chapter.
1000 direct variables for each type are provided, and variables are expressed using address values. The address is 000~999, expressed in three digits. The table below is the byte and data types for each direct variable type.
Direct Variable Type | Address Representation | Data Type |
---|---|---|
BYTE (B) | B000 ~ B999 | 1 Byte, Unsigned Integer |
WORD (W) | W000 ~ W999 | 2 Byte, Integer |
DWORD (I) | I000 ~ I999 | 4 Byte, Integer |
LWORD (L) | L000 ~ L999 | 8 Byte, Integer |
FLOAT (F) | F000 ~ F999 | 4 Byte, Floating Point (real number) |
DFLOAT (D) | D000 ~ D999 | 8 Byte, Floating Point (real number) |
For example, if you want to use 10 variables of the type 4byte integer, and you want to use them from address 110, you can use variables of the address I110 to I119. If one access to addresses below 100, a three-digit number must be expressed, including a zero in front of it, as shown in W002.
Reading and Writing
Data Structure
1 2 3 4 5 6 7 8 |
|
This data type is Union. When reading the value through a direct variable address such as "W001" and "D024", it returns using this union. Note that the address that read values should match the type of variables to be used in this union.
uint8_t byteVal : Used when BYTE type variable
int16_t wordVal : Used when WORD type variable
int32_t dwordVal : Used when DWORD type variable
int64_t lwordVal: Used when LWORD type variable
float floatVal : Used when FLOAT type variable
double dfloatVal : Used when DFLOAT type variable
Fuctions
- Constructor
1 |
|
-
NRMKFramework::ShmemManager & indyShm : Shared Memory Manager connected with Indy Shared Memory
-
Get Specific Type Direct Varialbe as Reference with Address Num
1 2 3 4 5 6 |
|
Each function is matched for each type. The parameter is 0~999, and only the address value is entered, not the "W000" formula that expresses the direct variable address. For example, if you want to get a direct variable "B019", you can call byteVar(19). Since it is returned as Reference Type, the values of the corresponding direct variables can be both read and writtten using this variable.
- Get Direct Variable's Value with Name
1 |
|
Reads the value of direct variable through parameters from the name of the direct variable including the address value such as "W000" and "D437". Since it returns the union DirectVariable, user must use the variable type appropriate for the specified direct variable within the union.
- Set Direct Variable's Value
1 2 3 4 5 6 |
|
The name of the direct variable including the address value, such as "W000", "D437", and the value to be used for the corresponding direct variable, are received as parameters. The type of direct variable for the name of the direct variable must match the type of value to be used for the direct variable.