TwiceAsNice
2019-02-18
|
This example demonstrate how to communicate with the MoCon directly. More...
#include <config.h>
#include <Nice/App/Application.h>
#include <Nice/App/ConfigClient.h>
#include <Basda/Mocca/XServiceWorkerInterface.h>
#include <Basda/Mocca/Constant.h>
Classes | |
class | Chat |
Functions | |
int | main (int argc, char *argv[]) |
This example demonstrate how to communicate with the MoCon directly.
WARNING: These commands are not the official interface to the MoCon. The user of this command takes the full responsibility. The user must handle all MoCon errors by itself. With that command the service lose the complete control of the MoCon and the parameter in the property tree might became out-dated!
Usage: For the direct MoCon communication exist 3 commands:
All command are inline commands, which means the commands can be only sequentially processed.
Method: void send(std::string CMD_ID, std::string CARD_NO, std::string MODULE_NO, std::string SELECT_ID, std::string PARAMETER, std::string LINES) The send method takes 6 parameter: commandID - the MoCon command number cardNo - the MoCon card number moduleNo - the MoCon module number selectID - the command select ID parameter - various command parameter lines - Some command response a lot of information / lines at once. The number of lines can be specified in order to receive not all lines at once. For the first command response the command receive must be use to receive the first number of lines. All further lines must be receive with the command reeiveDataRaw. If the line number is not present all lines will be received at once till the command acknowledge.
NOTE: The service can be setup in a way that its device controls several motors that are connected to different MoCons. While each MoCon has its own IP address, the motors on the different MoCons can have the same card and module number! With that command the server DO NOT KNOW to which motor the command belongs to! It will always send the command to the MoCon, whose motor name comes alphabetically first.
EXAMPLE: getPosition: mocca->send("166", "1", "1", "", "", ""); moveHome: mocca->send("125", "1", "1", "", "", ""); setExternalProfileData: mocca->send("221", "1", "1", "", "1 10 20 2000 2 1", ""); getTraceData: mocca->send("204", "1", "1", "", "", "100"); getDigitalInLong: mocca->send("197", "1", "1", "0", "", "");
Method: std::string receive() Receive the command response without parsing the command response string.
EXAMPLE: std::string receive = mocca->receive();
Method: std::string receiveDataRaw(std::string CMD_ID, std::string CARD_NO, std::string MODULE_NO, std::string LINES) This method receive number of lines of the defined command without to send the command again. If the command acknowledge is received the number of received line could be less than defined. commandID - the MoCon command number cardNo - the MoCon card number moduleNo - the MoCon module number lines - the number of lines that are expected next
EXAMPLE: getTraceData: mocca->receiveDataRaw("204", "1", "1", "100");
int main | ( | int | argc, |
char * | argv[] | ||
) |