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

Go to the source code of this file.

Functions

GrinderDiskScreenV01 MachineScreenLoadScript ()
 Initialize the grinder disk screen on load.
GrinderDiskScreenV01 MachineScreenUnloadScript ()
 Perform cleanup actions when the grinder disk screen is unloaded.
GrinderDiskScreenV01 MachineScreenPLCScript ()
 Periodic PLC update loop executed every Mach4 screen cycle.
GrinderDiskScreenV01 MachineScreenLowPriorityLoop ()
 Low-priority periodic update loop for the grinder disk screen.
GrinderDiskScreenV01 EnterTab (tab)
 Perform setup actions when entering a grinder tab.
GrinderDiskScreenV01 ExitTab (tab)
 Perform cleanup actions when leaving a grinder tab.
GrinderDiskScreenV01 IsManualModeActive ()
 Check whether the screen is currently in Manual mode.
GrinderDiskScreenV01 IsThruFeedModeActive ()
 Check whether the screen is currently in ThruFeed mode.
GrinderDiskScreenV01 IsOscillatorModeActive ()
 Check whether the screen is currently in Oscillator mode.
GrinderDiskScreenV01 IsDressModeActive ()
 Check whether the screen is currently in Dress mode.
GrinderDiskScreenV01 HideMachMenu ()
 Hide the Mach4 menu bar and persist the preference to the profile.
GrinderDiskScreenV01 ShowMachMenu ()
 Show the Mach4 menu bar and persist the preference to the profile.
GrinderDiskScreenV01 ConfigureMachMenu ()
 Apply the saved Mach menu visibility preference at startup.
GrinderDiskScreenV01 ToggleMachMenu ()
 Toggle the Mach4 menu bar between visible and hidden states.
GrinderDiskScreenV01 SetGrindAmount (Amount)
 Set the grind amount by writing a value to pound variable #516.
GrinderDiskScreenV01 UpdateGrindAmountBtn ()
 Update the grind amount button highlight to reflect the current pound variable value.
GrinderDiskScreenV01 IsMDIModeActive ()
 Check whether the screen is currently in MDI mode.
GrinderDiskScreenV01 GetMDIControlName ()
 Return the name of the MDI input control used on the Operations page.
GrinderDiskScreenV01 LoadJob ()
 Load the last used job file at screen startup.
GrinderDiskScreenV01 JobOpen ()
 Open a job file selected by the operator via a file dialog.
GrinderDiskScreenV01 JobClose ()
 Close the current job file, optionally saving changes first.
GrinderDiskScreenV01 JobSave ()
 Save the current job file to its existing path.
GrinderDiskScreenV01 JobSaveAs ()
 Save the current job file under a new name via a Save As dialog.

Function Documentation

◆ ConfigureMachMenu()

GrinderDiskScreenV01 ConfigureMachMenu ( )

Apply the saved Mach menu visibility preference at startup.

Reads the HideMachMenu integer from the MachMotion profile. If the stored value is 0 the menu is shown; otherwise it is hidden. Called during screen load to restore the operator's previous menu visibility preference.

See also
GrinderDiskScreenV01.HideMachMenu()
GrinderDiskScreenV01.ShowMachMenu()
Note
Documentation generated by AI on 2026-03-03

◆ EnterTab()

GrinderDiskScreenV01 EnterTab ( tab )

Perform setup actions when entering a grinder tab.

For tabs 0 and 3 (Manual and Dress), sets ContBitData bit 2 via Modbus to enable the dresser jog buttons on the PLC side. For tabs 1 and 2 (ThruFeed and Oscillator), activates output signal OSIG_OUTPUT63. Displays a message box if the Modbus SetBit operation fails.

Parameters
tab(number) The tab index being entered (0 = Manual, 1 = ThruFeed, 2 = Oscillator, 3 = Dress)
Note
Documentation generated by AI on 2026-03-03

◆ ExitTab()

GrinderDiskScreenV01 ExitTab ( tab )

Perform cleanup actions when leaving a grinder tab.

