Hello Guest it is March 28, 2024, 09:12:50 AM

Author Topic: Anyone know how to select tabs with an external input signal?  (Read 1338 times)

0 Members and 1 Guest are viewing this topic.

hello,
Anyone know how/code to select tabs with an external input signal?
trying to setup new screen with external physical buttons to select different tabs
any help appreciated

Regards 
Amyl
Re: Anyone know how to select tabs with an external input signal?
« Reply #1 on: March 21, 2020, 02:05:00 AM »
Sorry not sure if posting in right place ???
Using mach4 is it possible to implement this in the signal script?
eg
[mc.ISIG_INPUT3] = function (state)
  IF  (state == 1) then
  change  tab to Machine Diagnostics tab/window :)
 end
end

no idea if selecting tabs is implemented in the core or if even possible any ideas?
 
Re: Anyone know how to select tabs with an external input signal?
« Reply #2 on: March 21, 2020, 05:06:48 AM »
maybe to be more specific
is it possible to change variable  "Current Tab"  in Properties in Main Tabs in the Screen Tree Manager
with a series of mc.ISIG_INPUT functions?
is there a handle for Current Tab?

just trying to learn here
cheers
Re: Anyone know how to select tabs with an external input signal?
« Reply #3 on: March 21, 2020, 07:45:54 PM »
Hi,
I don't know if its possible, and certainly if it is I don't know how...at the moment.

I would guess that it is possible and probably not too difficult....once you have determined how.

All I can do at the moment is show what I have found and hope that I or others can furnish other ideas until a
solution is reached.

My investigations to date are in the pics attached. All of these screenshots were take while in screen edit mode and
also I undocked the ScreenTreeManager so that the screenshot contained all the relevant images.
The first screen shot is the MainTabs entry of the ScreenTree and noice the Properties, particularly the
DefaultTab and the CurrentTab, both 0.
The second screen shot is when the ProgramExtentsTab is displayed and note now that the MainTabs properties have
changed such that the DefaultTab is still 0 but the CurrentTab=1.
The third screen shot is when the MachineDiagnostiicsTab is displayed and note how the MainTabs properties
have changed again such that the DefaultTab is still 0 but the CurrentTab=2.
The last screenshot follows the same pattern, namely that the tab displayed is ProbingTab and the CurrentTab property
is  3.

I conclude that:
CurrentTab=0 means ProgramRunTab
CurrentTab=1 means ProgramExtentsTab
CurrentTab=2 means ProbingTab

and by extension:
CurrentTab=4 means OffsetsTab
CurrentTab=5 means SurfaceTab

So it looks to me that there is a variable OR a property 'CurrentTab' which if we could manipulate it programmatically
would allow you to achieve what you want.

So the research continues into indentifying the variable and/or property of 'CurrentTab'. If anyone knows anything about
it please chime in.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Anyone know how to select tabs with an external input signal?
« Reply #4 on: March 21, 2020, 10:00:54 PM »
Hi
Thanks for taking the time to reply much appreciated !!
This is also what i have figured out and if you change Current Tab variable (in Properties) it will select
different tabs .
thanks for the sense of direction that might be looking for a property
Im new to lua and trying to teach myself

 Im using mach4 hobby , anyone know if this is an industrial mach4
feature? maybe not implemented in hobby ?
 
Best Regards
Amyl 
Re: Anyone know how to select tabs with an external input signal?
« Reply #5 on: March 21, 2020, 10:12:24 PM »
Maybe something along the lines of

scr.SetProperty('MainTabs', 'Current Tab', '0')

stolen from:
 https://www.machsupport.com/forum/index.php?topic=30831.0

DazTheGas post

if this is correct how or were to implement this anyone have any idea?

[mc.ISIG_INPUT3] = function (state)
  IF  (state == 1) then
       scr.SetProperty('MainTabs', 'Current Tab', '3')
  end
end
Re: Anyone know how to select tabs with an external input signal?
« Reply #6 on: March 21, 2020, 10:39:49 PM »
wow this acturaly works  cool
 
put it in screen load script simple ! not sure if its the most efficient
way but it works hehe

[mc.ISIG_INPUT3] = function (state)
  IF  (state == 1) then
       scr.SetProperty('MainTabs', 'Current Tab', '3')
  end
end
Re: Anyone know how to select tabs with an external input signal?
« Reply #7 on: March 21, 2020, 11:30:39 PM »
Hi,
excellent work!

As if often the case once you have devised a strategy for achieving a particular goal the actual coding
of it is trivial.

