C++-samples | Sample25: Static Library The "LargeObjProcessors" are controlled by different tasks with different priorities that run on different CPU cores. In the info data area they count how often processing could be carried out ("Info- >ProcessedObjCount") and how often no object was available for processing within the delay time ("Info- >TakeObjFailedCount"). Understanding the sample The LargeObjPool is initialized in the PS transition by the InitPool() method with two LargeObj (defined by the parameter "ObjCount"). The pool essentially offers two methods, which are used by the "LargeObjProcessors": TakeObj() returns a LargeObj if one is available.
Based on a semaphore, the system waits until a timeout occurs to see if an object is made available. The objects themselves are stored in a map. Access to the map is protected by a CriticalSection. ReturnObj() provides a processed object to the pool for further processing. In its CycleUpdate() LargeObjProcessor uses TakeObj() from the pool to obtain a LargeObj for processing. If this is successful, processing is simulated via the help function ConsumeTime() before the LargeObj is returned to the pool via ReturnObj . Processing of all LargeObj must be complete before the system can be shut down.
This is achieved by the LargeObjPool informing the TwinCAT system via TcTryLockOpState() and TcReleaseOpState() that an object is being processed. As long as the stored counter is not 0, the TcCOM object "Pool" is reset and only shut down later by the Op->SafeOp transition. 15.19 Sample25: Static Library | Sample25: Static Library This article describes the implementation and use of a module of a static TwinCAT 3 C++ library. Download Here you can access the source code for this sample: https://github.com/Beckhoff/TC1300_Samples/tree/main/S25-StaticLibrary 1. Using a Visual Studio with TwinCAT installed, open the project via Open Project .... 2.
If you want to run the project on Windows or TwinCAT/BSD ® (not required for Beckhoff RT Linux ® ): Configure signing for this project by right-clicking on the project on the page, selecting Project -> Properties -> TC Sign , enabling TwinCAT signing, and configuring your certificate and password if necessary. Further information on signing C++ projects can be found in the chapter TwinCAT [ } 21] . 3. Select your target system. 4. Build the sample (e.g. Build->Build Solution ). 5. Activate the configuration by clicking . р The sample is ready for operation. TwinCAT 3 296 Version: 1.19.1