LabVIEW ======= LabVIEW can directly import and use .NET assemblies without requiring additional wrapper code. The BenHW .NET assembly (``BenHW.dll``) is available as a pre-built package and can be imported into LabVIEW to control Bentham Instruments hardware. For more information on importing .NET assemblies in LabVIEW, refer to the National Instruments knowledge article: `How to Call a .NET Assembly in LabVIEW `_. See the section "Import .NET Assembly Functions with Constructor Node" for detailed guidance. Prerequisites ------------- Before using the BenHW SDK in LabVIEW, ensure you have: * **.NET Framework 4.8 Runtime** installed on your system. If you don't have it, download and install it from: `Microsoft .NET Framework 4.8 `_ Installation ------------ To use the BenHW SDK in LabVIEW, download the pre-built DLL package from the Bentham server: 1. `Download benhw-labview-0.2.2.zip `_ 2. Extract the zip file to obtain ``BenHW.dll`` (the .NET Framework 4.8 assembly) and the native BenHW DLLs Usage ----- Once you have extracted the ``BenHW.dll`` assembly, follow these steps to use it in LabVIEW: Adding the .NET Constructor Node ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1. Open a VI in LabVIEW 2. In the **Block Diagram** window, open the **Functions** palette 3. Navigate to **Connectivity -> .NET -> Constructor Node** 4. Place the Constructor Node on your block diagram 5. Double-click the Node to choose .NET assembly 6. In the dialog, click **Browse** and select the extracted ``BenHW.dll`` file 7. Choose the **BenHW** constructor function (Note: The first "BenHW" in the list is just the namespace; select the one that represents the actual constructor) 8. Pass the path to ``benhw64.dll`` as a string constant wired to the constructor node's ``dllPath`` input parameter Calling SDK Methods ^^^^^^^^^^^^^^^^^^^ To call methods from the BenHW SDK: 1. From the **Functions** palette, add a **.NET Invoke Node** 2. Wire the reference output from the Constructor Node to the Invoke Node 3. Select the method you want to call from the list on the Invoke Node For detailed information about available methods, refer to the :doc:`dotnet_api` page. Using Get/Set Methods ^^^^^^^^^^^^^^^^^^^^^ The ``Get`` and ``Set`` methods require hardware tokens as input parameters. These tokens are integer values that identify specific hardware attributes. To use these methods: 1. Manually enter the token value as a numeric constant 2. Refer to the :doc:`tokens` page for a complete list of available tokens and their numeric values 3. Pass the token value to the ``Get`` or ``Set`` method along with other required parameters Example Workflow ^^^^^^^^^^^^^^^^ A typical LabVIEW application using the BenHW SDK might follow this sequence: 1. Create a BenHW instance using the **.NET Constructor** node 2. Call ``BuildSystemModel`` to load your system configuration file 3. Call ``LoadSetup`` to load your setup file 4. Call ``Initialise`` to initialize the hardware 5. Call ``Park`` to park all components 6. Call ``ZeroCalibration`` to perform zero calibration 7. Call ``SelectWavelength`` to select a wavelength 8. Call ``Automeasure`` to perform a measurement 9. Process the returned measurement value 10. Clean up by disposing of the BenHW instance when done Error Handling ^^^^^^^^^^^^^^ The BenHW .NET assembly throws ``SdkException`` when errors occur. Use LabVIEW's exception handling structures to catch and handle these exceptions appropriately. For more information about error codes and exceptions, refer to the :doc:`errors` page. Additional Resources -------------------- * :doc:`dotnet_api` - Complete .NET API reference * :doc:`tokens` - Hardware token reference * :doc:`errors` - Error codes and exceptions