#include "rsi.h"                
#include "SampleAppsHelper.h"    
#include "SampleApps.h"
 
 
int UserLimitDigialInputAction::Run()
{
  
  
 
  
  const int AXIS_COUNT = 1; 
  const int AXIS_NUMBER = 0; 
 
  const double USER_UNITS = 1048576; 
 
  const int IO_NODE_NUMBER = 0; 
  const int USER_LIMIT = 0; 
  const int CONDITION = 0; 
  const int INPUT_BIT_NUMBER = 0; 
 
  
  USE_HARDWARE = false;
 
  
 
  
 
  
  if (USE_HARDWARE)
  {
  }
  else
  {
    std::cout << "This sample app cannot be run without hardware." << std::endl;
    return 0;
  }
 
  
  IO* io;
  try
  {
    
 
    
    io = controller->
IOGet(IO_NODE_NUMBER);
 
    digitalInput = IOPoint::CreateDigitalInput(io, INPUT_BIT_NUMBER);
 
    auto mask1 = digitalInput->
MaskGet();
 
    auto mask2 = digitalInput->
MaskGet();
 
 
    
      CONDITION,
      RSIUserLimitLogic::RSIUserLimitLogicEQ,
 
    
    controller->
UserLimitConfigSet(USER_LIMIT, RSIUserLimitTriggerType::RSIUserLimitTriggerTypeSINGLE_CONDITION, RSIAction::RSIActionE_STOP_ABORT, AXIS_NUMBER, 0.0);
 
    printf("Waiting for the input bit to go high...\n");
    printf("\nPress Any Key To Exit.\n");
 
    
    while (controller->
OS->
KeyGet((int32_t)RSIWait::RSIWaitPOLL) < 0)
 
    {
    }
 
    
  }
  {
    printf(
"Text:  %s\n", rsiError.
text);
    return -1;
  }
  return 0;
}
 
uint64_t AddressGet()
Get the Host Address for the I/O point.
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 UserLimitConfigSet(int32_t number, RSIUserLimitTriggerType triggerType, RSIAction action, int32_t actionAxis, double duration, bool singleShot)
Configure a User Limit.
void Delete(void)
Delete the MotionController and all its objects.
IO * IOGet(int32_t nodeNumber)
IOGet returns a pointer to an IO object using its node number and initializes its internals.
bool UserLimitStateGet(int32_t number)
Get the state of a User Limit.
void UserLimitCountSet(int32_t userLimitCount)
Set the number of processed UserLimits in the MotionController.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
RapidCodeOS * OS
Provides access to operating system (Windows) features.
void Sleep(int32_t milliseconds)
Put the current thread to sleep.
int32_t KeyGet(int32_t milliseconds)
Wait for a key to be pressed and return its value.
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
static void SetupControllerForHardware(MotionController *controller)
Sets up the controller for hardware use by resetting it and starting the network.
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...