PLC Symbol Synchronization in QPLCManager Class
This function is part of a class called 'QPLCManager' and is used to synchronize the values of PLC symbols with the values in the PLC itself. The function takes in a void pointer and an integer as parameters, which are not used in the function. It first initializes some variables and gets the PLC symbol and symbol list from the 'QPLCManager' object. It then gets the PLC handler and variable list from the 'QPLCManager' object.
If the PLC handler's state is running, the function calls the 'SyncReadVarListFromPlc' function of the PLC handler, which reads the values of all variables in the variable list from the PLC and stores them in 'ppValues'. If the result of this operation is successful and 'ppValues' is not null and the number of values read is equal to the number of symbols in the symbol list, the function loops through each symbol in the symbol list and copies the value from 'ppValues' to the symbol's buffer. It then emits a signal to notify that the symbol values have been updated.
Finally, the function sleeps for 500 milliseconds using 'QThread::msleep' before returning.
``
原文地址: https://www.cveoy.top/t/topic/mQfU 著作权归作者所有。请勿转载和采集!