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

Go to the source code of this file.

Functions

GrinderSurfaceScreenV01 MachineScreenLoadScript ()
 Screen load callback that initializes job file and electromagnetic meter averaging.
GrinderSurfaceScreenV01 MachineScreenStartupScript ()
 Screen startup callback executed after the screen has been loaded and is ready.
GrinderSurfaceScreenV01 MachineScreenUnloadScript ()
 Screen unload callback to save job file changes before the screen exits.
GrinderSurfaceScreenV01 UpdateAxisDROs ()
 Update axis DRO display controls with current axis positions.
GrinderSurfaceScreenV01 MachineScreenPLCScript ()
 PLC script callback executed on every Mach4 PLC cycle for this screen.
GrinderSurfaceScreenV01 MachineScreenLowPriorityLoop ()
 Low-priority periodic loop to update job file name display controls.
GrinderSurfaceScreenV01 UpdateGrindTableControls ()
 Update all grind table UI controls with current machine state and sensor values.
GrinderSurfaceScreenV01 TeachPoundVar (PoundVar, AxisID)
 Teach a pound variable by capturing the current axis position.
GrinderSurfaceScreenV01 IsMDIModeActive ()
 Determine whether MDI mode is currently active on the screen.
GrinderSurfaceScreenV01 EndOfProgramParkBtn ()
 Toggle the End Of Program Park mode on or off via pound variable #548.
GrinderSurfaceScreenV01 EnableBSideGrindBtn ()
 Toggle the Enable B Side Grind mode on or off via pound variable #555.
GrinderSurfaceScreenV01 GrindDepthStartFollowBtn ()
 Toggle the Grind Depth Start Follow mode on or off via pound variable #549.
GrinderSurfaceScreenV01 LoadJob ()
 Load the most recently used job file from the Mach4 profile.
GrinderSurfaceScreenV01 JobOpen ()
 Open a job file selected by the operator.
GrinderSurfaceScreenV01 JobClose ()
 Close the current job file, prompting to save changes if needed.
GrinderSurfaceScreenV01 JobSave ()
 Save the current job file to its existing path.
GrinderSurfaceScreenV01 JobSaveAs ()
 Save the current job file under a new name chosen by the operator.

Function Documentation

◆ EnableBSideGrindBtn()

GrinderSurfaceScreenV01 EnableBSideGrindBtn ( )

Toggle the Enable B Side Grind mode on or off via pound variable #555.

Reads the current value of pound variable #555. If it is 0, sets it to 1 (enabled); if it is non-zero, sets it to 0 (disabled). Returns an error if reading or writing the pound variable fails.

Returns
(nil) No meaningful return value on success
(boolean) False on error, no return on success
(string) Error status message from w.FunctionError() on failure
Note
Documentation generated by AI on 2026-03-03

◆ EndOfProgramParkBtn()

GrinderSurfaceScreenV01 EndOfProgramParkBtn ( )

Toggle the End Of Program Park mode on or off via pound variable #548.

Reads the current value of pound variable #548. If it is 0, sets it to 1 (enabled); if it is non-zero, sets it to 0 (disabled). Returns an error if reading or writing the pound variable fails.

Returns
(nil) No meaningful return value on success
(boolean) False on error, no return on success
(string) Error status message from w.FunctionError() on failure
Note
Documentation generated by AI on 2026-03-03

◆ GrindDepthStartFollowBtn()

GrinderSurfaceScreenV01 GrindDepthStartFollowBtn ( )

Toggle the Grind Depth Start Follow mode on or off via pound variable #549.

Reads the current value of pound variable #549. If it is 0, sets it to 1 (enabled); if it is non-zero, sets it to 0 (disabled). Returns an error if reading or writing the pound variable fails.

Returns
(nil) No meaningful return value on success
(boolean) False on error, no return on success
(string) Error status message from w.FunctionError() on failure
Note
Documentation generated by AI on 2026-03-03

◆ IsMDIModeActive()

GrinderSurfaceScreenV01 IsMDIModeActive ( )

Determine whether MDI mode is currently active on the screen.

Checks the "Left" property of the "MDIGroup" screen object. If the value is "105", MDI mode is considered active.

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

◆ JobClose()

GrinderSurfaceScreenV01 JobClose ( )

Close the current job file, prompting to save changes if needed.

Screen entry point that wraps GrinderSurfaceScreenV01._JobClose() using w.pcall() for protected execution. Optionally saves unsaved changes before closing, then clears the last job name from the Mach4 profile. If the operation fails, the error is reported via w.AlarmMessage().

Note
This function is a screen entry point (button handler) and takes no parameters
Documentation generated by AI on 2026-03-03

◆ JobOpen()

GrinderSurfaceScreenV01 JobOpen ( )

Open a job file selected by the operator.

Screen entry point that wraps GrinderSurfaceScreenV01._JobOpen() using w.pcall() for protected execution. Optionally saves changes to the current job before opening a new one, then updates the last job name in the Mach4 profile. If the operation fails, the error is reported via w.AlarmMessage(). Operator action is logged via w.OperatorLog().

Note
This function is a screen entry point (button handler) and takes no parameters
Documentation generated by AI on 2026-03-03

◆ JobSave()

GrinderSurfaceScreenV01 JobSave ( )

Save the current job file to its existing path.

