Streaming Motion Buffer Management sample application.
This sample code is built for the RMP but the concepts should apply to all RapidSoftware Applications. It gives a very simple initialization of an RMP MotionController. It only prints out errors rather than handling them.
This application assumes that you will be generating points which have times of exactly 1 sample duration. If you want to generate points of size X samples, be sure to divide initial Sample Rate Deduction by X.
#if !defined(__INTIME__)
#include "rsi.h"
#include <process.h>
const int AXIS_COUNT = 2;
const int DESIRED_POINTS = 50;
const int SYNC_PERIOD = 10;
int32_t lastSample = 0;
#pragma region Fixed Size Implementation
const int POINT_BLOCK_COUNT = 10;
int32_t extraPointsSentToEvenOutBlock = 0;
int32_t AdjustPointsNeededToBlockCount(int32_t initialCount)
{
int32_t calculatedCount = 0;
int32_t adjustedInitialCount = initialCount - extraPointsSentToEvenOutBlock;
while ((adjustedInitialCount > 0) && (adjustedInitialCount > calculatedCount))
{
calculatedCount += POINT_BLOCK_COUNT;
}
extraPointsSentToEvenOutBlock += calculatedCount - initialCount;
return calculatedCount;
}
#pragma endregion
volatile int _continueMonitoring = true;
void monitoringThread(void* tmp)
{
while (_continueMonitoring)
{
int32_t pointsNeeded = sampleRecieved - lastSample;
pointsNeeded = AdjustPointsNeededToBlockCount(pointsNeeded);
lastSample = sampleRecieved;
}
}
{
{
printf(
"Error Found: %s\n", object->
ErrorLogGet()->text);
}
}
void streamingMotionBufferManagementMain()
{
checkErrors(controller);
try
{
checkErrors(controller);
_beginthread(monitoringThread, 0, controller);
bool exitCondition = false;
while (!exitCondition)
{
}
}
{
printf("\n%s\n", err.text);
}
_continueMonitoring = false;
}
#endif
void SyncInterruptEnableSet(bool enable)
Configure Sync (periodic) interrupts for the controller.
void SyncInterruptPeriodSet(uint32_t samples)
Configure the period for the Sync Interrupt on the controller.
void NetworkStart()
Start the network, doing both a discovery followed by starting to OPERATIONAL state.
void Delete(void)
Delete the MotionController and all its objects.
int32_t SyncInterruptWait()
Suspend the current thread until an interrupt arrives from the controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
const RsiError *const ErrorLogGet()
Get the next RsiError in the log.
int32_t ErrorLogCountGet()
Get the number of software errors in the error log.
The RapidCode base class. All non-error objects are derived from this class.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...