简体   繁体   中英

How can I get return values from C# .DLLs in LabVIEW 2012?

I'm currently working on exporting a .DLL library file in C# in Visual Studio 2010 to LabVIEW 2012. The class does a color transform from RGB to HSL values, and I've been successful in implementing Constructor and Invoke nodes in the LabVIEW project to call the .DLL file.

So far I can input numbers for the RGB values into the Invoke node, but I'm having trouble getting HSL output values; the option doesn't appear in the drop-down box for the node.

I'm relatively fresh to C# (and programming in general) and I think I've spotted where the input function is in the .DLL, but as for the output function I've no clue how to generate it, much less in such a way that LabVIEW can export it cleanly. I figure if I can input values, I should be able to get those HSL outputs as well.

Below is the C# code snippet in question. The rest of the class is the formula for the transform itself, so I don't think it's too relevant.

public class QuickColorTransform
{
    byte _R;
    byte _G;
    byte _B;

    byte _H;

    public byte H
    {
        get { return _H; }
        set { _H = value; }
    }
    byte _S;

    public byte S
    {
        get { return _S; }
        set { _S = value; }
    }
    byte _L;

    public byte L
    {
        get { return _L; }
        set { _L = value; }
    }

    public QuickColorTransform()
    {
        SetupLookups();
    }

    public void SetColor(byte Red, byte Green, byte Blue)
    {
        _R = Red;
        _G = Green;
        _B = Blue;
        Transform();
    }

    public void SetColor(Color ColorIn)
    {
        _R = ColorIn.R;
        _G = ColorIn.G;
        _B = ColorIn.B;
        Transform();
    }
}

Thanks in advance!

You have created public HSL getters, and LabVIEW knows how to access it. Just use a property node in your VI, and link it to the object reference after the call to SetColor() , HS and L will be in the choice list of the property node.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM