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

Go to the source code of this file.

Functions

CommonGrinderScreenV02 MachineCycleStop ()
 Safely execute the machine cycle stop sequence with error protection.
CommonGrinderScreenV02 UpdateGrinderWheelAttributes ()
 Update grinder wheel attribute pound variables from the current tool table entry.
CommonGrinderScreenV02 SelectDresserDiamondBtn (diamond, ctrl_name, event_source,...)
 Button handler that delegates to SelectDresserDiamond.
CommonGrinderScreenV02 SelectDresserDiamond (diamond)
 Set the dresser diamond type in the tool table and update the screen selection.
CommonGrinderScreenV02 GetDresserDiamond ()
 Get the current dresser diamond type from the tool table.
CommonGrinderScreenV02 UpdateDresserDiamondSelection ()
 Update the dresser diamond selection button colors and group enable states.
CommonGrinderScreenV02 TouchOffTeachX ()
 Teach the X-axis touch-off position by capturing the current machine position.
CommonGrinderScreenV02 TouchOffTeachZ ()
 Teach the Z-axis touch-off position by capturing the current machine position.
CommonGrinderScreenV02 ExecuteCalibrationBtn ()
 Execute a tool calibration using touch-off positions and measured dimensions.
CommonGrinderScreenV02 SetNewWheelOffsetOn ()
 Enable the new wheel offset mode by setting pound variable #9057 to 1.
CommonGrinderScreenV02 SetNewWheelOffsetOff ()
 Disable the new wheel offset mode by clearing pound variable #9057.
CommonGrinderScreenV02 IsNewWheelOffsetOn ()
 Check whether the new wheel offset mode is currently active.
CommonGrinderScreenV02 NewWheelOffsetToggle ()
 Toggle the new wheel offset mode on or off based on its current state.
CommonGrinderScreenV02 UpdateNewWheelOffset ()
 Update the NewWheelOffsetBtn background color to reflect the current new-wheel offset state.
CommonGrinderScreenV02 IsWorkHeadEnableMapped ()
 Check whether the WorkHeadEnableOutput OEM parameter signal is mapped.
CommonGrinderScreenV02 IsWorkHeadEnableImmediateOff ()
 Check whether the work head enable output uses immediate-off behavior.
CommonGrinderScreenV02 UpdateWorkHeadEnable ()
 Update the work head enable output signal based on spindle and machine state.
CommonGrinderScreenV02 TeachDresserBtn (fieldName,...)
 Button handler that delegates to TeachDresser.

Function Documentation

◆ ExecuteCalibrationBtn()

CommonGrinderScreenV02 ExecuteCalibrationBtn ( )

Execute a tool calibration using touch-off positions and measured dimensions.

Reads the measured X and Z values from the "MeasuredXDRO" and "MeasuredZDRO" screen controls and the previously taught touch-off positions from "XTouchOffDRO" and "ZTouchOffDRO". Validates that touch-off positions are non-zero, then calculates new X and Z tool offsets by subtracting the work offset and measured value from the machine touch-off position. In diameter mode, the X measured value is halved before use. Writes the calculated offsets to the tool table, clears wear offsets, activates the new offsets via an MDI T-command, and resets the touch-off DRO controls to zero.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - false if touch-off positions are zero or MDI command fails
(string) Status message from w.FunctionError() on error
Warning
Touch-off positions must be taught via TouchOffTeachX() and TouchOffTeachZ() before calling this function, or calibration will be aborted with a warning message
Note
Documentation generated by AI on 2026-03-03

◆ GetDresserDiamond()

CommonGrinderScreenV02 GetDresserDiamond ( )

Get the current dresser diamond type from the tool table.

Reads the "DresserDiamondType" user value from the tool table via w.GetToolTableUserValue() and returns it.

Returns
(number|nil) The current dresser diamond type value, or nil on error
(boolean) Success flag - false on tool table read error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ IsNewWheelOffsetOn()

CommonGrinderScreenV02 IsNewWheelOffsetOn ( )

Check whether the new wheel offset mode is currently active.

