Skip to content

Labview32¤

Wrapper around a 32-bit LabVIEW library.

Example of a server that loads a 32-bit LabVIEW library, labview_lib, in a 32-bit Python interpreter to host the library. The corresponding Labview64 class is created in a 64-bit Python interpreter and the Labview64 class sends requests to the Labview32 class which calls the 32-bit library to execute the request and then returns the response from the library.

Attention

This example requires that a 32-bit LabVIEW Run-Time Engine ≥ 2017 is installed and that the operating system is Windows.

Labview32 ¤

Labview32(host, port)

Bases: Server32

Wrapper around the 32-bit LabVIEW library, labview_lib.

Parameters:

Name Type Description Default
host str

The IP address (or hostname) to use for the server.

required
port int

The port to open for the server.

required
Source code in src/msl/examples/loadlib/labview32.py
30
31
32
33
34
35
36
37
38
def __init__(self, host: str, port: int) -> None:
    """Wrapper around the 32-bit LabVIEW library, [labview_lib][labview-lib].

    Args:
        host: The IP address (or hostname) to use for the server.
        port: The port to open for the server.
    """
    path = Path(__file__).parent / "labview_lib32.dll"
    super().__init__(path, "cdll", host, port)

stdev ¤

stdev(x, weighting=0)

Calculates the mean, variance and standard deviation of the values in the input x.

See the corresponding Labview64.stdev method.

Parameters:

Name Type Description Default
x Sequence[float]

The data to calculate the mean, variance and standard deviation of.

required
weighting int

Whether to calculate the sample (weighting = 0) or the population (weighting = 1) standard deviation and variance.

0

Returns:

Type Description
tuple[float, float, float]

The mean, variance and standard deviation.

Source code in src/msl/examples/loadlib/labview32.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def stdev(self, x: Sequence[float], weighting: int = 0) -> tuple[float, float, float]:
    """Calculates the mean, variance and standard deviation of the values in the input `x`.

    See the corresponding [Labview64.stdev][msl.examples.loadlib.labview64.Labview64.stdev] method.

    Args:
        x: The data to calculate the mean, variance and standard deviation of.
        weighting: Whether to calculate the sample (`weighting = 0`) or the
            population (`weighting = 1`) standard deviation and variance.

    Returns:
        The mean, variance and standard deviation.
    """
    data = (c_double * len(x))(*x)
    mean, variance, std = c_double(), c_double(), c_double()
    self.lib.stdev(data, len(x), weighting, byref(mean), byref(variance), byref(std))
    return mean.value, variance.value, std.value