|
Reading Variables in C# Jack SO from Hong Kong [8 posts] |
16 year
|
May I ask how to read the variable via socke with C#? I tried exploring the extension package but failed to find the way to read the variables such as COG_X or COG_AREA
Thanx a lot.
|
|
|
Anonymous |
16 year
|
Hi,
I am not an expert.
But perhaps this information can help until an expert answers : )
To see the available variables you can use this:
http://www.roborealm.com/help/Watch.php
To GET and SET variable from another program, like C#, use this:
http://www.roborealm.com/help/API.php
Hi to Hong Kong!
|
|
|
Reading Variables in C# Anonymous |
16 year
|
Jack,
In the C# Extension you will see this part of code:
if (name.Equals("name"))
{
imageData.name = name;
}
else
which is used to look for a variable called "name". To adapt an extension to use another variable you would add in something like:
if (name.Equals("another_var_name"))
{
int myIntVar = byteToInt(data);
}
else
or something like that.
As the last post mentions we're not sure if you really want to use an
Extension or the API.
Extensions are modules controlled by RoboRealm whereas the API is mean to control RoboRealm.
Extensions allow you to create new modules that will be called on each iteration of the processing loop. They are meant to be incorporated into RoboRealm in order to "extend" the applications modules. The ARE guaranteed to get each image that is processed by RoboRealm and will receive all variables that are current with the application. They can also stop the processing loop (dll only). RoboRealm will NOT run without a required extension and thus you need to make sure your extension is always available (or it is automatically loaded if a dll).
The API allows you to control RoboRealm from another application. You can do similar things as an extension such as getting the current image or placing a new image in the processing pipeline but you are NOT guaranteed to get every frame of the processing loop. RoboRealm will continue to run regardless of if your control program is running (unlike extensions).
So it depends on what you're trying to develop.
STeven.
|
|
|
The data reading problem Jack SO from Hong Kong [8 posts] |
16 year
|
Dear STeven
Thanx for your help. The Socket reads in data is in bytes format. After adopting the byteToInt() function, the streaming data seems not match the Roborealm program (pls see the screenshot attached)
Thanx, Roborealm is really a great program. I see another similar commercial SDK costing USD 10000 !!

|
|
|
screenshot Jack SO from Hong Kong [8 posts] |
16 year
|
Sorry, I posted the wrong pictures, here they are

|
|
|
C# Variables Anonymous |
16 year
|
Jack,
Opps, my mistake. I was thinking that the variables come in as a binary integer but in fact only the width and height come is as binary integers. All the other variables come in as strings. So instead of using the bytetoint function you instead need to treat data as a string and convert it from a string to a number.
Instead try
if (name.Equals("cog_x"))
{
int myValue = Convert.ToInt32(Encoding.ASCII.GetString(data, 0, len));
}
instead which should work better. We've include this in the Extension.cs example to help other out. Thanks for the screenshots!!
STeven.
|
|
|
Thanx. Jack SO from Hong Kong [8 posts] |
16 year
|
|