The 'syncSymbolRead' function is a member function of the QPLCManager class. It's called periodically to synchronize the values of the PLC variables with their corresponding symbols in the symbol list.

The function takes two parameters: a pointer to the QPLCManager instance and a period in milliseconds. It first retrieves the 'PlcSymbol' object from the QPLCManager and initializes some variables to store the PLC variable values and their number.

Next, it checks if the PLC handler is in the running state. If it is, it calls the 'SyncReadVarListFromPlc' function of the handler to read the values of the variables in the sync list. If the function returns successfully and the values and their number are valid, the function loops through the symbol list and updates the values of each symbol based on its data type and size.

Finally, it emits a signal to notify any listeners that the symbol values have been updated and sleeps for 500 milliseconds before returning.

QPLCManager::syncSymbolRead Function: Synchronizing PLC Variables

原文地址: https://www.cveoy.top/t/topic/mQgf 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录