Mach Modules Documentation
Lua Module API Documentation
Loading...
Searching...
No Matches
MillGUIModule.lua File Reference

Go to the source code of this file.

Functions

MillGUIModule ScreenLoadScript ()
 Execute mill module initialization tasks when the screen Lua environment first loads.
MillGUIModule StartUpScript ()
 Execute mill-specific startup initialization after the screen has loaded.
MillGUIModule ConfigureToolSizeEntryMode ()
 Read the ToolSizeEntryMode OEM parameter and apply it to the tool size entry configuration.
MillGUIModule PLCScript ()
 Execute periodic PLC cycle updates for the mill screen.
MillGUIModule LowPriorityLoop ()
 Execute low-priority periodic updates for the mill screen.
MillGUIModule RetractDialog ()
 Display a modal dialog for the user to select a retract position and return the selection.
UI CloseDialog ()
 Save the current radio box selection and destroy the retract positions dialog.
MillGUIModule IsRetractActive ()
 Check if the retract dialog should be shown and process the user's position selection.
MillGUIModule InitializeToolChangers ()
 Initialize tool changer outputs and configure GMS monitors for spindle and air pressure.
MillGUIModule UpdateToolReleaseButtonIndicator ()
 Update the TC_ToolReleaseButtonIndicatorOutput signal based on current machine state.
MillGUIModule MachineSpindleStateChanged ()
 Update the tool release button indicator output when the spindle state changes.
MillGUIModule InitializeSpindleToolRelease ()
 Configure the TC_ToolReleaseButtonIndicatorOutput signal to be ignored during disable and stop events.
MillGUIModule ToolReleaseButtonInputChanged (sig_state, idx, inst)
 Handle a change in the tool release button input signal state.

Function Documentation

◆ CloseDialog()

UI CloseDialog ( )

Save the current radio box selection and destroy the retract positions dialog.

Reads the currently selected position index from the radio box, writes it to the MachMotion profile under "LastGoToRetractPositionType" so it is restored on the next dialog open, stops the dialog's timer if running, and destroys the dialog window.

Note
This is a closure defined inside RetractDialog() and captures the UI table by upvalue
Documentation generated by AI on 2026-03-03

◆ ConfigureToolSizeEntryMode()

MillGUIModule ConfigureToolSizeEntryMode ( )

Read the ToolSizeEntryMode OEM parameter and apply it to the tool size entry configuration.

Retrieves the "ToolSizeEntryMode" OEM parameter string value. If the parameter is found, calls m.SetToolSizeEntryMode() with the retrieved value using a protected call (w.pcall). If SetToolSizeEntryMode() raises an error, the error is logged to the Mach4 controller log via mc.mcCntlLog() with the context identifier "MillGUIModule".

Note
Documentation generated by AI on 2026-03-03

◆ InitializeSpindleToolRelease()

MillGUIModule InitializeSpindleToolRelease ( )

Configure the TC_ToolReleaseButtonIndicatorOutput signal to be ignored during disable and stop events.

If the TC_ToolReleaseButtonIndicatorOutput OEM parameter signal is mapped, adds it to the output ignore list for IgnoreOutputsOnDisable, IgnoreOutputsOnStop, and IgnoreOutputsOnEmergencyStop events. This prevents the indicator output from being automatically deactivated when the machine is disabled or stopped.

Note
Documentation generated by AI on 2026-03-03

◆ InitializeToolChangers()

MillGUIModule InitializeToolChangers ( )

Initialize tool changer outputs and configure GMS monitors for spindle and air pressure.

Performs the following initialization steps:

  1. Adds TC_DustCoverOutput, TC_CarouselParkedOutput, and TC_CarouselEngagedOutput (and indexed variants) to the output ignore list for disable, stop, and emergency stop events.
  2. If TC_EnableToolInSpindleGMSMonitoring is "Yes", creates a Global Message System (GMS) alarm titled "Spindle On without Tool Locked!" that fires when the spindle turns on without a tool locked. Monitored signals include TC_ToolInSpindleInput, TC_ToolLockedInput, and TC_DrawBarUnClampOutput (and indexed variants).
  3. If TC_AirPressureInput is mapped, creates a GMS warning titled "Low Air Pressure" that fires when the input is high and the machine is enabled. GMS monitors are only created if they do not already exist (checked by title).
    Note
    Documentation generated by AI on 2026-03-03

◆ IsRetractActive()

MillGUIModule IsRetractActive ( )

Check if the retract dialog should be shown and process the user's position selection.

Checks the RetractEnabled and RetractGoToPositionEnabled OEM parameters. If both are "Yes", monitors the RetractDialog OEM register. When the register value is "OpenRetactDialog" (note: original spelling retained), opens the RetractDialog() to let the user select a retract position, then writes the selected position name back to the RetractDialog register so that M235 can act on the user's choice. This function is called from PLCScript on every PLC cycle.

Returns
(nil) No primary return value
(boolean) False if an OEM parameter lookup fails, true otherwise
(string) Status message - error detail, "Retract is disabled", or "IsRetractActive Completed"
Note
This function is interlocked with M235 via the RetractDialog OEM register
Documentation generated by AI on 2026-03-03

◆ LowPriorityLoop()

MillGUIModule LowPriorityLoop ( )

Execute low-priority periodic updates for the mill screen.

