90using RSI.RapidCode.dotNET;
100[Category(
"Software")]
101public class UserLimit : StaticMemoryTestBase
105 public void UserLimitDigitalInputOneCondition()
109 const int INPUT_INDEX = 0;
110 const int OUTPUT_INDEX = 1;
126 int userLimitNumber = 0;
131 uint test = (uint)input0.
MaskGet();
132 uint inputMask = (uint)input0.
MaskGet();
133 uint limtValue = (uint)input0.
MaskGet();
158 uint andMask = (uint)output0.
MaskGet();
159 uint orMask = (uint)output0.
MaskGet();
161 bool enableOutput =
true;
173 Assert.That(output0.
Get(), Is.False,
"We expect the output to NOT be triggered");
180 Assert.That(output0.
Get(), Is.True,
"We expect the output to be triggered");
188 public void UserLimitDigitalInputTwoCondition()
192 const int INPUT_INDEX0 = 0;
193 const int INPUT_INDEX1 = 1;
194 const int OUTPUT_INDEX = 2;
201 int userLimitNumber = 0;
218 uint input0Mask = (uint)input0.
MaskGet();
219 uint limitValue0 = (uint)input0.
MaskGet();
224 uint input1Mask = (uint)input1.
MaskGet();
225 uint limitValue1 = (uint)input1.
MaskGet();
257 uint andMask = (uint)output0.
MaskGet();
258 uint orMask = (uint)output0.
MaskGet();
260 bool enableOutput =
true;
272 Assert.That(output0.
Get(), Is.False,
"We expect the output to NOT be triggered");
274 Assert.That(output0.
Get(), Is.False,
"We expect the output to NOT be triggered");
276 Assert.That(output0.
Get(), Is.False,
"We expect the output to NOT be triggered");
283 Assert.That(output0.
Get(), Is.True,
"We expect the output to be triggered");
287 public void UserLimitDigitalInputEStopStorePosition()
291 const int AXIS_INDEX = 0;
292 const int INPUT_INDEX = 0;
293 const int AXIS_COUNT = 1;
294 const int USER_LIMIT = 0;
295 const int CONDITION = 0;
297 const int LIMIT_VALUE = 1;
300 const double DURATION = 0.125;
301 const int USER_DATA_INDEX = 0;
313 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
315 axis.MoveVelocity(10.0, 20.0);
321 controller.
UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, AXIS_INDEX, DURATION);
338 Console.WriteLine(
"TRIGGERED - User Limit Interrupt Position = " + interruptPosition / axis.UserUnitsGet());
345 public void UserLimitFeedRate()
349 const int USER_LIMIT = 0;
350 const int USER_LIMIT_COUNT = 1;
351 const int AXIS_COUNT = 1;
352 const int CONDITION = 0;
354 const double POSITION_TRIGGER_VALUE = 5;
357 const int DURATION = 0;
358 const double DEFAULT_FEED_RATE = 1.0;
359 const double DESIRED_FEED_RATE = 2.0;
362 UInt64 feedRateAddress;
368 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
370 axis.FeedRateSet(DEFAULT_FEED_RATE);
377 controller.
UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION);
380 feedRateAddress = axis.AddressGet(
RSIAxisAddressType.RSIAxisAddressTypeTARGET_FEEDRATE);
385 Assert.That(axis.FeedRateGet(), Is.EqualTo(DEFAULT_FEED_RATE),
"We expect the feedrate to be default");
386 axis.MoveSCurve(POSITION_TRIGGER_VALUE + 1);
387 axis.MotionDoneWait();
388 Assert.That(axis.FeedRateGet(), Is.EqualTo(DESIRED_FEED_RATE),
"We expect the feedrate to be changed");
392 public void UserLimitPositionOneCondition()
396 const int AXIS_COUNT = 1;
397 const int USER_LIMIT_COUNT = 1;
398 const int USER_LIMIT_NUMBER = 0;
399 const double TRIGGER_POSITION = 0.05;
400 const double MOVE_POSITION = 1.0;
401 const int OUTPUT_INDEX = 1;
402 const int WAIT_FOR_TRIGGER_MILLISECONDS = 100;
413 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
417 double limitValue = TRIGGER_POSITION;
438 uint andMask = (uint)output0.
MaskGet();
439 uint orMask = (uint)output0.
MaskGet(); ;
441 bool enableOutput =
true;
450 Assert.That(output0.
Get(), Is.False,
"We expect the output to NOT be triggered");
453 axis.MoveSCurve(MOVE_POSITION);
457 if (interruptType ==
RSIEventType.RSIEventTypeUSER_LIMIT)
461 Assert.That(controller.
InterruptSourceNumberGet(), Is.EqualTo(USER_LIMIT_NUMBER + AXIS_COUNT),
"We got a USER_LIMIT interrupt but it was the wrong one.");
462 Assert.That(output0.
Get(), Is.True,
"We expect the output to be turned on when the user limit triggers.");
466 Assert.Fail(
"We expected a USER_LIMIT interrupt when the trigger position was exceeded but instead got " + interruptType.ToString());
469 axis.AmpEnableSet(
false);
static void CheckErrors(RapidCodeObject rsiObject)
Check if the RapidCodeObject has any errors.
Helper Functions for checking logged creation errors, starting the network, etc.
uint64_t AddressGet()
Get the Host Address for the I/O point.
void Set(bool state)
Set the state of a Digital Output.
static IOPoint * CreateDigitalInput(Axis *axis, RSIMotorDedicatedIn motorDedicatedInNumber)
Create a Digital Input from an Axis' Dedicated Input bits.
static IOPoint * CreateDigitalOutput(Axis *axis, RSIMotorDedicatedOut motorDedicatedOutNumber)
Create a Digital Output from an Axis' Dedicated Output bits.
bool Get()
Get the state of Digital Input or Output.
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....
void UserLimitDisable(int32_t number)
Disable the processing of a User Limit.
void UserLimitConditionSet(int32_t number, int32_t conditionNumber, RSIUserLimitLogic logic, uint64_t addressOfUInt32, uint32_t userLimitMask, uint32_t limitValueUInt32)
Set the conditions for a User Limit with a 32-bit integer trigger value.
void MemorySet(uint64_t address, int32_t data)
Write a value to controller memory.
uint64_t AddressGet(RSIControllerAddressType type)
Get the an address for some location on the MotionController.
void UserLimitOutputSet(int32_t number, uint32_t andMask, uint32_t orMask, uint64_t outputPtr, bool enabled)
Configure a User Limit Output block.
void UserLimitInterruptUserDataAddressSet(int32_t number, uint32_t userDataIndex, uint64_t address)
Set the User Data address based on a User Limit trigger.
void UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
void UserLimitCountSet(int32_t userLimitCount)
Set the number of processed UserLimits in the MotionController.
void InterruptEnableSet(bool enable)
Control interrupts for this class.
void AxisCountSet(int32_t axisCount)
Set the number of allocated and processed axes in the controller.
double InterruptUserDataDoubleGet(uint32_t userDataIndex)
Get the user data associated with the interrupt, as a 64-bit double.
int32_t InterruptSourceNumberGet()
Get the number (or index) of the object (Axis, Motor, etc) that generated the interrupt.
RSIEventType InterruptWait(int32_t milliseconds)
Suspend the current thread until an interrupt arrives from the controller.
RSIControllerAddressType
Used to get firmware address used in User Limits, Recorders, etc.
RSIEventType
Event Types or Status Bits.
RSIUserLimitLogic
Logic options for User Limits.
RSIAction
Action to perform on an Axis.
RSIAxisAddressType
Used to get firmware address used in User Limits, Recorders, etc.
RSIUserLimitTriggerType
Trigger types for UserLimits.