TcOpen
TcOpen copied to clipboard
Write fast data as DAQ
closes #398
@patopat I sketched the solution that we were talking about online. Have a look.
- The
TcoDaqis abstract and it required the implementation ofPushmethod in the concrete implementation, where we copy the data into concrete type. -
TcoDaqItemis also abstract and it requires theDatamember to be implemented
Example of Push method implementation
METHOD Push : BOOL
VAR_INPUT
pData : PVOID;
END_VAR
//------------------------------
IF(_plcCarret > MAX_DAQ_BUFFER_INDEX) THEN
_plcCarret := 1;
END_IF
IF(NOT _buffer[_plcCarret].ExpectDequeing) THEN
Tc2_System.MEMCPY(ADR(_buffer[_plcCarret].Data), pData, SIZEOF(_buffer[_plcCarret].Data));
_buffer[_plcCarret].ExpectDequeing := TRUE;
_plcCarret := _plcCarret + 1;
END_IF;
There are simple to unit tests to prove the concept.
There is still some room for more generalization, that we can look into as we progress. https://github.com/TcOpenGroup/TcOpen/pull/399/files#diff-938374fdc157199afd88822992477c898473252b29b7a1fcef4583cb73dd8ba9
https://github.com/TcOpenGroup/TcOpen/pull/399/files#diff-f511d73d552f98d57ff1ec9d19224daacedeecc0048b002071919ce552cabc13