All creation methods, such as Create(), AxisGet(), NetworkNodeGet(), etc. Each return valid pointers to RapidCode objects. These pointers are never null, even when there is an error during object creation.
🔔 API Differences (C# vs. C++)
In the C# API, the pointers are replaced by references due to differences between C++ and C#. The creation methods return a reference to the object instead of a pointer. However, the method calls and error handling procedures remain the same. Null references are not returned by the creation methods in C#. Always check for errors after object creation, as described above.
⚙️ Error Checking After Creation
Immediately after the creation of a RapidCode object, you need to check if there were any errors during its creation. You do this by calling the ErrorLogCountGet() method on the created object. If ErrorLogCountGet() returns a value greater than zero, it means there were errors during the object creation.
⚙️ Handling Errors
To handle the errors, you call the ErrorLogGet() method once for each error on the created object to retrieve an RsiError object. You can then inspect the RsiError object to understand more about the error.
⚙️ Helper Functions
RapidCode also provides helper functions in both C++ and C#, like HelperFunctions::CheckErrors(), that work with all RapidCode objects. These helper functions operate on RapidCodeObject, hence they are compatible with all RapidCode objects. For example:
⚙️ Object Cleanup
Any and all objects created by RapidCode creation methods will be cleaned up by calling MotionController::Delete(). This should be done when your application is finished using RapidCode objects.
On Windows, the INtime node is selected by CreationParameters::NodeName, so Get() can only return controllers this process already created, plus index 0 (the default node, CreationParameters::NodeNameDefault). For any other controller, use Get(nodeName) to attach by INtime node name, or Create() with ControllerIndex and NodeName. As with all creation methods, a valid object is always returned; check ErrorLogCountGet() for errors.
Behavior change (10.7): previous versions ignored controllerIndex and returned the process's single controller, so Get(1) silently returned controller 0 on Windows. It now reports an error for indexes this process has no NodeName for.