using RSI.RapidCode.dotNET;
using System;
using NUnit.Framework;
[TestFixture]
[Category("Software")]
public class AxisConfig : SampleAppTestBase
{
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void AxisSettling()
{
const double POSITION_TOLERANCE_FINE = 200;
const double POSITION_TOLERANCE_COARSE = 300;
const double VELOCITY_TOLERANCE = 12000;
const double SETTLING_TIME = 5;
Assert.That(posTolFine, Is.EqualTo(POSITION_TOLERANCE_FINE), "The getter function should return a value equal to POSITION_TOLERANCE_FINE");
Assert.That(posTolCoarse, Is.EqualTo(POSITION_TOLERANCE_COARSE), "The getter function should return a value equal to POSITION_TOLERANCE_COARSE");
Assert.That(velTol, Is.EqualTo(VELOCITY_TOLERANCE), "The getter function should return a value equal to VELOCITY_TOLERANCE");
Assert.That(setTime, Is.EqualTo(SETTLING_TIME), "The getter function should return a value equal to SETTLING_TIME");
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void ConfigAmpFault()
{
const double AMP_FAULT_DURATION_TIME = 1;
Assert.That(isEnabled, Is.EqualTo(false), "The getter function should return a value equal to false");
Assert.That(faultAction, Is.EqualTo(RSIAction.RSIActionABORT), "The getter function should return a value equal to RSIActionABORT");
Assert.That(faultTriggerState, Is.EqualTo(false), "The getter function should return a value equal to false");
Assert.That(faultDuration, Is.EqualTo(AMP_FAULT_DURATION_TIME), "The getter function should return a value equal to AMP_FAULT_DURATION_TIME");
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void SetUserUnits()
{
const int ENCODER_RESOLUTION_BITS = 20;
double USER_UNITS = Math.Pow(2, ENCODER_RESOLUTION_BITS);
Assert.That(userUnits, Is.EqualTo(USER_UNITS));
Assert.That(userUnits, Is.EqualTo(1048576));
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void StopRate()
{
const double STOP_RATE = 1.2;
const double ESTOP_RATE = 1.3;
const double ESTOP_DECELERATION_RATE_T = 1.5;
Assert.That(axis.
StopTimeGet(), Is.EqualTo(STOP_RATE));
const double STOP_RATE_DEFAULT = 1.0;
const double ESTOP_RATE_DEFAULT = 0.05;
const double ESTOP_DECELERATION_RATE = 1000;
}
[Test, Timeout(Constants.MAX_TEST_TIME)]
public void HardwareLimits()
{
const bool ACTIVE_HIGH = true;
const bool ACTIVE_LOW = false;
const double HW_POS_DURATION_TIME = 0.01;
const double HW_NEG_DURATION_TIME = 0.01;
Assert.That(hPosLimAct, Is.EqualTo(RSIAction.RSIActionE_STOP), "Hardware Positive Limit Action should be set to RSIAction.RSIActionE_STOP");
Assert.That(hPosLimTrigState, Is.EqualTo(ACTIVE_HIGH), "Hardware Positive Limit TriggerState should be set to ACTIVE_HIGH");
Assert.That(hPosLimDur, Is.EqualTo(HW_POS_DURATION_TIME), "Hardware Positive Limit Duration set to HW_POS_DURATION_TIME");
Assert.That(hNegLimAct, Is.EqualTo(RSIAction.RSIActionE_STOP), "Hardware Positive Limit Action should be set to RSIAction.RSIActionE_STOP");
Assert.That(hNegLimTrigState, Is.EqualTo(ACTIVE_LOW), "Hardware Positive Limit TriggerState should be set to ACTIVE_LOW");
Assert.That(hNegLimDur, Is.EqualTo(HW_POS_DURATION_TIME), "Hardware Positive Limit Duration set to HW_POS_DURATION_TIME");
}
public void PhantomAxis()
{
axis = controller.
AxisGet(axisNumber);
const double positionToleranceMax = Double.MaxValue / 10.0;
}
}
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
Helper Functions for checking logged creation errors, starting the network, etc.
void HardwareNegLimitActionSet(RSIAction action)
Set the action that will occur when the Hardware Negative Limit Event triggers.
RSIAction AmpFaultActionGet()
Get the Amp Fault action.
double SettlingTimeGet()
Get the Settling time.
void HardwareNegLimitDurationSet(double seconds)
Set the duration required before the Hardware Negative Limit event triggers.
void HardwarePosLimitActionSet(RSIAction action)
Set the action that will occur when the Hardware Positive Limit Event triggers.
void PositionToleranceCoarseSet(double tolerance)
Set the Coarse Position Tolerance for Axis settling.
double UserUnitsGet()
Get the number of counts per User Unit.
bool AmpEnableGet()
Get the state of the Amp Enable Output.
double PositionToleranceFineGet()
Get the Fine Position Tolerance for axis settling.
RSIAction HardwarePosLimitActionGet()
Get the action that will occur when the Hardware Positive Limit Event triggers.
void HardwarePosLimitTriggerStateSet(bool state)
sets the trigger state.
void SoftwareNegLimitActionSet(RSIAction action)
Set the action that will occur when the Software Negative Limit Event triggers.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
void AmpFaultActionSet(RSIAction action)
Set the Amp Fault action.
void AmpFaultTriggerStateSet(bool state)
Set the trigger state of the Amp Fault input.
void HomeActionSet(RSIAction action)
Set the action that will occur when the Home Event triggers.
void ErrorLimitTriggerValueSet(double triggerValue)
Set the Position Error Limit trigger value.
void PositionToleranceFineSet(double tolerance)
Set the Fine Position Tolerance for Axis settling.
void ErrorLimitActionSet(RSIAction action)
Set the action that will occur when the Error Limit Event triggers.
double AmpFaultDurationGet()
Get the duration required before the Amp Fault event triggers.
double HardwareNegLimitDurationGet()
Get the duration required before the Hardware Negative Limit event triggers.
bool HardwarePosLimitTriggerStateGet()
trigger state return.
void HardwarePosLimitDurationSet(double seconds)
Set the duration required before the Hardware Positive Limit event triggers.
void VelocityToleranceSet(double tolerance)
Set the Velocity Tolerance used for settling.
double PositionToleranceCoarseGet()
Get the Coarse Position Tolerance for axis settling.
double EStopDecelerationGet()
Get the deceleration rate for an E-Stop, Modify Event.
bool AmpFaultTriggerStateGet()
Get the Amp Fault trigger state.
double VelocityToleranceGet()
Get the velocity tolerance used for settling.
void EStopDecelerationSet(double decel)
Set the deceleration rate for an E-Stop, Modify Event.
void MotorTypeSet(RSIMotorType type)
Set the motor type.
bool HardwareNegLimitTriggerStateGet()
Trigger state return.
double HardwarePosLimitDurationGet()
Get the duration required before the Hardware Positive Limit event triggers.
void AmpFaultDurationSet(double seconds)
Set the duration required before the Amp Fault event triggers.
RSIAction HardwareNegLimitActionGet()
Get the action that will occur when the Hardware Negative Limit Event triggers.
void HardwareNegLimitTriggerStateSet(bool state)
Sets the trigger state.
void SettlingTimeSet(double time)
Set the settling time.
void SoftwarePosLimitActionSet(RSIAction action)
Set the action that will occur when the Software Positive Limit Event triggers.
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
int32_t AxisCountGet()
Get the number of axes processing.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void StopTimeSet(double seconds)
Set the deceleration time for a Stop Event.
double EStopTimeGet()
Get E-Stop Event deceleration time.
void EStopTimeSet(double seconds)
Set the deceleration time for an E-Stop Event.
double StopTimeGet()
Get Stop Event deceleration time.