[Mono-dev] sigc++ signal C# wraper and monoBot Studio

buhochileno at gmail.com buhochileno at gmail.com
Wed Oct 31 12:10:34 EDT 2007

Hi Jon:
Thanks for all your help and patience Master :-), my WebCamOrbit wrapper 
test now work perfectly I learn so much this couple of days, so please 
let me know if I can help you with anything , now I'm going to begin the 
real implementation...

In our University whe have a couple of PC (notebook acctually) robot 
plataforms (built by us), all in linux with a lote of sensors (vision, 
gyroscope, sonar, etc). But all HW driver are in pure C and with a bad 
comunication system with the higher libraries (shared memory to put and 
read values).
So, with this C++ approach we can rebuild all drivers with a better 
message system for the higher programmers libraries. I know that is 
someway possible to access HW from mono/.net, but for efficency is 
better to have the software related to the hardware at low level as posible.
And the reason to also have C# wrappers is becouse we started to work in 
a "visual robotic" software for mono and opensource community, is 
something like Visual Robotics .NET from Microsoft, but in this case for 
mono and offcourse opensource, we allready have the "3D world designer" 
(this work pretty much like a windows form designer, you can put in your 
world robotic kits, sensors, walls, etc, and organize they behavior; 
something like: at 3PM read the heat sensor and take a picture and send 
me mail, or move the robot to that position; in a "design" way), as in 
the windows designer paradig, all the design is traslated to code and 
then the code is passed to the robot for the real execution (you can 
also run the code in a simulated environment). Also right now we are 
working and moving fast in the "code generation" part and in the main 
application (to select a object from the world and  see/change 
properties, add actions to a event handler, etc).

So this is a very interesting proyect that can be improved a lote with 
all the stuff that you tech me, so thank again Jon.

Greeting, Mauricio

Jonathan Pryor wrote:
> On Tue, 2007-10-30 at 20:14 -0300, buhochileno at gmail.com wrote:
>> Hi Jon, me again sorry, after implement the example code that you send 
>> me, I try to apply the learned stuf to my WebCamOrbit class, so I add
>> the following:
>> extern "C" void* CreateWebCamOrbit ()
>> {    return new WebCamOrbit ();
>> }
>> typedef void (*OnMoveHandler) (int , int); //Not necesary right??
> No, this is still necessary.
>> //the following is not right....
>> extern "C" void WebCamOrbit_AddOnMove (WebCamOrbit* wcOrbit, 
>> WebCamOrbit::type_OnMove& handler)
> Should be:
> 	OnMoveHandler handler
> WebCamOrbit::type_OnMove is the sigc++ type of this signal.  `handler'
> needs to be a C type (as .NET Marshaling doesn't do C++ marshaling), as
> that's what the Mono marshaler will be providing.
>> {    wcOrbit.OnMove().connect(sigc::mem_fun(wcOrbit, handler)); //I lost 
>> here
>> }
>> I lost in the "connect" call, becouse I need to pass the managed object 
>> and a pointer to the managed object method?, or do you recomend only use 
>> ptr_fun? or obviously there is another way to do it that I miss?.
> Only use ptr_fun.  You don't need to worry about separate object &
> method pointers, as a delegate implicitly references *both* an object
> and the method to invoke on the object.
> For example:
> 	// C#
> 	delegate string StringCreator ();
> 	object o = 42;
> 	StringCreator sc = o.ToString;
> 	string s = sc ();
> The `sc' creation line causes *both* the object `o' *and* the method
> System.Int32.ToString() to be referenced by the delegate `sc', so that
> when `sc' is invoked, it'll invoke `o.ToString()'.
> Consequently, your C++ code doesn't need to worry about separate object
> & method pointer issues, as Mono's delegate marshaler will handle it for
> you.
>  - Jon

More information about the Mono-devel-list mailing list