Hello everybody,
I am currently implementing PID function on my blacs driver for a MOG Labs QRF.
I managed to set up its PID settings through blacs tabs and I am trying now to display in real time the PID error function that can me asked through command line.
In my main_worker I am already able to write the result down on my terminal window but I am wondering if there is a strategy that lets me display the value in a more GUI version.
I tried to set up a slider whose position is changed continously trhough the reading of the error signal but two problems arose:
- my real time idea was to exploit while-ish loop that are not much liked by blacs.
- result to yield(....self.dev.ask()) is not giving me nothing but 'None'.
Should I set a general property such as self.....errorSignal that I can call to set the slider position or is there any better option?
I leave you pieces of code to understand better what i am trying to do.:
def display_errorSignal(self):
if not self.error_display:
self.ui.pushButton_errorSignal.setIcon(self.stop_icon)
self.error_display = True
while True:
signal=self.parent.event_queue.put(allowed_states=MODE_MANUAL, queue_state_indefinitely=True, delete_stale_states=False,
data=[self._display_errorSignal, [[self.channel], {}]])
if signal is not None:
self.ui.slider_ErrorSignal.setSliderPosition(signal)
time.sleep(0.5)
else:
self.ui.slider_ErrorSignal.setSliderPosition(0)
break
else:
self.ui.pushButton_errorSignal.setIcon(self.start_icon)
self.error_display = False
self.ui.slider_ErrorSignal.setSliderPosition(0)
def _display_errorSignal(self, parent, channel):
result = yield( self.parent.queue_work(self.parent.primary_worker,'errorPID', channel) )
self.ErrorSignal=result
return result
---------------------------------------------------------------------------------
def errorPID(self, channel):
# Andre: returns the value of the error signal fed into the PID control loop, for diagnostic purposes
result = self.dev.ask('PID, ERROR, %i' % (channel + 1))
value = float(result[0:4])
print(f'displaying error signal: {value}')
return value
Thank you all for the attention and in case for the help.
Best,
Andre