#include <cassert>
#include "rsi.h"
#include <cmath>
{
{
printf(
"%s\n", err->
text);
}
if (hasError)
{
exit(1);
}
}
{
{
printf("%s\n", err);
}
if (hasError)
{
exit(1);
}
}
void updateBufferPointsMain()
{
const double TIME_SLICE = 0.001;
const int AXIS_COUNT = 1;
const int REVS = 5;
const int RPS = 1;
const int CPS = (int)std::powl(2, 20);
const int TOTAL_POINTS = (int)(REVS / TIME_SLICE / RPS);
const int BUFFER_SZ = 100;
const int EMPTY_CT = 10;
PrintUpdateBufferErrors(controller);
try
{
PrintUpdateBufferNetworkErrors(controller);
PrintUpdateBufferErrors(multiAxis);
for (int i = 0; i < AXIS_COUNT; i++)
{
PrintUpdateBufferErrors(tempAxis);
}
std::vector<double> positions, times;
for (int i = 0; i < TOTAL_POINTS; i += AXIS_COUNT)
{
positions.push_back(i * TIME_SLICE * RPS);
times.push_back(TIME_SLICE);
}
assert(multiAxis->
StateGet() == RSIState::RSIStateIDLE);
multiAxis->
MovePT(RSIMotionType::RSIMotionTypePT, &positions[0], ×[0], 1, -1,
false,
true);
int curMotionElementID = 0, curMotionID = 0, finalMotionID = 0;
int numPointsToSend = BUFFER_SZ;
int endOfLastSent = 0;
bool exitCondition = false;
const int motionHoldGate = 3;
for (int i = 0; i < 2; ++i)
{
multiAxis->
MovePT(RSIMotionType::RSIMotionTypePT, &positions[0] + endOfLastSent * AXIS_COUNT, ×[0] + endOfLastSent, numPointsToSend, EMPTY_CT,
false, exitCondition);
endOfLastSent += numPointsToSend;
++finalMotionID;
}
while (!exitCondition)
{
if (std::abs(finalMotionID - curMotionID) < 2)
{
if (TOTAL_POINTS <= (endOfLastSent + BUFFER_SZ))
{
numPointsToSend = TOTAL_POINTS - endOfLastSent;
exitCondition = true;
}
multiAxis->
MovePT(RSIMotionType::RSIMotionTypePT, &positions[0] + endOfLastSent * AXIS_COUNT, ×[0] + endOfLastSent, numPointsToSend, EMPTY_CT,
false, exitCondition);
printf("MotionID %d\nEnd of Last Sent %d\nElement ID %d\nNum to Send %d\nIs Done %s\n===========================================\n\n",
curMotionID, endOfLastSent, curMotionElementID, numPointsToSend, exitCondition ? "yes" : "no");
endOfLastSent += numPointsToSend;
++finalMotionID;
}
}
printf("Updates Done. Waiting to finish motion.\n");
}
printf("\n%s\n", err.text);
}
}