Tutorial 1-3: Communicating with the network
The StartCommunication function attempts to start communication with any of the platforms the engine is running. If this function returns no error (None is returned), the engine will communicate with the servos, I/O modules, and other devices on the network. If this function returns an error, communication with the network failed due to the reason indicated by the error code. In addition, error messages may appear on the Rtx Server Console application that is automatically opened (unless the Rtx Server Console is suppressed in the RTX settings).
Depending on the settings of the Module.ini file in the WMX3 engine directory, the WMX3 engine will run one or more of the following hardware platforms supported by WMX3: EtherCAT, Realtime Express, and MECHATROLINK III. In addition, the WMX3 engine may also start the simulator platform.
The following settings will run just the simulator engine. The simulator engine is useful to test an application before controlling actual hardware. The simulator engine can also be configured to control axes that do not physically exist by enabling both the non-simulator engine and the simulator engine.
The remainder of the tutorial will assume that the simulator engine is running, although the same code can run on any platform.
[Platform 0]
Location = .\platform\simu\
DllName = SimuPlatform.rtdll
disable = 0
If communication has been started with StartCommunication, it must be stopped using StopCommunication before calling CloseDevice.
The following adds StartCommunication and StopCommunication function calls to the example code:
using namespace wmx3Api;
WMX3Api wmxlib;
wmxlib.CreateDevice(_T("C:\\Program Files\\SoftServo\\WMX3"), DeviceType::DeviceTypeNormal);
wmxlib.StartCommunication();
Sleep(5000); //Wait five seconds before stopping communication
wmxlib.StopCommunication();
wmxlib.CloseDevice();