Hello Guest it is April 22, 2021, 06:52:07 PM

Author Topic: more lua (?) questions  (Read 5371 times)

0 Members and 1 Guest are viewing this topic.

Re: more lua (?) questions
« Reply #10 on: May 02, 2017, 02:47:44 AM »
Hi Steve,

thank you for the additional calls. Works fine so far :)

When we deployed machines with PCs, be them test fixtures or some type of machine control, they were no longer treated as PCs.  If you used them for any other purpose than what they were put there to do, you were fired.  No questions asked.
I totally agree on that!

But I'm not a machinist, who learned programming, but a software developer who learned machinig. For so, we might have different points of view.
When I startet with software development, my tutor used to say: take care of your gui - one mouseclick wasted means hundreds of customers lost.
Related to the filename-issues he used to say: whenever I see something like that happen, I cut you off a finger.

So I had a hard start and became what I am ;)

by the way: do you use a lua-variant, that supports gettext?
If so, we could extract the user related texts to po-files. What you think about that?

... and what's in the screen-set file? Are the bitmaps part of the set-files? And the macros? Are they in the set-file or are they externally?
Or let me change the question: when I want to share my screen, what files do I have to include?

Offline smurph

  • *
  •  1,384 1,384
  • "That there... that's an RV."
    • View Profile
Re: more lua (?) questions
« Reply #11 on: May 02, 2017, 03:17:19 AM »
We use LUA 5.2.  i have no idea if it uses gettext or not.  :(

All of this stuff is also inside that screen set file.  Images, text, control properties, etc...  rename the .set to .zip and you will see it is just a zip archive.  The screen is implemented in an XML file which has all of the stuff embedded in it. 

Screens are meant to be user modified.  You can start with one of ours from the distribution.  However, you must name the screen set something different or it will get overwritten with an update!  All of the stuff that uses dialogs and regular OS provided controls like menus driven by the NLS po files.  But nothing in the screen set is at all unless it matched something in the po file accidently.  So most likely, you will need to supply German words for the button texts and stuff (codepage issues not withstanding).  None of the control property names are NLS either.

Macros CAN be external.  Most of the time in the Modules directory implemented as LUA modules.  The probing routines are an example of this.  Be careful modifying these as an update i likely to overwrite them as well. 

So to share a screen, most of the time, you would need to provide the screen set file AND any modules it may use.


Re: more lua (?) questions
« Reply #12 on: May 02, 2017, 03:21:24 AM »
Thanks for that info!
I'll keep on digging ;)
Re: more lua (?) questions
« Reply #13 on: May 02, 2017, 07:20:59 AM »

i did a simple test to identify strings containing invalid/unsupported charaters:
Code: [Select]
local chk1 = 'Hörst Du die Glöckchen?'
local chk2 = 'einRichtigLangerText'
local x = string.find(chk1, '%W+')
local y = string.find(chk2, '%W+')
local tx = type(x)
local ty = type(y)

if (tx ~= 'nil') then print('chk1 contains invalid characters') end
if (ty ~= 'nil') then print('chk2 contains invalid characters') end
This could be used with filenames and user input from textfields.

HTH Reinhard
Re: more lua (?) questions
« Reply #14 on: May 02, 2017, 10:49:01 AM »

The last line of the message in the ToolChangeMsg dialog is cut off, so I startet do search for the code.
I found it in mcMasterModule.lua - but I got messed up: wx.wxFont( ... ) is nothing I found in wx-docs. So what is this. Is it mach code, or is it lua?
I wonder, what happens with the dialog. There's plenty space down the last row, so who is responsible for the cutoff?

In ToolChangeMsg I found something like mc.mcProfileGetString(...) - is this related to gettext and po-files?
I changed the message text in the system load script, but if mcProfileGetString reads from mo-files, I revert my changes.

How can I get the sizes in the dialog right?

Offline smurph

  • *
  •  1,384 1,384
  • "That there... that's an RV."
    • View Profile
Re: more lua (?) questions
« Reply #15 on: May 02, 2017, 12:55:29 PM »
No, mc.mcProfileGetString() is a function to read the Machine.ini file settings in the machine profile.  For the rest, you will just have to study up on wxWidgets and Sizers. 


Offline DazTheGas

  •  753 753
  • DazTheGas
    • View Profile
Re: more lua (?) questions
« Reply #16 on: May 02, 2017, 02:50:42 PM »
Download a copy of wxFormbuilder, apart from creating forms and dialogs etc it is great source of learning wxLua by visualy creating something and browsing through the code. All code that is created in wxFormbuilder can be used in Mach4.

Theres always time for a choccy biccy
Re: more lua (?) questions
« Reply #17 on: May 02, 2017, 08:04:22 PM »
But how do we learn how to use wxformbuilder?  I have not been able to get started with it and have dropped back to just trying to copy Lua code from example programs.
and making better progress.  So far can't find a basic tutorial and can't seem to find a doc for wxformbuilder that is understandable.  All the docs are more like a dictionary. 
Isn't there something out there for the beginners to get us started?  How did you guys set started with wxformbuilder?  Staring at the code has not worked for me.  I seem
to be doing better with Lua itself and screens.
Re: more lua (?) questions
« Reply #18 on: May 03, 2017, 12:39:07 AM »
Yes, I treaten it wrong. Now I understood, that mcProfileGetString is used to determine, whether to show the toolchanger dialog.

Thanks for the hint about wxFormbuilder. I installed the linux-variant from github - which was straight forward.

starting the formbuilder shows up, that the builder is targeted to developers, that don't need it =:O
You need the wxWidgets docs. The key of wxWindows are the sizers - when you got that, the rest is straight forward.
But of cause, building gui with formbuilder is not as easy as java gui :)

