Shared Memory virtual I/O configuration
The workbench includes a fully integrated configurator for virtual I/O stored in a Windows named memory space. Virtual I/Os in shared memory are available in the T5 runtime for Windows XP.
Data exchange - configuration:
The T5 runtime maps its variables to any location in the shared memory block. A dedicated configuration tool is integrated in the Workbench. Run it using the "File / Open / Fieldbus Configuration" menu command from the main window. Then select the "Win32 Shared Memory" configuration.
The configuration is represented as a tree:
- Win32 Shared Memory
- Named Win32 memory space (*)
- Group (*)
- exchanged Variable (*)
(*) The items with this mark can appear several times in the configuration.
A- Memory spaces
You first need to declare a memory space. The space is identified by a name that will be used as the name of memory system object in Windows. You also need to specify the size (number of bytes) of the memory space. Several memory spaces can be declared in the same configuration.
Various open mode are available when the application starts:
- create the system memory and allocate the space for it
- link to a memory space already allocated
- try to link to the memory and allocate it if it does not exist
Additionally, you can specify an exclusive access to the memory.
Within a memory space, variables can be freely arranged in groups. The number of groups is not limited and has no particular effect on the runtime operations.
Then you need to map variables to locations in the memory space. For each variable, you must define its offset in the shared memory space, and its storage format.
In addition you must select an exchange mode for the variable. It can be:
- Input (from shared memory to the runtime)
- Output (from the runtime to shared memory)
In case of bidirectional access, the runtime use the following algorithm:
if value has changed in the runtime (*)
copy from the runtime to memory
copy from memory to the runtime
(*) On the first scan, the value is considered as changed if not 0.
You can freely map a variable of any data type to a memory item, even if its IEC data type does not match the storage format. The runtime automatically converts the value to the type of the variable. All data types are supported.
When several T5 runtimes are running on the same machine, access to shared memory can be an easy way to work with "super global" variables shared by various VMs. In that case the "create if no exist" open mode is the most flexible as the first VM started takes care of allocating the memory.