As a matter of programming style; directly using the 'scr.*********' table is not recommended. In most cases there is
an API or Mach variable that is 'exposed' for the purpose of customization...not withstanding the the scr.********* functions
can do the job. That is Smurph's recommendation anyway.

I myself am rather mystified by the syntax of the scr.********* table. I did find and post a list of the table entries:
https://www.machsupport.com/forum/index.php?topic=40051.msg271116#msg271116

Smurph has rather pointedly reminded us all to avoid many of the functions contained therein.

In this instance however you are using one of the basic and popular scr.********* functions and should be OK. The fact that
you have used the SigLib{} table speaks very well of the effort to learn Mach/Lua. Most newcomers settle for 'polling'
an input in the PLC script. The SigLib{} approach is FAR more elegant.

I too use Mach4Hobby but am not aware that MachIndustrial has any extra features related to this thread. Although I do
now recall that Mach4Industrial does make use of some of the scr.********* functions for a specific editing purpose....
although the details escape me. That's the good thing about Alzhiemer's...your always meeting some new!

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Anyone know how to select tabs with an external input signal?
« Reply #8 on: March 22, 2020, 02:50:16 AM »
haha
 yeah but its impossible until it works

would you be so kind to explain what you meant by :

"..not withstanding the the scr.********* functions
can do the job. That is Smurph's recommendation anyway."

does that mean if you don't understand you shouldn't mess with it?

whats the danger in using the scr*** table  directly   ?

do you mean an  API or Mach variable being "exposed" as in being readily available/ easy  to find/ apparent ?

Thanks for the kind words, but to be perfectly honest I'm far from knowing whats elegant and have zero programming style ;)
only the need to make it work, preferably  efficiently , and well  not break anything , can only hope i guess
 
I have read  somewhere (might have even been a manual :o  ) about "if statements slowing down the plc script and
the SigLib{} approach is the better answer, if i make lots of functions in the SigLib{} will that mess things up too? any limits there ?

surprising the person who replied to my message is local
also thanks for the link theres some great info there
no idea what a Enums is

cheers
Amyl
« Last Edit: March 22, 2020, 02:58:25 AM by habituralcnc »
Re: Anyone know how to select tabs with an external input signal?
« Reply #9 on: March 22, 2020, 05:08:43 AM »
Hi,
Quote
does that mean if you don't understand you shouldn't mess with it?

No, there is no danger per se in using the functions but rather there are better ways (normally) to do the same
thing.

Quote
do you mean an  API or Mach variable being "exposed" as in being readily available/ easy  to find/ apparent ?

As an example, you will no doubt have seen in the Enums and Pound variable lists the specific location/name of
the variable containing the current axis positions. You could read that memory location and get the data. However the
correct way to do so is with the mcAxisGetMachinePos() API. No doubt internal to Mach the API function reads and
returns the same Pound variable. If however the location of that variable changes, say in a more recent build, the code that
you used to read the data direct is now broken whereas the API would still work given that the API would be self consistent
with the new build.

The API mcAxisGetMachinePos() is a function that is 'exposed' so that a user might use it rather than the more direct method.
The same applies with the scr.********* functions. The manipulation of screen elements can be done with them directly but
preference is given to the APIs which 'expose' the same functionality.

Does that mean that the APIs are easy to find? Well they are documented, mostly, and mostly up to date, but they are
documented. It is true there are hundreds of APIs and it takes a lot of learning to be able to recognize and use them at will,
but they are not hidden.

Quote
if statements slowing down the plc script and
the SigLib{} approach is the better answer, if i make lots of functions in the SigLib{} will that mess things up too? any limits there ?

No, not really, any function or code you put in the SigLib{} table will only ever be executed IF the entry
matches the variable 'sig'. Consequently all those extra funtions add zero processing overhead beyond the
entry matching test. It is indeed this feature that makes the SigLib{} such an elegant solution.

Quote
no idea what a Enums is

An Enum is short for 'enumerator'. For example mc.mcISIG_INPUT4 is actually a number, in fact the number 3, being
the (0, 1, 2) 3rd input. Much easier for humans to remember ISIG_INPUT4 than a plain old '3'. When the code is
compiled the compiler will substitute the number for the Enum, but that detail is not apparent to us for all its importance
to the computer running the code.

Quote
surprising the person who replied to my message is local

Should I assume you are in Canterbury somewhere? I used to live in Akaroa and had done for many years but have
shifted recently to Selwyn Huts on the shore of Lake Elesmere.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'