APIs, concepts, guides, and more
ControllerInterrupts.cpp
1
24#include "rsi.h" // Import our RapidCode Library.
25#include "SampleAppsHelper.h" // Import our SampleApp helper functions.
26using namespace RSI::RapidCode; // Import the RapidCode namespace
27
28void controllerInterruptsMain()
29{
31 const int TIMEOUT = (5000); //ms
32
33 RSIEventType interruptType;
34
35 // Initialize Controller, enable interrupts
38
39 controller->InterruptEnableSet(true);
40 try
41 {
42 SampleAppsHelper::StartTheNetwork(controller); // [Helper Function] Initialize the network.
43
44 while (controller->OS->KeyGet((int32_t)RSIWait::RSIWaitPOLL) < 0)
45 {
46 // add code here to generate interrupts (move axes, etc.)
47
48 // wait for an interrupt
49 interruptType = controller->InterruptWait(TIMEOUT);
50
51 if (interruptType != RSIEventType::RSIEventTypeTIMEOUT)
52 {
53 printf("IRQ %ld\n", interruptType);
54 printf("%s\n", controller->InterruptNameGet());
55 printf("InterruptSourceNumber = %ld\n", controller->InterruptSourceNumberGet());
56 printf("InterruptSampleTimer = %ld\n", controller->InterruptSampleTimeGet());
57 printf("\n");
58 }
59 else
60 {
61 printf("Timeout waiting for interrupts...\n");
62 }
63 }
64 }
65 catch (RsiError const& err)
66 {
67 printf("\n%s\n", err.text);
68 }
69 controller->Delete(); // Delete the controller as the program exits to ensure memory is deallocated in the correct order.
70 system("pause"); // Allow time to read Console.
72}
73
static MotionController * CreateFromSoftware()
Initialize and start the RMP EtherCAT controller.
Represents the RMP soft motion controller. This class provides an interface to general controller con...
Definition rsi.h:800
Represents the error details thrown as an exception by all RapidCode classes. This class contains an ...
Definition rsi.h:111
RSIEventType
Event Types or Status Bits.
Definition rsienums.h:966
@ RSIWaitPOLL
return immediately, use polling
Definition rsienums.h:1030
static void CheckErrors(RapidCodeObject *rsiObject)
Checks for errors in the given RapidCodeObject and throws an exception if any non-warning errors are ...
static void StartTheNetwork(MotionController *controller)
Starts the network communication for the given MotionController.