85using RSI.RapidCode.dotNET;
96public class UserLimit : StaticMemoryTestBase
100 public void UserLimitDigitalInputOneCondition()
104 const int INPUT_INDEX = 0;
105 const int OUTPUT_INDEX = 1;
121 int userLimitNumber = 0;
126 uint test = (uint)input0.
MaskGet();
127 uint inputMask = (uint)input0.
MaskGet();
128 uint limtValue = (uint)input0.
MaskGet();
153 uint andMask = (uint)output0.
MaskGet();
154 uint orMask = (uint)output0.
MaskGet();
156 bool enableOutput =
true;
168 Assert.False(output0.
Get(),
"We expect the output to NOT be triggered");
175 Assert.True(output0.
Get(),
"We expect the output to be triggered");
183 public void UserLimitDigitalInputTwoCondition()
187 const int INPUT_INDEX0 = 0;
188 const int INPUT_INDEX1 = 1;
189 const int OUTPUT_INDEX = 2;
196 int userLimitNumber = 0;
213 uint input0Mask = (uint)input0.
MaskGet();
214 uint limitValue0 = (uint)input0.
MaskGet();
219 uint input1Mask = (uint)input1.
MaskGet();
220 uint limitValue1 = (uint)input1.
MaskGet();
252 uint andMask = (uint)output0.
MaskGet();
253 uint orMask = (uint)output0.
MaskGet();
255 bool enableOutput =
true;
267 Assert.False(output0.
Get(),
"We expect the output to NOT be triggered");
269 Assert.False(output0.
Get(),
"We expect the output to NOT be triggered");
271 Assert.False(output0.
Get(),
"We expect the output to NOT be triggered");
278 Assert.True(output0.
Get(),
"We expect the output to be triggered");
282 public void UserLimitDigitalInputEStopStorePosition()
286 const int AXIS_INDEX = 0;
287 const int INPUT_INDEX = 0;
288 const int AXIS_COUNT = 1;
289 const int USER_LIMIT = 0;
290 const int CONDITION = 0;
292 const int LIMIT_VALUE = 1;
295 const double DURATION = 0.125;
296 const int USER_DATA_INDEX = 0;
308 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
310 axis.MoveVelocity(10.0, 20.0);
316 controller.
UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, AXIS_INDEX, DURATION);
333 Console.WriteLine(
"TRIGGERED - User Limit Interrupt Position = " + interruptPosition / axis.UserUnitsGet());
340 public void UserLimitFeedRate()
344 const int USER_LIMIT = 0;
345 const int USER_LIMIT_COUNT = 1;
346 const int AXIS_COUNT = 1;
347 const int CONDITION = 0;
349 const double POSITION_TRIGGER_VALUE = 5;
352 const int DURATION = 0;
353 const double DEFAULT_FEED_RATE = 1.0;
354 const double DESIRED_FEED_RATE = 2.0;
357 UInt64 feedRateAddress;
363 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
365 axis.FeedRateSet(DEFAULT_FEED_RATE);
372 controller.
UserLimitConfigSet(USER_LIMIT, TRIGGER_TYPE, ACTION, axis.NumberGet(), DURATION);
375 feedRateAddress = axis.AddressGet(
RSIAxisAddressType.RSIAxisAddressTypeTARGET_FEEDRATE);
380 Assert.AreEqual(DEFAULT_FEED_RATE, axis.FeedRateGet(),
"We expect the feedrate to be default");
381 axis.MoveSCurve(POSITION_TRIGGER_VALUE + 1);
382 axis.MotionDoneWait();
383 Assert.AreEqual(DESIRED_FEED_RATE, axis.FeedRateGet(),
"We expect the feedrate to be changed");
387 public void UserLimitPositionOneCondition()
391 const int AXIS_COUNT = 1;
392 const int USER_LIMIT_COUNT = 1;
393 const int USER_LIMIT_NUMBER = 0;
394 const double TRIGGER_POSITION = 0.05;
395 const double MOVE_POSITION = 1.0;
396 const int OUTPUT_INDEX = 1;
397 const int WAIT_FOR_TRIGGER_MILLISECONDS = 100;
408 axis = CreateAndReadyAxis(Constants.AXIS_NUMBER);
412 double limitValue = TRIGGER_POSITION;
433 uint andMask = (uint)output0.
MaskGet();
434 uint orMask = (uint)output0.
MaskGet(); ;
436 bool enableOutput =
true;
445 Assert.False(output0.
Get(),
"We expect the output to NOT be triggered");
448 axis.MoveSCurve(MOVE_POSITION);
452 if (interruptType ==
RSIEventType.RSIEventTypeUSER_LIMIT)
456 Assert.That(controller.
InterruptSourceNumberGet(), Is.EqualTo(USER_LIMIT_NUMBER + AXIS_COUNT),
"We got a USER_LIMIT interrupt but it was the wrong one.");
457 Assert.True(output0.
Get(),
"We expect the output to be turned on when the user limit triggers.");
461 Assert.Fail(
"We expected a USER_LIMIT interrupt when the trigger position was exceeded but instead got " + interruptType.ToString());
464 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, Sequencers, 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, Sequencers, etc.
RSIUserLimitTriggerType
Trigger types for UserLimits.