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

Go to the source code of this file.

Functions

CommonDualTableScreenV02 InitializeDualTable ()
 Initialize the dual table feature for all Mach4 instances.
CommonDualTableScreenV02 IsDualTableEnabled (inst)
 Check if the dual table feature is enabled for the specified instance.
CommonDualTableScreenV02 SetDualTableToDefaultSelection ()
 Switch the active dual table to the configured default table selection.
CommonDualTableScreenV02 SetDualTableModeSelectionBtn (tablenumber)
 Handle operator button press to select a dual table.
CommonDualTableScreenV02 IsDualTableModeSelection (tablenumber)
 Check if the specified table number is the currently active dual table selection.
CommonDualTableScreenV02 ToggleDualTableAutoSwitchTableEnabled ()
 Toggle dual table auto-switching between tables for the selected instance.
CommonDualTableScreenV02 IsDualTableAutoSwitchTableEnabled ()
 Check if dual table auto-switching between tables is enabled for the selected instance.
CommonDualTableScreenV02 ToggleDualTableAutoStartNextProgram ()
 Toggle the dual table auto-start next program setting for the selected instance.
CommonDualTableScreenV02 IsDualTableAutoStartNextProgramActive ()
 Check if dual table auto-start next program is active for the selected instance.
CommonDualTableScreenV02 IsDualTableAutoStartNextProgramTableFlagSet (tablenumber)
 Check if the auto-start program flag is set for a specific dual table.
CommonDualTableScreenV02 SetDualTableAutoStartNextProgramTableFlag (tablenumber)
 Set the auto-start program table flag for a specific dual table.
CommonDualTableScreenV02 ResetDualTableAutoStartNextProgramTableFlag (tablenumber)
 Reset the auto-start program table flag for a specific dual table.
CommonDualTableScreenV02 SelectFileForTable (tablenumber)
 Open a file selection dialog to choose a G-code file for a specific dual table.
CommonDualTableScreenV02 DualTable Create ()
 Create and initialize a dual table instance for the specified Mach4 instance.
CommonDualTableScreenV02 DualTable IsEnabled ()
 Check if the dual table feature is enabled for this instance.
CommonDualTableScreenV02 DualTable OnEnableUpdateDualTable ()
 Update dual table state when the machine is enabled.
CommonDualTableScreenV02 DualTable DualTableAutoStart ()
 Trigger dual table auto-start of the next program after a table switch.
CommonDualTableScreenV02 DualTable IsDualTableEnabledWithUserMessage ()
 Check if dual table is enabled and display a user-facing warning if not.
CommonDualTableScreenV02 DualTable IsDualTableMotorSwappingEnabled ()
 Check if dual table motor swapping is enabled, using a cache for performance.
CommonDualTableScreenV02 DualTable IsDualTableModeSelection ()
 Check if the specified table number is the currently active dual table selection.
CommonDualTableScreenV02 DualTable AreTablesCloseToTheSamePosition ()
 Check if the dual table master and slave motors are close to the same physical position.
CommonDualTableScreenV02 DualTable GetDualTableModeSelection ()
 Get the currently selected dual table number.
CommonDualTableScreenV02 DualTable SetDualTableModeSelectionBtn ()
 Handle the operator button press to select a dual table.
CommonDualTableScreenV02 DualTable SetDualTableModeSelection ()
 Activate the specified table and update all related dual table state.
CommonDualTableScreenV02 DualTable IsAxisMappedToDualTable ()
 Check if the specified axis is mapped to either the master or slave dual table axis.
CommonDualTableScreenV02 DualTable ActivateTable ()
 Activate a dual table in a protected call context.
CommonDualTableScreenV02 DualTable DualTablePrepareForHoming ()
 Prepare dual table motor mappings before a homing operation begins.
CommonDualTableScreenV02 DualTable DualTableFinishHoming ()
 Complete the homing sequence for dual table motor swapping.
CommonDualTableScreenV02 DualTable DualTableApplyDefaultMotorMappings ()
 Configure default motor-to-axis mappings for dual table operation.
