beckhoff TwinCAT 3 — 12.5 Memory allocation

Programming Reference | Memory allocation Win32 API [ } 150] is not available in kernel mode Windows kernel mode API must not be used directly. TwinCAT SDK provides functions, which are supported. User mode libraries (DLL) cannot be used. (see Third Party Libraries [ } 228] ) The storage capacity for dynamic allocation in a real-time context is limited by the router memory (this can be configured during engineering), see Memory allocation [ } 150] . A subset of the C++ runtime library functions (CRT) is supported C++ exceptions are not supported. Runtime Type Information ( RTTI [ } 150] ) is not supported.

Subset of STL is supported (see STL / Containers [ } 208] ) Support for functions from math.h through TwinCAT implementation (see Mathematical Functions [ } 206] ) TwinCAT functions as replacement for Win32 API functions The original Win32 API is not available in Windows kernel mode. For this reason a list of the common functions of the Win32 API and their equivalents for TwinCAT is provided here: RTTI dynamic_cast function in TwinCAT TwinCAT has no support for dynamic_cast . Instead, it may be possible to use the TCOM strategy. Define an ICustom interface, which is derived from ITcUnknown and contains the methods, which are called from a derived class.

The base class CMyBase is derived from ITcUnknown and implements this interface. The class CMyDerived is derived from CMyBase and from ICustom. It overwrites the TcQueryInterface method, which can then be used instead of dynamic cast. TcQueryInterface can also be used to display the IsType() function through evaluation of the return value. See Interface ITcUnknown [ } 187] . 12.5 Memory allocation | Memory allocation Generally we recommend reserving memory with the aid of member variables of the module class. This is done automatically for data areas defined in the TMC editor. It is also possible to allocate and release memory dynamically.

Operator new / delete TcMemAllocate / TcMemFree This memory allocation can be used in the transitions [ } 44] or in the OP state of the state machine. TwinCAT 3 150 Version: 1.19.1 Win32API TwinCAT functionality WinSock TF6311 TCP/UDP real-time Message boxes Tracing [} 209] File I/O See Interface ITcFileAccess [} 164], Interface ITcFileAccessAsync [} 171] and Sample19: Synchronous File Access [} 289], Sample20: FileIO- Write [} 290], Sample20a: FileIO-Cyclic Read / Write [} 290] Synchronization See Sample11a: Module communication: Method call C++ module to C++ module [} 284] Visual C CRT See RtlR0.h