Resets the grind amount to 0 via SetGrindAmount(). For tabs 0 and 3 (Manual and Dress), clears ContBitData bit 2 to disable the dresser jog buttons on the PLC side. For tabs 1 and 2 (ThruFeed and Oscillator), deactivates output signal OSIG_OUTPUT63. Displays a message box if the Modbus ClearBit operation fails.

Parameters
tab(number) The tab index being exited (0 = Manual, 1 = ThruFeed, 2 = Oscillator, 3 = Dress)
Note
Documentation generated by AI on 2026-03-03

◆ GetMDIControlName()

GrinderDiskScreenV01 GetMDIControlName ( )

Return the name of the MDI input control used on the Operations page.

Returns
(string) The screen object name of the MDI input control ("MDILine(1)")
(boolean) Success flag - always true
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ HideMachMenu()

GrinderDiskScreenV01 HideMachMenu ( )

Hide the Mach4 menu bar and persist the preference to the profile.

Calls scr.ShowMenu(false) to hide the Mach4 menu bar, then writes 1 to the HideMachMenu key in the MachMotion profile so the preference is restored on the next screen load.

See also
GrinderDiskScreenV01.ShowMachMenu()
GrinderDiskScreenV01.ConfigureMachMenu()
Note
Documentation generated by AI on 2026-03-03

◆ IsDressModeActive()

GrinderDiskScreenV01 IsDressModeActive ( )

Check whether the screen is currently in Dress mode.

Returns true when the global CURRENT_MODE equals 3, which corresponds to the Dress tab (tab index 3) of the GrinderTabs control. CURRENT_MODE is updated every low-priority loop cycle from the active tab.

Returns
(boolean) True if Dress mode is active (CURRENT_MODE == 3), false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsManualModeActive()

GrinderDiskScreenV01 IsManualModeActive ( )

Check whether the screen is currently in Manual mode.

Returns true when the global CURRENT_MODE equals 0, which corresponds to the Manual tab (tab index 0) of the GrinderTabs control. CURRENT_MODE is updated every low-priority loop cycle from the active tab.

Returns
(boolean) True if Manual mode is active (CURRENT_MODE == 0), false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsMDIModeActive()

GrinderDiskScreenV01 IsMDIModeActive ( )

Check whether the screen is currently in MDI mode.

Returns true only when the operator is on page 1 (Operations page) and has tab index 2 (MDI tab) selected in the OperationsTabs control. Both conditions must be satisfied simultaneously for MDI mode to be considered active.

Returns
(boolean) True if MDI mode is active, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsOscillatorModeActive()

GrinderDiskScreenV01 IsOscillatorModeActive ( )

Check whether the screen is currently in Oscillator mode.

Returns true when the global CURRENT_MODE equals 2, which corresponds to the Oscillator tab (tab index 2) of the GrinderTabs control. CURRENT_MODE is updated every low-priority loop cycle from the active tab.

Returns
(boolean) True if Oscillator mode is active (CURRENT_MODE == 2), false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsThruFeedModeActive()

GrinderDiskScreenV01 IsThruFeedModeActive ( )

Check whether the screen is currently in ThruFeed mode.

Returns true when the global CURRENT_MODE equals 1, which corresponds to the ThruFeed tab (tab index 1) of the GrinderTabs control. CURRENT_MODE is updated every low-priority loop cycle from the active tab.

Returns
(boolean) True if ThruFeed mode is active (CURRENT_MODE == 1), false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ JobClose()

GrinderDiskScreenV01 JobClose ( )

Close the current job file, optionally saving changes first.

Screen entry point that wraps GrinderDiskScreenV01._JobClose() in a protected call. Prompts the operator to save any unsaved changes before closing, then closes the job and clears the LastJobName profile entry so no job is auto-loaded on the next screen load. If the protected call fails, an alarm message is raised.

Note
This function is a #SCREENENTRYPOINT and should only be called from screen event handlers
Documentation generated by AI on 2026-03-03

◆ JobOpen()

GrinderDiskScreenV01 JobOpen ( )

Open a job file selected by the operator via a file dialog.

