loading
 
Multiple RR instances in API
from Australia  [87 posts]
16 year
I would like to run two instances of RR using my API software. Is it possible? At the moment I use API and an RR program to extract the data and process it. Then, the processed data is sent back to RR.

I would like to split the activity so that the processed data from the API is sent into a new RR instance where it can be used further. How can I refer to a different RR instance using C++ API?

Cheers,

Nemanya
John Christian from Norway  [25 posts] 16 year
If you look in the options for the API Server in RR you can specify another port for the other instance (you can also pass this as a parameter when you start RR using -api_port <portnumber>). When you use the C++ API you then have to open another connection using this port number. This way you can have many RR servers going on the same machine.
from Australia  [87 posts] 16 year
Hi John,

How can I specify another port for the other instance. I change the API Server port from 6060 to 6061 and close it down. When I open it, the API port is 6061 but port 6060 does not exist any more. I have enabled "allow multiple instances running".

How can I get API access to multiple RR instances? If I could have unique API Server port numbers then I think that I could access then easily by establishing a unique connection for each one.

Regards,
Nemanya
John Christian from Norway  [25 posts] 16 year
I just tried it, and it does work. Try this:

Open RoboRealm.
Choose Allow Multiple Instances
Close RoboRealm (this will save the settings)
Make a bat file with:

RoboRealm.exe -api_port 6060
RoboRealm.exe -api_port 6061

Running this batch file will run two roborealms each with different ports for the API. Perhaps you forgot to close the application after you have set the "Allow Multiple Instances" option? That tricked me at first too.
Anonymous 16 year
Thanks for the posting John, that's how you do it!!

STeven.
from Australia  [87 posts] 16 year
Hey guys,

I've tried to run multiple instances of RR using C++ API in many different ways, also the way you recommended it. It was all without success.

The API port is set to 6060, multiple instances allowed.

As you recommended to use  for example -api_port 6061 at the end of the opening statement results in error.

I change the format from:
rr.open("c:\\Program Files\\RoboRealm\\RoboRealm.exe");
to:
rr.open("c:\\Program Files\\RoboRealm\\RoboRealm.exe -api_port 6061");

And it doesn't work. Could you confirm as to where I should change the API port number. I've tried making a parallel set of files with a different SERVER_PORTNUM, from 6060 to 6061, but then it just opens the 6060 instance put not the 6061 one.

Cheers,
Nemanya
Anonymous 16 year
Try this:

1. Open a command console: Click on Start->Run->Type in cmd
2. cd to roborealm folder
3. enter "RoboRealm.exe -api_port 6061" and then press return.
4. enter "RoboRealm.exe -api_port 6060" and then press return (note port number difference).

If you now only see one RoboRealm instance running you've forgotten to turn on the multi-instance checkbox. See Options->Startup tab and first checkbox in that interface. Be sure its on. Close that interface and exit RoboRealm. Repeat sequence above.

You should end up with 2 RoboRealm instances running .. one listening on port 6060 and the other on 6061. Now you can use the API in that manner that the application has been configured correctly.

STeven.
Anonymous 16 year
Hi Steven.
It all works fine. I didn't have to change anything.

I realize how it works, but don't know how to code that up in C++ code for API.

Here is the segment of code. How can I apply the above idea?

    RR_API * rr;
    rr = new RR_API();

    // open up RoboRealm.
    rr->open("C:\\Program Files\\RoboRealm\\RoboRealm.exe");

    if (!rr->connect(SERVER))
    {
        printf("RoboRealm does not appear to be running.\nPlease run RoboRealm and try again.");
        exit(0);
    }

    rr->run("off");
    rr->loadProgram("geometric_detect.robo");
    rr->run("on");

Sorry for bothering you, but it sure bothers me that I can't get it right.

Nemanya
Anonymous 16 year
You'll have to create two RR_API objects and use the format you had before in the open command to initialize the port. i.e.

RR_API rr1, rr2;

// open up RoboRealm.
rr1.open("C:\\\\Program Files\\\\RoboRealm\\\\RoboRealm.exe -api_port 6060");
rr2.open("C:\\\\Program Files\\\\RoboRealm\\\\RoboRealm.exe -api_port 6061");

