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

Go to the source code of this file.

Functions

GrinderDiskGUIModule ScreenLoadScript ()
 Initialize the GrinderDisk screen by loading required macro modules.
GrinderDiskGUIModule UpdateSignalLibraryArray ()
 Update the signal library array for the GrinderDisk screen.
GrinderDiskGUIModule PLCScript ()
 Execute PLC script tasks on each control cycle for the GrinderDisk screen.
GrinderDiskGUIModule LowPriorityLoop ()
 Execute low-priority periodic tasks for the GrinderDisk screen.
GrinderDiskGUIModule GetToolTableAttributes ()
 Return the list of tool table attribute names and their associated pound variable indices.
GrinderDiskGUIModule UpdateToolTableAttributes ()
 Update screen DROs and pound variables with tool table attribute values for the current tool.
GrinderDiskGUIModule PLCSeqBitData0Btn ()
 Button handler that triggers PLC sequence 0, with spindle interlock protection.
GrinderDiskGUIModule PLCSeqBitData1Btn ()
 Button handler that triggers PLC sequence 1.
GrinderDiskGUIModule PLCSeqBitData2Btn ()
 Button handler that triggers PLC sequence 2.
GrinderDiskGUIModule PLCSeqBitData3Btn ()
 Button handler that triggers PLC sequence 3.
GrinderDiskGUIModule PLCSeqBitData4Btn ()
 Button handler that triggers PLC sequence 4.
GrinderDiskGUIModule PLCSeqBitData5Btn ()
 Button handler that triggers PLC sequence 5.
GrinderDiskGUIModule PLCSeqBitData6Btn ()
 Button handler that triggers PLC sequence 6.
GrinderDiskGUIModule PLCSeqBitData7Btn ()
 Button handler that triggers PLC sequence 7.
GrinderDiskGUIModule PLCSeqBitData8Btn ()
 Button handler that triggers PLC sequence 8.
GrinderDiskGUIModule PLCSeqBitData9Btn ()
 Button handler that triggers PLC sequence 9.
GrinderDiskGUIModule PLCSeqBitData10Btn ()
 Button handler that triggers PLC sequence 10.
GrinderDiskGUIModule PLCSeqBitData11Btn ()
 Button handler that triggers PLC sequence 11.
GrinderDiskGUIModule PLCSeqBitData12Btn ()
 Button handler that triggers PLC sequence 12.
GrinderDiskGUIModule PLCSeqBitData13Btn ()
 Button handler that triggers PLC sequence 13.
GrinderDiskGUIModule ManualAutoBtn ()
 Toggle the machine operating mode between Manual (201) and Auto (202).
GrinderDiskGUIModule CalculateCenterlineOffsetBtn ()
 Calculate and store the centerline offset between the X and Y axis positions.
GrinderDiskGUIModule CompFineInBtn ()
 Apply a fine compensation move in the inward direction.
GrinderDiskGUIModule CompFineOutBtn ()
 Apply a fine compensation move in the outward direction.
GrinderDiskGUIModule Comp (CompAmount)
 Apply a compensation move to the grinding axes by a specified amount.
GrinderDiskGUIModule ZeroTotalCompBtn ()
 Reset the cumulative compensation total to zero.
GrinderDiskGUIModule PLCBitData0Btn ()
 Toggle bit 0 of the ContBitData register on device 0.
GrinderDiskGUIModule PLCBitData1Btn ()
 Toggle bit 1 of the ContBitData register on device 0.
