Archived

This forum has been archived. Please start a new discussion on GitHub.

Porting ICE to LabVIEW using .Net interface

I've been trying to port the Hello World Client Server Application mentioned in the ICE documentation to LabVIEW by using .NET constructors found in the Ice.dll Util constructor.

I was able to get the following working (well sort of)
initialize the server,
createAbjectAdapterWithEndpoints,

ICE::Objectprt object = new PrinterI;

I have quite figure out how to code the line above in LabVIEW, so I created a separate vi (program) and got a reference to that program. I can run that reference and my program will run, so I tried casting the reference to match Ice::ObjectPtr and it wires up ok, but I don't think it is correct. Any ideas?

adapter->add(object, ic->stringToIdentity)



adapter->activate()
iv->waitForShutdown() or waitfordeactivate() (hangs my application so I have left them out for now and just added a while loop that I can terminate when I'm ready to deactive and ic->destroy.

I haven't bothered with the excepts yet, only because LabVIEW can trap any errors and place them in a front panel display.


On the Client side I've been able to convert

Ice::initialize()
Ice::ObjectPrx base = ic->stringToProxy("SimplePrinter:default -p 1000");

then I get stuck and haven't figured out how to code the checkedCast(base) to get a reference that I can run/call to use on the next line. I couldn't find any methods using the .Net constructors, properties, or invoke that made any sense.

printer->printerString("Hello World!");

Any ideas? Is something like this even possible?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    We're not very familiar with LabView but to cast an Ice.ObjectPrx proxy to another proxy type you can use the static checkedCast method defined on the generated proxy helper class. For example, if you have the following Slice:
    // Slice
    module Demo
    {
       interface Printer
       {
           void print(string s);
       };
    }
    

    And compile it with slice2cs, it generates the following C# proxy helper class:
    namespace Demo
    {
        public sealed class PrinterPrxHelper : Ice.ObjectPrxHelperBase, PrinterPrx
        {
            public static PrinterPrx checkedCast(Ice.ObjectPrx b)
            {
                ...
            }
            ...
        }
    

    See the Ice manual for more information on the Slice-to-C# mapping. If you can't access this static checkedCast method from LabView, it's perhaps easier to create a LabView Virtual Instrument (VI) that initializes the communicator and returns the correct proxy?

    Cheers,
    Benoit.
  • Thanks for the advice. I have solved this for now by writing and compiling a dll that labview can call. This dll is compiled in MS visual C++ and makes all the necessary calls to the ice dlls.

    I'll work some more on labview making direct calls to ice dlls, if I ever get the time.