Console.WriteLine("📜 Recorder");
int exitCode = 0;
const int VALUES_PER_RECORD = 2;
const int RECORD_PERIOD_SAMPLES = 1;
const int RECORD_TIME = 250;
const int INPUT_INDEX = 0;
MotionController controller = MotionController.Get();
try
{
Helpers.VerifyHardwareUsage(controller);
Helpers.VerifyAxisCount(controller);
controller.RecorderCountSet(1);
if (controller.RecorderEnabledGet() == true)
{
controller.RecorderStop();
controller.RecorderReset();
}
controller.RecorderPeriodSet(RECORD_PERIOD_SAMPLES);
controller.RecorderCircularBufferSet(false);
controller.RecorderDataCountSet(VALUES_PER_RECORD);
Console.WriteLine($"Axis Actual Position data type: {actualPositionDataType}");
controller.RecorderDataAddressSet(1, digitalInput.
AddressGet());
controller.RecorderStart();
controller.OS.Sleep(RECORD_TIME / 2);
controller.MemorySet(digitalInput.
AddressGet(), 1 << INPUT_INDEX);
controller.OS.Sleep(RECORD_TIME / 2);
int recordsAvailable = controller.RecorderRecordCountGet();
Console.WriteLine($"There are {recordsAvailable} records available");
for (int i = 0; i < recordsAvailable; i++)
{
controller.RecorderRecordDataRetrieve();
FirmwareValue positionFirmwareValue = controller.RecorderRecordDataFirmwareValueGet(0);
double positionRecord = positionFirmwareValue.
Double;
FirmwareValue digitalInputFirmwareValue = controller.RecorderRecordDataFirmwareValueGet(1);
int digitalInputValue = digitalInputFirmwareValue.
Int32;
if ((digitalInputValue & digitalInput.
MaskGet()) == digitalInput.
MaskGet())
{
Console.WriteLine($"Encoder position was: {positionRecord} when input triggered");
break;
}
}
controller.RecorderStop();
controller.RecorderReset();
}
catch (Exception e)
{
Console.WriteLine($"❌ Error: {e.Message}");
}
finally
{
controller.Delete();
}
return exitCode;
Constants used in the C# sample apps.
const bool USE_HARDWARE
Default: false.
const int EXIT_FAILURE
Exit code for failed execution.
const int AXIS_0_INDEX
Default: 0.
const int EXIT_SUCCESS
Exit code for successful execution.
uint64_t AddressGet(RSIAxisAddressType addressType)
Get the an address for some location on the Axis.
RSIDataType AddressDataTypeGet(RSIAxisAddressType type)
Get the data type for an address the Axis.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
uint64_t AddressGet()
Get the Host Address for the I/O point.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
int32_t MaskGet()
Get the bit mask for the I/O point.
Represents one specific point: Digital Output, Digital Input, Analog Output, or Analog Input....
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
RSIDataType
Data types for User Limits and other triggers.
RSIAxisAddressType
Used to get firmware address used in User Limits, Recorders, etc.
Helpers namespace provides utility functions for common tasks in RMP applications.
Union representing a generic RMP firmware value with multiple data types, stored in 64-bits.
double Double
Double precision (64-bit) floating-point.
int32_t Int32
32-bit signed integer.