CommonDualTableScreenV02 DualTable DualTableApplyHomingMotorMappings ()
 Configure motor-to-axis mappings for dual table homing operations.

Function Documentation

◆ ActivateTable()

CommonDualTableScreenV02 DualTable ActivateTable ( )

Activate a dual table in a protected call context.

Calls _ActivateTable() using w.pcall() for protected execution. If the activation fails, calls Cancelled() to reset the table selection to an invalid state. This wrapper ensures that failed table activations are handled gracefully without leaving the machine in an inconsistent state.

Parameters
tablenumber(number) The table number to activate (1, 2, or 3)
See also
CommonDualTableScreenV02.DualTable:_ActivateTable() for the actual activation implementation
CommonDualTableScreenV02.DualTable:Cancelled() for error recovery behavior
Note
Documentation generated by AI on 2026-03-03

◆ AreTablesCloseToTheSamePosition()

CommonDualTableScreenV02 DualTable AreTablesCloseToTheSamePosition ( )

Check if the dual table master and slave motors are close to the same physical position.

Retrieves the motor positions for both the master and slave motors in setup units, converts them to inches, and checks if the absolute difference is within 0.25 inches. Logs the position difference for diagnostic purposes.

Returns
(boolean) True if the tables are within 0.25 inches of each other, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ Create()

CommonDualTableScreenV02 DualTable Create ( )

Create and initialize a dual table instance for the specified Mach4 instance.

Constructs a new DualTable object using setmetatable and reads all required OEM parameters: MasterAxisID, SlaveAxisAxisID, MasterMotorID, SlaveMotorID, DualTableAxisParkPosition, DualTableForceTableSelectionOnStartup, and DualTableMotorSwappingEnabled. If motor swapping is enabled and the dual table feature is active, hides the slave axis from the UI via m.screen.HideAxis(). Raises w.Error() if any OEM parameter lookup fails.

Parameters
inst(number) The Mach4 instance handle. If nil, uses mc.mcGetInstance() with a descriptive tag
Returns
(table) The newly created DualTable object with all configuration fields populated
Note
Documentation generated by AI on 2026-03-03

◆ DualTableApplyDefaultMotorMappings()

CommonDualTableScreenV02 DualTable DualTableApplyDefaultMotorMappings ( )

Configure default motor-to-axis mappings for dual table operation.

Unmaps all motors from both master and slave axes, then maps each motor back to its default axis (master motor to master axis, slave motor to slave axis). Applies the new mappings to the motion controller after configuration.

Note
Documentation generated by AI on 2026-03-03

◆ DualTableApplyHomingMotorMappings()

CommonDualTableScreenV02 DualTable DualTableApplyHomingMotorMappings ( )

Configure motor-to-axis mappings for dual table homing operations.

Unmaps all motors from both master and slave axes, then configures mappings based on whether the tables are close to the same position:

  • If tables are NOT close to the same position: maps each motor to its own axis and sets the slave axis home order to match the master axis so both home simultaneously.
  • If tables ARE close to the same position: disables the slave axis and maps both master and slave motors to the master axis so only one axis homes. Applies the new mappings to the motion controller after configuration.
    Note
    Documentation generated by AI on 2026-03-03

◆ DualTableAutoStart()

CommonDualTableScreenV02 DualTable DualTableAutoStart ( )

Trigger dual table auto-start of the next program after a table switch.

Executes the PreDualTableAutoStart hook chain before proceeding. If auto-start next program is active, checks whether the per-table flag feature is enabled and whether the flag is set for the currently selected table. If the flag is not set, logs a message and returns without starting. If the flag is set, resets it and then calls mcCntlCycleStart if the machine is in a valid (non-running) state.

Returns
(nil) No meaningful primary return value on success
(boolean) False if the PreDualTableAutoStart hook fails, otherwise no explicit return
(string) Status message from w.FunctionError() on hook failure
Note
Cycle start is silently ignored if the machine is already in FRUN or MRUN state
Documentation generated by AI on 2026-03-03

◆ DualTableFinishHoming()

