InoDrive / UserApp / get_var


InoDrive.UserApp.get_var(self, argv=None, **kwargs)

Get Variable(s) value by name or id in User Application, does not poll User Application Variable List.

Arguments:

self (Object): Reference to User Application Instance.
*args (Tuple or List): Argument can be a single Variable Name (String) or a ID (Integer). Can also be a List of Variable Name’s or ID’s.
**kwargs (Dict):

floatPrecision (Integer): (Optional) Keyword argument to round up floating point value to nearest digit.

Returns:

Variable (Boolean, Integer, Floating Point) or Dict:

• If argument is a Single Variable Name or ID -> Returns the Variable value.
• If argument is a List of Variable’s Name’s or ID’s -> Returns Dictionary of Variable Name’s paired with their value.

import CkInoDriveAPI

# Instantiate InoDrive Object and Connect by Name
Drive = CkInoDriveAPI.InoDrive(target='Name', autoConnect=True)

# Start polling User Application for Variable Listing
Drive.UserApp.start_poll()

# Get Specific Variable Value by ID
foo = Drive.UserApp.get_var(0)

# Get Specific Variable Value by Name
foo = Drive.UserApp.get_var('foo')

# Get Multiple Specific Variables by ID
var_list = Drive.UserApp.get_var([0, 1])

# Get Multiple Specific Variables by Name
var_list = Drive.UserApp.get_var(['foo', 'bar'])

if var_list is not None:
    print(var_list)

# Assume Variable Float Returns a Value of 13.44456
# Expected Return is 13.44
float = Drive.UserApp.get_var('Float', floatPrecision=2)