using RSI.RapidCode.dotNET;
using System;
using NUnit.Framework;
#if DOXYGEN
#endif
{
{
bool hasErrors = false;
System.Text.StringBuilder errorStringBuilder = new System.Text.StringBuilder();
{
{
errorStringBuilder.AppendLine("WARNING: " + error.Message);
}
else
{
hasErrors = true;
errorStringBuilder.AppendLine("ERROR: " + error.Message);
}
}
if (errorStringBuilder.Length > 0)
{
Console.WriteLine(errorStringBuilder.ToString());
}
if (hasErrors)
{
throw new Exception(errorStringBuilder.ToString());
}
}
{
{
Console.WriteLine("Starting Network..");
}
{
for (int i = 0; i < messagesToRead; i++)
{
}
Console.WriteLine("Expected OPERATIONAL state but the network did not get there.");
}
else
{
Console.WriteLine("Network Started");
}
}
}
public static class Constants
{
public const int SAMPLES = 2;
public const int AXIS_NUMBER = 0;
public const int X_AXIS_NUMBER = 0;
public const int Y_AXIS_NUMBER = 1;
public const int Z_AXIS_NUMBER = 2;
public const int A_AXIS_NUMBER = 3;
public const int B_AXIS_NUMBER = 4;
public const int C_AXIS_NUMBER = 5;
public const int MAIN_AXIS_NUMBER = 0;
public const int DRIVEN_AXIS_NUMBER = 1;
public const int HOLDING_AXIS_INDEX = 0;
public const int MOVING_AXIS_INDEX = 1;
public const int AXIS_COUNT = 6;
public const int FIRST_AXIS_NUMBER = 0;
public const int SECOND_AXIS_NUMBER = 1;
public const int THIRD_AXIS_NUMBER = 2;
public const double USER_UNITS = 1;
public const double AKD_USER_UNITS = 1048576;
public const double POSITION = 2;
public const double VELOCITY = 200;
public const double ACCELERATION = 100;
public const double DECELERATION = 100;
public const double JERK_PERCENT = 50;
public const double POSITION_A = 5;
public const double POSITION_B = 10;
public const int MAX_TEST_TIME = 3000;
public const int COMP_NUM_ZERO = 0;
public const int COMP_NUM_ONE = 1;
public const int COMP_NUM_TWO = 2;
}
public class TestBase
{
public Axis CreateAndReadyAxis(
int AxisNumber)
{
ResetAxis(axis);
return axis;
}
public void InitializeAllAxes()
{
axis = controller.
AxisGet(Constants.AXIS_NUMBER);
x_axis = controller.
AxisGet(Constants.X_AXIS_NUMBER);
y_axis = controller.
AxisGet(Constants.Y_AXIS_NUMBER);
z_axis = controller.
AxisGet(Constants.Z_AXIS_NUMBER);
a_axis = controller.
AxisGet(Constants.A_AXIS_NUMBER);
b_axis = controller.
AxisGet(Constants.B_AXIS_NUMBER);
c_axis = controller.
AxisGet(Constants.C_AXIS_NUMBER);
main_axis = controller.
AxisGet(Constants.MAIN_AXIS_NUMBER);
driven_axis = controller.
AxisGet(Constants.DRIVEN_AXIS_NUMBER);
jointsMultiAxis = controller.
MultiAxisGet(Constants.AXIS_COUNT);
}
public void DisableAllAxes()
{
{
}
}
public void ResetAxis(
Axis myAxis)
{
EnableAmp(myAxis);
}
public void EnableAmp(
Axis myAxis)
{
}
public void TearDownFixture()
{
DisableAllAxes();
}
}
public class SampleAppTestBase : TestBase
{
[SetUp]
public void SetUp()
{
{
ResetAxis(axis);
}
}
[OneTimeSetUp]
public void OneTimeSetUp()
{
InitializeAllAxes();
}
[TearDown]
public void TearDown()
{
DisableAllAxes();
}
[OneTimeTearDown]
public void OneTimeTearDown()
{
}
}
[TestFixture]
[Category("Software")]
public class StaticMemoryTestBase : TestBase
{
[OneTimeSetUp]
public void OneTimeSetUp()
{
}
[SetUp]
public void Setup()
{
}
[TearDown]
public void TearDown()
{
TearDownFixture();
}
}
[TestFixture]
[Category("Software")]
public class HelperFunctionsTests : SampleAppTestBase
{
[Test]
public void CheckErrorsTest()
{
string expectedErrorSubstring = "Motion: RSIStateERROR";
}
[Test]
public void CheckErrorsWarningTest()
{
const int BAD_AXIS_NUMBER = 777;
Assert.Throws(Is.TypeOf<Exception>().And.Message.Contains(BAD_AXIS_NUMBER.ToString()), () =>
HelperFunctions.
CheckErrors(badAxis));
}
}
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
static void StartTheNetwork(MotionController controller)
Start the controller communication/network.
Helper Functions for checking logged creation errors, starting the network, etc.
void UserUnitsSet(double countsPerUserUnit)
Sets the number of counts per User Unit.
void ErrorLimitTriggerValueSet(double triggerValue)
Set the Position Error Limit trigger value.
void PositionSet(double position)
Set the Command and Actual positions.
void MoveSCurve(double position, double vel, double accel, double decel, double jerkPct)
Command a point-to-point S-Curve motion.
Represents a single axis of motion control. This class provides an interface for commanding motion,...
void DefaultVelocitySet(double velocity)
Set the default velocity in UserUnits.
void DefaultAccelerationSet(double acceleration)
Set the default acceleration in UserUnits.
void DefaultDecelerationSet(double deceleration)
Set the default deceleration in UserUnits.
Represents a collection of joints in Cartesian space with forward and inverse kinematics....
Axis * AxisGet(int32_t axisNumber)
AxisGet returns a pointer to an Axis object and initializes its internals.
RSINetworkState NetworkStateGet()
void Reset()
Reset the controller which stops and restarts the RMP firmware.
void MotionCountSet(int32_t motionCount)
Set the number of processed Motion Supervisors in the controller.
const char *const NetworkLogMessageGet(int32_t messageIndex)
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
void Delete(void)
Delete the MotionController and all its objects.
void Shutdown()
Shutdown the controller.
MultiAxis * MultiAxisGet(int32_t motionSupervisorNumber)
MultiAxisGet returns a pointer to a MultiAxis object and initializes its internals.
int32_t AxisCountGet()
Get the number of axes processing.
int32_t NetworkLogMessageCountGet()
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
void NetworkStart()
Start the network with RSINetworkStartupMethodNORMAL.
Represents multiple axes of motion control, allows you to map two or more Axis objects together for e...
void ClearFaults()
Clear all faults for an Axis or MultiAxis.
void AmpEnableSet(bool enable)
Enable all amplifiers.
void Abort()
Abort an axis.
void ThrowExceptions(bool state)
Configure a class to throw exceptions.
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 ...
bool isWarning
Whether the error is or is not a warning.
RSINetworkState
State of network.