CommonDualTableScreenV02 DualTable DualTableFinishHoming ( )

Complete the homing sequence for dual table motor swapping.

After homing is complete, if the machine is enabled and the slave axis has no mapped motors, enables the slave axis and marks it as homed so it reports correct status. Then retrieves the current table selection (defaulting to table 1 if out of range) and calls SetDualTableModeSelection() to restore correct motor-to-axis mappings for the selected table.

Note
Returns immediately if dual table is not enabled or motor swapping is not enabled
Documentation generated by AI on 2026-03-03

◆ DualTablePrepareForHoming()

CommonDualTableScreenV02 DualTable DualTablePrepareForHoming ( )

Prepare dual table motor mappings before a homing operation begins.

Configures the motor-to-axis mappings required for homing dual table axes. If neither the master nor slave axis is homed, de-references both axes and resets their home orders from profile settings before applying homing motor mappings. If both are already homed, applies homing motor mappings directly. Raises an error if the machine is not enabled.

Warning
Raises w.Error() if the machine is not enabled when this function is called
Note
Returns immediately if dual table is not enabled or motor swapping is not enabled
Documentation generated by AI on 2026-03-03

◆ GetDualTableModeSelection()

CommonDualTableScreenV02 DualTable GetDualTableModeSelection ( )

Get the currently selected dual table number.

Reads the OEM parameter "DualTableModeSelection" and returns its numeric value. A value of -1 indicates no valid table is currently selected.

Returns
(number) The currently selected table number (1, 2, 3, or -1 if none selected)
Note
Documentation generated by AI on 2026-03-03

◆ InitializeDualTable()

CommonDualTableScreenV02 InitializeDualTable ( )

Initialize the dual table feature for all Mach4 instances.

Creates the m.DualTable table if it does not already exist. Iterates over all available instances and creates a DualTable object for each instance that does not already have one, using m.screen.DualTable:Create(). After creation, calls CreateHookScripts() on each instance's DualTable object to register all machine event hooks.

Note
Documentation generated by AI on 2026-03-03

◆ IsAxisMappedToDualTable()

CommonDualTableScreenV02 DualTable IsAxisMappedToDualTable ( )

Check if the specified axis is mapped to either the master or slave dual table axis.

Returns true if the given axis ID matches either the MasterAxisID or SlaveAxisAxisID configured for this dual table instance. If motor swapping is not enabled, always returns true since all axes are considered valid.

Parameters
axis(number) The axis number to check
Returns
(boolean) True if the axis is a dual table axis or motor swapping is disabled, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableAutoStartNextProgramActive()

CommonDualTableScreenV02 IsDualTableAutoStartNextProgramActive ( )

Check if dual table auto-start next program is active for the selected instance.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Returns
(boolean) False if dual table is not enabled, otherwise true if auto-start next program is active
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableAutoStartNextProgramTableFlagSet()

CommonDualTableScreenV02 IsDualTableAutoStartNextProgramTableFlagSet ( tablenumber )

Check if the auto-start program flag is set for a specific dual table.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Parameters
tablenumber(number) The table number to check the auto-start flag for
Returns
(boolean) False if dual table is not enabled, otherwise true if the flag is set for the specified table
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableAutoSwitchTableEnabled()

CommonDualTableScreenV02 IsDualTableAutoSwitchTableEnabled ( )

Check if dual table auto-switching between tables is enabled for the selected instance.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Returns
(boolean) False if dual table is not enabled, otherwise true if auto-switch table is enabled
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableEnabled()

CommonDualTableScreenV02 IsDualTableEnabled ( inst )

Check if the dual table feature is enabled for the specified instance.

Reads the OEM parameter "DualTableEnabled" and returns true if its value is "Yes". If the feature is not enabled, resets DualTableModeSelection and DualTableAutoSwitchTableEnabled OEM parameters to 0 to ensure a clean disabled state.

Parameters
inst(number) The Mach4 instance handle. If not provided, uses current instance
Returns
(boolean) True if dual table is enabled ("Yes"), false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableEnabledWithUserMessage()

