Python command: Solartron

Use the Solartron commands in Python to read numeric data values from a Solartron Orbit 3 network.

These commands are most commonly used by a sub-inspection Formula test with the FormulaMode property set to ClickToggle.

Note: This functionality was developed and tested for the Solartron network via USB connection to the data collection PC. Other connection types such as Ethernet, RS232, Wireless (Bluetooth), etc. have not been tested, and GainSeeker may or may not detect these connections and use them correctly.

If connected via USB, the GainSeeker Inspections module and PC Collect module should auto-detect the Solartron network and communicate as described, without installing any Solartron software.

See Python commands for other commands you can use with GainSeeker.

Commands

Syntax

Example

Description/Remarks

New or changed in GainSeeker version

solartron.connect()

myresult = solartron.connect()

Establishes a connection to the Solartron network and sets the value of a variable (myresult) to True if the connection is successful and ready to use or False if GainSeeker is not able to connect.

Establishes a connection to all available Solartron Orbit networks.

This command returns True if the connection is successful and ready to use or False if GainSeeker is not able to connect.

This connection is only active until the current Python script ends. If running the Python script in a sub-inspection, clicking the "X" button to close the sub-inspection before the script ends will also close the active Solartron connection.

9.3

solartron.disconnect()

solartron.disconnect()

Disconnects from all Solartron Orbit networks.

Does not return a value.

9.3

solartron.geterror()

my_error = solartron.geterror()

Returns the error message about the most recent solartron command.

If no error occurred during the most recent solartron command, this returns None.

If an error occurred during the most recent solartron command, this returns that error message.

9.3

solartron.read(idx)

where idx is the TestID property of the test on the sub-inspection

my_value = solartron.read(0)

Gets the calculated reading based on the SolartonSettings property for the Numeric Input test with testid 0 on the current sub-inspection.

 

inspect.cursubi.ni(0).solartronmoduleid = "110A523P17"

my_value = solartron.read(0)

First, this changes the Module ID setting for this test's SolartronSettings property to "110A523P17".

Then it gets the calculated reading for that Solartron Module ID based on the SolartonSettings property for the Numeric Input test with testid 0.

Returns the calculated reading based on the SolartonSettings property for the specified Numeric Input test on the current sub-inspection. (The SolartonSettings property sets the Solartron Module ID and variables for calculating a final value from the raw data input.)

You must use the solartron.connect() command to successfully connect to the Solartron Orbit network before calling solartron.read().

The calculated reading will be rounded to the number of decimals configured for the SPC standard that has been set for this Numeric Input test. If an SPC standard has not been configured for the Numeric Input test, the calculated reading will not be rounded.

This returns None if the SolartonSettings property for the specified Numeric Input test is blank (so no Solartron Module ID is specified), if the script has not already called the solartron.connect() command to successfully connect to the Solartron Orbit network, or if an error occurs while trying to read the value.

9.3

solartron.readraw(moduleid)

my_value = solartron.readraw("110A523P17")

Gets the raw reading from the specified Solartron Module ID.

Returns the raw reading from the specified Solartron Module ID. (This reading will not be rounded.)

The Module ID must be a string.

You must use the solartron.connect() command to successfully connect to the Solartron Orbit network before calling solartron.readraw().

This returns None if an error occurs while trying to read the value or if the script has not already called the solartron.connect() command to successfully connect to the Solartron Orbit network.

9.3

Example script

This script is designed for the following context:

 

import time

connected = solartron.connect()
if not connected:
    disp.message(solartron.geterror() +
"\r\nThe script will attempt to reconnect in 5 seconds.")
    time.sleep(
5)
else:
    test_id_list = [x
for x in inspect.cursubi.testidlist if inspect.cursubi.gettesttype(x) == "NUMERICINPUT" and inspect.cursubi.ni(x).solartronmoduleid]
    
while not cancelrequested:
        
for ni_id in test_id_list:
            read_val = solartron.read(ni_id)
            
if read_val is not None:
                inspect.cursubi.ni(ni_id).values = [read_val]
            
else:
                disp.message(solartron.geterror())
                
#ToDo: Perform other error trapping as needed
        
        inspect.update()
        
#time.sleep(.5) #uncomment to have a .5 second pause before taking another set of readings

solartron.disconnect()