Called on a low-priority loop to perform UI refresh tasks that do not need to run every PLC cycle. Performs the following updates:

  • Updates the tool offset DRO background colors to indicate active offsets via m.screen.UpdateToolOffsetDROColors()
  • Refreshes the tool release button indicator output via m.UpdateToolReleaseButtonIndicator()
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineSpindleStateChanged()

MillGUIModule MachineSpindleStateChanged ( )

Update the tool release button indicator output when the spindle state changes.

Called as a hook when the machine spindle state changes. Delegates to UpdateToolReleaseButtonIndicator() to refresh the TC_ToolReleaseButtonIndicatorOutput signal.

Returns
(nil) No primary return value
(boolean) Always true
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ PLCScript()

MillGUIModule PLCScript ( )

Execute periodic PLC cycle updates for the mill screen.

Called every PLC cycle to perform real-time UI and machine state updates. Performs the following tasks:

  • Updates the tool verify DRO via m.UpdateToolVerifyDRO()
  • Updates feedrate text and DRO labels via m.screen.UpdateFeedrateDROLabels()
  • Checks whether the retract dialog should be opened via m.IsRetractActive()
    Note
    Documentation generated by AI on 2026-03-03

◆ RetractDialog()

MillGUIModule RetractDialog ( )

Display a modal dialog for the user to select a retract position and return the selection.

Retrieves the list of configured go-to positions via w.GetConfiguredGoToPositions(). If no positions are configured, substitutes a placeholder entry. Builds a radio box dialog presenting the configured position names and restores the last selection from the MachMotion profile key "LastGoToRetractPositionType". The dialog includes "Move" and "Stay" buttons:

  • "Move": closes the dialog and returns the selected position name
  • "Stay": sets the selection to "Do Not Move" and closes the dialog A timer polls every 200 ms to close the dialog automatically if Mach is shutting down or if the stop status is no longer active. The inner closure UI.CloseDialog() saves the current radio box selection to the profile before destroying the dialog window.
    Returns
    (string) The name of the selected retract position, or "Do Not Move" if the user chose Stay
    (boolean) Always true
    (string) Status message from w.FunctionCompleted()
    Note
    Documentation generated by AI on 2026-03-03

◆ ScreenLoadScript()

MillGUIModule ScreenLoadScript ( )

Execute mill module initialization tasks when the screen Lua environment first loads.

Called once when the screen script is first loaded. Performs the following tasks:

  1. Sets the SVN version strings for the MillGUIModule using w.SetVersionStrings()
  2. Initializes the spindle tool release indicator via m.InitializeSpindleToolRelease()
  3. Registers the CreateMillPreCannedCommands function with the CommandRegistrar so that mill-specific pre-canned commands are populated during system initialization
    Note
    Documentation generated by AI on 2026-03-03

◆ StartUpScript()

MillGUIModule StartUpScript ( )

Execute mill-specific startup initialization after the screen has loaded.

Called during the startup sequence to configure mill hardware and UI elements. Performs the following initialization steps in order:

  1. Configures the tool size entry mode via m.ConfigureToolSizeEntryMode()
  2. Initializes tool changers via m.InitializeToolChangers()
  3. Configures the conversational button via m.screen.ConfigureConversationalButton()
  4. Configures the tool length measurement (TLM) mode via m.ConfigureTLMMode()
  5. Adds spindle rotation column to the tool table via m.AddSpindleRotationToToolTable()
  6. Adds ignore auto tool setter column to the tool table via m.AddIgnoreAutoToolSetterToToolTable()
  7. Adds tool size column to the tool table via m.AddToolSizeToToolTable()
  8. Adds tool path color columns to the tool table via m.AddToolPathColorsToToolTable()
  9. Adds tool setter offset column to the tool table via m.AddToolSetterOffsetToToolTable()
  10. Adds tool changer override column to the tool table via m.AddToolChangerOverrideToToolTable()
    Note
    Documentation generated by AI on 2026-03-03

◆ ToolReleaseButtonInputChanged()

MillGUIModule ToolReleaseButtonInputChanged ( sig_state ,
idx ,
inst  )

Handle a change in the tool release button input signal state.

Called when the TC_ToolReleaseButtonInput signal changes state. On a rising edge (sig_state true), calls ToolRelease() to open the draw bar. On a falling edge (sig_state false), calls ToolClamp() to close the draw bar. The idx parameter identifies which spindle's button input triggered the event.

Parameters
sig_state(boolean) The new state of the tool release button input signal
idx(number) The spindle index associated with the button that changed state
inst(number) The Mach4 instance handle. If not provided, uses selected instance
Note
Documentation generated by AI on 2026-03-03

◆ UpdateToolReleaseButtonIndicator()

MillGUIModule UpdateToolReleaseButtonIndicator ( )

Update the TC_ToolReleaseButtonIndicatorOutput signal based on current machine state.

If the TC_ToolReleaseButtonIndicatorOutput OEM parameter signal is mapped, computes the desired indicator state and updates the output only if it has changed. The indicator is active (true) when all of the following conditions are met:

  • Machine is enabled
  • Spindle is not on
  • SpindleDelayActive register is 0
  • Machine state is one of: IDLE, FRUN_MACROH, FRUN_MACROH_JOG, MRUN_MACROH, or MRUN_MACROH_JOG Also updates any indexed variants (TC_ToolReleaseButtonIndicatorOutput2, etc.) if they exist and are mapped.
    Note
    This function is called from PLCScript and LowPriorityLoop to keep the indicator in sync
    Documentation generated by AI on 2026-03-03