CommonDualTableScreenV02 DualTable IsDualTableEnabledWithUserMessage ( )

Check if dual table is enabled and display a user-facing warning if not.

Calls IsEnabled() to check the dual table enabled state. If the feature is not enabled, displays a warning message to the operator via m.SetWarningMessage() before returning false.

Returns
(boolean) True if dual table is enabled, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableModeSelection() [1/2]

CommonDualTableScreenV02 DualTable IsDualTableModeSelection ( )

Check if the specified table number is the currently active dual table selection.

Compares the given table number against the current DualTableModeSelection OEM parameter value. Defaults to table 1 if tablenumber is nil.

Parameters
tablenumber(number|nil) The table number to check. If nil, defaults to 1
Returns
(boolean) True if the specified table is currently selected, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableModeSelection() [2/2]

CommonDualTableScreenV02 IsDualTableModeSelection ( tablenumber )

Check if the specified table number is the currently active dual table selection.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Parameters
tablenumber(number) The table number to check against the current selection
Returns
(boolean) False if dual table is not enabled, otherwise true if the specified table is currently selected
Note
Documentation generated by AI on 2026-03-03

◆ IsDualTableMotorSwappingEnabled()

CommonDualTableScreenV02 DualTable IsDualTableMotorSwappingEnabled ( )

Check if dual table motor swapping is enabled, using a cache for performance.

Reads the OEM parameter "DualTableMotorSwappingEnabled" and returns true if its value is "Yes". The result is cached using w.IsCached() / w.GetCache() / w.SetCache() to avoid repeated OEM parameter lookups on subsequent calls.

Returns
(boolean) True if dual table motor swapping is enabled, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ IsEnabled()

CommonDualTableScreenV02 DualTable IsEnabled ( )

Check if the dual table feature is enabled for this instance.

Returns
(boolean) True if dual table is enabled, false otherwise
Note
Documentation generated by AI on 2026-03-03

◆ OnEnableUpdateDualTable()

CommonDualTableScreenV02 DualTable OnEnableUpdateDualTable ( )

Update dual table state when the machine is enabled.

Called as part of the EnableFinal hook to synchronize dual table motor mappings after machine enable. Verifies all axes are homed before proceeding. If motor swapping is enabled, checks the current table selection and verifies motor mappings are correct, forcing a table re-selection if mappings are wrong or ForceTableSelectionOnStartup is set. If motor swapping is not enabled, retrieves the current table selection and runs the corresponding safe-start G-code via MDI command.

Note
Returns immediately if dual table is not enabled or axes are not all homed
Documentation generated by AI on 2026-03-03

◆ ResetDualTableAutoStartNextProgramTableFlag()

CommonDualTableScreenV02 ResetDualTableAutoStartNextProgramTableFlag ( tablenumber )

Reset the auto-start program table flag for a specific dual table.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Parameters
tablenumber(number) The table number whose auto-start flag should be reset
Returns
(boolean) False if dual table is not enabled, otherwise the result of the delegate call
Note
Documentation generated by AI on 2026-03-03

◆ SelectFileForTable()

CommonDualTableScreenV02 SelectFileForTable ( tablenumber )

Open a file selection dialog to choose a G-code file for a specific dual table.

Displays a wxWidgets file open dialog filtered for common G-code file types. Remembers the last browsed directory per table number. If the GC Adapter OEM parameter is enabled, the selected file is pre-processed through the adapter before being saved. Saves the selected file path to the DualTableGCodeTable1 or DualTableGCodeTable2 OEM parameter depending on tablenumber. If the selected table is currently active, immediately loads the G-code file.

Parameters
tablenumber(number) The table number to select a file for (1 or 2)
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted() or w.FunctionError()
Note
Returns immediately without showing a dialog if dual table is not enabled
Documentation generated by AI on 2026-03-03

◆ SetDualTableAutoStartNextProgramTableFlag()

CommonDualTableScreenV02 SetDualTableAutoStartNextProgramTableFlag ( tablenumber )