Reads pound variable #9057 via mc.mcCntlGetPoundVar() and returns true if its value equals 1.

Returns
(boolean) True if the new wheel offset mode is active (pound var #9057 == 1), false otherwise
(boolean) Success flag - false on pound variable read error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ IsWorkHeadEnableImmediateOff()

CommonGrinderScreenV02 IsWorkHeadEnableImmediateOff ( )

Check whether the work head enable output uses immediate-off behavior.

Reads the "WorkHeadEnableImmediateOff" OEM parameter string and returns true if its value is "Yes". The result is cached under the key ("WorkHeadEnableImmediateOff", "Enabled") to avoid repeated OEM parameter reads on subsequent calls.

Returns
(boolean) True if the work head enable output turns off immediately when the spindle stops, false if it waits for the delay and RPM to drop
Note
Documentation generated by AI on 2026-03-03

◆ IsWorkHeadEnableMapped()

CommonGrinderScreenV02 IsWorkHeadEnableMapped ( )

Check whether the WorkHeadEnableOutput OEM parameter signal is mapped.

Calls w.IsOEMParamSigMapped() for the "WorkHeadEnableOutput" signal and caches the result under the key ("WorkHeadEnable", "Mapped") to avoid repeated lookups on subsequent calls.

Returns
(boolean) True if the WorkHeadEnableOutput signal is mapped, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ MachineCycleStop()

CommonGrinderScreenV02 MachineCycleStop ( )

Safely execute the machine cycle stop sequence with error protection.

Calls m.screen._MachineCycleStop() inside a w.pcall() protected context. If an error occurs during the stop sequence, it is caught and returned as a failure rather than propagating to the caller. On success, returns the completion status from the inner function.

Returns
(boolean) True if the cycle stop completed successfully, false if an error occurred
(boolean) Success flag - true if operation completed, false on error
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ NewWheelOffsetToggle()

CommonGrinderScreenV02 NewWheelOffsetToggle ( )

Toggle the new wheel offset mode on or off based on its current state.

Reads the current new-wheel offset state via m.screen.IsNewWheelOffsetOn(). If it is active, calls m.screen.SetNewWheelOffsetOff(). If it is inactive, calls m.screen.SetNewWheelOffsetOn().

Note
Documentation generated by AI on 2026-03-03

◆ SelectDresserDiamond()

CommonGrinderScreenV02 SelectDresserDiamond ( diamond )

Set the dresser diamond type in the tool table and update the screen selection.

Writes the given diamond type value to the "DresserDiamondType" tool table user value via w.SetToolTableUserValue(), then calls m.screen.UpdateDresserDiamondSelection() to refresh the button and image states on screen.

Parameters
diamond(number) The dresser diamond type to select (1 = single, 2 = double, 3 = flat)
Returns
(nil) No meaningful primary return value
(boolean) Success flag - false on tool table write error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ SelectDresserDiamondBtn()

CommonGrinderScreenV02 SelectDresserDiamondBtn ( diamond ,
ctrl_name ,
event_source ,
... )

Button handler that delegates to SelectDresserDiamond.

Extracts the diamond parameter and calls m.screen.SelectDresserDiamond() to write the selected diamond type to the tool table and refresh the button states on screen. Additional button event arguments (ctrl_name, event_source, ...) are accepted but ignored.

Parameters
diamond(number) The dresser diamond type to select (1 = single, 2 = double, 3 = flat)
ctrl_name(string) The name of the control that triggered this event (unused)
event_source(any) The event source object (unused)
...(any) Additional event arguments (unused)
Note
Documentation generated by AI on 2026-03-03

◆ SetNewWheelOffsetOff()

CommonGrinderScreenV02 SetNewWheelOffsetOff ( )

Disable the new wheel offset mode by clearing pound variable #9057.

Sets pound variable #9057 to 0 via mc.mcCntlSetPoundVar(), then calls m.screen.UpdateNewWheelOffset() to refresh the button display.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - false on pound variable write error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ SetNewWheelOffsetOn()

CommonGrinderScreenV02 SetNewWheelOffsetOn ( )

Enable the new wheel offset mode by setting pound variable #9057 to 1.

Sets pound variable #9057 to 1 via mc.mcCntlSetPoundVar(), then calls m.screen.UpdateNewWheelOffset() to refresh the button display.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - false on pound variable write error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ TeachDresserBtn()

CommonGrinderScreenV02 TeachDresserBtn ( fieldName ,
... )

Button handler that delegates to TeachDresser.

Extracts the fieldName parameter and calls m.screen.TeachDresser() to store the current machine position for the dresser axis associated with fieldName. Additional button event arguments (...) are accepted but ignored.

Parameters
fieldName(string) The tool table user value field name identifying the dresser position
...(any) Additional event arguments (unused)
Note
Documentation generated by AI on 2026-03-03

◆ TouchOffTeachX()

CommonGrinderScreenV02 TouchOffTeachX ( )

Teach the X-axis touch-off position by capturing the current machine position.

Reads the current X-axis machine position via mc.mcAxisGetMachinePos() and writes it to the "XTouchOffDRO" screen control value.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if position was captured successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ TouchOffTeachZ()

CommonGrinderScreenV02 TouchOffTeachZ ( )

Teach the Z-axis touch-off position by capturing the current machine position.

Reads the current Z-axis machine position via mc.mcAxisGetMachinePos() and writes it to the "ZTouchOffDRO" screen control value.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if position was captured successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ UpdateDresserDiamondSelection()

CommonGrinderScreenV02 UpdateDresserDiamondSelection ( )

Update the dresser diamond selection button colors and group enable states.

Reads the current dresser diamond type from m.screen.GetDresserDiamond() and updates the appearance of three diamond selection buttons and their associated image controls. The selected button is highlighted with BTN_COLOR_ON and shows the enabled image; unselected buttons use BTN_COLOR_OFF and show the disabled image. Additionally, enables the input group controls (Diamond1Group, Diamond2Group, Diamond3Group) according to a cumulative rule: Diamond type 1 enables only group 1, type 2 enables groups 1 and 2, and type 3 enables all three groups.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateGrinderWheelAttributes()

CommonGrinderScreenV02 UpdateGrinderWheelAttributes ( )

Update grinder wheel attribute pound variables from the current tool table entry.

Reads all wheel attributes defined by m.screen.GetWheelAttributes() for the currently active tool and synchronizes their values into the corresponding Mach4 pound variables via mc.mcCntlSetPoundVar(). The update is skipped if the machine is running or generating a tool path unless the "WheelParameterChanged" OEM parameter flag is set to 1, which forces an immediate update regardless of machine state. After processing, the "WheelParameterChanged" OEM parameter is reset to 0. If the current tool number is 0 (no tool loaded), all pound variables are set to 0 instead of the tool table values.

Returns
(nil) No meaningful primary return value on error or early exit
(boolean) Success flag - false on tool lookup or pound variable read/write error
(string) Status message from w.FunctionError() on error
Note
Documentation generated by AI on 2026-03-03

◆ UpdateNewWheelOffset()

CommonGrinderScreenV02 UpdateNewWheelOffset ( )

Update the NewWheelOffsetBtn background color to reflect the current new-wheel offset state.

Reads the current new-wheel offset state via m.screen.IsNewWheelOffsetOn() and sets the "NewWheelOffsetBtn" background color to BTN_COLOR_ON if active, or BTN_COLOR_OFF if inactive.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateWorkHeadEnable()

CommonGrinderScreenV02 UpdateWorkHeadEnable ( )

Update the work head enable output signal based on spindle and machine state.

When the WorkHeadEnableOutput signal is mapped, reads the spindle on signal, SpindleDelayActive OEM parameter, and the current true spindle RPM to determine whether the work head enable output should be active. The output is set to true when:

  • The spindle is on and the machine is enabled, OR
  • The spindle delay is still active or RPM is above 5, AND the immediate-off mode is not enabled Otherwise the output is set to false. If the signal is not mapped, no action is taken.
    Note
    Documentation generated by AI on 2026-03-03