From fb4b3a15e27b8de43f5cfd664de9c41e36ea751d Mon Sep 17 00:00:00 2001 From: Leandro Martins dos Santos Date: Fri, 10 Oct 2025 13:25:29 +0100 Subject: [PATCH] Fix indexing and calculated indexes only when buffer changes --- pmacApp/pmc/trajectory_scan_ppmac.pmc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pmacApp/pmc/trajectory_scan_ppmac.pmc b/pmacApp/pmc/trajectory_scan_ppmac.pmc index 3165403..312e92c 100644 --- a/pmacApp/pmc/trajectory_scan_ppmac.pmc +++ b/pmacApp/pmc/trajectory_scan_ppmac.pmc @@ -183,7 +183,8 @@ Version->*d global PVT_Time global UserCmd -global CalculatedBase // Calculated temporary variable for Current base address +global CalculatedBaseInt // Calculated temporary variable for Current base address +global CalculatedBaseDouble // Calculated temporary variable for Current base address // ***************************************************************************************** // Set the version number @@ -222,6 +223,12 @@ CurrentBufferAdr = BufferAdr_A // Set CurrentBuffer values to buffer A CurrentBufferFill = BufferFill_A CurrentBuffer = 0 +// Convert absolute address to the index of integer data in the user shared memory buffer (USHM) +CalculatedBaseInt = CurrentBufferAdr/ _SIZEOF_INTEGER_; +// Convert absolute address to the index of double data in the user shared memory buffer (USHM) +CalculatedBaseDouble = CurrentBufferAdr/ _SIZEOF_DOUBLE_; + + PrevBufferFill = BufferLength // Set PrevBufferFill to pass outer while loop condition GoSub101 // Check which axes are required @@ -262,6 +269,9 @@ While(AbortTrigger == 0 && Error == 0 && CurrentBufferFill > 0 && PrevBufferFill CurrentBufferFill = BufferFill_A BufferFill_B = 0 } + CalculatedBaseInt = CurrentBufferAdr/ _SIZEOF_INTEGER_; + CalculatedBaseDouble = CurrentBufferAdr/ _SIZEOF_DOUBLE_; + // Move to final point of buffer if next buffer has points If(AbortTrigger == 0 && CurrentBufferFill > 0) // Do move with previous buffer N-1 and N and current buffer 1 { @@ -382,14 +392,12 @@ Return // ************************************************************************************************* N103: - // Convert absolute address to the index of integer data in the user shared memory buffer (USHM) - CalculatedBase = CurrentBufferAdr/ _SIZEOF_INTEGER_; // Integer type buffers - Time_Idx = CalculatedBase + CurrentIndex + Time_Idx = CalculatedBaseInt + CurrentIndex User_Idx = Time_Idx + BuffLen // Double type buffers // Convert index of integer data to double data in USHM - A_Idx = (User_Idx + BuffLen) * _SIZEOF_INTEGER_ / _SIZEOF_DOUBLE_ + A_Idx = CalculatedBaseDouble + BuffLen + CurrentIndex B_Idx = A_Idx + BuffLen C_Idx = B_Idx + BuffLen U_Idx = C_Idx + BuffLen