Set the auto-start program table flag for a specific dual table.

Delegates to the DualTable instance for the selected Mach4 instance. Returns false immediately if dual table is not enabled.

Parameters
tablenumber(number) The table number whose auto-start flag should be set
Returns
(boolean) False if dual table is not enabled, otherwise the result of the delegate call
Note
Documentation generated by AI on 2026-03-03

◆ SetDualTableModeSelection()

CommonDualTableScreenV02 DualTable SetDualTableModeSelection ( )

Activate the specified table and update all related dual table state.

Performs the full table selection sequence: verifies machine is enabled and idle, activates the table via ActivateTable(), disables auto-switching if table 3 is selected, loads the appropriate G-code file via DualTableLoadGCode(), and writes the new table selection to the DualTableModeSelection OEM parameter.

Parameters
tablenumber(number) The table number to select and activate (1, 2, or 3)
Warning
Machine must be enabled and in IDLE state. Displays a warning and returns if not.
Note
Documentation generated by AI on 2026-03-03

◆ SetDualTableModeSelectionBtn() [1/2]

CommonDualTableScreenV02 DualTable SetDualTableModeSelectionBtn ( )

Handle the operator button press to select a dual table.

Validates that the machine is enabled and in IDLE or HOME state before proceeding. If motor swapping is enabled, verifies that both master and slave axes are homed, prompting to home if not. When motor swapping is enabled, presents a CycleStartDialog confirmation before activating the table. Without motor swapping, calls SetDualTableModeSelection() directly.

Parameters
tablenumber(number) The table number selected by the operator (1, 2, or 3)
Returns
(nil) No meaningful primary return value
(boolean) False on homing error, otherwise no explicit return
(string) Status message from w.FunctionError() on error
Warning
Machine must be enabled and in IDLE or HOME state. Displays a warning and returns if not.
Note
Documentation generated by AI on 2026-03-03

◆ SetDualTableModeSelectionBtn() [2/2]

CommonDualTableScreenV02 SetDualTableModeSelectionBtn ( tablenumber )

Handle operator button press to select a dual table.

Logs the operator action and delegates to the DualTable instance for the selected Mach4 instance. Returns immediately without action if dual table is not enabled.

Parameters
tablenumber(number) The table number selected by the operator (1, 2, or 3)
Returns
(boolean) True on success
(boolean) True - success flag
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03

◆ SetDualTableToDefaultSelection()

CommonDualTableScreenV02 DualTable SetDualTableToDefaultSelection ( )

Switch the active dual table to the configured default table selection.

Retrieves the selected Mach4 instance and delegates to the DualTable instance's SetDualTableToDefaultSelection() method. Returns immediately if dual table is not enabled.

Note
Documentation generated by AI on 2026-03-03

Reads the "DualTableDefaultTable" OEM parameter to determine the default table number. Supported values are "Table 1" (1), "Table 2" (2), "Current Table" (-1, no switch), and any other value defaults to table 3. If the current selection differs from the default and the default is not "Current Table", calls SetDualTableModeSelectionBtn() to switch to the default table.

Note
Returns immediately if dual table is not enabled
Documentation generated by AI on 2026-03-03

◆ ToggleDualTableAutoStartNextProgram()

CommonDualTableScreenV02 ToggleDualTableAutoStartNextProgram ( )

Toggle the dual table auto-start next program setting for the selected instance.

Logs the operator action, then delegates to the DualTable instance for the selected Mach4 instance to toggle the auto-start next program setting. Returns immediately if dual table is not enabled.

Note
Documentation generated by AI on 2026-03-03

◆ ToggleDualTableAutoSwitchTableEnabled()

CommonDualTableScreenV02 ToggleDualTableAutoSwitchTableEnabled ( )

Toggle dual table auto-switching between tables for the selected instance.

Logs the operator action, then delegates to the DualTable instance for the selected Mach4 instance to toggle the auto-switch table enabled setting. Returns immediately if dual table is not enabled.

Returns
(boolean) True on success (from w.FunctionCompleted())
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03