diff --git a/docs/src/interfaces/clients/virtual.rst b/docs/src/interfaces/clients/virtual.rst index e032b7c94..bb7a05cab 100644 --- a/docs/src/interfaces/clients/virtual.rst +++ b/docs/src/interfaces/clients/virtual.rst @@ -77,7 +77,7 @@ The VariableWait helper function can also be used. .. code-block:: python # Wait for the uptime to be greater than 1000 seconds - VariableWait(root.AxiVersion.UpTime, lambda varValues: varValues['root.UpTime'].value > 1000) + VariableWait([root.AxiVersion.UpTime], lambda varValues: varValues[0].value > 1000) The VirtualClient maintains a connection to the Rogue core. The status of this connection can be directly accessed through the linked attribute. Additionally a callback function diff --git a/python/pyrogue/_Process.py b/python/pyrogue/_Process.py index 5f8ec7982..cee45b883 100644 --- a/python/pyrogue/_Process.py +++ b/python/pyrogue/_Process.py @@ -169,10 +169,11 @@ def _process(self): # No function run example process else: self.Message.setDisp("Started") + self.TotalSteps.set(100) for i in range(101): if self._runEn is False: break time.sleep(1) - self.Progress.set(i/100) + self._setSteps(i+1) self.Message.setDisp(f"Running for {i} seconds.") self.Message.setDisp("Done") diff --git a/python/pyrogue/_Variable.py b/python/pyrogue/_Variable.py index 06ea016c9..263d64715 100644 --- a/python/pyrogue/_Variable.py +++ b/python/pyrogue/_Variable.py @@ -31,11 +31,19 @@ def VariableWait(varList, testFunction, timeout=0): """ Wait for a number of variable conditions to be true. Pass a variable or list of variables, and a test function. - The test function is passed a dictionary containing the current - variableValue state index by variable path + The test function is passed a list containing the current + variableValue state indexed by position as passed in the wait list. + Each variableValue entry has an additional field updated which indicates + if the variable has refreshed while waiting. This can be used to trigger + on any update to the variable, regardless of value. + + i.e. w = VariableWait([root.device.var1,root.device.var2], + lambda varValues: varValues[0].value >= 10 and \ + varValues[1].value >= 20) + i.e. w = VariableWait([root.device.var1,root.device.var2], - lambda varValues: varValues['root.device.var1'].value >= 10 and \ - varValues['root.device.var1'].value >= 20) + lambda varValues: varValues[0].updated and \ + varValues[1].updated) Parameters ---------- @@ -53,13 +61,6 @@ def VariableWait(varList, testFunction, timeout=0): # Container class class varStates(object): - """ - - - - - """ - def __init__(self): self.vlist = odict() self.cv = threading.Condition() @@ -68,7 +69,6 @@ def __init__(self): def varUpdate(self,path,varValue): """ - Parameters ---------- path : @@ -84,6 +84,7 @@ def varUpdate(self,path,varValue): with self.cv: if path in self.vlist: self.vlist[path] = varValue + self.vlist[path].updated = True self.cv.notify() # Convert single variable to a list @@ -98,6 +99,7 @@ def varUpdate(self,path,varValue): for v in varList: v.addListener(states.varUpdate) states.vlist[v.path] = v.getVariableValue(read=False) + states.vlist[v.path].updated = False # Go into wait loop ret = False