GrinderDiskGUIModule IncrementDecrementDRO (Var, Increment)
 Increment or decrement a pound variable (# variable) by a specified amount.
GrinderDiskGUIModule SetDresserPosition (AxisID)
 Set a dresser position for the specified axis by teaching the current machine position.
GrinderDiskGUIModule TeachDresserPosition (fieldName)
 Teach (capture) the current machine position into a named dresser position field.
GrinderDiskGUIModule WriteToolData (fieldName, Data, CurrentTool)
 Write a data value to a named field in the current tool's tool table entry.
GrinderDiskGUIModule ToggleOutput (OutputNumber)
 Toggle the state of a machine output signal.
GrinderDiskGUIModule StartPLCSeq (SequenceNumber)
 Execute a PLC sequence by sequence number via the Modbus interface.

Function Documentation

◆ CalculateCenterlineOffsetBtn()

GrinderDiskGUIModule CalculateCenterlineOffsetBtn ( )

Calculate and store the centerline offset between the X and Y axis positions.

Reads the current X and Y axis positions, computes the midpoint offset as ((XPos + YPos) / 2) - XPos, negates the result, and stores it in pound variable #503.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the calculation and store completed successfully
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ Comp()

GrinderDiskGUIModule Comp ( CompAmount )

Apply a compensation move to the grinding axes by a specified amount.

Checks for active GMS alarms and warnings before proceeding. Behavior depends on the active grinding mode:

  • Oscillator mode: Adjusts both X and Y axis positions directly by half the compensation amount.
  • Thru-feed mode: Executes an MDI G-code string to apply the compensation with a backlash removal move, using the BacklashFeedrate and GrindWidth pound variables. After a successful move, updates the "CompTotal" OEM register and saves the fixture file. The machine must be enabled and in IDLE state for compensation to be applied.
    Parameters
    CompAmount(number) The compensation distance to apply. Positive values move out, negative values move in
    Returns
    (nil) No meaningful primary return value
    (boolean) Success flag - true if compensation was applied or skipped cleanly
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Warning
    The machine must be enabled and in IDLE state before calling this function
    All GMS alarms and warnings must be cleared before compensation can be applied
    Note
    Documentation generated by AI on 2026-03-03

◆ CompFineInBtn()

GrinderDiskGUIModule CompFineInBtn ( )

Apply a fine compensation move in the inward direction.

Reads the "CompFineAmount" OEM register to determine the step size, then calls Comp() with the negative absolute value of that amount to move inward (negative direction).

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the compensation was applied successfully
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.Comp() for the compensation implementation
GrinderDiskGUIModule.CompFineOutBtn() for the outward direction equivalent
Note
Documentation generated by AI on 2026-03-03

◆ CompFineOutBtn()

GrinderDiskGUIModule CompFineOutBtn ( )

Apply a fine compensation move in the outward direction.

Reads the "CompFineAmount" OEM register to determine the step size, then calls Comp() with the absolute value of that amount to move outward (positive direction).

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the compensation was applied successfully
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.Comp() for the compensation implementation
GrinderDiskGUIModule.CompFineInBtn() for the inward direction equivalent
Note
Documentation generated by AI on 2026-03-03

◆ GetToolTableAttributes()

GrinderDiskGUIModule GetToolTableAttributes ( )

Return the list of tool table attribute names and their associated pound variable indices.

Provides a fixed array of two-element tables, each containing a tool table extended data field name and its corresponding Mach4 pound variable index. Currently returns: {"X1DressPosition", 540} and {"Y1DressPosition", 541}.

Returns
(table) Array of {fieldName (string), poundVarIndex (number)} pairs describing each tool attribute and its associated pound variable
Note
Documentation generated by AI on 2026-03-03

◆ IncrementDecrementDRO()

GrinderDiskGUIModule IncrementDecrementDRO ( Var ,
Increment  )

Increment or decrement a pound variable (# variable) by a specified amount.

Reads the current value of the Mach4 pound variable at the given index, adds the increment value (which may be negative to decrement), and writes the result back.

Parameters
Var(number) The pound variable index to modify
Increment(number) The amount to add to the current value. Use a negative value to decrement
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ LowPriorityLoop()

GrinderDiskGUIModule LowPriorityLoop ( )

Execute low-priority periodic tasks for the GrinderDisk screen.

Called during the low-priority loop cycle. Currently delegates to UpdateToolTableAttributes() to refresh tool table DROs and pound variables.

Note
Documentation generated by AI on 2026-03-03

◆ ManualAutoBtn()

GrinderDiskGUIModule ManualAutoBtn ( )

Toggle the machine operating mode between Manual (201) and Auto (202).

Reads pound variable #563 to determine the current mode. If the value is 201 (Manual), it is changed to 202 (Auto). Otherwise it is set to 201 (Manual).

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

◆ PLCBitData0Btn()

GrinderDiskGUIModule PLCBitData0Btn ( )

Toggle bit 0 of the ContBitData register on device 0.

Reads the current state of bit 0 in the "ContBitData" register on Modbus device 0. If the bit is set, it is cleared; if it is clear, it is set. Displays a message box if the set or clear operation fails.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - always true if the toggle attempt was made
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ PLCBitData1Btn()

GrinderDiskGUIModule PLCBitData1Btn ( )

Toggle bit 1 of the ContBitData register on device 0.

Reads the current state of bit 1 in the "ContBitData" register on Modbus device 0. If the bit is set, it is cleared; if it is clear, it is set. Displays a message box if the set or clear operation fails.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - always true if the toggle attempt was made
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ PLCScript()

GrinderDiskGUIModule PLCScript ( )

Execute PLC script tasks on each control cycle for the GrinderDisk screen.

Called periodically by the Mach4 PLC loop. If the LOAD_METER_ENABLED_2nd OEM parameter is set to "Yes", updates the spindle load meter display via m.UpdateSpindleLoadMeter(). Additional update functions (feedrate DRO labels, DRO positions, tool verify DRO) are currently commented out.

Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData0Btn()

GrinderDiskGUIModule PLCSeqBitData0Btn ( )

Button handler that triggers PLC sequence 0, with spindle interlock protection.

Before starting sequence 0, checks the PLCSeqBitData bit 0 on device 0 to determine if spindles are already on. If they are, returns an error immediately. Otherwise, checks bit 2 of the PLCBitData register; if that bit is clear, sequence 0 is started via StartPLCSeq(). If bit 2 is set, a warning message is displayed to wait for spindles to stop.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence was started or the interlock check completed
(string) Status message from w.FunctionCompleted() or w.FunctionError()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData10Btn()

GrinderDiskGUIModule PLCSeqBitData10Btn ( )

Button handler that triggers PLC sequence 10.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 10.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData11Btn()

GrinderDiskGUIModule PLCSeqBitData11Btn ( )

Button handler that triggers PLC sequence 11.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 11.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData12Btn()

GrinderDiskGUIModule PLCSeqBitData12Btn ( )

Button handler that triggers PLC sequence 12.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 12.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData13Btn()

GrinderDiskGUIModule PLCSeqBitData13Btn ( )

Button handler that triggers PLC sequence 13.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 13.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData1Btn()

GrinderDiskGUIModule PLCSeqBitData1Btn ( )

Button handler that triggers PLC sequence 1.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 1.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData2Btn()

GrinderDiskGUIModule PLCSeqBitData2Btn ( )

Button handler that triggers PLC sequence 2.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 2.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData3Btn()

GrinderDiskGUIModule PLCSeqBitData3Btn ( )

Button handler that triggers PLC sequence 3.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 3.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData4Btn()

GrinderDiskGUIModule PLCSeqBitData4Btn ( )

Button handler that triggers PLC sequence 4.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 4.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData5Btn()

GrinderDiskGUIModule PLCSeqBitData5Btn ( )

Button handler that triggers PLC sequence 5.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 5.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData6Btn()

GrinderDiskGUIModule PLCSeqBitData6Btn ( )

Button handler that triggers PLC sequence 6.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 6.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData7Btn()

GrinderDiskGUIModule PLCSeqBitData7Btn ( )

Button handler that triggers PLC sequence 7.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 7.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData8Btn()

GrinderDiskGUIModule PLCSeqBitData8Btn ( )

Button handler that triggers PLC sequence 8.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 8.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ PLCSeqBitData9Btn()

GrinderDiskGUIModule PLCSeqBitData9Btn ( )

Button handler that triggers PLC sequence 9.

Delegates to GrinderDiskGUIModule.StartPLCSeq() with sequence index 9.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the sequence call completed
(string) Status message from w.FunctionCompleted()
See also
GrinderDiskGUIModule.StartPLCSeq() for sequence execution details
Note
Documentation generated by AI on 2026-03-03

◆ ScreenLoadScript()

GrinderDiskGUIModule ScreenLoadScript ( )

Initialize the GrinderDisk screen by loading required macro modules.

Configures the Lua package path to include the profile Macros directory, then force-reloads the m225 and m400 macro modules by clearing their cached entries in package.loaded before requiring them. This ensures the latest versions of these macros are active when the screen loads.

Returns
(boolean) Always true as the primary return value
(boolean) Success flag - always true
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ SetDresserPosition()

GrinderDiskGUIModule SetDresserPosition ( AxisID )

Set a dresser position for the specified axis by teaching the current machine position.

Verifies that the position display is in unlocked mode before allowing the teach operation. Delegates to TeachDresserPosition() using the appropriate field name based on the axis ID. Only X_AXIS and Y_AXIS are currently supported.

Parameters
AxisID(number) The axis identifier for which to set the dresser position (e.g., mc.X_AXIS, mc.Y_AXIS)
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the position was set successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Warning
The position display must be in unlocked mode; otherwise the operation is rejected with a warning dialog
Note
Documentation generated by AI on 2026-03-03

◆ StartPLCSeq()

GrinderDiskGUIModule StartPLCSeq ( SequenceNumber )

Execute a PLC sequence by sequence number via the Modbus interface.

Updates the machine stop status before calling the PLC sequence. Uses mb.SeqCall() to trigger the specified sequence on device 0. If the sequence call fails, displays an error message dialog. Debugging is disabled by default.

Parameters
SequenceNumber(number) The index of the PLC sequence to execute
Note
Documentation generated by AI on 2026-03-03

◆ TeachDresserPosition()

GrinderDiskGUIModule TeachDresserPosition ( fieldName )

Teach (capture) the current machine position into a named dresser position field.

Determines the relevant axis from the field name, optionally prompts the operator for confirmation (based on the ConfirmationDialogs OEM parameter), then reads the current machine position for that axis and writes it to the tool table via WriteToolData(). The tool file is saved after a successful write. Supports X, Y, and Z dresser position fields.

Parameters
fieldName(string) The tool table field name identifying the dresser position to teach. Supported values include: "X1DressPosition", "X2DressPosition", "X3DressPosition", "XDresserOffset", "Y1DressPosition", "Y2DressPosition", "Y3DressPosition", "Z1DressPosition", "Z2DressPosition", "Z3DressPosition"
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the position was taught and saved successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

◆ ToggleOutput()

GrinderDiskGUIModule ToggleOutput ( OutputNumber )

Toggle the state of a machine output signal.

Reads the current state of the specified output signal and inverts it. If the signal is currently active (true), it is deactivated, and vice versa.

Parameters
OutputNumber(number) The output signal identifier (e.g., mc.OSIG_OUTPUT20)
Note
Documentation generated by AI on 2026-03-03

◆ UpdateSignalLibraryArray()

GrinderDiskGUIModule UpdateSignalLibraryArray ( )

Update the signal library array for the GrinderDisk screen.

Currently a stub implementation that returns a success status without performing any signal library updates.

Returns
(boolean) Always true
(boolean) Success flag - always true
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ UpdateToolTableAttributes()

GrinderDiskGUIModule UpdateToolTableAttributes ( )

Update screen DROs and pound variables with tool table attribute values for the current tool.

Retrieves the current tool number and iterates over the tool attributes defined by GetToolTableAttributes(). For each attribute, reads the extended tool data string from the tool table and writes it to the corresponding screen DRO (named "<AttributeName>DRO") and the associated pound variable. If the tool number is 0 or less, DROs are set to "0" and pound variables are set to 0.

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

◆ WriteToolData()

GrinderDiskGUIModule WriteToolData ( fieldName ,
Data ,
CurrentTool  )

Write a data value to a named field in the current tool's tool table entry.

Writes a numeric value to the specified extended tool data field for the given tool. If CurrentTool is nil, the function retrieves the currently active tool number. If the tool number is 0 or less, the write is rejected. On success, the tool file is saved automatically.

Parameters
fieldName(string) The name of the tool table extended data field to write
Data(number) The numeric value to store in the tool table field
CurrentTool(number|nil) The tool number to write to. If nil, uses the current tool
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the write completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Documentation generated by AI on 2026-03-03

References CurrentTool().

◆ ZeroTotalCompBtn()

GrinderDiskGUIModule ZeroTotalCompBtn ( )

Reset the cumulative compensation total to zero.

Sets the "CompTotal" OEM register to 0, clearing the running total of all compensation amounts that have been applied.

Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if the operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03