loading
 
No "send" command in API wrapper?
from United States  [214 posts]
15 year
Hello,

I am starting to use the API wrapper in a C# program and I noticed that the "Send" command that is included in the API source example does not seem to be available through the wrapper.  I was hoping to use the "Send" command to send "<request>xyz</request>" commands to RR, such as updating a parameter in an already-running RGB_Filter.  I tried using the wrapper's "Execute" function but that doesn't seem to work.  Am I missing something, or is there a reason the "Send" function is not included in the wrapper?

Thanks!
patrick

Anonymous 15 year
Sorry if I don't under stand it correctly but couldn't you just use the set_parameter cmd ?

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

This request allows you to modify a module parameter as seen in the GUI interface. In some modules you can replace the static number/text with a [variable] specification but not all GUI number/text items support this format. Instead you can use this API call to directly change a parameter within that interface.

<request>
    <set_parameter>
        <module>MODULE_NAME</module>
        <module_number>MODULE_INDEX</module_number>
        <name>PARAM_NAME</name>
        <value>PARAM_VALUE</value>
    </set_parameter>
</request>

MODULE_NAME - the name of the module to modify (eg. Color_Filter) MODULE_INDEX - which module to modify in case you have more than one module of the same name (i.e. two Color_Filter modules). PARAM_NAME - the parameter to modify as seen in the XML string of the robofile (eg. min_distance) PARAM_VALUE - what to change the parameter value to (eg. 65)
Anonymous 15 year
The send command in the wrapper is set to private if you want to use it in your code you could set it to public and you should have access but then you would have to write your own return code. Alternatively you can add to the wrapper class an update function to update a param. Place the code within the wrapper and it should work correctly

        public bool update(string Module_Name, int Module_Index, string name, int value)
        {
            if (!connected) return false;

            if (send("<request><set_parameter><module>"+Module_Name+"</module><module_number>"+Module_Index+"</module_number><name>"+name+"</name><value>"+value+"</value></set_parameter></request>"))
            {
                String buffer;
                if ((buffer = readMessage()) != null)
                {
                    if (buffer.Equals("<response>ok</response>"))
                        return true;
                }
            }

            return false;            
        }
from United States  [214 posts] 15 year
This is brilliant!  Many thanks for the quick solution--works like a charm.  I think your update routine would make a nice addition to the stock RR_COM_API.dll.  It would also be nice to have the raw send function exposed so that other <request> blocks could be sent on the fly.

Thanks again,
patrick
from United States  [214 posts] 15 year
I noticed that the very latest RR_COM_API.dll *does* include a SetParameter function similar to the update function posted above.  Not sure how I missed it before--seems I had to re-regsvr32 the new dll to get it reflected in my C# program.  I also noticed that the way you run RR from your program has changed.  The new sequence that worked for me was:

object port = 6060;
RoboRealm = new RR_COM_APILib.API_Wrapper();
RoboRealm.Open("C:/Program Files/RoboRealm/RoboRealm.exe", ref port);
RoboRealm.Connect("localhost");

Finally, I didn't see this in the API documentation so maybe it will help someone else.  I had to set the Timeout parameter on the API server to 0 from the default 30 seconds--else, I kept losing my connection to RR every 30 seconds...

--patrick

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