anyway - I got it and I'm quite content with my new toolchanger dialog (see picture below)
My changes are - small changes to Mc Master:
Code: [Select]
--M6 message box
UI.MyFrame1 = wx.wxDialog (wx.NULL, wx.wxID_ANY, tostring(m_title), wx.wxDefaultPosition, wx.wxSize( 620, 270 ), wx.wxCAPTION + wx.wxCLOSE_BOX + wx.wxSTAY_ON_TOP + wx.wxSYSTEM_MENU+wx.wxTAB_TRAVERSAL )
UI.MyFrame1:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )
UI.MyFrame1 :SetBackgroundColour( wx.wxSystemSettings.GetColour( wx.wxSYS_COLOUR_3DLIGHT ))
UI.fgSizer1 = wx.wxFlexGridSizer( 2, 1, 0, 0 )
UI.fgSizer1:AddGrowableCol( 0 )
UI.fgSizer1:AddGrowableRow( 0 )
UI.fgSizer1:SetFlexibleDirection( wx.wxBOTH )
UI.fgSizer1:SetNonFlexibleGrowMode( wx.wxFLEX_GROWMODE_ALL )

UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )

UI.m_staticText1 = wx.wxStaticText( UI.MyFrame1, wx.wxID_ANY, tostring(m_message), wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxALIGN_CENTRE )
UI.m_staticText1:Wrap( -1 )
UI.m_staticText1:SetFont( wx.wxFont( 18, wx.wxFONTFAMILY_DEFAULT, wx.wxFONTSTYLE_NORMAL, wx.wxFONTWEIGHT_NORMAL, False, "" ) )

UI.bSizer1:Add( UI.m_staticText1, 0, wx.wxALIGN_CENTER + wx.wxEXPAND, 5 )

UI.fgSizer1:Add( UI.bSizer1, 1, wx.wxEXPAND, 5 )

UI.bSizer2 = wx.wxBoxSizer( wx.wxVERTICAL )

UI.m_okay = wx.wxButton( UI.MyFrame1, wx.wxID_ANY, "Ok", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.bSizer2:Add( UI.m_okay, 0, wx.wxALL, 5 )

UI.fgSizer1:Add( UI.bSizer2, 1, wx.wxALIGN_CENTER_HORIZONTAL, 5 )

UI.MyFrame1:SetSizer( UI.fgSizer1 )
UI.MyFrame1:Centre( wx.wxBOTH )

-- Connect Events
UI.m_okay:Connect( wx.wxEVT_LEFT_UP, function(event)
        end ) -- end of m_okay:Connect() !

return UI;
and some changes to the screen startup code (signal array):
Code: [Select]
--M6 messagebox
[mc.OSIG_TOOL_CHANGE] = function (state)
    local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)

if (selectedtool ~= currenttool) then
        if( state == 1) then
            local tmp = mc.mcToolGetDesc(inst, selectedtool)
            mm.ToolChangeMsg('\n Ein Werkzeugwechsel wurde mit M6 angefordert. \nBitte das folgende Werkzeug einlegen:\n\n#' .. selectedtool .. '\t>>' .. tmp .. '<< ' .. '\n\n und mit Druck auf \"Start\" Verarbeitung fortsetzen!', 'Werkzeugwechsel im Gange!')
Re: more lua (?) questions
« Reply #19 on: May 03, 2017, 02:00:52 AM »

I have a strange error:
I can't switch to tab "man. Fahrt" by property call. I already renamed the tab, but no way. Stepping through debugger raises no error, but doesn't change gui either.
I wanted to synchronize the little notebook with the main notebook in that way, that when I activate the "Einrichten" tab, the "man. Fahrt" tab should be active. When I activate "GCode ausführen" tab, then the "Maschine" tab should be active.
The strange thing is, synchronization works for GCode page, but not for "Einrichten" page.

Any idea how I could narrow the bug?