Hello Guest it is March 29, 2024, 11:20:53 AM

Author Topic: Mach 4 Bar Graph Display Element and Registers  (Read 1008 times)

0 Members and 1 Guest are viewing this topic.

Mach 4 Bar Graph Display Element and Registers
« on: April 20, 2019, 07:25:04 PM »
Another question for everyone. I have written a serial script that is able to monitor the spindle load of my machine in real time. I'd like to add a bar graph in the spindle area which follows the value of the load, preferably colored green for 0-100%, yellow for 100-150%, and red for 150%-250%.

The bar chart display object looks perfect for what I am trying to do, but I cannot figure out a way to get to the value saved in my global register. It looks like it supports only Mach 4 internal values. Is this accurate? If so, would there be a possibility of expanding the functionality of this object in the future? Are there any workarounds to accomplish what I am trying to do? Thanks much!
Re: Mach 4 Bar Graph Display Element and Registers
« Reply #1 on: April 24, 2019, 09:12:02 AM »
Just wanted to follow up on this post. I am still unsure if there is a way to interface with this object (or the rotary gauge either) for non system variables. If anyone has a way to do this I would be very interested.

Also the only way I know to display the data from my global register is a DRO. If there is any other elegant solution for showing this data, please let me know!
Re: Mach 4 Bar Graph Display Element and Registers
« Reply #2 on: April 24, 2019, 09:15:11 AM »
Would it be possible to add a wx.wxGauge to the screen? I can programmatically set the value of this, but I have no idea if Mach 4 allows use of graphics from the wxWidgets library that are not built in.
Re: Mach 4 Bar Graph Display Element and Registers
« Reply #3 on: April 25, 2019, 04:24:38 AM »
Are you not able to select the Register from the properties menu for the gauge control? (see attachment)

If you have not yet created a register, with mach disabled go to Configure>Plugins>Regfile and then add a new instance register and then restart mach. This will appear within the iRegs0 menu when you go to Diagnostics>Regfile. This will also appear in the Register property dropdown for the gauge control. You will need to write a value to the register for the gauge to update.

Alternatively you can use the scr.SetProperty which is used for modifying GUI controls
e.g.
Code: [Select]
scr.SetProperty('gau(1)', 'Value', '10')
Any control property can be edited using this, but it is always advisable to set values etc. using the proper methods.

You can also use wx.wxGauge, but this would required a lua panel if you want to embed it in the screen and gets a bit more confusing..
Re: Mach 4 Bar Graph Display Element and Registers
« Reply #4 on: April 25, 2019, 08:40:39 AM »
Very interesting....

When I open the properties for either a bar gauge or the crescent gauge, I only see the option "code". If I could get to what you are seeing then this would be perfect!

I do have the value in my regfile -> global register. Should this be in the instance section? I'm not sure I understand the difference. Either way, I have been able to read and write to the register.

Which version of Mach 4 are you using? I am at the last fully supported 3884, but I see now that the recommended download has been updated to 4162 so I will change to that.

I figured that would be the case about the wxGauge and would like to avoid LUA panels for the time being.

Thanks for your thoughts and time!

Re: Mach 4 Bar Graph Display Element and Registers
« Reply #5 on: April 25, 2019, 10:29:42 PM »
Upgraded from 3884 to 4162 and the options to tie the bar gauge to a register is now there! Problem solved. Thanks