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 |
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. |
|
||||||||||||||||
PC Collect inspection |
The testid variable identifies which activity triggered the execution of a Python script.
|
8.8, 9.1 |
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