TcOpen icon indicating copy to clipboard operation
TcOpen copied to clipboard

Write fast data as DAQ

Open github-actions[bot] opened this issue 2 years ago • 1 comments

closes #398

github-actions[bot] avatar Apr 03 '22 07:04 github-actions[bot]

@patopat I sketched the solution that we were talking about online. Have a look.

  • The TcoDaq is abstract and it required the implementation of Push method in the concrete implementation, where we copy the data into concrete type.
  • TcoDaqItem is also abstract and it requires the Data member 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

PTKu avatar May 05 '22 09:05 PTKu