Screen entry point that wraps GrinderSurfaceScreenV01._JobSave() using w.pcall() for protected execution. If the save operation fails, the error is reported via w.AlarmMessage(). Logs the operator action before saving.

Note
This function is a screen entry point (button handler) and takes no parameters
Documentation generated by AI on 2026-03-03

◆ JobSaveAs()

GrinderSurfaceScreenV01 JobSaveAs ( )

Save the current job file under a new name chosen by the operator.

Screen entry point that wraps GrinderSurfaceScreenV01._JobSaveAs() using w.pcall() for protected execution. If the save-as operation fails, the error is reported via w.AlarmMessage(). On success, the last job name profile entry is updated with the new file path.

Note
This function is a screen entry point (button handler) and takes no parameters
Documentation generated by AI on 2026-03-03

◆ LoadJob()

GrinderSurfaceScreenV01 LoadJob ( )

Load the most recently used job file from the Mach4 profile.

Screen entry point that wraps GrinderSurfaceScreenV01._LoadJob() using w.pcall() for protected execution. Retrieves the last job file path from the Mach4 profile string "LastJobName" and loads it if one exists. If the operation fails, the error is reported via w.AlarmMessage().

Note
This function is a screen entry point (button handler) and takes no parameters
Documentation generated by AI on 2026-03-03

◆ MachineScreenLoadScript()

GrinderSurfaceScreenV01 MachineScreenLoadScript ( )

Screen load callback that initializes job file and electromagnetic meter averaging.

Called by Mach4 when this screen is first loaded. Performs two initialization tasks:

  • Creates a new JobFile instance (GrinderSurfaceScreenV01.CurrentJob) configured for pound variable range 400-414 and 500-600, with overwrite enabled and a surface grinder parameter header.
  • Reads the "ElectromagneticMeterMeterAveraging" OEM parameter and constructs a rolling averager (MagneticMeterAverage) with that averaging window size.
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenLowPriorityLoop()

GrinderSurfaceScreenV01 MachineScreenLowPriorityLoop ( )

Low-priority periodic loop to update job file name display controls.

Called on a low-priority timer cycle. If a job file is currently loaded, updates the "JobFileNameText" and "JobFilePathText" screen labels with the current job file name and full file path respectively.

Note
Documentation generated by AI on 2026-03-03

◆ MachineScreenPLCScript()

GrinderSurfaceScreenV01 MachineScreenPLCScript ( )

PLC script callback executed on every Mach4 PLC cycle for this screen.

Called repeatedly by the Mach4 PLC loop while this screen is active. Delegates all control update logic to GrinderSurfaceScreenV01.UpdateGrindTableControls().

Note
Documentation generated by AI on 2026-03-03

◆ MachineScreenStartupScript()

GrinderSurfaceScreenV01 MachineScreenStartupScript ( )

Screen startup callback executed after the screen has been loaded and is ready.

Note
This function is currently a stub and contains no implementation
Documentation generated by AI on 2026-03-03

◆ MachineScreenUnloadScript()

GrinderSurfaceScreenV01 MachineScreenUnloadScript ( )

Screen unload callback to save job file changes before the screen exits.

Called by Mach4 when this screen is being unloaded. If a current job file is loaded, calls OptSaveChanges() to prompt the operator to save any unsaved changes before the screen closes.

Note
Documentation generated by AI on 2026-03-03

◆ TeachPoundVar()

GrinderSurfaceScreenV01 TeachPoundVar ( PoundVar ,
AxisID  )

Teach a pound variable by capturing the current axis position.

Reads the current position of the specified axis using mc.mcAxisGetPos() and writes that position into the specified Mach4 pound variable using mc.mcCntlSetPoundVar(). Returns an error if either the position read or the pound variable write fails.

Parameters
PoundVar(number) The pound variable number to set with the current axis position
AxisID(number) The axis identifier (e.g., mc.X_AXIS) whose position is to be captured
Returns
(nil) No meaningful return value on success
(boolean) False on error, no return on success
(string) Error status message from w.FunctionError() on failure
Note
Documentation generated by AI on 2026-03-03

◆ UpdateAxisDROs()

GrinderSurfaceScreenV01 UpdateAxisDROs ( )

Update axis DRO display controls with current axis positions.

Note
This function is currently a stub and contains no implementation
Documentation generated by AI on 2026-03-03

◆ UpdateGrindTableControls()

GrinderSurfaceScreenV01 UpdateGrindTableControls ( )

Update all grind table UI controls with current machine state and sensor values.

Performs the following updates on every PLC cycle:

  • If the electromagnetic meter is enabled, reads the meter register value, calculates a percentage relative to configured scale min/max, applies rolling averaging via MagneticMeterAverage, clamps the result to 0-150, and updates the gauge control.
  • Sets LED indicators for clamp, unclamp, and table over-travel/stroke limit inputs.
  • Reads pound variables #548, #549, and #555 to update button colors for End Of Program Park, Grind Depth Start Follow, and Enable B Side Grind buttons respectively.
  • Calculates the effective step-over amount by applying the current feedrate override to pound variable #519 and updates the corresponding DRO.
    Returns
    (nil) No meaningful return value on success
    (boolean) False on error
    (string) Error status message from w.FunctionError() on failure
    Note
    Documentation generated by AI on 2026-03-03