Screen entry point that wraps GrinderDiskScreenV01._JobOpen() in a protected call. Prompts the operator to save any unsaved changes in the current job, then opens a file chooser dialog. After a new job is opened, the selected file path is written to the LastJobName profile entry so it is restored on the next screen load. Logs the open action to the operator log. If the protected call fails, an alarm message is raised.

Note
This function is a #SCREENENTRYPOINT and should only be called from screen event handlers
Documentation generated by AI on 2026-03-03

◆ JobSave()

GrinderDiskScreenV01 JobSave ( )

Save the current job file to its existing path.

Screen entry point that wraps GrinderDiskScreenV01._JobSave() in a protected call. Saves the current job without prompting for a file name. If the protected call fails, an alarm message is raised instead of propagating the error.

Note
This function is a #SCREENENTRYPOINT and should only be called from screen event handlers
Documentation generated by AI on 2026-03-03

◆ JobSaveAs()

GrinderDiskScreenV01 JobSaveAs ( )

Save the current job file under a new name via a Save As dialog.

Screen entry point that wraps GrinderDiskScreenV01._JobSaveAs() in a protected call. Prompts the operator to choose a new file path, saves the job, and updates the LastJobName profile entry so the new path is remembered across sessions. If the protected call fails, an alarm message is raised instead of propagating the error.

Note
This function is a #SCREENENTRYPOINT and should only be called from screen event handlers
Documentation generated by AI on 2026-03-03

◆ LoadJob()

GrinderDiskScreenV01 LoadJob ( )

Load the last used job file at screen startup.

Screen entry point that wraps GrinderDiskScreenV01._LoadJob() in a protected call. Reads the LastJobName profile string and, if non-empty, loads that job into GrinderDiskScreenV01.CurrentJob. This is typically called during GrinderDiskScreenV01.MachineScreenLoadScript() to restore the operator's previous session. If the protected call fails, an alarm message is raised instead of propagating the error.

Note
This function is a #SCREENENTRYPOINT and should only be called from screen event handlers
Documentation generated by AI on 2026-03-03

◆ MachineScreenLoadScript()

GrinderDiskScreenV01 MachineScreenLoadScript ( )

Initialize the grinder disk screen on load.

Called by the Mach4 screen engine when the screen is first loaded. Performs the following initialization steps in order:

  • Creates a new JobFile object (GrinderDiskScreenV01.CurrentJob) configured for pound variable range "500-514, 516, 540-547" with overwrite enabled and a header table.
  • Calls LoadJob() to restore the last used job file from the MachMotion profile.
  • Calls EnterTab(0) to apply initial tab setup for the Manual tab.
  • Calls ConfigureMachMenu() to restore the operator's saved menu visibility preference.
  • Reads the OscillatorEnabled OEM parameter and enables or disables all Oscillator-related buttons and hides or shows the OscillatingGrindingGroup panel accordingly.
  • Reads the ThruFeedEnabled OEM parameter and hides or shows the ThruFeedGrindingGroup panel accordingly.
    Returns
    (nil) No return value on success
    (boolean) False if an OEM parameter read fails
    (string) Status message from w.FunctionError() on error
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenLowPriorityLoop()

GrinderDiskScreenV01 MachineScreenLowPriorityLoop ( )

Low-priority periodic update loop for the grinder disk screen.

