These are special Python variables that can be used in specific areas of GainSeeker.
See Python commands for other commands you can use with GainSeeker.
Contents [Hide] |
Variable |
Applies to |
Description |
New or changed in GainSeeker version |
||||||||||||||||||
PC Collect inspection |
In a Formula test with the FormulaMode property set to ClickToggle, when the inspector clicks the Formula button a second time to finish running the script, this variable will be set to True and the current script will complete execution but not automatically run again. This is a global variable. Your Python script can use a while loop that executes some code while this variable is False and exits the script when this variable is True. This is especially useful if you need to perform some setup steps such as opening a port or connecting to a device, which you may only want to execute once (for better performance). |
9.3 |
|||||||||||||||||||
PC Collect inspection |
This variable can be set to one of these values:
You can set this variable in any script in the sub-inspection. Each time a sub-inspection is opened, this variable is reset to False . |
|
|||||||||||||||||||
Set this variable equal to the final desired value of the custom statistic you are creating or editing. |
|
||||||||||||||||||||
Set this variable equal to the final desired value of the measurement being entered. You can also set this variable to an asterisk ( * ) in place of a missing measurement. For more information, see Entering an incomplete subgroup. If the inspector clicks Cancel while waiting for a reading from the Device Profile, this variable will be set to None. |
9.3 |
||||||||||||||||||||
PC Collect inspection |
The testid variable identifies which activity triggered the execution of a Python script.
|
8.8, 9.1, 9.2, 9.3 |
Your sub-inspection contains a Pass/Fail test with TestID of 1 and a Traceability test with TestID of 2.
If the Pass/Fail test fails, you want the inspector to complete the Traceability test.
For the above scenario, you could use the following code in a Formula test (where the FormulaMode property is set to Post):
if inspect.cursubi.passfail(1).value == 1 and inspect.cursubi.trace(2).value == "" :
disp.message("Please complete the required traceability.") #This reminds the operator to complete the traceability.
cancelsubmit = True #This will prevent the operator from submitting the sub-inspection.
else:
cancelsubmit = False #This will allow the operator to submit the sub-inspection.
Keep in mind that all Special Variables are global variables. This means that if you want to use a Python function to set one of these variables, you must either declare that variable as global within your function, or use the main script to set the value of the variable based on a value returned by the function or an attribute of a class object.
For example, these two scripts DO NOT WORK because they fail to set the global variable:
Example 1:
def updateCancelSubmit():
# since we are assigning a value to cancelsubmit in the local scope of this function,
# Python assumes we want a local variable.
# this local variable will not affect the global cancelsubmit variable
cancelsubmit = True
updateCancelSubmit()
# will print False because the value of the global cancelsubmit variable remains unchanged
print cancelsubmit
Example 2:
def updateCancelSubmit(cancelsubmit):
# in this example we are passing in the VALUE of the global cancelsubmit variable,
# but this is still a local variable and changing the value will not affect the global cancelsubmit variable
cancelsubmit = True
updateCancelSubmit(cancelsubmit)
# will print False because the value of the global cancelsubmit variable remains unchanged
print cancelsubmit
Here are some examples that would CORRECTLY set a special variable:
def myfunction() :
global cancelsubmit #declares that we mean the global variable 'cancelsubmit'
if some_condition_is_met :
cancelsubmit = True
myfunction()
def myfunction() :
myvar = False
if some_condition_is_met :
myvar = True
return myvar #calling myfunction() will return the value of this myvar variable
cancelsubmit = myfunction() #because we are setting this outside of the function, it is automatically treated as a global variable
class myclass() :
myvar = False
def myfunction(self):
self.myvar = True
mything = myclass() #creates a new 'mything' object based on the class 'myclass'
mything.myfunction() #calls the 'myfunction' method on the 'mything' object
cancelsubmit = mything.myvar #because we are setting this outside of the function, it is automatically treated as a global variable