Retrieving parameters values

More
20 May 2025 18:25 #328820 by Hastrh2o
Retrieving parameters values was created by Hastrh2o
Hi,

I'm trying to retrieve several numbered parameters, but with a minimum of hal widgets. I know I should have tried to build a custom widget, but I never did it and thought it would be easier this way. I changed my point of view (using one hal widget per parameter), but I would like to know how this should have been written :
        ACTION.CALL_MDI("M68 E5 Q#1203")
        while not STATUS.is_interp_idle():
            time.sleep(0.1)
        self.w.paramEdit_MG_D.setText("{:3.1f}".format(self.w.lcdnumber.value()))
        ACTION.CALL_MDI("M68 E5 Q#1204")
        while not STATUS.is_interp_idle():
            time.sleep(0.1)
        self.w.paramEdit_MD_D.setText("{:3.1f}".format(self.w.lcdnumber.value()))

In postgui.hal I have :
net multivar   grimmui.lcdnumber <= motion.analog-out-05

The code is running, but don't do what I want. It seems lcdnumber.value() is not updated fast enough to have paramEdit_MD_D updated with the right text, both paramEdit_MG_D and paramEdit_MD_D are receiving the same text. The " while not STATUS.is_interp_idle():" does nothing.

Thanks

Please Log in or Create an account to join the conversation.

More
21 May 2025 02:14 #328840 by cmorley
Replied by cmorley on topic Retrieving parameters values
I'm assuming this is just test code, as you could just set the paramEdit directly (based on the code you showed)

Typically I would use a callback (changed signal) from the lcdnumber or better yet a plain HAL pin to update paramEdit_MG_D.

while not STATUS.is_interp_idle(): might be better to try :
STATUS.cmd.wait_complete()

As an alternative you could use the HAL module to read the pins directly:
value = hal.get_value("motion.analog-out-05")

Please Log in or Create an account to join the conversation.

More
22 May 2025 10:46 - 22 May 2025 10:48 #328902 by Hastrh2o
Replied by Hastrh2o on topic Retrieving parameters values
What do you mean by "you could just set the paramEdit directly " ?

STATUS.cmd.wait_complete() doesn't solve my problem.

I tried (in a button_click callback) :

ACTION.CALL_MDI("M68 E4 Q#1217")
while not STATUS.cmd.wait_complete():
time.sleep(0.1)
self.w.doubleSpinBox_DJG.setValue(self.w.lcdnumberDJ.value())

and I have to click twice to see lcdnumberDJ updated

So I try

ACTION.CALL_MDI("M68 E4 Q#1217")
time.sleep(2)
self.w.doubleSpinBox_DJG.setValue(self.w.lcdnumberDJ.value())

I watch motion.analog-out-04 in halshow at the same time, I see it changing immediatly when I click and then lcdnumberDJ appearing 2s later but without being updated. I click a second time and it works.
Do you know why ? I surely need to call some process_message like function between .. ?
Last edit: 22 May 2025 10:48 by Hastrh2o.

Please Log in or Create an account to join the conversation.

Moderators: cmorley
Time to create page: 0.070 seconds
Powered by Kunena Forum