Called repeatedly by the Mach4 screen engine at low priority. Performs the following updates each cycle:

  • Reads the active GrinderTabs tab on page 0 and stores it in CURRENT_MODE; sets CURRENT_MODE to -1 when not on page 0. Writes the value to the ScreenCurrentTab OEM register.
  • Calls UpdateGrindAmountBtn() to refresh grind amount button highlights.
  • Reads X/Y axis positions and pound variables #513, #514, #515 to determine whether the machine is at the grind position; updates the AtGrindPositionLED accordingly.
  • Updates the ManualAutoBtn label and color based on pound variable #563 (201 = Manual, 202 = Auto).
  • Updates JogContText and JogIncText LEDs from the continuous and incremental jog I/O signals.
  • Blinks SparkoutTimeDRO yellow while the dwell signal (OSIG_DWELL) is active.
  • Updates DresserIn/DresserOut, Oscillator position, and SpindleHood LEDs from their respective OEM parameter signals, hiding indicators when features are disabled.
  • Updates PLCBitData button colors and LEDs for bits 0-4 from Modbus device 0.
  • Manages the Cycle Stop flag (PLCBitData bit 4) and the idle state bit (ContBitData bit 3).
    Returns
    (nil) No return value on success
    (boolean) False on error reading registers or pound variables
    (string) Status message from w.FunctionError() on error
    Warning
    This function reads multiple OEM parameters and Modbus registers each cycle; ensure all referenced OEM parameters are configured before the screen is loaded
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenPLCScript()

GrinderDiskScreenV01 MachineScreenPLCScript ( )

Periodic PLC update loop executed every Mach4 screen cycle.

Performs the following updates each cycle:

  • Reads the current job file name and path and updates the JobFileNameText and JobFilePathText screen labels if a job is loaded.
  • Calls m.screen.UpdateDROPostions() to refresh all DRO position displays.
  • Reads Modbus PLCSeqBitData bits 0-63 from device 0 and updates the corresponding button colors and label LEDs (PLCSeqBitData0Btn through PLCSeqBitData63Btn).
  • Reads X and Y axis positions and writes their sum to the WidthDRO screen object.
    Returns
    (nil) No return value
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenUnloadScript()

GrinderDiskScreenV01 MachineScreenUnloadScript ( )

Perform cleanup actions when the grinder disk screen is unloaded.

Called by the Mach4 screen engine when the screen is being unloaded. If GrinderDiskScreenV01.CurrentJob is not nil, calls OptSaveChanges() on it to prompt the operator to save any unsaved job file changes before the screen closes.

Note
Documentation generated by AI on 2026-03-03

◆ SetGrindAmount()

GrinderDiskScreenV01 SetGrindAmount ( Amount )

Set the grind amount by writing a value to pound variable #516.

Writes the provided Amount to Mach4 pound variable #516 via mc.mcCntlSetPoundVar(), then immediately calls UpdateGrindAmountBtn() to refresh the button highlight state on screen.

Parameters
Amount(number) The grind amount to set. Typical values are 0, 0.0005, 0.001, or 0.002
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if pound variable was written successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ ShowMachMenu()

GrinderDiskScreenV01 ShowMachMenu ( )

Show the Mach4 menu bar and persist the preference to the profile.

Calls scr.ShowMenu(true) to make the Mach4 menu bar visible, then writes 0 to the HideMachMenu key in the MachMotion profile so the preference is restored on the next screen load.

See also
GrinderDiskScreenV01.HideMachMenu()
GrinderDiskScreenV01.ConfigureMachMenu()
Note
Documentation generated by AI on 2026-03-03

◆ ToggleMachMenu()

GrinderDiskScreenV01 ToggleMachMenu ( )

Toggle the Mach4 menu bar between visible and hidden states.

Reads the current HideMachMenu profile value and calls either GrinderDiskScreenV01.HideMachMenu() or GrinderDiskScreenV01.ShowMachMenu() to invert the current state. The new state is persisted to the MachMotion profile automatically by the called function.

See also
GrinderDiskScreenV01.HideMachMenu()
GrinderDiskScreenV01.ShowMachMenu()
Note
Documentation generated by AI on 2026-03-03

◆ UpdateGrindAmountBtn()

GrinderDiskScreenV01 UpdateGrindAmountBtn ( )

Update the grind amount button highlight to reflect the current pound variable value.

Reads pound variable #516 to determine the active grind amount. Clears all four grind amount button highlights (GrindAmount0Btn through GrindAmount3Btn), then lights the button corresponding to the current value (0, 0.0005, 0.001, or 0.002). The update is skipped if the value has not changed since the last call, using the global LAST_GRIND_AMOUNT to track state.

Returns
(nil) No return value on success
(boolean) False on error reading pound variable
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03