STeven.
Anonymous 16 year
Hi STeven,

Using a terminal, I easily access multiple RR instances using different port number.
However, as you mentioned above

RR_API rr1, rr2;

rr1.open("C:\\Program Files\\RoboRealm\\RoboRealm.exe -api_port 6060");    Sleep(500);
rr2.open("C:\\Program Files\\RoboRealm\\RoboRealm.exe -api_port 6061");  

if (!rr1.connect(SERVER))
{
    cout << "RoboRealm does not appear to be running.\nPlease run RoboRealm and try again." << endl;
    exit(0);
}    

The RR fails to open at the rr1.connect point.

If I just use
   rr1.open("C:\\Program Files\\RoboRealm\\RoboRealm.exe");
it opens and connects correctly (one instance).

Regards,
Nemanya
from Australia  [87 posts] 16 year
The only reason I need to run two RR instances using single C program is that one RR instance observes and samples. This is then passed onto the C program (.exe) using API. This then further calculates the results and passes it onto the second RR instance for analysing the refined image data using shape matching & other modules.

I must have tried a thousand ways to activate two RR instances using C++ API. I think that the problem is in the connect(server) part. As that is where the API port is set internally to 6060. Therefore any new opening of RR with C opens it over the previous one, rather than a new instance.

Regards,
Nemanya
Anonymous 16 year
Nemanya,

Ok, to make things easier we've updated the open and connect routines in the C++ version of the API to accept a port number. You should be able to download the API again and simply overwrite the RR_API.cpp and RR_API.h files in your project. Then remove the "-api_port etc" from your quoted string and instead put on the port number as an integer at the end of the open and connect function calls (after a comma). See the main.cpp in the API as an example if you need additional guidance.

Hopefully that should make things easier for you to get running. Let us know how it goes.

STeven.
from Australia  [87 posts] 16 year
Hi STeven,

Thanks for your time.

I have updated the API and changed the code. When running, it opens up the first RR instance rr1 and loads the program. When it comes to opening rr2 it comes up with the message "RoboRealm does not appear to be running. Please run RoboRealm and try again." and exits. I also tried opening rr1 and rr2 using the same PORTNUM 6060. There the rr2 opens over rr1 and is the only instance running. Below is the code I am running. Why can it not connect to rr2 PORTNUM 6061?

-----------------------------------------------------------------

#define PORTNUM1 6060
#define PORTNUM2 6061

RR_API * rr1;
RR_API * rr2;
rr1 = new RR_API();
rr2 = new RR_API();

rr1->open("C:\\Program Files\\RoboRealm\\RoboRealm.exe", PORTNUM1);

if (!rr1->connect(SERVER, PORTNUM1))
{
printf("RoboRealm does not appear to be running.\nPlease run RoboRealm and try again.");
exit(0);
}

rr1->run("off");
rr1->loadProgram("geometric.robo");
Sleep(500);
rr1->run("on");

rr2->open("C:\\Program Files\\RoboRealm\\RoboRealm.exe", PORTNUM2);

if (!rr2->connect(SERVER, PORTNUM2))
{
printf("RoboRealm does not appear to be running.\nPlease run RoboRealm and try again.");
exit(0);
}

rr2->run("off");
rr2->loadProgram("analysis.robo");
Sleep(500);
rr2->run("on");

--------------------------------------------------

Cheers,
Nemanya
Anonymous 16 year
Just to close this thread in case anyone else is reading this ... this issue has been resolved in the latest version of the API. Multiple instances of RoboRealm are capable of talking over different API port numbers. Please be sure that you are using the most recent version of the API for this change.

On the command line you can execute RoboRealm using

RoboRealm.exe -api_port 6060

to set the API port to 6060.

Also be sure to set the Options Button->Startup tab -> Allow multiple instances checkbox to on in order to run more than one copy of RoboRealm.

Please note that this change has only been made to the C++ version of the open function in the API. If you need this capability in other languages please contact us.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index