|
Mach Modules Documentation
Lua Module API Documentation
|
Go to the source code of this file.
Functions | |
| CommonGUIModule | RunHooks (hook_name,...) |
| Run registered hook scripts for the specified hook event. | |
| CommonGUIModule | RunHooksSilent (hook_name,...) |
| Run registered hook scripts silently without logging completion messages. | |
| CommonGUIModule | EnableBtn () |
| Enable the machine after verifying alarm, emergency stop, and safety relay preconditions. | |
| CommonGUIModule | ToggleEnableBtn () |
| Button handler to toggle the machine enable state on or off. | |
| CommonGUIModule | DisableBtn () |
| Disable the machine by setting the machine enable signal to false. | |
| CommonGUIModule | StartEnableSequence (async) |
| Initiate the machine enable sequence with re-entrancy protection and jog inhibit management. | |
| CommonGUIModule | StartDisableSequence () |
| Initiate the machine disable sequence with re-entrancy protection. | |
| CommonGUIModule | IsMachEnabled (inst) |
| Check whether the machine is currently enabled and update global enable state variables. | |
| CommonGUIModule | EmergencyStop () |
| Perform an emergency stop by disabling drives and turning off all active outputs. | |
| CommonGUIModule | CycleStartBtn () |
| Button handler to initiate a cycle start operation. | |
| CommonGUIModule | CycleStart (inst) |
| Initiate a cycle start with re-entrancy protection and cycle start hold handling. | |
| CommonGUIModule | IsMSTAndDryRunActive () |
| Check whether MST lock or dry run is active and prompt the operator to confirm cycle start. | |
| CommonGUIModule | OpenExternalApplication () |
| Open the external conversational assistant application. | |
| CommonGUIModule | MDIBtn () |
| Button handler to execute MDI (Manual Data Input) G-code from the MDI input field. | |
| CommonGUIModule | FeedHoldBtn () |
| Button handler to initiate a feed hold to pause program execution. | |
| CommonGUIModule | FeedHold (inst) |
| Initiate a feed hold to pause program execution with re-entrancy protection. | |
| CommonGUIModule | FeedHoldRetractBtn () |
| Button handler to initiate a feed hold retract operation. | |
| CommonGUIModule | FeedHoldRetract (inst) |
| Initiate a feed hold retract operation with re-entrancy protection. | |
| CommonGUIModule | IsFeedHoldRetract () |
| Check whether the feed hold retract output signal is currently active. | |
| CommonGUIModule | CycleStopBtn () |
| Button handler to stop the currently running G-code program. | |
| CommonGUIModule | CycleStop (...) |
| Stop the currently running G-code program with re-entrancy protection. | |
| CommonGUIModule | CycleStopRestoreGCodeLineNum (gcodeline, inst) |
| Restore the G-code line number to the value recorded at the time of cycle stop. | |
| CommonGUIModule | ConvertIgnoreOutputsString (output_range) |
| Convert a semicolon or comma-separated output range string to an array of output numbers. | |
| CommonGUIModule | StopAuxiliaries () |
| Stop all auxiliary outputs and signals after a cycle stop or disable event. | |
| CommonGUIModule | RewindBtn () |
| Button handler to rewind the currently loaded G-code file to the beginning. | |
| CommonGUIModule | Rewind () |
| Rewind the currently loaded G-code file to the beginning. | |
| CommonGUIModule | ResetBtn () |
| Button handler to reset the controller, running pre/post reset hooks. | |
| CommonGUIModule | EnableResetBtn () |
| Button handler to initiate the combined enable and reset sequence. | |
| CommonGUIModule | ToggleEnableResetBtn () |
| Button handler to toggle the enable/reset state based on current machine enable status. | |
| CommonGUIModule | EnableReset () |
| Perform a combined enable and reset operation with re-entrancy protection. | |
| CommonGUIModule | MotionControllerPreEnable () |
| Run the motion controller pre-enable sequence for all instances. | |
| CommonGUIModule | Reset () |
| Reset the Mach4 controller with re-entrancy protection. | |
| CommonGUIModule | ResetSafetyRelay () |
| Reset the safety relay circuit with re-entrancy protection. | |
| CommonGUIModule | IsSafetyRelayCleared () |
| Check whether the safety relay circuit is currently in the cleared (OK) state. | |
| CommonGUIModule | MotionInhibitStart () |
| Activate motion inhibit while the machine is running to pause program execution. | |
| CommonGUIModule | MotionInhibitEnd () |
| Release an active motion inhibit and allow program execution to continue. | |
| CommonGUIModule | IsMotionInhibitEnabled () |
| Check whether the motion inhibit interlock feature is configured and enabled. | |
| CommonGUIModule | IsMotionInhibitActive () |
| Check whether the motion inhibit signal is currently active. | |
| CommonGUIModule | UpdateMotionInhibit () |
| Release motion inhibit if the machine becomes idle. | |
| CommonGUIModule | InhibitJoggingWhenNotHomed () |
| Update jogging inhibit state for all instances based on homing status. | |
| CommonGUIModule | InhibitJoggingWhenNotHomedOverrideToggle (inst) |
| Toggle the jog inhibit override state for the specified instance. | |
| CommonGUIModule | SetInhibitJoggingWhenNotHomedOverride (on_off, inst) |
| Set the jog inhibit override state for the specified instance. | |
| CommonGUIModule | GetInhibitJoggingWhenNotHomedOverride (inst) |
| Get the current jog inhibit override state for the specified instance. | |
| CommonGUIModule | IsPartCounterQuotaReached () |
| Check whether the required part counter quota has been reached. | |
| CommonGUIModule | GcodeRecentNoCBtn () |
| Button handler to open the recent G-code file list without the GC Adapter. | |
| CommonGUIModule | GcodeRecentBtn () |
| Button handler to open the Recent GCode file selector. | |
| UI | CloseDialog () |
| Close the Recent GCode dialog and release associated resources. | |
| CommonGUIModule | GcodeLoadBtn () |
| Button handler to load a G-code file. | |
| CommonGUIModule | GcodeEditBtn () |
| Button handler to open the currently loaded G-code file in an editor. | |
| CommonGUIModule | GcodeCloseBtn () |
| Button handler to close the currently loaded G-code file. | |
| CommonGUIModule | GcodeClose () |
| Close the currently loaded G-code file. | |
| CommonGUIModule | GcodeShortcutBtn (short_num, inst) |
| Button handler to load a G-code shortcut file by index. | |
| CommonGUIModule | GcodeShortcut (short_num, inst) |
| Load a G-code shortcut file by index for the specified instance. | |
| CommonGUIModule | DeReferenceAllBtn () |
| Button handler to dereference all axes on the current Mach4 instance. | |
| CommonGUIModule | DeReferenceAll () |
| Dereference all axes on the current Mach4 instance. | |
| CommonGUIModule | DeReferenceAllInstances (inst_list) |
| Dereference all axes on each instance in the provided instance list. | |
| CommonGUIModule | DeReferenceAxis (Axis, _inst) |
| Dereference (un-home) a single axis or all axes on the specified instance. | |
| CommonGUIModule | HomeOverrideAxes (main_axis, inst) |
| Home override (OB/secondary) axes associated with the specified primary axis. | |
| CommonGUIModule | HomeAllBtn () |
| Button handler to home all axes using the configured HomeAllBtnOptions parameter. | |
| CommonGUIModule | HomeAllSelectedInstance (confirm_homing, only_dereferenced_axes) |
| Home all axes on the currently selected Mach4 instance with optional confirmation. | |
| CommonGUIModule | HomeAll (confirm_homing, only_dereferenced_axes, inst_list) |
| Home all axes on one or more Mach4 instances with full precondition checks and hook support. | |
| CommonGUIModule | HomeAllDereferencedAxes (confirm_homing, selected_inst) |
| Home all dereferenced (unhomed) axes only, with optional confirmation. | |
| CommonGUIModule | HomeAxis (AxisID, use_confirmation) |
| Home a single axis with optional confirmation dialog and comprehensive precondition checks. | |
| CommonGUIModule | HomeXBtn () |
| Button handler to home the X axis. | |
| CommonGUIModule | HomeYBtn () |
| Button handler to home the Y axis. | |
| CommonGUIModule | HomeZBtn () |
| Button handler to home the Z axis. | |
| CommonGUIModule | HomeABtn () |
| Button handler to home the A axis. | |
| CommonGUIModule | HomeBBtn () |
| Button handler to home the B axis. | |
| CommonGUIModule | HomeCBtn () |
| Button handler to home the C axis. | |
| CommonGUIModule | HomeOB1Btn () |
| Button handler to home the OB1 (AXIS6) axis. | |
| CommonGUIModule | HomeOB2Btn () |
| Button handler to home the OB2 (AXIS7) axis. | |
| CommonGUIModule | HomeOB3Btn () |
| Button handler to home the OB3 (AXIS8) axis. | |
| CommonGUIModule | HomeOB4Btn () |
| Button handler to home the OB4 (AXIS9) axis. | |
| CommonGUIModule | HomeOB5Btn () |
| Button handler to home the OB5 (AXIS10) axis. | |
| CommonGUIModule | HomeOB6Btn () |
| Button handler to home the OB6 (AXIS11) axis. | |
| CommonGUIModule | AutoEnableSoftlimits (inst) |
| Automatically enable software limits after homing if configured to do so. | |
| CommonGUIModule | CycleStartSoftLimitRecovery (inst) |
| Check and recover axes that are outside the software limit zone before cycle start. | |
| CommonGUIModule | WaitForHoming (AxisID, inst) |
| Wait for the machine to return to IDLE state after a homing operation. | |
| CommonGUIModule | IsAxisHoming (AxisID) |
| Check whether a specific axis is currently in the process of homing. | |
| CommonGUIModule | CreateLimitSwitchActiveMessage (message, title) |
| Create a persistent GMS notification for a limit switch active condition. | |
| CommonGUIModule | ClearLimitSwitchActiveMessage (handle) |
| Close and dismiss a limit switch active notification by handle. | |
| CommonGUIModule | SoftLimitToggleBtn () |
| Button handler to toggle software limits on or off. | |
| CommonGUIModule | OpenM00Notification (message, line, inst) |
| Open an M00/M01 program stop notification and record the stop line number. | |
| CommonGUIModule | CloseM00Notification () |
| Close the M00/M01 stop notification and clear the optional stop active register. | |
| CommonGUIModule | IsM00Active (inst) |
| Check whether a program stop (M00) is currently active at the current G-code line. | |
| CommonGUIModule | VerifyHoming (IgnoreSaftyCheck, inst) |
| Verify that all required axes are homed - delegates to the wrapper module implementation. | |
| CommonGUIModule | IsAxisHomed (AxisID, IgnoreSaftyCheck, inst) |
| Check whether a specific axis is homed - delegates to the wrapper module implementation. | |
| CommonGUIModule | ZeroAllBtn (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Button handler to zero all axis fixture offsets simultaneously. | |
| CommonGUIModule | ZeroAxis (AxisID, IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the fixture offset for a single axis with optional confirmation and edit mode checks. | |
| CommonGUIModule | ZeroMultipleAxes (AxisID, IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the fixture offset for one or more axes simultaneously. | |
| CommonGUIModule | ZeroXBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the X axis fixture offset. | |
| CommonGUIModule | ZeroYBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the Y axis fixture offset. | |
| CommonGUIModule | ZeroZBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the Z axis fixture offset. | |
| CommonGUIModule | ZeroABtn (IgnoreConfirmationDialogs) |
| Button handler to zero the A axis fixture offset. | |
| CommonGUIModule | ZeroBBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the B axis fixture offset. | |
| CommonGUIModule | ZeroCBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the C axis fixture offset. | |
| CommonGUIModule | ZeroXYBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the X and Y axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroXY (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the X and Y axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroXZBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the X and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroXZ (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the X and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroYZBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the Y and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroYZ (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the Y and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroXYZBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the X, Y, and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroXYZ (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the X, Y, and Z axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroABCBtn (IgnoreConfirmationDialogs) |
| Button handler to zero the A, B, and C axes fixture offsets simultaneously. | |
| CommonGUIModule | ZeroABC (IgnoreConfirmationDialogs, IgnoreEditMode) |
| Zero the A, B, and C axes fixture offsets simultaneously. | |
| CommonGUIModule | ModifyAxisPosition (AxisID, Position, SkipUpdating) |
| Modify an axis position by setting a new fixture offset value. | |
| CommonGUIModule | SetCurrentFixtureOffsetDRO (value, AxisID,...) |
| DRO callback to set the current fixture offset for the specified axis. | |
| CommonGUIModule | SetCurrentFixtureOffset (AxisID, value, inst) |
| Set the current fixture offset value for the specified axis. | |
| CommonGUIModule | UpdateGlobalWithActiveFixtureIndex () |
| Update the global active fixture offset index variables from the current Mach4 state. | |
| CommonGUIModule | ActivateFixtureOffset (fixture) |
| Activate a fixture offset by executing the corresponding G-code command via MDI. | |
| CommonGUIModule | IsFixtureOffset (fixture) |
| Check whether the specified fixture offset index is currently active. | |
| CommonGUIModule | ReverseRunBtn () |
| Button handler to initiate a reverse run operation. | |
| CommonGUIModule | IsMistOn () |
| Check whether the mist coolant output is currently active. | |
| CommonGUIModule | MistOn () |
| Turn on the mist coolant output for the selected instance. | |
| CommonGUIModule | MistOff () |
| Turn off the mist coolant output for the selected instance. | |
| CommonGUIModule | MistToggleBtn () |
| Button handler to toggle mist coolant on or off. | |
| CommonGUIModule | FloodOn () |
| Turn on the flood coolant output for the selected instance. | |
| CommonGUIModule | FloodOff () |
| Turn off the flood coolant output for the selected instance. | |
| CommonGUIModule | IsFloodOn () |
| Check whether the flood coolant output is currently active. | |
| CommonGUIModule | CoolantToggleBtn () |
| Button handler to toggle flood coolant on or off. | |
| CommonGUIModule | AllCoolantOffBtn () |
| Button handler to turn off all coolant outputs (mist and flood). | |
| CommonGUIModule | SingleBlockToggleBtn (inst) |
| Button handler to toggle single block mode on or off. | |
| CommonGUIModule | IsSingleBlockOn (inst) |
| Check whether single block mode is currently active for the specified instance. | |
| CommonGUIModule | SingleBlockOn (inst) |
| Turn on single block mode for the specified instance. | |
| CommonGUIModule | SingleBlockOff (inst) |
| Turn off single block mode for the specified instance. | |
| CommonGUIModule | OptionalStopToggleBtn () |
| Button handler to toggle the optional stop (M1) feature on or off. | |
| CommonGUIModule | IsOptionalStopOn () |
| Check whether the optional stop (M1) feature is currently enabled. | |
| CommonGUIModule | OptionalStopOn () |
| Turn on the optional stop (M1) feature for the current instance. | |
| CommonGUIModule | OptionalStopOff () |
| Turn off the optional stop (M1) feature for the current instance. | |
| CommonGUIModule | MachineCoordToggleBtn () |
| Toggle the machine coordinate display mode on or off. | |
| CommonGUIModule | BlockDeleteToggleBtn () |
| Toggle block delete mode on or off, showing a level selection dialog if needed. | |
| UI | SetupDialog () |
| Initialize the block delete level checkboxes from the saved Mach4 profile values. | |
| UI | SaveSettings () |
| Save the current block delete level checkbox states to the Mach4 profile and apply them. | |
| CommonGUIModule | DistanceToGoToggleBtn () |
| Toggle the distance-to-go display mode on or off. | |
| CommonGUIModule | LimitOverrideToggle () |
| Toggle the limit override signal on or off with password protection. | |
| CommonGUIModule | RunFromHereBtn () |
| Button handler to initiate a run-from-here operation at the current G-code line. | |
| w | OperatorLog (inst, "Run From Here Pressed") |
| Write an operator action message to the Mach4 operator log. | |
| CommonGUIModule | FileResumeBtn () |
| Button handler to initiate the file resume sequence. | |
| CommonGUIModule | FileResume () |
| Execute the file resume sequence using the configured resume mode. | |
| CommonGUIModule | IsFileResumeActive () |
| Check whether a file resume or run-from-here operation is currently active. | |
| CommonGUIModule | FileResumeAdvancedBtn () |
| Button handler to initiate the advanced file resume sequence. | |
| CommonGUIModule | FileResumeAdvanced () |
| Execute the advanced file resume sequence to reposition and restart from the current G-code line. | |
| CommonGUIModule | FileResumeSimplifedBtn () |
| Button handler to initiate the simplified file resume sequence. | |
| CommonGUIModule | FileResumeSimplifed () |
| Execute the simplified file resume sequence to reposition and restart from the current G-code line. | |
| CommonGUIModule | FindToolChangeBtn () |
| Open the Find Tool Change dialog for the currently loaded G-code file. | |
| CommonGUIModule | SearchGCodeBtn () |
| Open the G-code search dialog for the currently loaded G-code file. | |
| CommonGUIModule | IsDryRunOn () |
| Check whether dry run mode is currently active for the selected instance. | |
| CommonGUIModule | SetDryRun (on_off) |
| Set the dry run mode on or off for the selected instance. | |
| CommonGUIModule | DryRunToggleBtn () |
| Button handler to toggle dry run mode on or off. | |
| CommonGUIModule | DryRunToggle () |
| Toggle dry run mode on or off based on its current state. | |
| CommonGUIModule | IncludeCommentsInMessages (on_off) |
| Enable or disable inclusion of G-code comments in message output. | |
| CommonGUIModule | SaveFixtureOffsets () |
| Save fixture offsets to disk for all idle Mach4 instances. | |
| CommonGUIModule | SaveToolOffsets () |
| Save tool offsets to disk for all idle Mach4 instances. | |
| CommonGUIModule | SaveSysVars () |
| Save system variables to disk for all idle Mach4 instances. | |
| CommonGUIModule | ManagePartZeros () |
| Record the current fixture offsets to the profile as a rolling history of up to 10 entries. | |
| CommonGUIModule | SetWarningMessage (Message, TimeOut, EveryWhere, Title, Size, inst) |
| Display a warning message - delegates to the wrapper module implementation. | |
| CommonGUIModule | GetBlendedVelocity () |
| Calculate the blended (resultant) velocity across all enabled linear axes. | |
| CommonGUIModule | IsAxisRotary (AxisID, inst) |
| Check whether a specified axis is configured as a rotary axis. | |
| CommonGUIModule | InitializeRotaryAxesFeedrateMode () |
| Initialize the feedrate mode for all configured rotary axes from OEM parameters. | |
| CommonGUIModule | SetRotaryAxisFeedrateMode (axis_id, val) |
| Set the feedrate mode for a rotary axis. | |
| CommonGUIModule | IsRotaryAxisFeedrateModeConstantSurfaceSpeed (axis_id) |
| Check whether a rotary axis feedrate mode is set to Constant Surface Speed. | |
| CommonGUIModule | GetAxisVelocity (AxisID) |
| Get the current velocity of a single axis for the selected instance. | |
| CommonGUIModule | ManualMode (Active) |
| Activate or deactivate manual mode for the current Mach4 instance. | |
| CommonGUIModule | ManualModeToggle () |
| Toggle manual mode on or off based on the current ManualModeActive register state. | |
| CommonGUIModule | ManualModeIsActive (AutoMessage) |
| Check whether manual mode is currently active and optionally display a warning. | |
| CommonGUIModule | MSTLockToggleBtn () |
| Toggle the M-S-T lock on or off based on its current state. | |
| CommonGUIModule | IsMSTLockOn () |
| Check whether the M-S-T lock is currently active for the selected instance. | |
| CommonGUIModule | MSTLockOn () |
| Turn on the M-S-T lock for the selected instance if the machine is idle. | |
| CommonGUIModule | MSTLockOff () |
| Turn off the M-S-T lock for the selected instance. | |
| CommonGUIModule | ZAxisLockToggleBtn () |
| Button handler placeholder for Z-axis lock toggle. | |
| CommonGUIModule | MachineLockToggleBtn () |
| Button handler placeholder for machine lock toggle. | |
| CommonGUIModule | IsWorkLightEnabled () |
| Check whether the work light output signal is mapped and the feature is enabled. | |
| CommonGUIModule | InitializeWorkLight () |
| Initialize the work light feature and restore its previous on/off state. | |
| CommonGUIModule | WorkLightOn () |
| Turn on the work light output signal and save the on state. | |
| CommonGUIModule | WorkLightOff (dontsaveoutputstate) |
| Turn off the work light output signal and optionally save the off state. | |
| CommonGUIModule | IsWorkLightOn () |
| Check whether the work light output signal is currently active. | |
| CommonGUIModule | WorkLightToggle () |
| Toggle the work light on or off based on its current state. | |
| CommonGUIModule | DisableLoggingOnOutputs () |
| Disable signal-change logging on high-frequency axis movement and deceleration output signals. | |
| CommonGUIModule | PLCSequenceDialogBtn () |
| Open the PLC Sequence dialog allowing the operator to manually trigger PLC sequences. | |
| UI | ClosePLCSeqDialog () |
| Close the PLC Sequence dialog and release associated resources. | |
| CommonGUIModule | CommandsDialogBtn () |
| Open the Commands dialog allowing the operator to browse and run user commands. | |
| UI | filter (search_term) |
| Filter the commands list box to show only entries matching the search term. | |
| UI | CloseCommandsDialog () |
| Close the Commands dialog and release associated resources. | |
| CommonGUIModule | GoToPositionDialogBtn () |
| Open the GoTo Positions dialog allowing the operator to select and move to a named position. | |
| UI | CloseDialog (reason) |
| Close the GoTo Positions dialog and release the cycle start hold. | |
| CommonGUIModule | MoveToGoToPosition (goto_position_name) |
| Move the machine to the named GoTo position using a configured G-code string. | |
| CommonGUIModule | ToggleOnScreenJogBtn () |
| Toggle the on-screen jog buttons panel on or off. | |
| CommonGUIModule | InitializeSelectedSpindle (inst) |
| Initialize the selected spindle to the configured default spindle number. | |
| CommonGUIModule | GetDefaultSpindleNumber (inst) |
| Get the default spindle number for the specified Mach4 instance. | |
| CommonGUIModule | GetSelectedSpindleNumber (inst) |
| Get the currently selected spindle number for the specified Mach4 instance. | |
| CommonGUIModule | IsSelectedSpindleNumber (inst, spindle) |
| Check whether the specified spindle number is currently selected for the given instance. | |
| CommonGUIModule | SetSelectedSpindleNumber (inst, spindle) |
| Set the selected spindle number for the specified Mach4 instance. | |
| CommonGUIModule | ToggleSpindleBrake (inst) |
| Toggle the spindle brake on or off based on its current state. | |
| CommonGUIModule | ToggleSpindleFWD (use_confirmation, inst) |
| Toggle the spindle between forward and stopped states. | |
| CommonGUIModule | ToggleSpindleREV (use_confirmation, inst) |
| Toggle the spindle between reverse and stopped states. | |
| CommonGUIModule | IsSpindleOn (inst) |
| Check whether the spindle is currently running in any direction. | |
| CommonGUIModule | SpindleSafetyCheck (inst) |
| Verify that the machine is in a safe state to start the spindle. | |
| CommonGUIModule | SpindleFWDBtn (use_confirmation) |
| Button handler to start the spindle in forward direction. | |
| CommonGUIModule | SpindleFWD (use_confirmation) |
| Start the spindle in forward direction by executing the M3 M-code script. | |
| CommonGUIModule | SpindleREVBtn (use_confirmation) |
| Button handler to start the spindle in reverse direction. | |
| CommonGUIModule | SpindleREV (use_confirmation) |
| Start the spindle in reverse direction by executing the M4 M-code script. | |
| CommonGUIModule | SpindleStopBtn () |
| Button handler to stop the spindle. | |
| CommonGUIModule | SpindleStop () |
| Stop the spindle by executing the M5 M-code script. | |
| CommonGUIModule | StopSpindleDuringToolPathRegen (inst) |
| Stop the spindle during a tool path regeneration operation. | |
| CommonGUIModule | SetSpindleOverride (percentage) |
| Set the spindle override percentage with hook support and bounds clamping. | |
| CommonGUIModule | SpindleFWDWait (use_confirmation) |
| Start the spindle in forward direction and wait for it to reach speed. | |
| CommonGUIModule | SpindleREVWait (use_confirmation) |
| Start the spindle in reverse and wait for it to reach speed. | |
| CommonGUIModule | SpindleStopWait () |
| Stop the spindle and wait for the stop to complete. | |
| CommonGUIModule | CheckSpindleOverride (value,...) |
| Clamp a spindle override percentage to the configured minimum and maximum bounds. | |
| CommonGUIModule | GetSpindleOverride () |
| Get the current spindle override percentage. | |
| CommonGUIModule | SpindleOverrideIncrement (increment) |
| Increment the spindle override percentage by the configured or specified increment. | |
| CommonGUIModule | SpindleOverrideDecrement (increment) |
| Decrement the spindle override percentage by the configured or specified increment. | |
| CommonGUIModule | SetFeedrateOverride (percentage) |
| Set the feedrate override percentage with hook support and bounds clamping. | |
| CommonGUIModule | GetFeedrateOverride () |
| Get the current feedrate override percentage. | |
| CommonGUIModule | CheckFeedrateOverride (value,...) |
| Clamp a feedrate override percentage to the configured minimum and maximum bounds. | |
| CommonGUIModule | FeedrateOverrideIncrementAmount (amount, increment) |
| Increment the feedrate override by repeatedly calling FeedrateOverrideIncrement. | |
| CommonGUIModule | FeedrateOverrideIncrement (increment) |
| Increment the feedrate override percentage by the configured or specified increment. | |
| CommonGUIModule | FeedrateOverrideDecrementAmount (amount, increment) |
| Decrement the feedrate override by repeatedly calling FeedrateOverrideDecrement. | |
| CommonGUIModule | FeedrateOverrideDecrement (increment) |
| Decrement the feedrate override percentage by the configured or specified increment. | |
| CommonGUIModule | SpindleOrientBtn () |
| Button handler to orient the spindle. | |
| CommonGUIModule | SpindleOrient (use_confirmation) |
| Orient the spindle to its home position using M19. | |
| CommonGUIModule | SpindleOrientToggleBtn (use_confirmation) |
| Toggle spindle orient on or off based on current orient state. | |
| CommonGUIModule | IsSpindleOriented () |
| Check whether the spindle is currently in the oriented position. | |
| CommonGUIModule | IsSpindleOrientedBtn () |
| Get the spindle orient state for use by a button indicator, including blink behavior. | |
| CommonGUIModule | SpindleBrakeOnBtn () |
| Button handler to apply the spindle brake. | |
| CommonGUIModule | SpindleBrakeOn () |
| Apply the spindle brake by executing the SpindleBrakeOn M-code script. | |
| CommonGUIModule | SpindleBrakeOffBtn () |
| Button handler to release the spindle brake. | |
| CommonGUIModule | SpindleBrakeOff () |
| Release the spindle brake by executing the SpindleBrakeOff M-code script. | |
| CommonGUIModule | SpindleWarmUpBtn () |
| Button handler to start the spindle warm-up sequence. | |
| CommonGUIModule | SpindleWarmUp () |
| Execute a spindle warm-up sequence at the configured idle speed. | |
| CommonGUIModule | IsSpindleWarmUpNeeded () |
| Check whether a spindle warm-up is currently needed. | |
| CommonGUIModule | SpindleWarmUpInterLockWithCycleStart () |
| Interlock spindle warm-up with cycle start to prevent running without completing warm-up. | |
| CommonGUIModule | SkipSpindleWarmUpBtn () |
| Button handler for skipping the spindle warm-up cycle. | |
| CommonGUIModule | SkipSpindleWarmUp () |
| Skip an active spindle warm-up cycle and mark warm-up as completed. | |
| CommonGUIModule | IsGangSpindleEnabled () |
| Check whether the gang spindle feature is enabled. | |
| CommonGUIModule | IsGangSpindleControlSourceCommandTypeRPM () |
| Check whether the gang spindle control source command type is RPM. | |
| CommonGUIModule | IsGangSpindleInGroup (idx) |
| Check whether a gang spindle at the given index is part of an active group. | |
| CommonGUIModule | GetGangSpindleMaxRPM () |
| Get the maximum RPM for the gang spindle control source. | |
| CommonGUIModule | GetGangSpindleCount () |
| Get the total number of configured gang spindles for the current instance. | |
| CommonGUIModule | IsGangSpindleEngaged (idx) |
| Check whether a specific gang spindle index is currently engaged. | |
| CommonGUIModule | UpdateGangSpindles () |
| Update all gang spindle command registers, feedback aggregation, and control signals. | |
| CommonGUIModule | StepIntoSubPrograms () |
| Set single-block execution to step into sub-programs. | |
| CommonGUIModule | StepOverSubPrograms () |
| Set single-block execution to step over (not into) sub-programs. | |
| CommonGUIModule | IsStepIntoSubPrograms () |
| Check whether step-into sub-programs mode is currently active. | |
| CommonGUIModule | StepIntoSubProgramsToggle () |
| Toggle between step-into and step-over sub-program execution modes. | |
| CommonGUIModule | CutterCompensationType_A (on_off) |
| Enable or disable cutter compensation type A. | |
| CommonGUIModule | IsCutterCompensationType_A () |
| Check whether cutter compensation type A is currently enabled. | |
| CommonGUIModule | CutterCompensationToggleType_A () |
| Toggle cutter compensation type A on or off. | |
| CommonGUIModule | CutterCompensationType_B (on_off) |
| Enable or disable cutter compensation type B. | |
| CommonGUIModule | IsCutterCompensationType_B () |
| Check whether cutter compensation type B is currently enabled. | |
| CommonGUIModule | CutterCompensationToggleType_B () |
| Toggle cutter compensation type B on or off. | |
| CommonGUIModule | CutterCompensationType_C (on_off) |
| Enable or disable cutter compensation type C (tool nose radius compensation vector correction). | |
| CommonGUIModule | IsCutterCompensationType_C () |
| Check whether cutter compensation type C is currently enabled. | |
| CommonGUIModule | CutterCompensationToggleType_C () |
| Toggle cutter compensation type C on or off. | |
| CommonGUIModule | CompileScriptsBtn () |
| Recompile all M-code scripts and reload the screen configuration. | |
| CommonGUIModule | InitializeSpindleRanges () |
| Initialize the spindle gear range for all Mach4 instances from the PLC or profile. | |
| CommonGUIModule | InitializeTools () |
| Initialize tool and pocket tracking for all Mach4 instances on startup. | |
| CommonGUIModule | UpdateCurrentToolAndPocketGlobals () |
| Update the global current tool number and tool pocket number arrays for all instances. | |
| CommonGUIModule | OpenToolPocketsDialogBtn () |
| Open the tool pockets dialog by setting the trigger register. | |
| CommonGUIModule | NextToolBtn (use_confirmation) |
| Change to the next tool number in the tool changer. | |
| CommonGUIModule | PreviousToolBtn (use_confirmation) |
| Change to the previous tool number in the tool changer. | |
| CommonGUIModule | ParkToolBtn (use_confirmation) |
| Park the current tool by changing to tool number 0. | |
| CommonGUIModule | PreviousPocketBtn (use_confirmation) |
| Change to the previous tool pocket in the tool changer carousel. | |
| CommonGUIModule | NextPocketBtn (use_confirmation) |
| Change to the next tool pocket in the tool changer carousel. | |
| CommonGUIModule | IsCurrentTool (toolIndex, inst) |
| Check whether the specified tool index matches the currently loaded tool. | |
| CommonGUIModule | ToolChangeToTool (toolIndex, inst) |
| Execute a tool change to a specific tool number. | |
| CommonGUIModule | JogToolMagazineToPreviousPocket (spindle) |
| Jog the tool magazine to the previous pocket position. | |
| CommonGUIModule | JogToolMagazineToNextPocket (spindle) |
| Jog the tool magazine to the next pocket position. | |
| CommonGUIModule | JogToolMagazineToNearestPocket (pocket_increment, spindle, inst) |
| Move the tool magazine to the nearest pocket, optionally advancing by one pocket increment. | |
| CommonGUIModule | EnableHomeDialog () |
| Display the enable and home startup dialog if the machine has not yet been homed. | |
| CommonGUIModule | EnableHomeDialog_CycleStart () |
| Execute the enable and home sequence when the operator confirms via cycle start. | |
| CommonGUIModule | EnableHomeDialog_Cancel () |
| Cancel the enable and home startup dialog without performing any action. | |
| CommonGUIModule | CheckEnableAndHomeFlag () |
| Check whether the enable and home startup dialog is currently active. | |
| CommonGUIModule | EnableAndHome () |
| Enable the machine and home all dereferenced axes in a single operation. | |
| CommonGUIModule | EdgeFinderXPlusBtn () |
| Apply a negative X-axis fixture offset using the configured edge finder diameter. | |
| CommonGUIModule | EdgeFinderXMinusBtn () |
| Apply a positive X-axis fixture offset using the configured edge finder diameter. | |
| CommonGUIModule | EdgeFinderYPlusBtn () |
| Apply a positive Y-axis fixture offset using the configured edge finder diameter. | |
| CommonGUIModule | EdgeFinderYMinusBtn () |
| Apply a negative Y-axis fixture offset using the configured edge finder diameter. | |
| CommonGUIModule | LoadConversational () |
| Open the conversational (mill wizard) dialog by setting the trigger register. | |
| CommonGUIModule | RunToolSetterHeightWizard (settername) |
| Run the tool setter height wizard to calculate and store the tool setter height. | |
| CommonGUIModule | RunToolSetterZPositionWizard (settername, auto_setter, manual_setter_height) |
| Run the tool setter Z position wizard to calculate and store the tool setter Z machine position. | |
| CommonGUIModule | CalibrateToolSetters () |
| Open the Calibrate Tool Setters dialog for managing tool setter configurations. | |
| UI | format_number (number) |
| Format a number to a fixed 4-decimal-place string. | |
| UI | GetSelectedToolSetterIndex () |
| Get the zero-based index of the currently selected item in the setter_list listbox. | |
| UI | GetSelectedToolSetter () |
| Get the name of the currently selected tool setter from the setter_list listbox. | |
| UI | OnAddNewClick () |
| Add a new tool setter entry with default values to the list and in-memory table. | |
| UI | OnRemoveClick () |
| Remove the currently selected tool setter from the list and the in-memory table. | |
| UI | OnRenameToolSetter () |
| Rename the currently selected tool setter via a modal rename dialog. | |
| UI | OnToolSetterListSelected () |
| Populate all detail fields in the tool setter configuration panel for the selected setter. | |
| UI | OnToolSetterTypeChanged () |
| Update the tool setter type and enable or disable related controls when the radio button changes. | |
| UI | OnProbeInputChanged () |
| Update the probe input selection for the selected tool setter when the dropdown changes. | |
| UI | OnToolSetterHeightChanged () |
| Validate and store the tool setter height value from the height_dro text field. | |
| UI | OnLaunchHeightWizardClick () |
| Launch the tool setter height wizard and apply the result to the selected setter. | |
| UI | OnZPositionChanged () |
| Validate and store the Z position value from the zpos_dro text field for the selected tool setter. | |
| UI | OnCaptureZPositionClick () |
| Capture the current Z machine position as the tool setter Z position. | |
| UI | OnLaunchZPosWizardClick () |
| Launch the tool setter Z position wizard and apply the result to the selected setter. | |
| UI | OnSoftlimitsChanged () |
| Update the disable softlimits flag for the selected tool setter when the toggle changes. | |
| UI | OnFixturesOffsetsChanged () |
| Update the fixture offsets toggle state for the selected tool setter and enable or disable the mode dropdown. | |
| UI | OnFixtureOffsetModeChanged () |
| Update the fixture offset mode for the selected tool setter when the dropdown selection changes. | |
| UI | GetGoToPositionSelection () |
| Find the list index of the start GoTo position stored for the selected tool setter. | |
| UI | GetEndGoToPositionSelection () |
| Find the list index of the end GoTo position stored for the selected tool setter. | |
| UI | OnGoToPositionChanged () |
| Update the start GoTo position for the selected tool setter when the dropdown selection changes. | |
| UI | OnEndGoToPositionChanged () |
| Update the end GoTo position for the selected tool setter when the dropdown selection changes. | |
| UI | OnCancel () |
| Stop the calibrate tool setters dialog timer and destroy the dialog window. | |
| UI | Save () |
| Persist all tool setter configurations to the Mach4 profile. | |
| UI | OnSave () |
| Save all tool setter data and close the calibrate tool setters dialog. | |
| UI | Initialize () |
| Populate the tool setter list and pre-select the currently configured setter. | |
| CommonGUIModule | ToolSetterSelection (FilterToolSetterTypes, OffsetTypes) |
| Display the tool setter selection dialog for choosing the active manual or auto setter. | |
| UI | GetCurrentToolSetterName () |
| Get the name of the currently active tool setter from the appropriate OEM register. | |
| UI | OnClose () |
| Stop the tool setter selection dialog timer and destroy the dialog window. | |
| CommonGUIModule | CalculateManualToolSetterPosition (IgnoreConfirmationDialogs) |
| Manually measure and store the tool setter Z position from the current machine position. | |
| CommonGUIModule | CalculateAutoToolSetterPosition (IgnoreConfirmationDialogs) |
| Measure and store the auto tool setter position by executing M901 via MDI. | |
| CommonGUIModule | CalculateToolLengthManualBtn (IgnoreConfirmationDialogs) |
| Manually measure and set the tool length offset using the manual tool setter. | |
| CommonGUIModule | CalculateZWorkOffsetManualBtn (IgnoreConfirmationDialogs) |
| Manually measure the Z work (fixture) offset using the manual tool setter position. | |
| CommonGUIModule | CalculateZWorkOffsetAutoBtn (IgnoreConfirmationDialogs) |
| Automatically measure the Z fixture offset using the auto tool setter. | |
| CommonGUIModule | CalculateToolLengthAutoBtn (IgnoreConfirmationDialogs) |
| Automatically measure tool lengths for one or more tools using the auto tool setter. | |
| CommonGUIModule | OpenToolTable () |
| Open the tool table dialog if the screen is in edit mode. | |
| CommonGUIModule | LaserPointerInitialize () |
| Initialize the laser pointer by adding its output signal to the ignore lists. | |
| CommonGUIModule | IsLaserPointerOn () |
| Check whether the laser pointer output signal is currently active. | |
| CommonGUIModule | LaserPointerOn () |
| Turn the laser pointer output signal on and apply the stored laser pointer offsets. | |
| CommonGUIModule | LaserPointerOff () |
| Turn the laser pointer output signal off and reset the laser pointer offsets. | |
| CommonGUIModule | LaserPointerToggle () |
| Toggle the laser pointer between on and off states. | |
| CommonGUIModule | SetLaserPointerOffset () |
| Apply the stored laser pointer X and Y offsets to the corresponding pound variables. | |
| CommonGUIModule | ResetLaserPointerOffset () |
| Clear the laser pointer X and Y offset pound variables back to zero. | |
| CommonGUIModule | GetLaserPointerOffsetVars () |
| Get the Mach4 pound variable indices used for laser pointer X and Y offsets. | |
| CommonGUIModule | TeachLaserPointerOffsets () |
| Capture the current X and Y axis positions as the laser pointer offset values. | |
| CommonGUIModule | LaserPointerCycleStartCheck () |
| Check if the laser pointer is active before cycle start and prompt the operator to confirm. | |
| CommonGUIModule | GetCurrentGearRange () |
| Get the current spindle gear range from the PLC, register, or profile. | |
| CommonGUIModule | SendToolTable () |
| Serialize and send the tool name table to the MachMotion plugin via register command. | |
| CommonGUIModule | GetCurrentTool () |
| Get the current tool number from the PLC, file, or Mach4 tool changer memory. | |
| CommonGUIModule | CommonScreenUnloadScript (MachEnable) |
| Wrapper entry point for the screen unload script; delegates to the protected implementation. | |
| CommonGUIModule | CommonPLCScript () |
| Entry point for the Mach4 PLC script; executes the main PLC loop with error protection. | |
| CommonGUIModule | StartScreenTimers () |
| Start all screen-managed blink timers for normal and slow blink rates. | |
| CommonGUIModule | CommonTimerScript (timer) |
| Entry point for Mach4 timer events; dispatches to machine-type and screen timer handlers. | |
| CommonGUIModule | CommonSignalScript (sig, sig_state) |
| Entry point for Mach4 signal change events; converts signal state and dispatches to handler. | |
| CommonGUIModule | CommonMessageScript (inst, msg_type, param1, param2) |
| Entry point for Mach4 message events; validates and dispatches supported message types. | |
| CommonGUIModule | RegisterForMachMessage (inst, msg_type, callback_func, param1, param2) |
| Register a callback function to be called when a specific Mach4 message event occurs. | |
| CommonGUIModule | HandleMachMessages (inst, msg_type, param1, param2) |
| Dispatch incoming Mach4 messages to all registered callback functions. | |
| CommonGUIModule | AddToRunScriptQueue (func) |
| Add a function or Lua code string to the RUN_SCRIPT_QUEUE for deferred execution. | |
| CommonGUIModule | ExecuteRunScriptQueue () |
| Execute and remove the first queued item from RUN_SCRIPT_QUEUE. | |
| CommonGUIModule | ClearRunScriptQueue () |
| Clear all pending items from the RUN_SCRIPT_QUEUE. | |
| CommonGUIModule | CommonSelectedInstanceChanged () |
| Handle a change in the selected Mach4 instance and notify all registered listeners. | |
| CommonGUIModule | DemoModeWarning () |
| Display a warning dialog if the software is running in demo mode (unlicensed). | |
| CommonGUIModule | OpenMachMotionPluginConfig () |
| Open the MachMotion plugin configuration dialog for the selected Mach4 instance. | |
| CommonGUIModule | OpenGMSPluginConfig () |
| Open the GMS plugin configuration dialog. | |
| CommonGUIModule | OpenMachMotionModbusPluginConfig () |
| Open the MachMotion Modbus plugin configuration dialog. | |
| CommonGUIModule | OpenMachineCalibrationPluginConfig () |
| Open the MachineCalibration plugin configuration dialog. | |
| CommonGUIModule | OpenMachineCalibrationPluginManualConfig () |
| Open the MachineCalibration plugin manual calibration configuration dialog. | |
| CommonGUIModule | OpenMachineCalibrationPluginAutomaticConfig () |
| Open the MachineCalibration plugin automatic calibration configuration dialog. | |
| CommonGUIModule | OpenMachineCalibrationPluginScrewMappingConfig () |
| Open the MachineCalibration plugin screw mapping configuration dialog. | |
| CommonGUIModule | OpenSetupWizard () |
| Open the MachMotion setup wizard via the plugin command interface. | |
| CommonGUIModule | OpenGCodeNestingBtn () |
| Log the operator action and open the G-code nesting interface. | |
| CommonGUIModule | OpenGCodeNesting () |
| Open the G-code nesting interface module. | |
| CommonGUIModule | OpenMotionControllerConfig () |
| Open the motion controller configuration dialog for the selected Mach4 instance. | |
| CommonGUIModule | ResetCurrentPocket () |
| Reset the current tool pocket number to a user-specified value. | |
| CommonGUIModule | AutoUpdaterManualCheck () |
| Trigger a manual check of the auto-updater via the MachMotion plugin register. | |
| CommonGUIModule | IsLimitSwitchActive (inst) |
| Check whether any limit switch is currently active. | |
| CommonGUIModule | JogOffHomeSwitchDialog (homing_axis, inst) |
| Display a modal dialog allowing the operator to jog an axis off its home switch. | |
| UI | StartJog (axis, direction) |
| Start a velocity jog on the specified axis at the current slider rate and direction. | |
| UI | StopJog () |
| Stop all currently active jog motions on all axes. | |
| UI | CloseDialog (CloseWindow) |
| Stop all active jogs, destroy the jog timer, and mark the jog-off home switch dialog as closed. | |
| CommonGUIModule | IsHomeSwitchActive (homing_axis, inst) |
| Check whether any home switch (or a specific axis home switch) is currently active. | |
| CommonGUIModule | CheckHomeSwitchesForHoming (homing_axis, inst) |
| Check if any home switch is active before homing and prompt the operator to jog off if needed. | |
| CommonGUIModule | CycleStartInhibitDialog () |
| Display a modal dialog listing all active cycle start inhibit messages. | |
| UI | UpdateRows (MessageArray, RowNum) |
| Populate the alarms grid with the provided alarm message array. | |
| CommonGUIModule | SetToolDiameterDRO (ToolDiameterOffset,...) |
| Set the tool diameter (or radius) offset for the current tool and save the tool file. | |
| CommonGUIModule | SetToolLengthDRO (ToolLengthOffset,...) |
| Set the tool length offset for the current tool and optionally enable it. | |
| CommonGUIModule | SetSelectedToolDRO (SelectedTool,...) |
| Set the currently selected tool number pound variable. | |
| CommonGUIModule | SetCurrentToolDRO (selectedtool,...) |
| Set the current tool number, updating pocket assignments and tool length offset as configured. | |
| CommonGUIModule | SetFeedrateDRO (FeedRate,...) |
| Set the active feedrate via MDI command when the machine is idle and enabled. | |
| CommonGUIModule | SetSpindleSpeedDRO (Speed,...) |
| Set the spindle speed via MDI command when the machine is idle and enabled. | |
| CommonGUIModule | ToolLengthVerifyToggle () |
| Toggle tool length verification mode on or off. | |
| CommonGUIModule | ToolLengthVerifyOn () |
| Enable tool length verification mode. | |
| CommonGUIModule | ToolLengthVerifyOff () |
| Disable tool length verification mode and reset the verify DRO display. | |
| CommonGUIModule | UpdateSpindleControls () |
| Update spindle control button states when spindle direction or delay state changes. | |
| CommonGUIModule | IsSubSpindleEnabled (inst) |
| Check whether the sub-spindle feature is enabled for the specified instance. | |
| CommonGUIModule | SubSpindleForwardToggle (use_confirmation) |
| Toggle the sub-spindle between forward and stopped states. | |
| CommonGUIModule | SubSpindleReverseToggle (use_confirmation) |
| Toggle the sub-spindle between reverse and stopped states. | |
| CommonGUIModule | IsSubSpindleOn () |
| Check whether the sub-spindle is currently running in either direction. | |
| CommonGUIModule | SubSpindleForward (use_confirmation) |
| Run the sub-spindle in the forward direction, optionally prompting for confirmation. | |
| CommonGUIModule | SubSpindleReverse (use_confirmation) |
| Run the sub-spindle in reverse direction, optionally prompting for confirmation. | |
| CommonGUIModule | SubSpindleStop () |
| Stop the sub-spindle by executing the M105 M-code script. | |
| CommonGUIModule | SubSpindleUpdate () |
| Update sub-spindle analog output speed for all enabled instances. | |
| CommonGUIModule | UpdateToolVerifyDRO () |
| Update the tool length verify DRO display if tool length verification is active. | |
| CommonGUIModule | MotionControllerInitialization () |
| Initialize all motion controller objects for each Mach4 instance. | |
| CommonGUIModule | SpindleSpeedCheck () |
| Configure and apply the spindle speed check enable state and tolerance percentage. | |
| CommonGUIModule | OpenGMSDiagnosticsDialog () |
| Open the GMS diagnostics dialog via the GMS plugin command interface. | |
| CommonGUIModule | ScanWarningsAlarms () |
| Update the alarm dialog button icon based on current GMS alarm and warning state. | |
| CommonGUIModule | DisplayModelNumber () |
| Display the machine model number in the screen warning message area. | |
| CommonGUIModule | UpdateScreenLayout () |
| Enforce single rotary axis constraint for V1 screens by disabling conflicting axes. | |
| CommonGUIModule | LoadAllModules () |
| Load and initialize all required Lua modules for the CommonGUIModule screen environment. | |
| loader_handler (err) | |
| Error handler for module loading that appends a stack traceback to the error message. | |
| CommonGUIModule | InitializeAllModules () |
| Initialize all hardware interface module objects for all Mach4 instances. | |
| CommonGUIModule | loadrequire (modulename, PrintError) |
| Attempt to require a Lua module by name with optional error dialog on failure. | |
| CommonGUIModule | MonitorFixtureOffsets () |
| Save fixture offsets and optionally regenerate the tool path when offsets are modified. | |
| CommonGUIModule | UpdateLubeTimer () |
| Update the lube system timer and trigger lube cycles based on configured mode and action. | |
| CommonGUIModule | RunLubeCycle () |
| Execute the lube system M-code script if the lube system is enabled and not already cycling. | |
| CommonGUIModule | RunLubeCycleOnStartup () |
| Run the lube cycle once on startup if configured and not yet run. | |
| CommonGUIModule | UpdateScreenWarningMessage () |
| Placeholder function stub for updating the screen warning message area (currently disabled). | |
| CommonGUIModule | UpdateLastGCodeFileName () |
| Monitor the loaded G-code filename and trigger header processing when the file changes. | |
| CommonGUIModule | ReadGcodeHeaderParameters () |
| Read G-code header parameters from the currently loaded G-code file. | |
| CommonGUIModule | ZeroDROBtn (Axis) |
| Zero a single axis DRO by computing an offset from the current machine position. | |
| CommonGUIModule | ZeroAllDROBtn () |
| Zero all axis DROs by computing offsets from current machine positions. | |
| CommonGUIModule | AuxiliaryBtn (AuxButton, MouseUp, MouseDn) |
| Handle auxiliary button press and release events, toggling or pulsing configured output signals. | |
| CommonGUIModule | IsToolSizeEntryDiameterMode (mode) |
| Check if the tool size entry mode is configured for diameter mode. | |
| CommonGUIModule | SetToolSizeEntryMode (mode) |
| Configure the tool size entry mode for the Tool Offsets dialog and screen display. | |
| CommonGUIModule | GetSpindleBrakeOutputSignalId () |
| Get the signal ID for the spindle brake output, or -1 if not enabled. | |
| CommonGUIModule | CreateLimitSwitchAlarm (msg) |
| Create a GMS alarm message for a limit switch activation event. | |
| CommonGUIModule | CommonUpdateSignalLibraryArray () |
| Rebuild the signal library arrays and update auxiliary button configuration. | |
| CommonGUIModule | UpdateSignalLibraryArray () |
| Build the signal library arrays for limit switches, home signals, and special signals for all instances. | |
| CommonGUIModule | CommonLowPriorityLoop () |
| Execute the common low-priority PLC loop tasks at a reduced scan rate. | |
| CommonGUIModule | CycleStartDialog (Message, Title, inst) |
| Display a modal Cycle Start confirmation dialog and wait for operator confirmation. | |
| CommonGUIModule | CycleStartDialog_NotModal (Message, Title, CmdOnStart, CmdOnCancel) |
| Display a non-modal Cycle Start confirmation dialog with optional on-start and on-cancel callbacks. | |
| UI | clean_up () |
| Release the cycle start hold and close the Cycle Start dialog. | |
| CommonGUIModule | GetAndSortCutRecovery (Sections, FileFilter, ZeroFilter, RotationFilter) |
| Read and sort cut recovery position records from the Mach4 profile. | |
| CommonGUIModule | GoToLine (LineNumber, IsMachineCoords, X, Y, Z, A, B, C, Tag) |
| Move the machine to a specified G-code line number using a dry run. | |
| CommonGUIModule | GoToLastLostCut () |
| Move to the position of the most recent lost cut or cycle stop event. | |
| CommonGUIModule | GetCheckPoint (name) |
| Return the module DbgCheckPoint object, creating a new one if it does not exist. | |
| CommonGUIModule | MonitorMachFileRunTime () |
| Monitor the G-code file run time and update history when a part is completed. | |
| CommonGUIModule | UpdateMachFileRunTimeHistory (run_time) |
| Shift the G-code file run time history registers and store a new run time entry. | |
| CommonGUIModule | UpdateEnabledAxesCache () |
| Refresh the cached enabled state flags for all instances and axes. | |
| CommonGUIModule | UpdateHomedAxesCache () |
| Refresh the cached homed state flags for all instances and axes. | |
| CommonGUIModule | UpdateRotaryAxesCache () |
| Refresh the cached rotary axis flags for all instances and axes. | |
| CommonGUIModule | UpdateAxesArrayCache () |
| Refresh the cached axis letter and short name arrays for all instances and axes. | |
| CommonGUIModule | GetAxisLetterName (AxisID, inst) |
| Get the letter label for the specified axis, accounting for instance count and rotary configuration. | |
| CommonGUIModule | GetAxisShortName (AxisID, inst) |
| Get the short display name for the specified axis, accounting for instance count and rotary configuration. | |
| CommonGUIModule | CommonScreenLoadScript () |
| Protected entry point for the Mach4 screen load script. | |
| myfunc_wrapper () | |
| Example wrapper function showing how to profile a specific function call-tree. | |
| CommonGUIModule _LuaProfiling | Configure () |
| Perform one-time setup for the Lua profiling facility. | |
| CommonGUIModule _LuaProfiling | CreateCommands () |
| Register user commands for starting, stopping, and timed screen profiling. | |
| CommonGUIModule _LuaProfiling | UpdateTimedProfiling () |
| Check whether a timed profiling session has expired and stop the profiler if so. | |
| CommonGUIModule _LuaProfiling | IsProfiling () |
| Check whether the Lua profiler is currently active. | |
| CommonGUIModule _LuaProfiling | StartProfiler (context) |
| Start the Lua profiler with an optional context label. | |
| CommonGUIModule _LuaProfiling | StartProfilerTimed (context, seconds) |
| Start the Lua profiler for a fixed duration in seconds. | |
| CommonGUIModule _LuaProfiling | PauseProfiler (logpath) |
| Temporarily pause an active Lua profiling session without losing collected data. | |
| CommonGUIModule _LuaProfiling | ResumeProfiler (logpath) |
| Resume a previously paused Lua profiling session. | |
| CommonGUIModule _LuaProfiling | StopProfiler (logpath) |
| Stop the Lua profiler and generate a profiling report file. | |
| CommonGUIModule | OnFileQueueTimer () |
| Timer callback that processes the Lua file queue with function tracing. | |
| CommonGUIModule | ProcessFileQueue () |
| Process one command from the Lua file queue, handling errors and stop status. | |
| CommonGUIModule | ScreenIsLoadedScript () |
| Entry point called when the Mach4 screen has finished loading all controls. | |
| CommonGUIModule | CommonStartUpScript () |
| Protected wrapper for the common CNC startup initialization sequence. | |
| CommonGUIModule | AutoLoadLastGCode (inst) |
| Protected wrapper that auto-loads the last G-code file for all instances on startup. | |
| CommonGUIModule | LoadGCode (GcodeFileName) |
| Load a G-code file into the current Mach4 instance if it is not already loaded. | |
| CommonGUIModule | OverrideLimits () |
| Validate and swap spindle and feedrate override min/max OEM parameters if inverted. | |
| CommonGUIModule | ResetAllOverrideAxes (inst) |
| Reset all override (OB1-OB6) axes to zero position and restore their override mappings. | |
| CommonGUIModule | StartJogging (Axis, Direction, inst) |
| Start jogging the specified axis in the given direction using external jog parameters. | |
| CommonGUIModule | StopJogging (Axis) |
| Stop jogging on the specified axis or all axes. | |
| CommonGUIModule | IsAxisJogging (Axis) |
| Check whether the specified axis is currently jogging. | |
| CommonGUIModule | SetJogModeIncremental () |
| Set the jog mode to incremental stepping. | |
| CommonGUIModule | IsJogModeIncremental () |
| Check whether the current jog mode is incremental. | |
| CommonGUIModule | SetJogModeContinuous () |
| Set the jog mode to continuous velocity jogging. | |
| CommonGUIModule | IsJogModeContinuous () |
| Check whether the current jog mode is continuous. | |
| CommonGUIModule | ConfigureTLMMode () |
| Configure the Tool Length Management (TLM) mode so that the T word on the M6 line is used as the selected tool. | |
| CommonGUIModule StackLight | NewStackLight () |
| Create and initialize a new StackLight object for the given Mach4 instance. | |
| CommonGUIModule StackLight | UpdateStackLight () |
| Update all configured stack light outputs based on current machine state and alarm conditions. | |
| CommonGUIModule StackLight | GetRedStackLightState () |
| Get the desired state for the red stack light based on alarm and machine enable conditions. | |
| CommonGUIModule StackLight | GetYellowStackLightState () |
| Get the desired state for the yellow stack light based on warning conditions and machine state. | |
| CommonGUIModule StackLight | GetGreenStackLightState () |
| Get the desired state for the green stack light based on machine state and alarm conditions. | |
| CommonGUIModule StackLight | GetWhiteStackLightState () |
| Get the desired state for the white stack light based on machine state transitions. | |
| CommonGUIModule | InstallerUpdateModule () |
| Run the installer update module script if the MachMotion build number has changed. | |
| CommonGUIModule | UpdateDoorInterlock () |
| Monitor and update the door interlock output based on machine state. | |
| CommonGUIModule | IsDoorInterlockActive () |
| Check whether the door interlock is currently active. | |
| CommonGUIModule | ToggleCapturingToolPathMousePositions () |
| Toggle tool path mouse position capture on or off. | |
| CommonGUIModule | StartCapturingToolPathMousePositions () |
| Start capturing tool path mouse positions on all tool path panels. | |
| CommonGUIModule | StopCapturingToolPathMousePositions () |
| Stop capturing tool path mouse positions on all tool path panels. | |
| CommonGUIModule | IsCapturingToolPathMousePositions () |
| Check whether the tool path panel is currently capturing mouse positions. | |
| CommonGUIModule | PartCounterDialog () |
| Open the Part Counter dialog for viewing and editing part count parameters. | |
| UI | SetPartsCurrentProgram () |
| Write the current program parts value from the numeric control to the Mach4 parameter. | |
| UI | SetPartsTotal () |
| Write the total parts value from the numeric control to the Mach4 parameter. | |
| UI | SetPartsRequired () |
| Write the parts required value from the numeric control to the Mach4 parameter. | |
| UI | SetMcodeNumber () |
| Write the M-code number value from the numeric control to the Mach4 parameter. | |
| UI | SetMCodeCounter () |
| Write the M-code counter enable/disable selection to the Mach4 parameter. | |
| UI | SetParameter (param, value) |
| Set a Mach4 parameter to the specified value with logging. | |
| UI | UpdatePartCounters () |
| Refresh all Part Counter numeric controls with the current Mach4 parameter values. | |
| UI | ClosePartCounterDialog () |
| Stop the Part Counter timer and destroy the Part Counter dialog. | |
| CommonGUIModule | GenericGridDialog (GridTable) |
| Display a resizable modal grid dialog for viewing and editing tabular data. | |
| UI | CloseGenericGridDialog () |
| Close the Generic Grid dialog and release its timer resources. | |
| UI | CellChangedGenericGridDialog (row, col) |
| Handle a cell value change event in the Generic Grid dialog. | |
| UI | UpdateGenericGridDialog () |
| Timer callback to keep the Generic Grid dialog alive and handle shutdown. | |
| CommonGUIModule | YesNoDialog (yes_no_table) |
| Display a modal Yes/No dialog with bitmap buttons for binary user decisions. | |
| CommonGUIModule | IsSchedulerActive (inst) |
| Check whether the file scheduler is currently active. | |
| CommonGUIModule | LoadNextSheduledFile (inst) |
| Load the next file in the schedule after the current G-code file finishes running. | |
| CommonGUIModule Scheduler | New () |
| Create and initialize a new Scheduler object, disabling any previously active scheduler. | |
| CommonGUIModule Scheduler | CheckName () |
| Check whether the given file name matches the top scheduled file, accounting for GCAdapter naming. | |
| CommonGUIModule Scheduler | GetSchedule () |
| Get the in-memory schedule table for a given instance. | |
| CommonGUIModule Scheduler | GetLastSchedule () |
| Load the schedule table with file data from the OEM register for a given instance. | |
| CommonGUIModule Scheduler | ToggleEnable () |
| Toggle the scheduler active state when the machine is idle. | |
| CommonGUIModule Scheduler | Enable () |
| Enable the scheduler and load the top scheduled file into Mach4. | |
| CommonGUIModule Scheduler | ClearSchedule (leave_reg) |
| Clear all scheduled file entries for a given instance, optionally preserving the register. | |
| CommonGUIModule Scheduler | PopSchedule () |
| Decrement the quantity of the current top scheduled file and advance the schedule. | |
| CommonGUIModule Scheduler | GetTopFile () |
| Return the file path of the first (top) entry in the schedule for a given instance. | |
| CommonGUIModule Scheduler | Edit () |
| Open the Schedule Editor dialog to view and modify the current schedule. | |
| CommonGUIModule Scheduler | CreateEditControls () |
| Create and display the Schedule Editor dialog with list control and management buttons. | |
| self UI | DestroyGauge () |
| Destroy the Schedule Editor dialog and release its reference. | |
| CommonGUIModule Scheduler | SetColumns () |
| Create and insert the column headers for the Schedule Editor list control. | |
| CommonGUIModule Scheduler | SetColumnsWidth () |
| Recalculate and apply column widths for the Schedule Editor list control. | |
| CommonGUIModule Scheduler | SendFilesToRegister (inst) |
| Serialize all scheduled files to an OEM register string for persistence. | |
| CommonGUIModule Scheduler | GetSchedFiles () |
| Read all file entries from the Schedule Editor list control into a formatted table. | |
| CommonGUIModule Scheduler | SaveSchedule (inst) |
| Save a table of scheduled file entries to the in-memory schedule for a given instance. | |
| CommonGUIModule Scheduler | InsertFiles () |
| Insert an array of file entries into the Schedule Editor list control. | |
| CommonGUIModule Scheduler | GetItemData () |
| Retrieve the file path and quantity data for a specific item in the Schedule Editor list control. | |
| CommonGUIModule Scheduler | GetSelectedItem () |
| Get the item data for the currently selected item in the Schedule Editor list control. | |
| CommonGUIModule Scheduler | ChangeQty (qty) |
| Set the quantity column value of an item in the Schedule Editor list control. | |
| CommonGUIModule Scheduler | SwapItems (idx2) |
| Swap the display data of two items in the Schedule Editor list control. | |
| CommonGUIModule Scheduler | ClearSelection () |
| Clear the selection state of all selected items in the Schedule Editor list control. | |
| CommonGUIModule Scheduler | MoveItemUp () |
| Move the currently selected scheduled item up one position in the schedule list. | |
| CommonGUIModule Scheduler | MoveItemDown () |
| Move the currently selected scheduled item down one position in the schedule list. | |
| CommonGUIModule Scheduler | DeleteItem () |
| Delete the currently selected item from the Schedule Editor list control. | |
| CommonGUIModule Scheduler | Clear () |
| Delete all items from the Schedule Editor list control. | |
| CommonGUIModule Scheduler | MoveToTop () |
| Move the currently selected scheduled item to the top of the schedule list. | |
| CommonGUIModule Scheduler | MoveToBot () |
| Move the currently selected scheduled item to the bottom of the schedule list. | |
| CommonGUIModule Scheduler | Load () |
| Open a file browser dialog and return the selected G-code file paths for scheduling. | |
| CommonGUIModule Scheduler | OnSize () |
| Handle resize events for the Schedule Editor dialog. | |
| CommonGUIModule Scheduler | EditQty () |
| Open a dialog allowing the user to edit the quantity of the selected scheduled item. | |
| CommonGUIModule JobFile | New (job_name) |
| Create and initialize a new JobFile object with the given configuration table and job name. | |
| CommonGUIModule JobFile | Open () |
| Open a file browser dialog to select and load a job file, then apply it to Mach4. | |
| CommonGUIModule JobFile | ReLoad () |
| Reload the last loaded job file from the path stored in the MachMotionOEMParameters register. | |
| CommonGUIModule JobFile | OptSaveChanges () |
| Optionally prompt the user to save changes to the job file if any edits are detected. | |
| CommonGUIModule JobFile | Close () |
| Close the currently loaded job file, prompting to save if there are unsaved edits. | |
| CommonGUIModule JobFile | SaveAs () |
| Save the job file to a new location chosen by the user, with password protection. | |
| CommonGUIModule JobFile | HasEdits () |
| Check whether the current Mach4 state differs from the values stored in the job file. | |
| CommonGUIModule JobFile | UpdateNotesOnlyToJobFile () |
| Write only the Notes section of the job file to disk, leaving all other fields unchanged. | |
| CommonGUIModule JobFile | ReadDataFromMach () |
| Read current Mach4 state (pound variables, registers, notes) and write to the job file on disk. | |
| CommonGUIModule JobFile | GetFileVersion () |
| Read the job file version number from the CSV file header. | |
| CommonGUIModule JobFile | WriteDataToMach () |
| Dispatch job file data writing to the appropriate version handler. | |
| CommonGUIModule JobFile | ClearValues () |
| Reset all pound variables and registers tracked by the job file to their stored values. | |
| CommonGUIModule JobFile | GetFilePath () |
| Get the full file path of the currently loaded job file. | |
| CommonGUIModule JobFile | GetFileName () |
| Get the file name (without path) of the currently loaded job file. | |
| CommonGUIModule JobFile | HasFileLoaded () |
| Check whether a job file is currently loaded. | |
| CommonGUIModule JobFile | CheckPassword () |
| Verify that the operator has the required password level to save the job file. | |
| CommonGUIModule | CleanJobFiles () |
| Remove the JobFiles section from the Mach4 profile for the current instance. | |
| CommonGUIModule JobFile | GetPoundVarTable () |
| Retrieve the complete pound variable table from the job file's in-memory data. | |
| CommonGUIModule JobFile | GetPoundVarValue () |
| Retrieve a pound variable value from the job file's in-memory pound variable table. | |
| CommonGUIModule JobFile | GetRegisterValue () |
| Retrieve a register value from the job file's in-memory register table. | |
| CommonGUIModule JobFile | GetNotesCount () |
| Get the number of notes stored in the job file's in-memory notes table. | |
| CommonGUIModule JobFile | GetAllNotes () |
| Retrieve all notes from the job file's in-memory notes table. | |
| CommonGUIModule JobFile | GetNote () |
| Retrieve a specific note line from the job file's in-memory notes table. | |
| CommonGUIModule JobFile | GetTableRecordCount () |
| Count the number of key-value pairs in a table. | |
| CommonGUIModule JobFile | NotesDialog () |
| Open the Job Notes dialog for viewing and editing job file notes. | |
| UI | LoadNotes () |
| Build the full notes string from the job file's in-memory notes table. | |
| UI | CancelButtonClick () |
| Handle the Cancel button click in the Job Notes dialog. | |
| UI | OkButtonClick () |
| Handle the OK button click in the Job Notes dialog. | |
| UI | StoreNotes () |
| Store the current notes from the dialog editor into the job file's in-memory notes table. | |
| UI | SaveNotesToFile () |
| Save the current notes from the dialog to the job file on disk. | |
| UI | ConstructNotesString () |
| Construct the full notes string from all lines in the multi-line notes text control. | |
| CommonGUIModule | DefaultJob () |
| Create and initialize the default job file object for the screen. | |
| CommonGUIModule SearchGCode | Initialize (inst) |
| Initialize the GCode Search object, read the loaded file, and open the search dialog. | |
| CommonGUIModule SearchGCode | CreateSearchDialog () |
| Create and display the GCode Search dialog with search bar, grid, and navigation buttons. | |
| CommonGUIModule SearchGCode | ReadLoadedFile (inst) |
| Read the currently loaded G-code file line by line into an internal table. | |
| CommonGUIModule SearchGCode | GoToSelectedLine () |
| Navigate to the G-code line selected in the GCode Search grid. | |
| CommonGUIModule SearchGCode | InitializeGrid () |
| Set default settings and column labels for the GCode Search grid. | |
| CommonGUIModule SearchGCode | EmptyGrid () |
| Clear all values from the GCode Search grid and delete all rows except the first. | |
| CommonGUIModule SearchGCode | Search () |
| Search the loaded G-code file for lines matching a keyword. | |
| CommonGUIModule SearchGCode | UpdateGrid () |
| Insert search matches into the GCode Search grid. | |
| CommonGUIModule | GetRemainingDwellTime (inst) |
| Get the remaining dwell time for the current dwell operation. | |
| CommonGUIModule | GetTargetDwellTime (inst) |
| Get the target dwell time for the current dwell operation. | |
| CommonGUIModule | TeachWorkShiftOffsets (AxisID) |
| Teach the work shift offset for a single axis from the current machine position. | |
| CommonGUIModule | StoreLastValueWorkShiftOffsets () |
| Save work shift offsets for all instances where the mode is "Restore Last Value". | |
| CommonGUIModule | StoreWorkShiftOffsets (inst) |
| Save the work shift offsets for all coordinate axes to OEM parameter storage. | |
| CommonGUIModule | StoreWorkShiftOffsetsAxis (AxisID, inst) |
| Save the work shift offset for a single axis to the OEM parameter store. | |
| CommonGUIModule | RestoreWorkShiftOffsets () |
| Restore saved work shift offsets to all axes for all instances based on OEM parameter mode. | |
| CommonGUIModule | StoreLastValueHeadShiftOffsets () |
| Save head shift offsets for all instances where the mode is "Restore Last Value". | |
| CommonGUIModule | StoreHeadShiftOffsets (inst) |
| Save the head shift offsets for all coordinate axes to OEM parameter storage. | |
| CommonGUIModule | StoreHeadShiftOffsetsAxis (AxisID, inst) |
| Save the head shift offset for a single axis to the OEM parameter store. | |
| CommonGUIModule | RestoreHeadShiftOffsets () |
| Restore saved head shift offsets to all axes for all instances based on OEM parameter mode. | |
| CommonGUIModule | StoreMachOverrides () |
| Save the current Mach4 speed overrides to the profile for later restoration. | |
| CommonGUIModule | ReStoreMachOverrides () |
| Restore previously saved Mach4 speed overrides from the profile. | |
| CommonGUIModule | EmergencyStopNotification () |
| Show or close a GMS notification for an active Emergency Stop signal. | |
| CommonGUIModule | MDIDialog () |
| Open the MDI (Manual Data Input) command dialog. | |
| UI | ConstructMDIString () |
| Build the complete MDI command string from all lines in the multi-line text control. | |
| UI | UpdateHistoryBtns () |
| Update the enabled state of the MDI history navigation buttons. | |
| UI | SaveToHistory (gcode) |
| Save the current MDI command text to the MDI history file. | |
| CommonGUIModule | GetMDIHistoryFilename () |
| Get the full file path for the MDI history file. | |
| CommonGUIModule | ClearToolChangeState () |
| Clear the tool change state for the currently selected spindle. | |
| CommonGUIModule | ManualToolChangeDialog (tool_number, auto_tc_override, inst) |
| Display the manual tool change dialog prompting the operator to install the requested tool. | |
| CommonGUIModule | ModifyZOffsetsInToolChangeDialog (inst) |
| Display a dialog allowing the operator to choose a method for modifying Z head shift offsets during a tool change. | |
| CommonGUIModule | ModifyZOffsetsInToolChangeFinalDialog (modify_type, inst) |
| Display the final safety-check dialog after modifying Z offsets during a tool change. | |
| CommonGUIModule | InitializeToolPathZoomLimits () |
| Initialize the tool path zoom limits from OEM parameters. | |
| CommonGUIModule | InitializeEnabledAxes (GCodeParameterNumber) |
| Write the enabled axis configuration to a G-code parameter bit field. | |
| CommonGUIModule | PowerOffBtn () |
| Button handler that delegates to CommonGUIModule.PowerOffControl(). | |
| CommonGUIModule | UPSPowerOffControl () |
| Initiate a delayed power-off sequence triggered by UPS loss of power. | |
| CommonGUIModule | PowerOffControl (skip_confirmation) |
| Prompt the user to confirm a power-off request and then shut down the control. | |
| CommonGUIModule | PowerOff () |
| Save critical data and shut down the Windows operating system. | |
| CommonGUIModule | CloseMach (showwarningmessage) |
| Close the Mach4 CNC software, optionally prompting the user for confirmation. | |
| CommonGUIModule | RunLuaScriptFromDialog () |
| Open the Run Lua Script dialog for interactive Lua code execution. | |
| UI | DebugOutputAppend (msg) |
| Append a timestamped message to the debug output text control. | |
| UI | print (...) |
| Redirect Lua print() calls from executed scripts to the debug output window. | |
| UI | SetErrorStyle (is_error) |
| Set the debug output background color to indicate error or normal state. | |
| UI | GetRawLuaString () |
| Return the raw, unmodified Lua text as typed by the user in the editor. | |
| UI | ConstructLuaString () |
| Build the full Lua execution string wrapping the user's script. | |
| UI | SaveToHistory () |
| Save the current editor content to the Lua script history file. | |
| UI | RunLuaCode () |
| Execute the Lua code currently in the Run Lua Script dialog editor. | |
| CommonGUIModule | AppendRunLuaDebugMessage (...) |
| Append a message to the Run Lua Script dialog's Debug Output window. | |
| CommonGUIModule | DebugPrint (...) |
| Convenience alias for AppendRunLuaDebugMessage. | |
| CommonGUIModule | RunLuaPrint (...) |
| Convenience alias for AppendRunLuaDebugMessage. | |
| CommonGUIModule | MachMenuDialog () |
| Open the Mach menu configuration dialog. | |
| UI | CloseMachMenuDialog () |
| Close the Mach Menu configuration dialog and save the hide-on-startup preference. | |
| CommonGUIModule | HideMachMenu () |
| Hide the Mach4 menu bar and persist the setting to the profile. | |
| CommonGUIModule | ShowMachMenu () |
| Show the Mach4 menu bar and persist the setting to the profile. | |
| CommonGUIModule | InitializeMachMenu () |
| Initialize the Mach4 menu bar visibility based on the saved profile setting. | |
| CommonGUIModule | ToggleMachMenu () |
| Toggle the Mach4 menu bar between hidden and visible. | |
| CommonGUIModule | EndOfProgram (inst) |
| Handle the end-of-program event (M30 macro entry point). | |
| CommonGUIModule | UpdateEndOfProgramTimeOn () |
| Check and reset the end-of-program output signal for all instances when its timer expires. | |
| CommonGUIModule | ResetEndOfProgramOutput (inst) |
| Reset the end-of-program output signal and clear the EndOfProgram register. | |
| CommonGUIModule | IsGCodeFileRepeatEnabled () |
| Check whether the G-code file repeat feature is enabled in OEM parameters. | |
| CommonGUIModule | IsGCodeFileRepeatOn () |
| Check whether the G-code file repeat mode is currently active. | |
| CommonGUIModule | GCodeFileRepeatOn () |
| Turn on the G-code file repeat mode. | |
| CommonGUIModule | GCodeFileRepeatOff () |
| Turn off the G-code file repeat mode. | |
| CommonGUIModule | GCodeFileRepeatToggle () |
| Toggle the G-code file repeat mode on or off. | |
| CommonGUIModule | GCodeFileRepeatCycleStart () |
| Execute a G-code file repeat cycle start sequence. | |
| CommonGUIModule | SupportBtn () |
| Open the MachMotion support web page in the default browser. | |
| CommonGUIModule | OnlineManualsBtn () |
| Open the MachMotion online manuals web page in the default browser. | |
| CommonGUIModule | RemoteSupportBtn () |
| Open the MachMotion remote support tool. | |
| CommonGUIModule | ShowMachineStats () |
| Show machine statistics (currently commented out/disabled). | |
| CommonGUIModule | CreatePreCannedCommands () |
| Register all pre-canned machine commands, feedback options, and button configurations. | |
| CommonGUIModule | AddToolPathColorsToToolTable () |
| Add a TpColor user field to the tool table if not already present. | |
| CommonGUIModule | AddSpindleRotationToToolTable () |
| Add a SpindleRotation user field to the tool table if not already present. | |
| CommonGUIModule | AddIgnoreAutoToolSetterToToolTable () |
| Add an IgnoreAutoToolSetter user field to the tool table if not already present. | |
| CommonGUIModule | AddToolSetterOffsetToToolTable () |
| Add a ToolSetterOffset user field to the tool table if configured. | |
| CommonGUIModule | AddToolChangerOverrideToToolTable () |
| Add a ToolChangerOverride user field to the tool table if using auto tool changer. | |
| CommonGUIModule | AddToolSizeToToolTable () |
| Add a ToolSize user field to the tool table and migrate legacy oversized tool data. | |
| CommonGUIModule | ApplyToolpathSettings () |
| Apply saved toolpath display settings to all active tool path panels. | |
| CommonGUIModule | StartCannedReciprocatingAxis (axis_id, position_a, position_b, dwell, feedrate) |
| Start a canned reciprocating axis cycle between two positions. | |
| CommonGUIModule | StopCannedReciprocatingAxis (axis_id, stop_type) |
| Stop a canned reciprocating axis cycle. | |
| CommonGUIModule | IsCannedReciprocatingAxisRunning (axis_id) |
| Check whether a canned reciprocating axis cycle is currently running. | |
| CommonGUIModule | PositionDisplayUnLocked () |
| Delegate to unlock the position display. | |
| CommonGUIModule | PositionDisplayLocked () |
| Delegate to lock the position display. | |
| CommonGUIModule | PositionDisplayDROMode () |
| Delegate to set the position display to DRO mode. | |
| CommonGUIModule | OnScreenJogButtonsOn () |
| Delegate to show the on-screen jog buttons. | |
| CommonGUIModule | OnScreenJogButtonsOff () |
| Delegate to hide the on-screen jog buttons. | |
| CommonGUIModule | ModifyAxisDROPosition (AxisID) |
| Delegate to modify the DRO position for the specified axis. | |
| CommonGUIModule | ScreenConfigurationDialog () |
| Delegate to open the screen configuration dialog. | |
| CommonGUIModule | GetPositionDisplayUnlocked () |
| Delegate to get whether the position display is unlocked. | |
| CommonGUIModule | RegenerateToolPathDialog () |
| Delegate to regenerate the tool path dialog via the wrapper module. | |
| CommonGUIModule ActivateFixtureOffset | ( | fixture | ) |
Activate a fixture offset by executing the corresponding G-code command via MDI.
Converts the fixture index to a G-code string. For fixture indices 1-6, generates a standard G54-G59 command (fixture + 53). For indices >= 7, generates an extended G54.1 P command (fixture - 6). Executes the command via w.MDICommand() and regenerates the tool path via w.RegenerateToolPathDialog().
| fixture | (number) The fixture offset index to activate (1-6 for G54-G59, 7+ for G54.1 P commands) |
| CommonGUIModule AddIgnoreAutoToolSetterToToolTable | ( | ) |
Add an IgnoreAutoToolSetter user field to the tool table if not already present.
Checks if the 'IgnoreAutoToolSetter' user field exists in the tool table. If not, creates the field with choices: No=0, Yes=1. Has no effect if the tool table is not initialized.
| CommonGUIModule AddSpindleRotationToToolTable | ( | ) |
Add a SpindleRotation user field to the tool table if not already present.
Checks if the 'SpindleRotation' user field exists in the tool table. If not, creates the field with choices: Any=0, FWD Rotation=1, REV Rotation=2, No Rotation=3. Has no effect if the tool table is not initialized.
| CommonGUIModule AddToolChangerOverrideToToolTable | ( | ) |
Add a ToolChangerOverride user field to the tool table if using auto tool changer.
Checks the OEM parameter 'ToolChangerMethod'. If set to "Auto", and the tool table is initialized, adds a 'ToolChangerOverride' user field with choices: None=0, Manual=1. Has no effect if ToolChangerMethod is not "Auto" or the tool table is not initialized.
| CommonGUIModule AddToolPathColorsToToolTable | ( | ) |
Add a TpColor user field to the tool table if not already present.
Checks if the 'TpColor' user field exists in the tool table. If not, creates the field as a String type with description "ToolPath Color (HTML #RRGGBB)". This field allows per-tool toolpath color customization using HTML hex color codes. Has no effect if the tool table is not initialized.
| CommonGUIModule AddToolSetterOffsetToToolTable | ( | ) |
Add a ToolSetterOffset user field to the tool table if configured.
Checks the OEM parameter 'AutoToolSetterAlignToolEdgeOffset'. If set to "Tool Setter Offset", and the tool table is initialized, adds a 'ToolSetterOffset' user field of type Float with 4 decimal places. Has no effect if the OEM parameter is not set to "Tool Setter Offset" or the tool table is not initialized.
| CommonGUIModule AddToolSizeToToolTable | ( | ) |
Add a ToolSize user field to the tool table and migrate legacy oversized tool data.
Checks if the 'ToolSize' user field exists in the tool table. If not, it creates the field with choices: Normal=0, Oversized=1. Additionally, it scans all tool pockets for the legacy oversized-tool encoding (pocket >= 1000) and converts those entries to the new user field format by dividing the pocket number by 1000 and setting ToolSize to "1".
| CommonGUIModule AddToRunScriptQueue | ( | func | ) |
Add a function or Lua code string to the RUN_SCRIPT_QUEUE for deferred execution.
param func - A function reference or string containing Lua code to execute
Initializes RUN_SCRIPT_QUEUE as an empty table if it does not exist, then appends the provided function reference or Lua code string to the end of the queue via table.insert(). The queued item will be executed on the GUI thread during the next call to ExecuteRunScriptQueue(), avoiding cross-thread conflicts with REST API requests.
| func | (function|string) A function reference or string containing Lua code to execute |
References func().
| CommonGUIModule AllCoolantOffBtn | ( | ) |
Button handler to turn off all coolant outputs (mist and flood).
Logs the button press via w.OperatorLog(). If either the mist (OSIG_MISTON) or flood (OSIG_COOLANTON) output signal is currently active for the selected instance, sets both signals to false via w.SetSignalState() to turn off all coolant.
| CommonGUIModule AppendRunLuaDebugMessage | ( | ... | ) |
Append a message to the Run Lua Script dialog's Debug Output window.
If the Run Lua Script dialog is currently open (CommonGUIModule._RunLuaUIRef is set), formats the provided arguments into a single string and appends it to the debug output panel. If more than one argument is provided, they are concatenated with a space separator. Has no effect if the dialog is not open, to avoid UI popups or logging side effects.
| ... | (any) One or more values to display; will be converted via tostring() |
| CommonGUIModule ApplyToolpathSettings | ( | ) |
Apply saved toolpath display settings to all active tool path panels.
Reads toolpath color, line width, and slider settings from the Mach4 profile and applies them to all registered tool path panel objects. Settings applied include background colors, rapid/line/arc colors, highlight color, axis line color, soft limit color, path and axis line widths, follow mode, draw limits, draw triad, and left-click mouse function (rotate vs. pan based on DisableRotate profile value).
| CommonGUIModule AutoEnableSoftlimits | ( | inst | ) |
Automatically enable software limits after homing if configured to do so.
Reads the AutoEnableSoftlimits OEM parameter string via w.GetOEMParamValueString(). If the parameter is not "No", enables software limits via w.SetSoftLimits(true) for the specified instance.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule AutoLoadLastGCode | ( | inst | ) |
Protected wrapper that auto-loads the last G-code file for all instances on startup.
Delegates to CommonGUIModule._AutoLoadLastGCode() via w.Protected() for error handling. The inner function iterates over all Mach4 instances and, for each instance where AutoLoadLastGcode OEM parameter is "Yes", checks if the last loaded G-code file still exists and is not already loaded in another instance. If conditions are met, loads the file via w.LoadGCodeFile() and runs header parameter processing hooks. After loading, updates the tool path panels and runs PostAutoLoadLastGCode hooks.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule AutoUpdaterManualCheck | ( | ) |
Trigger a manual check of the auto-updater via the MachMotion plugin register.
Sets the mm_AutoUpdaterManualCheck register to 1 via w.SetRegValue(). If the register write fails, logs the error via w.OperatorLog(). Returns success after the command is sent.
| CommonGUIModule AuxiliaryBtn | ( | AuxButton | , |
| MouseUp | , | ||
| MouseDn | ) |
Handle auxiliary button press and release events, toggling or pulsing configured output signals.
Executes user-defined callback (UserAuxiliaryBtn1-6) if configured for the specified button. On mouse down (MouseDn), if the button is in toggle mode (AUX_BTN_TOGGLE == 1), activates the assigned output signal. On mouse up (MouseUp), handles both toggle and momentary (pulse) modes: in momentary mode, toggles the signal state; in toggle mode, deactivates the signal. User callbacks can short-circuit the default behavior by returning false as the primary value.
| AuxButton | (number) The auxiliary button index (1-6) |
| MouseUp | (boolean) True if this is a mouse button release event |
| MouseDn | (boolean) True if this is a mouse button press event |
| CommonGUIModule BlockDeleteToggleBtn | ( | ) |
Toggle block delete mode on or off, showing a level selection dialog if needed.
Logs the button press via w.OperatorLog(). Reads the BlockDeleteLevelsEnabled OEM parameter to determine which behavior to use. If block delete is currently active (OSIG_BLOCK_DELETE is true), turns off all block delete levels (0 through MC_MAX_BLOCKDELETE) and regenerates the tool path if ToolPathAutoRegen is enabled. If BlockDeleteLevelsEnabled equals "Level 0", activates only level 0 and regenerates if needed. Otherwise, if no dialog is already open (DIALOG_IS_OPEN[2]), presents a dialog with checkboxes for levels 0-9, an OK button, and a timer to handle shutdown. On OK or close, saves the selections and regenerates if configured.
| CommonGUIModule CalculateAutoToolSetterPosition | ( | IgnoreConfirmationDialogs | ) |
Measure and store the auto tool setter position by executing M901 via MDI.
Checks manual mode. If a user override exists (user.UserCalculateAutoToolSetterPosition), calls it instead. Otherwise verifies that an auto tool setter is configured and the screen is in edit mode. Sets CALCULATE_SETTER_POSITION to true and enables the AutoCalculateToolLengthBtn screen object. Presents a CycleStartDialog; on confirmation, executes "m901" via mc.mcCntlMdiExecute() to run the auto tool setter position measurement cycle.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode check. Defaults to false |
| CommonGUIModule CalculateManualToolSetterPosition | ( | IgnoreConfirmationDialogs | ) |
Manually measure and store the tool setter Z position from the current machine position.
Checks manual mode. If a user override exists (user.UserCalculateManualToolSetterPosition), calls it instead. Otherwise verifies edit mode and that a manual tool setter is enabled. With confirmation (unless IgnoreConfirmationDialogs is true), computes the tool setter position via w.GetCalculatedManualToolSetterPosition() and stores it via w.SetToolSetterPosition(). Sets CALCULATE_SETTER_POSITION to true and enables the ManualCalculateToolLengthBtn screen object. Logs the resulting position via w.OperatorLog().
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode and confirmation dialogs. Defaults to false |
| CommonGUIModule CalculateToolLengthAutoBtn | ( | IgnoreConfirmationDialogs | ) |
Automatically measure tool lengths for one or more tools using the auto tool setter.
Checks manual mode and tool setter availability. If a user override function exists (user.UserCalculateToolLengthAutoBtn), calls it instead. Otherwise reads the ConfirmationDialogs OEM parameter and verifies that an auto tool setter is configured and the screen is in edit mode. Builds a G-code comment from the screen's tool range text string or the current tool number, interprets it as a range, and presents a CycleStartDialog listing the tools to be measured. On confirmation, executes "M900 (Data:...)" via mc.mcCntlMdiExecute() to run the auto tool length measurement cycle.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode and confirmation checks. Defaults to false |
| CommonGUIModule CalculateToolLengthManualBtn | ( | IgnoreConfirmationDialogs | ) |
Manually measure and set the tool length offset using the manual tool setter.
Checks manual mode. If a user override exists (user.UserCalculateToolLengthManualBtn), calls it instead. Otherwise verifies edit mode and that a manual tool setter is configured. Reads the tool setter name, height, and Z position. Gets the current tool number and Z machine position. Computes the tool length as Z - (ToolSetterPosition + ManualToolSetterHeight) and writes it to the tool table via mc.mcToolSetData(). Activates the tool length offset via mc.mcCntlSetOffsetIndex() and saves the tool file via mc.mcToolSaveFile().
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode and confirmation checks. Defaults to false |
| CommonGUIModule CalculateZWorkOffsetAutoBtn | ( | IgnoreConfirmationDialogs | ) |
Automatically measure the Z fixture offset using the auto tool setter.
Checks manual mode and tool setter availability. If a user override exists (user.UserCalculateZWorkOffsetAutoBtn), calls it instead. Otherwise verifies that an auto tool setter is configured and the screen is in edit mode. Presents a CycleStartDialog asking the operator to confirm auto measurement of the Z fixture offset. On confirmation, executes "M902" via mc.mcCntlMdiExecute() to run the auto Z fixture offset measurement cycle.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode check. Defaults to false |
| CommonGUIModule CalculateZWorkOffsetManualBtn | ( | IgnoreConfirmationDialogs | ) |
Manually measure the Z work (fixture) offset using the manual tool setter position.
Checks manual mode. If a user override exists (user.UserCalculateZWorkOffsetManualBtn), calls it instead. Otherwise verifies edit mode and that a manual tool setter is configured. Reads the ToolSetterFixtureOffsetMode to determine how to apply the offset: mode 0 calls m.ModifyAxisPosition() on Z; mode 1 sets SV_WORK_SHIFT_Z; mode 2 sets SV_HEAD_SHIFT_Z; mode 3 iterates G54-G59 fixtures and applies the offset to each. Reads ManualToolSetterHeight from the selected fixture setter and uses it as the offset amount.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips edit mode and confirmation checks. Defaults to false |
| CommonGUIModule CalibrateToolSetters | ( | ) |
Open the Calibrate Tool Setters dialog for managing tool setter configurations.
Creates and displays a non-modal dialog allowing the operator to add, remove, rename, and configure tool setters. Each tool setter has properties including type (manual/auto), probe input selection, height, Z position, softlimit disable flag, fixture offset usage, fixture offset mode, and start/end GoTo positions. Provides wizard launch buttons for guided height and Z position calibration. A 100ms timer monitors for Mach shutdown and closes the dialog automatically. Changes are saved to the Mach4 profile via w.WriteToolSetter() when the Save button is pressed. Reloads the screen tool setter configuration via m.screen.InitializeToolSetters() after saving if available.
| UI CancelButtonClick | ( | ) |
Handle the Cancel button click in the Job Notes dialog.
Displays a Yes/No confirmation dialog asking the user to confirm cancellation without saving. If the user selects Yes, calls UI.CloseDialog() to close the dialog.
| UI CellChangedGenericGridDialog | ( | row | , |
| col | ) |
Handle a cell value change event in the Generic Grid dialog.
Updates the GridTable.Data table at [row+1][col+1] with the new cell value retrieved from the wxGrid via GetCellValue(). Initializes GridTable.Data[row+1] as an empty table if it does not already exist.
| row | (number) The zero-based row index of the changed cell |
| col | (number) The zero-based column index of the changed cell |
| CommonGUIModule Scheduler ChangeQty | ( | qty | ) |
Set the quantity column value of an item in the Schedule Editor list control.
Updates column 1 (quantity) of the item at the specified zero-based index in the wxListCtrl (self.UI.m_listCtrl2) using SetItem(). Does nothing if idx is out of bounds.
| idx | (number) The zero-based index of the item to update |
| qty | (string|number) The new quantity value to display in the quantity column |
| CommonGUIModule CheckEnableAndHomeFlag | ( | ) |
Check whether the enable and home startup dialog is currently active.
If ENABLE_HOME_DIALOG_ACTIVE is true and the emergency stop signal is not active, resets ENABLE_HOME_DIALOG_ACTIVE to false. Returns true if the dialog is active, false otherwise.
| CommonGUIModule CheckFeedrateOverride | ( | value | , |
| ... ) |
Clamp a feedrate override percentage to the configured minimum and maximum bounds.
Reads FeedrateOverrideMaxPercent and FeedrateOverrideMinPercent OEM parameters. If value is nil, reads the current feedrate override via mc.mcCntlGetFRO(). Clamps value to the [min, max] range and returns the clamped result.
| value | (number|nil) The feedrate override percentage to check. If nil, uses the current override value |
| ... | (any) Additional arguments (unused, reserved for hook compatibility) |
| CommonGUIModule CheckHomeSwitchesForHoming | ( | homing_axis | , |
| inst | ) |
Check if any home switch is active before homing and prompt the operator to jog off if needed.
Calls CommonGUIModule.IsHomeSwitchActive() to check the specified axis (or all axes if nil). If a home switch is active and the corresponding axis is enabled (AXIS_ENABLED_INST), opens the JogOffHomeSwitchDialog for the operator to jog off the switch. After the dialog closes, checks again; if the switch is still active, raises an error via w.Error().
| homing_axis | (number|nil) The axis index to check, or nil to check all axes |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule Scheduler CheckName | ( | ) |
Check whether the given file name matches the top scheduled file, accounting for GCAdapter naming.
Compares f_name against the top scheduled file path (self:GetTopFile()). If the EnableGCAdapter OEM parameter is "Yes", also constructs an adapted file name using the GCAdapterConfig.lua settings and compares against that. Returns true if neither the raw file name nor the adapted file name matches the top scheduled file. Delegates the actual work to self:_CheckName() via w.pcall() for error protection.
| f_name | (string) The file path to check against the top of the schedule |
| CommonGUIModule JobFile CheckPassword | ( | ) |
Verify that the operator has the required password level to save the job file.
If jb.Password is nil, returns true immediately (no protection). If jb.Password is between 1 and 3 inclusive, calls w.PasswordProtection() with that level and returns the result. All other password values return true (no protection).
| CommonGUIModule CheckSpindleOverride | ( | value | , |
| ... ) |
Clamp a spindle override percentage to the configured minimum and maximum bounds.
Reads SpindleOverrideMaxPercent and SpindleOverrideMinPercent OEM parameters. If value is nil, reads the current spindle override via m.GetSpindleOverride(). Clamps value to the [min, max] range and returns the clamped result.
| value | (number|nil) The spindle override percentage to check. If nil, uses the current override value |
| ... | (any) Additional arguments (unused, reserved for hook compatibility) |
| UI clean_up | ( | ) |
Release the cycle start hold and close the Cycle Start dialog.
Stops and destroys the dialog timer (UI.dlg_timer). Calls w.Formatting.CloseDialog() to close the cycle start dialog window and releases the cycle start hold via w.ReleaseCycleStartHold(). This function is defined as a closure inside CommonGUIModule._CycleStartDialog() and is called on both normal close and cancel paths.
| CommonGUIModule CleanJobFiles | ( | ) |
Remove the JobFiles section from the Mach4 profile for the current instance.
Calls mc.mcProfileDeleteSection() to delete the entire "JobFiles" section from the Mach4 profile, clearing all registered job file entries.
| CommonGUIModule Scheduler Clear | ( | ) |
Delete all items from the Schedule Editor list control.
Calls DeleteAllItems() on the Schedule Editor's wxListCtrl (self.UI.m_listCtrl2) to remove all scheduled file entries from the UI.
| CommonGUIModule ClearLimitSwitchActiveMessage | ( | handle | ) |
Close and dismiss a limit switch active notification by handle.
Delegates to w.CloseGMSNotification() to close the GMS notification referenced by the provided handle. Used to dismiss limit switch warning messages created by CommonGUIModule.CreateLimitSwitchActiveMessage().
| handle | (any) The notification handle returned by CreateLimitSwitchActiveMessage() |
| CommonGUIModule ClearRunScriptQueue | ( | ) |
Clear all pending items from the RUN_SCRIPT_QUEUE.
Iterates the RUN_SCRIPT_QUEUE in reverse order (from last to first) and sets each element to nil, effectively emptying the queue. Used to purge the queue during error recovery or shutdown. Does nothing if RUN_SCRIPT_QUEUE is nil.
| CommonGUIModule Scheduler ClearSchedule | ( | leave_reg | ) |
Clear all scheduled file entries for a given instance, optionally preserving the register.
Removes all entries from the in-memory schedule table (self.scheduled_files[_inst]). If leave_reg is false (the default), also clears the OEM register identified by self.FILE_REG via w.SetOEMParamValueString(). If leave_reg is true, the register is left unchanged. Delegates the actual work to self:_ClearSchedule() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| leave_reg | (boolean|nil) If true, do not clear the OEM register. Defaults to false |
| CommonGUIModule Scheduler ClearSelection | ( | ) |
Clear the selection state of all selected items in the Schedule Editor list control.
Iterates through all selected items in the wxListCtrl (self.UI.m_listCtrl2) using GetNextItem() with wxLIST_STATE_SELECTED, and deselects each one by calling SetItemState() with a state of 0. Continues until no more selected items are found (index == -1).
| CommonGUIModule ClearToolChangeState | ( | ) |
Clear the tool change state for the currently selected spindle.
Retrieves the selected instance and the selected spindle for that instance, then calls w.SetToolChangeStatus() with a value of 0 to reset the "ToolChangeState" status. Useful for recovering after a failed tool change.
| CommonGUIModule JobFile ClearValues | ( | ) |
Reset all pound variables and registers tracked by the job file to their stored values.
Iterates over all pound variables in the configured range (jb.RangeString) and sets each to its value stored in jb.FileTable.PoundVars via mc.mcCntlSetPoundVar(). Then iterates over jb.RegTable and resets each register to its stored value via w.SetRegValueString(). Uses 0 as a fallback if a stored value is nil.
| value | (number|nil) Currently unused; reserved for a clear value. Defaults to 0 if nil or non-numeric |
| CommonGUIModule JobFile Close | ( | ) |
Close the currently loaded job file, prompting to save if there are unsaved edits.
Calls jb:HasEdits() to check for unsaved changes. If changes exist, displays a Yes/No dialog asking whether to save before closing. If the user chooses Yes, calls jb:Save(). Then delegates to jb:_Close() to clear the file state and call close callbacks.
| UI CloseCommandsDialog | ( | ) |
Close the Commands dialog and release associated resources.
Stops and clears the CommandsDialog_Timer if active. Destroys the CommandsDialog window. Sets DIALOG_IS_OPEN["CommandsDialog"] to false to allow the dialog to be reopened.
| UI CloseDialog | ( | ) |
Close the Recent GCode dialog and release associated resources.
Close the Run Lua Script dialog and save state.
Close the Modify Z Offsets In Tool Change Final dialog and send selection data.
Close the Modify Z Offsets In Tool Change Final dialog and send selection data across a register.
Close the Modify Z Offsets In Tool Change dialog and send the operator's selection across a register.
Close the MDI dialog, save history, and clear the MDI active output signal.
Close the Job Notes dialog and release its global handle.
Stop the dialog timer and mark the cycle start inhibit dialog as closed.
Close the Block Delete dialog and release associated resources.
Stops the dialog's timer if active. Saves the dialog's staged position and size via w.Formatting.SaveStagedDialog(). Destroys the recent_dialog window. This function is defined as a local closure within CommonGUIModule.GcodeRecentBtn() and is called from both the timer shutdown handler and the close window event.
Stops and clears the BlockDeleteTimer if active. Sets DIALOG_IS_OPEN[2] to false to allow the dialog to be reopened. Destroys the BlockDelete dialog window. This function is defined as a local closure within CommonGUIModule.BlockDeleteToggleBtn() and is called from both the OK button handler and the close window event.
Stops and clears the ListAlarmMessageTimer, then sets DIALOG_IS_OPEN[5] to false to allow the dialog to be reopened in the future. This is a closure defined inside CommonGUIModule.CycleStartInhibitDialog().
Checks that JOB_NOTES_DIALOG_HANDLE is set, clears it to nil, stops the dialog timer if active, then closes the dialog via w.Formatting.CloseDialog() with the key "JobNotesDialog".
Calls UI.ConstructMDIString() to get the current MDI text and saves it to history via UI.SaveToHistory(). Clears the "MDI" I/O state via w.SetIoState() to turn off the MDI button indicator. Stops and clears the dialog timer, then closes the dialog via w.Formatting.CloseDialog() with the key "MDIDialog". Clears the MDI_DIALOG_HANDLE global.
Reads the current radio-box selection and position input value, maps them to a normalized selection index (0=continue, 1=manual jog, 2=manual tool setter, 3=auto tool setter), and packages both into a Lua table sent via w.SendTableAcrossRegister(). Does not send if Mach is shutting down. Stops the dialog timer and closes via w.Formatting.CloseDialog() with the key "ModifyZHeadShiftOffset".
Packages the modify_type value captured in the enclosing closure into a Lua table and sends it via w.SendTableAcrossRegister() so the M-code waiting on the dialog can read the user's implicit selection. Does not send across the register if Mach is shutting down. Stops the dialog timer and closes the dialog via w.Formatting.CloseDialog() with the key "ModifyZHeadShiftOffsetFinal".
Packages the modify_type value into a Lua table and sends it across a register via w.SendTableAcrossRegister() so the M-code waiting on the dialog can read the user's selection. Stops the dialog timer and closes the dialog via w.Formatting.CloseDialog() with the key "ModifyZHeadShiftOffsetFinal". Does not send across the register if Mach is shutting down.
Saves the current editor content to history, stops and clears the dialog timer, persists the splitter sash position to the Mach4 profile, saves the dialog size/position via w.Formatting.SaveStagedDialog(), clears the external UI reference from both CommonGUIModule._RunLuaUIRef and _G._RunLuaUIRef, then destroys the dialog window.
| UI CloseDialog | ( | CloseWindow | ) |
Stop all active jogs, destroy the jog timer, and mark the jog-off home switch dialog as closed.
Calls UI.StopJog() to halt any active jog motion on all axes. Stops and clears the JogOffHomeSwitchTimer, then sets DIALOG_IS_OPEN[4] to false to allow the dialog to be reopened. This is a closure defined inside CommonGUIModule.JogOffHomeSwitchDialog().
| CloseWindow | (any) Unused parameter, accepted for event handler compatibility |
| UI CloseDialog | ( | reason | ) |
Close the GoTo Positions dialog and release the cycle start hold.
Saves the current radio box selection to the MachMotion profile. Resets GOTO_POSITION_MODE to 0. Stops and destroys the goto_timer if active. Destroys the dialog. Calls w.ReleaseCycleStartHold() with the provided reason string.
| reason | (string) Description of why the dialog is being closed, passed to w.ReleaseCycleStartHold() |
| UI CloseGenericGridDialog | ( | ) |
Close the Generic Grid dialog and release its timer resources.
Stops and clears the UI.GenericGridDialogTimer if it is active, then ends the modal dialog with return code 1 via EndModal().
| CommonGUIModule CloseM00Notification | ( | ) |
Close the M00/M01 stop notification and clear the optional stop active register.
Calls w.CloseGMSNotification() to dismiss the active stop notification referenced by m.M00_NotificationHandle. Sets the OptionalStopActive OEM register to 0 via w.SetOEMRegValue(). Clears m.M00_NotificationHandle and m.M00LineNumber to nil.
| CommonGUIModule CloseMach | ( | showwarningmessage | ) |
Close the Mach4 CNC software, optionally prompting the user for confirmation.
If showwarningmessage is true, displays a Yes/No dialog asking the user to confirm before closing. If confirmed (or skipped), saves the tool table via mc.mcToolSaveFile() and the fixture offsets via mc.mcFixtureSaveFile(), then exits Mach4 via scr.Exit(true).
| showwarningmessage | (boolean) If true, shows a confirmation dialog before closing |
| UI CloseMachMenuDialog | ( | ) |
Close the Mach Menu configuration dialog and save the hide-on-startup preference.
Stops the dialog timer, reads the current state of the "Hide Menu On Startup" checkbox, and writes HideMachMenu=1 or HideMachMenu=0 to the MachMotion profile accordingly. Then destroys the dialog and clears the DIALOG_IS_OPEN["MachMenu"] flag.
| UI ClosePartCounterDialog | ( | ) |
Stop the Part Counter timer and destroy the Part Counter dialog.
Stops UI.PartCounterTimer if it is active and sets it to nil, then calls Destroy() on UI.PartCounterDialog to free the wx dialog. Sets the DIALOG_IS_OPEN flag for "PartCounterDialog" to false.
| UI ClosePLCSeqDialog | ( | ) |
Close the PLC Sequence dialog and release associated resources.
Stops and clears the PLCSeqTimer if active. Destroys the PLC_Seq_Dialog window. Sets DIALOG_IS_OPEN["PLC_SEQ"] to false to allow the dialog to be reopened.
| CommonGUIModule CommandsDialogBtn | ( | ) |
Open the Commands dialog allowing the operator to browse and run user commands.
Guards against duplicate opens via DIALOG_IS_OPEN["CommandsDialog"]. Requires password level 3. Retrieves all user commands via w.GetAllCommands() and sorts them alphabetically. Builds a resizable dialog with a search field, a list box of command names, and a Run Command button. A timer polls for machine shutdown and updates the button feedback color based on the selected command's state. Running a command calls w.RunUserCommand() and saves the last selection to the profile.
| CommonGUIModule CommonLowPriorityLoop | ( | ) |
Execute the common low-priority PLC loop tasks at a reduced scan rate.
-------------------— Common Low Priority PLC Loop ----------------------—
Called periodically from _CommonPLCScript() when LOW_PRIORITY_LOOP_COUNTER reaches LOW_PRIORITY_LOOP_SCANS. Executes the following tasks in order: user.UserPLCLowPriorityScript(), UpdateGlobalWithActiveFixtureIndex(), UpdateCurrentToolAndPocketGlobals(), _LuaProfiling.UpdateTimedProfiling(), UpdateLubeTimer(), UpdateLastGCodeFileName(), UpdateDoorInterlock(), SubSpindleUpdate(), UpdateMotionInhibit(), InhibitJoggingWhenNotHomed(), a stuck-state check (E-stops if machine is in a run state while disabled), LowPriorityLoop() (machine type), and screen.LowPriorityLoop(). Errors from user.UserPLCLowPriorityScript() are caught and logged via w.FunctionError().
| CommonGUIModule CommonMessageScript | ( | inst | , |
| msg_type | , | ||
| param1 | , | ||
| param2 | ) |
Entry point for Mach4 message events; validates and dispatches supported message types.
Checks whether msg_type is present in CommonGUIModule.MachMsg["Supported Types"]. If the message type is not supported, returns immediately. Otherwise calls CommonGUIModule.HandleMachMessages() via w.pcall() for error protection. If an error occurs, logs it via w.FunctionError().
| inst | (number) The Mach4 instance handle that generated the message |
| msg_type | (number) The Mach4 message type constant (e.g., mc.MSG_REG_CHANGED) |
| param1 | (number|string) First message parameter (register handle, IO handle, or pound var index) |
| param2 | (number|string) Second message parameter (new value or state) |
| CommonGUIModule CommonPLCScript | ( | ) |
Entry point for the Mach4 PLC script; executes the main PLC loop with error protection.
Checks ENABLE_MAIN_PLC_SCRIPT and returns immediately if it is false. Calls CommonGUIModule._CommonPLCScript() via w.pcall() for error protection. If an error occurs, logs it via w.Log() and displays a warning message box via w.wxMessageBox() up to 5 times (tracked by PLC_SCRIPT_ERROR counter) to prevent infinite error dialogs. Sets FIRST_RUN to true after each PLC cycle.
| CommonGUIModule CommonScreenLoadScript | ( | ) |
Protected entry point for the Mach4 screen load script.
Wraps CommonGUIModule._CommonScreenLoadScript() via pcall() for top-level error handling. If an error occurs, attempts to retrieve the checkpoint object via CommonGUIModule.GetCheckPoint() and includes its stringified context in the error message displayed via wx.wxMessageBox(). After the load script completes (successfully or not), calls h.StartScreenLoadedCheck() if the GUIModule (h) is available.
| CommonGUIModule CommonScreenUnloadScript | ( | MachEnable | ) |
Wrapper entry point for the screen unload script; delegates to the protected implementation.
Calls CommonGUIModule._CommonScreenUnloadScript() via w.Protected() to execute the full screen unload sequence (save vars, save offsets, disable hardware, stop timers, etc.) with error protection. The MachEnable parameter controls whether the machine is disabled as part of the unload sequence.
| MachEnable | (boolean|nil) If true, skips machine disable and hardware shutdown steps. Defaults to false if not provided, causing a full disable sequence on unload |
| CommonGUIModule CommonSelectedInstanceChanged | ( | ) |
Handle a change in the selected Mach4 instance and notify all registered listeners.
Calls w.UpdateSelectedInstance() to synchronize the internal selected instance state. Calls m.screen.CommonSelectedInstanceChanged() if it is defined. Runs the "SelectedInstanceChanged" hooks via m.RunHooks(). Updates the SELECTED_INSTANCE global variable to the newly selected instance.
| CommonGUIModule CommonSignalScript | ( | sig | , |
| sig_state | ) |
Entry point for Mach4 signal change events; converts signal state and dispatches to handler.
Converts sig_state to a boolean via w.ToBoolean(). Calls CommonGUIModule._CommonSignalScript() via w.Protected() for error protection, passing the signal ID, converted state, and current instance handle.
| sig | (number) The Mach4 signal ID that changed state |
| sig_state | (number|boolean) The new signal state (converted to boolean internally) |
| CommonGUIModule CommonStartUpScript | ( | ) |
Protected wrapper for the common CNC startup initialization sequence.
Delegates all startup work to CommonGUIModule._CommonStartUpScript() via w.Protected() for error handling. Handles initialization that can only be done after Mach4 is fully initialized, including starting the file queue timer, running machine-type and user startup scripts, configuring lube timers, enabling soft limits, sending the tool table, running the installer update module, and waiting for motion controller initialization.
| CommonGUIModule CommonTimerScript | ( | timer | ) |
Entry point for Mach4 timer events; dispatches to machine-type and screen timer handlers.
Calls m.TimerScript(timer) if it is defined, then calls m.screen.TimerScript(timer) if it is defined. Handles the BlinkObjectNomal timer by toggling BLINK_OBJECT_ACTIVE and running the "BlinkObjects" hooks via m.RunHooks(). Handles the BlinkObjectSlow timer by toggling BLINK_OBJECT_SLOW_ACTIVE and running the "BlinkObjectsSlow" hooks.
| timer | (number) The timer ID that fired, compared against SCREEN_TIMERS entries |
| CommonGUIModule CommonUpdateSignalLibraryArray | ( | ) |
Rebuild the signal library arrays and update auxiliary button configuration.
-------------------— Signal Library Array ----------------------—
Calls CommonGUIModule.UpdateSignalLibraryArray() if it exists to rebuild the base signal handlers. Then iterates over all AUX_BTN_QUANTITY auxiliary buttons, reading each button's output signal assignment and toggle mode from the Mach4 profile (AuxiliaryOutputButton# and AuxiliaryOutputButton#Toggle keys under MachMotion section). Updates AUX_OUTPUT_ARRAY and AUX_BTN_TOGGLE for each button, and enables or disables the corresponding screen button object ("Aux#Btn") based on whether a valid output signal is assigned. Runs the "UpdateSignalLibrary" hooks via m.RunHooks() on completion.
| CommonGUIModule CompileScriptsBtn | ( | ) |
Recompile all M-code scripts and reload the screen configuration.
Checks that the machine is idle before proceeding. Disables the main PLC script, runs hooks via m.RunHooks("CompileScripts"), stores machine overrides, and recompiles M-code scripts for all instances via mc.mcCntlCompileScripts(). Unloads the common screen, removes cached Lua bytecode files, reinitializes the scheduler, and sets configuration registers to trigger a full reload. Re-enables the main PLC script on completion.
| CommonGUIModule _LuaProfiling Configure | ( | ) |
Perform one-time setup for the Lua profiling facility.
Sets the active flag to false. Clears any previously loaded profiler module and attempts to require() the 'profiler' module via pcall(). If loading fails for any reason, sets prof.profiler to nil and logs the error via mc.mcCntlLog(). If loading succeeds, stores the profiler module reference in prof.profiler for later use by StartProfiler().
| CommonGUIModule ConfigureTLMMode | ( | ) |
Configure the Tool Length Management (TLM) mode so that the T word on the M6 line is used as the selected tool.
Reads bit PV_TLM2_M6E_BIT from the PV_TLM2 parameter. If the bit is 0, sets it to 1 via w.SetParameterBit(). This causes Mach4 to treat the T word on the current M6 line as the tool to activate rather than queuing it as the next tool.
| UI ConstructLuaString | ( | ) |
Build the full Lua execution string wrapping the user's script.
Prepends a header that locally overrides print() and UI.print() to redirect output to the debug output panel, wraps the user's raw code in a protected function, and appends a footer containing an xpcall error handler that appends the traceback to the debug output and sets the error background style on failure. The user's code is obtained via UI._GetEditorText() and is not modified.
| UI ConstructMDIString | ( | ) |
Build the complete MDI command string from all lines in the multi-line text control.
Iterates over all lines in the MDI text control (UI.mdi_line) and concatenates them with newline separators. The first line has no leading newline; subsequent lines are joined with "\n".
| UI ConstructNotesString | ( | ) |
Construct the full notes string from all lines in the multi-line notes text control.
Iterates over all lines in UI.notes_line using GetNumberOfLines() and GetLineText(). Lines are concatenated with newline separators; the first line has no leading newline.
| CommonGUIModule ConvertIgnoreOutputsString | ( | output_range | ) |
Convert a semicolon or comma-separated output range string to an array of output numbers.
Normalizes semicolons to commas via string.gsub(). Strips any trailing comma from the string. Delegates to w.InterpretRangeString() to expand range expressions (e.g., "1-5,7") into a flat array of output numbers. Returns the resulting array directly.
| output_range | (string) A semicolon or comma-separated string of output numbers or ranges (e.g., "1;3;5-8") |
| CommonGUIModule CoolantToggleBtn | ( | ) |
Button handler to toggle flood coolant on or off.
Logs the button press via w.OperatorLog(). Checks the current flood state via m.IsFloodOn(). If flood is currently on, calls m.FloodOff() to turn it off. Otherwise calls m.FloodOn() to turn it on.
| CommonGUIModule _LuaProfiling CreateCommands | ( | ) |
Register user commands for starting, stopping, and timed screen profiling.
Creates two user commands using w.CreateCommandActionOption(), w.CreateCommandFeedbackOption(), w.CreateSimpleCommand(), and w.SetCommandButtonLabels():
| CommonGUIModule Scheduler CreateEditControls | ( | ) |
Create and display the Schedule Editor dialog with list control and management buttons.
Builds the complete Schedule Editor UI including a wxListCtrl showing scheduled files with File and Qty columns, navigation buttons (Up, Down, Delete, Clear, To Top, To Bottom), and Load/Save/Close action buttons. Loads the current schedule into the list via self:InsertFiles(), connects all button event handlers, and shows the dialog via w.Formatting.ShowDialog(). Registers a resize event to maintain correct column widths.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule CreateLimitSwitchActiveMessage | ( | message | , |
| title | ) |
Create a persistent GMS notification for a limit switch active condition.
Calls w.CreateGMSNotification() with instance 0, a timeout of -1 (persistent), sticky=true, visible=true, and priority -3. Uses black foreground color (Red=0, Green=0, Blue=0). Returns the notification handle for later dismissal via ClearLimitSwitchActiveMessage().
| message | (string) The warning message text to display in the notification |
| title | (string) The title of the notification |
| CommonGUIModule CreateLimitSwitchAlarm | ( | msg | ) |
Create a GMS alarm message for a limit switch activation event.
If the machine was previously enabled (MACH_WAS_ENABLED is true), checks whether a GMS message with the given title already exists via w.GetGMSHandleFromTitle(). If no existing message is found and the LimitSwitchAlarmEnabled OEM parameter is "Yes", creates a new GMS Alarm message with title "Limit Switch Active!" and the provided msg as the description, with a Notification action via w.CreateSystemGlobalMessage().
| msg | (string) The limit switch alarm description text (e.g., "X++ Limit Switch Active") |
| CommonGUIModule CreatePreCannedCommands | ( | ) |
Register all pre-canned machine commands, feedback options, and button configurations.
This function creates a comprehensive set of machine commands that can be assigned to operator panel buttons, screen buttons, or keyboard shortcuts. It registers action options, feedback options, and simple commands for the following categories:
| CommonGUIModule SearchGCode CreateSearchDialog | ( | ) |
Create and display the GCode Search dialog with search bar, grid, and navigation buttons.
Builds the full GCode Search UI including a text search bar (with Enter-key handler), a resizable wxGrid showing line numbers and G-code content, and Go To / Close buttons. Registers event handlers for search, grid double-click (go to line), close button, window close, and resize events. Shows the dialog via w.Formatting.ShowDialog().
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule CutterCompensationToggleType_A | ( | ) |
Toggle cutter compensation type A on or off.
If type A is currently active (IsCutterCompensationType_A() returns true), calls m.CutterCompensationType_A(false) to disable it. Otherwise calls m.CutterCompensationType_A(true) to enable it. Uses the PV_CCT_BIT_SUP bit of the PV_CCT (parameter 5003) Mach4 parameter.
| CommonGUIModule CutterCompensationToggleType_B | ( | ) |
Toggle cutter compensation type B on or off.
If type B is currently active (IsCutterCompensationType_B() returns true), calls m.CutterCompensationType_B(false) to disable it. Otherwise calls m.CutterCompensationType_B(true) to enable it. Uses the PV_CCT_BIT_SUP bit of the PV_CCT (parameter 5003) Mach4 parameter.
| CommonGUIModule CutterCompensationToggleType_C | ( | ) |
Toggle cutter compensation type C on or off.
If type C is currently active (IsCutterCompensationType_C() returns true), calls m.CutterCompensationType_C(false) to disable it. Otherwise calls m.CutterCompensationType_C(true) to enable it. Uses the PV_CCT_BIT_SUV bit of the PV_CCT (parameter 5003) Mach4 parameter.
| CommonGUIModule CutterCompensationType_A | ( | on_off | ) |
Enable or disable cutter compensation type A.
Sets or clears the PV_CCT_BIT_SUP bit (bit 0) of the PV_CCT parameter (5003) via w.SetParameterBit(). If on_off is true, clears the bit to 0 (type A enabled); if false or nil, sets the bit to 1. Initializes PV_CCT_BIT_SUP and PV_CCT to their default values if they are nil. Type A is the default compensation mode when the SUP bit is 0.
| on_off | (boolean|nil) True to enable cutter compensation type A, false or nil to disable |
| CommonGUIModule CutterCompensationType_B | ( | on_off | ) |
Enable or disable cutter compensation type B.
Sets or clears the PV_CCT_BIT_SUP bit (bit 0) of the PV_CCT parameter (5003) via w.SetParameterBit(). If on_off is true, sets the bit to 1 (type B enabled); if false or nil, clears the bit to 0. Initializes PV_CCT_BIT_SUP and PV_CCT to their default values if they are nil. Type B compensation differs from type A in the direction of cutter radius compensation.
| on_off | (boolean|nil) True to enable cutter compensation type B, false or nil to disable |
| CommonGUIModule CutterCompensationType_C | ( | on_off | ) |
Enable or disable cutter compensation type C (tool nose radius compensation vector correction).
Sets or clears the PV_CCT_BIT_SUV bit (bit 1) of the PV_CCT parameter (5003) via w.SetParameterBit(). If on_off is true, sets the bit to 1 (type C enabled); if false or nil, clears the bit to 0 (type C disabled). Initializes PV_CCT_BIT_SUV and PV_CCT to their default values if they are nil.
| on_off | (boolean|nil) True to enable cutter compensation type C, false or nil to disable |
| CommonGUIModule CycleStart | ( | inst | ) |
Initiate a cycle start with re-entrancy protection and cycle start hold handling.
If a cycle start hold is currently active, releases it via w.ReleaseCycleStartHold() and returns. Guards against concurrent execution using w.FuncTracing["m.CycleStart"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._CycleStart() via w.pcall() for protected execution. On error, returns a formatted error via w.FunctionError().
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule CycleStartBtn | ( | ) |
Button handler to initiate a cycle start operation.
Delegates to m.CycleStart() to perform the full cycle start sequence. This is the primary UI entry point for the Cycle Start button on the screen.
| CommonGUIModule CycleStartDialog | ( | Message | , |
| Title | , | ||
| inst | ) |
Display a modal Cycle Start confirmation dialog and wait for operator confirmation.
Sets the active Mach4 instance, then delegates to CommonGUIModule._CycleStartDialog() with ShowModal set to true via w.pcall() for error protection. If an error occurs, logs it via w.FunctionError() and returns false. The dialog displays a green-background prompt with a Cycle Start button (if no hardware operator panel is configured) and a Cancel button. Blocks until the operator presses Cycle Start, Cancel, or the machine is disabled.
| Message | (string) The prompt message to display in the dialog |
| Title | (string) The dialog title bar text |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule CycleStartDialog_NotModal | ( | Message | , |
| Title | , | ||
| CmdOnStart | , | ||
| CmdOnCancel | ) |
Display a non-modal Cycle Start confirmation dialog with optional on-start and on-cancel callbacks.
Delegates to CommonGUIModule._CycleStartDialog() with ShowModal set to false via w.pcall() for error protection. If an error occurs, logs it via w.FunctionError() and returns false. The dialog displays a green-background prompt and waits for the hardware or software cycle start button. When confirmed or cancelled, executes the corresponding callback command via w.PostToFileQueue().
| Message | (string) The prompt message to display in the dialog |
| Title | (string) The dialog title bar text |
| CmdOnStart | (string|nil) Lua code string to post to the file queue when Cycle Start is pressed |
| CmdOnCancel | (string|nil) Lua code string to post to the file queue when Cancel is pressed |
| CommonGUIModule CycleStartInhibitDialog | ( | ) |
Display a modal dialog listing all active cycle start inhibit messages.
Reads the mm_FaultMessages register and parses it as a CSV string. Strips leading spaces and "Inhibit Cycle Start: " or "Inhibit Cycle Start (Enabled): " prefixes from each message. If no messages are found or if the dialog is already open (DIALOG_IS_OPEN[5]), returns an error. Otherwise creates and displays a modal dialog containing a grid of inhibit messages with an OK button. Uses a timer to monitor for Mach shutdown.
| CommonGUIModule CycleStartSoftLimitRecovery | ( | inst | ) |
Check and recover axes that are outside the software limit zone before cycle start.
Only active when the CycleStartSoftLimitRecovery OEM parameter is "Yes" and software limits are enabled. Iterates over all enabled coordinate axes and collects any that are outside the soft limit zone via w.IsAxisInSideSoftLimitsZone(). If any axes are out of limits, presents a CycleStartDialog listing the axis names and prompting the operator to confirm. On confirmation, calls w.MoveAxisIntoSoftLimitZone() for each out-of-limits axis with a step of 0.01. If the operator cancels, returns false.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule CycleStop | ( | ... | ) |
Stop the currently running G-code program with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing["m.CycleStop"]. If already in progress, logs a skip message and returns false. Otherwise calls m._CycleStop() via w.pcall() with all provided arguments for protected execution. Accepts a variadic argument list that is passed through to _CycleStop to indicate the stop mode (0=CycleStop, 1=Reset, 2=EnableReset, 10=Custom).
| ... | (any) Optional stop mode number passed to _CycleStop (0=CycleStop, 1=Reset, 2=EnableReset, 10=Custom) |
| CommonGUIModule CycleStopBtn | ( | ) |
Button handler to stop the currently running G-code program.
Calls m.CycleStop(0) to initiate a standard cycle stop sequence and returns a successful completion status. This is the primary UI entry point for the Cycle Stop button.
| CommonGUIModule CycleStopRestoreGCodeLineNum | ( | gcodeline | , |
| inst | ) |
Restore the G-code line number to the value recorded at the time of cycle stop.
Calls mc.mcCntlSetGcodeLineNbr() to set the G-code line number back to the value that was captured when cycle stop was pressed. This ensures the G-code editor and line counter reflect the correct resume point after a stop.
| gcodeline | (number) The G-code line number to restore |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| UI DebugOutputAppend | ( | msg | ) |
Append a timestamped message to the debug output text control.
Formats the message with the current local time (HH:MM:SS) and appends it as a new line to the debug output wxTextCtrl. Has no effect if the dialog or debug output control is not available.
| msg | (any) The message to append; will be converted via tostring() |
| CommonGUIModule DebugPrint | ( | ... | ) |
Convenience alias for AppendRunLuaDebugMessage.
Forwards all arguments to CommonGUIModule.AppendRunLuaDebugMessage(). Appends a message to the Run Lua Script dialog's Debug Output window if it is open. Has no effect if the dialog is not currently visible.
| ... | (any) One or more values to display in the debug output window |
| CommonGUIModule DefaultJob | ( | ) |
Create and initialize the default job file object for the screen.
Instantiates a new JobFile object via m.JobFile:New() with a pound variable range of 500-999, no registers, overwrite enabled, show-notes-on-open enabled, and a standard header. Assigns the result to m.screen.DefaultJob and registers it under the job name "m.screen.DefaultJob".
| CommonGUIModule Scheduler DeleteItem | ( | ) |
Delete the currently selected item from the Schedule Editor list control.
Retrieves the currently selected item index via self:GetSelectedItem(). If a valid item is selected (index ~= -1), deletes it from the wxListCtrl and moves the selection to the item above it. The optional item_idx parameter is accepted but defaults to idx+1 if nil.
| item_idx | (number|nil) Optional override for the item index to delete. Defaults to the current selection index + 1 |
| CommonGUIModule DemoModeWarning | ( | ) |
Display a warning dialog if the software is running in demo mode (unlicensed).
Checks the m.__DemoModeWarningIssued flag to avoid issuing the warning twice. Calls w.CheckIfLicensed() to determine the current license status of the MACHMOTION_PLUGIN. If the license status is -1 (unknown), starts a 1-second recurring timer to retry later. If the software is unlicensed, sets m.__DemoModeWarningIssued to true and displays a modal warning message box informing the user that the software will randomly timeout in demo mode. Does nothing if the software is properly licensed.
| CommonGUIModule DeReferenceAll | ( | ) |
Dereference all axes on the current Mach4 instance.
Delegates to CommonGUIModule.DeReferenceAxis(-1) to dereference all axes on the current instance. This marks all axes as unhomed, requiring a new homing sequence before the machine can run G-code.
| CommonGUIModule DeReferenceAllBtn | ( | ) |
Button handler to dereference all axes on the current Mach4 instance.
Logs the button press via w.OperatorLog() and delegates to m.DeReferenceAll() to dereference all axes. Returns a successful completion status after the operation.
| CommonGUIModule DeReferenceAllInstances | ( | inst_list | ) |
Dereference all axes on each instance in the provided instance list.
Retrieves the list of instances via w.GetInstancesTable(inst_list). For each instance in the list, calls CommonGUIModule.DeReferenceAxis(-1, _inst) to dereference all axes on that instance.
| inst_list | (number|table|nil) An instance handle, table of instance handles, or nil to use all instances |
| CommonGUIModule DeReferenceAxis | ( | Axis | , |
| _inst | ) |
Dereference (un-home) a single axis or all axes on the specified instance.
Logs the dereference action via w.Log(). If Axis is nil, -1, greater than mc.MC_MAX_AXES, or less than mc.X_AXIS, calls mc.mcAxisDerefAll() to dereference all axes on the instance. Otherwise calls mc.mcAxisDeref() to dereference only the specified axis.
| Axis | (number|nil) The axis identifier to dereference, or -1 (or nil) to dereference all axes |
| _inst | (number|nil) The instance to operate on. If not provided, uses the selected instance |
| self UI DestroyGauge | ( | ) |
Destroy the Schedule Editor dialog and release its reference.
Destroy the GCode Search dialog and release its reference.
Destroy the quantity entry dialog and release its reference.
Calls Destroy() on self.UI.MyFrame1 to free the wx dialog window and sets self.UI.MyFrame1 to nil to prevent dangling references.
Calls Destroy() on QUI.QtyDialog to free the wx dialog window and sets QUI.QtyDialog to nil to prevent dangling references.
Calls Destroy() on self.UI.m_Dialog1 to free the wx dialog and sets self.UI.m_Dialog1 to nil to prevent dangling references.
| CommonGUIModule DisableBtn | ( | ) |
Disable the machine by setting the machine enable signal to false.
Calls w.SetMachEnable(false) to disable the machine for the current instance. This is a simple, immediate disable with no pre-disable hooks or sequencing.
| CommonGUIModule DisableLoggingOnOutputs | ( | ) |
Disable signal-change logging on high-frequency axis movement and deceleration output signals.
Iterates over all Mach4 instances and a predefined list of high-frequency output signals (OSIG_MOVING_X through OSIG_MOVING_OB6 and OSIG_GCODE_DECEL). For each signal, retrieves the signal handle and, if logging is currently enabled, disables it via mc.mcSignalSetLogEnable(). This reduces log file noise from signals that toggle at high frequency during motion.
| CommonGUIModule DisplayModelNumber | ( | ) |
Display the machine model number in the screen warning message area.
Reads the control configuration string via w.GetControlConfiguration() and displays it prefixed with "Model:" in the screen warning message area via CommonGUIModule.SetWarningMessage() with the temporary flag set to false and the persistent flag set to true.
| CommonGUIModule DistanceToGoToggleBtn | ( | ) |
Toggle the distance-to-go display mode on or off.
Logs the button press via w.OperatorLog(). If the OSIG_DIST_TOGO signal is currently false, sets it to true via w.SetSignalState(). Otherwise sets it to false. This toggles whether the DRO displays the remaining distance to the target position or the current machine position.
| CommonGUIModule DryRunToggle | ( | ) |
Toggle dry run mode on or off based on its current state.
Checks manual mode via m.ManualModeIsActive(). If manual mode is active or the check fails, returns an error. Otherwise calls m.SetDryRun() with the inverse of the current dry run state as returned by m.IsDryRunOn().
| CommonGUIModule DryRunToggleBtn | ( | ) |
Button handler to toggle dry run mode on or off.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.DryRunToggle() to perform the actual toggle operation.
| CommonGUIModule EdgeFinderXMinusBtn | ( | ) |
Apply a positive X-axis fixture offset using the configured edge finder diameter.
Logs the button press, updates stop status, and optionally displays a confirmation dialog if the ConfirmationDialogs OEM parameter is set to "Yes". Reads the EdgeFinderDiameter OEM parameter and calls m.ModifyAxisPosition() to offset the X axis by +(EdgeFinderDiameter/2), accounting for the edge finder contacting the negative X side of the workpiece.
| CommonGUIModule EdgeFinderXPlusBtn | ( | ) |
Apply a negative X-axis fixture offset using the configured edge finder diameter.
Logs the button press, updates stop status, and optionally displays a confirmation dialog if the ConfirmationDialogs OEM parameter is set to "Yes". Reads the EdgeFinderDiameter OEM parameter and calls m.ModifyAxisPosition() to offset the X axis by -(EdgeFinderDiameter/2), accounting for the edge finder contacting the positive X side of the workpiece.
| CommonGUIModule EdgeFinderYMinusBtn | ( | ) |
Apply a negative Y-axis fixture offset using the configured edge finder diameter.
Logs the button press, updates stop status, and optionally displays a confirmation dialog if the ConfirmationDialogs OEM parameter is set to "Yes". Reads the EdgeFinderDiameter OEM parameter and calls m.ModifyAxisPosition() to offset the Y axis by +(EdgeFinderDiameter/2), accounting for the edge finder contacting the positive Y side of the workpiece.
| CommonGUIModule EdgeFinderYPlusBtn | ( | ) |
Apply a positive Y-axis fixture offset using the configured edge finder diameter.
Logs the button press, updates stop status, and optionally displays a confirmation dialog if the ConfirmationDialogs OEM parameter is set to "Yes". Reads the EdgeFinderDiameter OEM parameter and calls m.ModifyAxisPosition() to offset the Y axis by -(EdgeFinderDiameter/2), accounting for the edge finder contacting the negative Y side of the workpiece.
| CommonGUIModule Scheduler Edit | ( | ) |
Open the Schedule Editor dialog to view and modify the current schedule.
Loads the last saved schedule from the OEM register via self:GetLastSchedule(), then opens the Schedule Editor UI via self:CreateEditControls(). Delegates the actual work to self:_Edit() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule Scheduler EditQty | ( | ) |
Open a dialog allowing the user to edit the quantity of the selected scheduled item.
Creates a small dialog with a numeric input control and an OK button for entering a new quantity value. On confirmation (OK button or Enter key), reads the current selection index via self:GetSelectedItem() and updates the quantity via self:ChangeQty(). The dialog position and size are saved and restored via w.Formatting.ShowDialog() and w.Formatting.SaveStagedDialog() with key "QtyConfig".
| CommonGUIModule EmergencyStop | ( | ) |
Perform an emergency stop by disabling drives and turning off all active outputs.
For each Mach4 instance, disables the drive enable and hardware enable outputs via w.SetDriveEnable() and w.SetHardwareEnable(). Reads the IgnoreOutputsOnEmergencyStop OEM parameter and converts it to an array via m.ConvertIgnoreOutputsString(). Iterates all active output signals and turns off any that are not the spindle brake output and not listed in the ignore array. Also turns off Spindle Speed Variation (SSV) mode via w.SpindleSpeedVariation().
| CommonGUIModule EmergencyStopNotification | ( | ) |
Show or close a GMS notification for an active Emergency Stop signal.
Checks the state of the mc.ISIG_EMERGENCY signal. If the signal is active (true), creates a persistent GMS notification window with the message "Emergency Stop Is Active!" using w.CreateGMSNotification() and stores the handle in EMERGENCYSTOP_NOTIFICATION_HANDLE. If the signal is not active, closes the existing notification via w.CloseGMSNotification(). Intended to be called periodically from a screen timer.
| CommonGUIModule SearchGCode EmptyGrid | ( | ) |
Clear all values from the GCode Search grid and delete all rows except the first.
Calls ClearGrid() to blank all cell values, then deletes all rows after the first using DeleteRows() if the grid has more than one row.
| CommonGUIModule Scheduler Enable | ( | ) |
Enable the scheduler and load the top scheduled file into Mach4.
Sets the scheduler state to active via w.SetOEMParamValue() if not already active. If the in-memory schedule is empty, attempts to reload it from the OEM register via self:GetLastSchedule(). If the schedule has at least one entry and the top file is not already loaded in another instance, closes the current G-code file, verifies the machine is IDLE, and loads the top file via w.LoadGCodeFile(). Raises an error if the machine is not idle when attempting to load. Delegates the actual work to self:_Enable() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule EnableAndHome | ( | ) |
Enable the machine and home all dereferenced axes in a single operation.
First ensures the safety relay is cleared via m.ResetSafetyRelay() if needed. Calls m.Reset() to clear alarms. Checks for active emergency stop or GMS alarms and warnings; if any are present, cancels the operation with a warning message. If the machine is not already enabled, sets the GUIEnableBtn register and calls w.SetMachEnable(true) followed by m.StartEnableSequence(0). If the machine is enabled after the enable sequence, calls m.HomeAllDereferencedAxes(false) to home all axes that have not yet been referenced. Sets MachineEnableStatus register on success.
| CommonGUIModule EnableBtn | ( | ) |
Enable the machine after verifying alarm, emergency stop, and safety relay preconditions.
Calls w.SetStopStatusAll() to update stop status. Runs the EnableBtn hook scripts. Reads GMS alarm status via w.GetGMSAlarms(); if alarms are active, displays a warning and returns an error. Checks for active emergency stop via w.GetSignalState(mc.ISIG_EMERGENCY); if active, displays a warning and returns an error. Calls m.MotionControllerPreEnable() to perform motion controller pre-enable checks. Calls m.ResetSafetyRelay() to reset the safety relay circuit; if that fails, displays a warning and returns an error. If all preconditions pass, calls w.SetMachEnable(true) to enable the machine.
| CommonGUIModule EnableHomeDialog | ( | ) |
Display the enable and home startup dialog if the machine has not yet been homed.
Checks the EnableAndHomeDialog OEM parameter to determine if the dialog is enabled. If already open (ENABLE_HOME_DIALOG_ACTIVE == true), returns immediately. Calls m.VerifyHoming() to check homing status; if the machine is already homed, cancels the dialog. Sets ENABLE_HOME_DIALOG_ACTIVE to true and shows a non-modal CycleStartDialog prompting the operator to enable and home all axes, with callbacks to m.EnableHomeDialog_CycleStart() and m.EnableHomeDialog_Cancel().
| CommonGUIModule EnableHomeDialog_Cancel | ( | ) |
Cancel the enable and home startup dialog without performing any action.
Resets the ENABLE_HOME_DIALOG_ACTIVE global flag to false, effectively dismissing the enable and home dialog without enabling the machine or homing any axes.
| CommonGUIModule EnableHomeDialog_CycleStart | ( | ) |
Execute the enable and home sequence when the operator confirms via cycle start.
Resets the ENABLE_HOME_DIALOG_ACTIVE global flag to false and calls m.EnableAndHome() to perform the full enable and home sequence for all dereferenced axes.
| CommonGUIModule EnableReset | ( | ) |
Perform a combined enable and reset operation with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing for m.EnableReset, m.StartEnableSequence, and m.StartDisableSequence. If any of these are already in progress, logs a skip message and returns an error. Otherwise calls m._EnableReset() via w.pcall() for protected execution. On error, returns a formatted error via w.FunctionError().
| CommonGUIModule EnableResetBtn | ( | ) |
Button handler to initiate the combined enable and reset sequence.
Delegates to m.EnableReset() to perform the combined enable and reset operation. This button handler is the primary UI entry point for the Enable/Reset button on the screen.
| CommonGUIModule EndOfProgram | ( | inst | ) |
Handle the end-of-program event (M30 macro entry point).
Records the end-of-program start time, runs the "EndOfProgram" hooks, handles G-code file repeat (if active), and loads the next scheduled file in the scheduler queue. Called from the Lua File Queue when an M30 macro completes.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ExecuteRunScriptQueue | ( | ) |
Execute and remove the first queued item from RUN_SCRIPT_QUEUE.
If RUN_SCRIPT_QUEUE is non-nil and contains at least one item, removes the first item via table.remove(). If the item is a function, calls it directly. If the item is a string, compiles it via load() and executes the resulting function. If compilation fails, logs the error via w.Log(). Should be called periodically from the GUI thread to process REST API requests in a non-blocking manner.
| CommonGUIModule FeedHold | ( | inst | ) |
Initiate a feed hold to pause program execution with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing["m.FeedHold"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._FeedHold() via w.pcall() for protected execution. On error, returns a formatted error via w.FunctionError().
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule FeedHoldBtn | ( | ) |
Button handler to initiate a feed hold to pause program execution.
Delegates to m.FeedHold() to perform the feed hold sequence. This is the primary UI entry point for the Feed Hold button on the screen.
| CommonGUIModule FeedHoldRetract | ( | inst | ) |
Initiate a feed hold retract operation with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing["m.FeedHoldRetract"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._FeedHoldRetract() via w.pcall() for protected execution. On error, returns a formatted error via w.FunctionError().
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule FeedHoldRetractBtn | ( | ) |
Button handler to initiate a feed hold retract operation.
Delegates to m.FeedHoldRetract() to perform the feed hold retract sequence. This is the primary UI entry point for the Feed Hold Retract button on the screen.
| CommonGUIModule FeedrateOverrideDecrement | ( | increment | ) |
Decrement the feedrate override percentage by the configured or specified increment.
Reads the current feedrate override and rounds it to the nearest integer. If no increment is provided, selects the SmallIncrement (< 10%) or LargeIncrement (>= 10%) from OEM parameters. Runs registered hooks via m.RunHooks("FeedrateOverrideDecrement"). Subtracts the increment from the current percentage and delegates to m.SetFeedrateOverride() to apply the clamped new value.
| increment | (number|nil) Amount to decrement. If nil, uses the configured small or large increment |
| CommonGUIModule FeedrateOverrideDecrementAmount | ( | amount | , |
| increment | ) |
Decrement the feedrate override by repeatedly calling FeedrateOverrideDecrement.
Treats amount as a positive quantity regardless of sign. If amount exceeds 100, logs a warning and aborts. Otherwise calls m.FeedrateOverrideDecrement(increment) once for each unit of amount, allowing the increment logic to adapt to the current percentage on each iteration.
| amount | (number) The total number of decrement steps to apply. Must be <= 100 |
| increment | (number|nil) The per-step decrement amount passed to FeedrateOverrideDecrement. If nil, uses configured increment |
| CommonGUIModule FeedrateOverrideIncrement | ( | increment | ) |
Increment the feedrate override percentage by the configured or specified increment.
Reads the current feedrate override and rounds it to the nearest integer. If no increment is provided, selects the SmallIncrement (< 10%) or LargeIncrement (>= 10%) from OEM parameters. Runs registered hooks via m.RunHooks("FeedrateOverrideIncrement"). Adds the increment to the current percentage and delegates to m.SetFeedrateOverride() to apply the clamped new value.
| increment | (number|nil) Amount to increment. If nil, uses the configured small or large increment |
| CommonGUIModule FeedrateOverrideIncrementAmount | ( | amount | , |
| increment | ) |
Increment the feedrate override by repeatedly calling FeedrateOverrideIncrement.
Treats amount as a positive quantity regardless of sign. If amount exceeds 100, logs a warning and aborts. Otherwise calls m.FeedrateOverrideIncrement(increment) once for each unit of amount, allowing the increment logic to adapt to the current percentage on each iteration.
| amount | (number) The total number of increment steps to apply. Must be <= 100 |
| increment | (number|nil) The per-step increment amount passed to FeedrateOverrideIncrement. If nil, uses configured increment |
| CommonGUIModule FileResume | ( | ) |
Execute the file resume sequence using the configured resume mode.
Sets the FileResumeIsActive OEM parameter to 1 to indicate a resume is in progress. Calls w.Protected(m._FileResume) to execute the internal resume logic with error protection. Resets FileResumeIsActive to 0 when complete. The internal _FileResume function reads the FileResumeMode OEM register and delegates to either m.FileResumeAdvanced() or m.FileResumeSimplifed() based on the configured mode.
| CommonGUIModule FileResumeAdvanced | ( | ) |
Execute the advanced file resume sequence to reposition and restart from the current G-code line.
Reads the current file name and G-code line number (incremented by 1). If no file is loaded or the line is <= 1, returns early. Checks if the mm_RunFromHereDialog register is already set and clears it if so. Updates stop status and checks manual mode. If a user FileResume script is defined, calls it. Otherwise sets the mm_RunFromHereDialog register to 1 to trigger the advanced run-from-here dialog.
| CommonGUIModule FileResumeAdvancedBtn | ( | ) |
Button handler to initiate the advanced file resume sequence.
Logs the button press via w.OperatorLog(). Sets the FileResumeIsActive OEM parameter to 1, calls w.Protected(m.FileResumeAdvanced) to execute the advanced resume sequence with error protection, then resets FileResumeIsActive to 0.
| CommonGUIModule FileResumeBtn | ( | ) |
Button handler to initiate the file resume sequence.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.FileResume() to perform the actual file resume operation.
| CommonGUIModule FileResumeSimplifed | ( | ) |
Execute the simplified file resume sequence to reposition and restart from the current G-code line.
Reads the current file name and G-code line number. If no file is loaded or the line is <= 1, returns early. Updates stop status and checks manual mode. Calls the user FileResumeSimplifed script if defined. Otherwise performs a dry run to the current line, optionally executes a tool change if the required tool differs from the current tool, prompts the operator via CycleStartDialog at each stage, repositions all enabled axes via MDI commands (XY then Z separately), restores spindle direction and coolant state, and then calls mcCntlCycleStart to resume execution.
| CommonGUIModule FileResumeSimplifedBtn | ( | ) |
Button handler to initiate the simplified file resume sequence.
Logs the button press via w.OperatorLog(). Sets the FileResumeIsActive OEM parameter to 1, calls w.Protected(m.FileResumeSimplifed) to execute the simplified resume sequence with error protection, then resets FileResumeIsActive to 0.
| UI filter | ( | search_term | ) |
Filter the commands list box to show only entries matching the search term.
If the search term is empty, restores the full Commands_List in the list box. Otherwise converts both the search term and each command name to lowercase and performs a substring match. Clears and repopulates the Commands_ListBox with matching entries. Preserves the current selection if it remains in the filtered list.
| search_term | (string) The text to search for within the command names |
Referenced by GetAllDevices().
| CommonGUIModule FindToolChangeBtn | ( | ) |
Open the Find Tool Change dialog for the currently loaded G-code file.
Logs the button press via w.OperatorLog(). Reads the currently loaded G-code file name via mc.mcCntlGetGcodeFileName(). If a file is loaded, updates the stop status and checks manual mode via m.ManualModeIsActive(). Calls the user script UserFindToolChange if defined; otherwise sets the mm_FindToolChangeDialog register to 1 to trigger the built-in dialog. If no file is loaded, logs a cancellation message.
| CommonGUIModule FloodOff | ( | ) |
Turn off the flood coolant output for the selected instance.
Runs registered hooks via m.RunHooks("FloodOff"). If hooks allow continuation, updates stop status and sets the OSIG_COOLANTON output signal to false via w.SetSignalState() for the selected instance.
| CommonGUIModule FloodOn | ( | ) |
Turn on the flood coolant output for the selected instance.
Runs registered hooks via m.RunHooks("FloodOn"). Checks the MSTLock and DryRun OEM registers; if either is active, displays a warning and skips the flood command. If neither lock is active, updates stop status and sets the OSIG_COOLANTON output signal to true via w.SetSignalState() for the selected instance.
| UI format_number | ( | number | ) |
Format a number to a fixed 4-decimal-place string.
Uses string.format with "%0.4f" to convert the provided number to a string with exactly four decimal places. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| number | (number) The numeric value to format |
Uses string.format with "%0.4f" to convert the provided number to a string with exactly four decimal places. This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| number | (number) The numeric value to format |
Referenced by tonumber(), and tostring().
| CommonGUIModule GcodeClose | ( | ) |
Close the currently loaded G-code file.
Runs registered hooks via m.RunHooks("GcodeClose"). Requires password level 1 via m.screen.CheckPassword(). If preconditions pass, closes the file via h.DoFunctionNameInst() and resets GCAdapter rotation tracking via m.screen.ResetGCRotate(). Runs the PostGcodeClose hook on completion.
| CommonGUIModule GcodeCloseBtn | ( | ) |
Button handler to close the currently loaded G-code file.
Logs the button press via w.OperatorLog() and delegates to m.GcodeClose() to perform the actual file close operation.
| CommonGUIModule GcodeEditBtn | ( | ) |
Button handler to open the currently loaded G-code file in an editor.
Logs the button press via w.OperatorLog(). Requires password level 2 via m.screen.CheckPassword(). Calls mc.mcCntlReset() to ensure Mach4 has exited any subroutines and returned to the main program before editing. Opens the editor via h.DoFunctionNameInst(). Runs the PostGcodeEdit hook on completion.
| CommonGUIModule GCodeFileRepeatCycleStart | ( | ) |
Execute a G-code file repeat cycle start sequence.
Runs the "PreGCodeFileRepeatCycleStart" hooks, then waits for the machine to reach IDLE state using w.WaitOnCondition(). Once idle, verifies the machine is not already running before calling mc.mcCntlCycleStart(). Also runs the "GCodeFileRepeatCycleStart" hooks which can cancel the cycle start by returning nil or false.
| CommonGUIModule GCodeFileRepeatOff | ( | ) |
Turn off the G-code file repeat mode.
Sets the OEM parameter 'GCodeFileRepeatActive' to 0 for the current instance. Has no effect if G-code file repeat is not enabled via the OEM parameter.
| CommonGUIModule GCodeFileRepeatOn | ( | ) |
Turn on the G-code file repeat mode.
Sets the OEM parameter 'GCodeFileRepeatActive' to 1 for the current instance. Has no effect if G-code file repeat is not enabled via the OEM parameter.
| CommonGUIModule GCodeFileRepeatToggle | ( | ) |
Toggle the G-code file repeat mode on or off.
If G-code file repeat is not enabled via the OEM parameter, does nothing. Otherwise, calls GCodeFileRepeatOff() if currently on, or GCodeFileRepeatOn() if currently off.
| CommonGUIModule GcodeLoadBtn | ( | ) |
Button handler to load a G-code file.
Logs the button press via w.OperatorLog(). Runs registered hooks via m.RunHooks("GcodeLoad"). Requires password level 1 via m.screen.CheckPassword(). If the EnableGCAdapter OEM parameter is "Yes", loads the file through the GC Adapter via m.GCACaller.AdaptFiles(); otherwise uses h.DoFunctionNameInst() to open a standard file load dialog. Resets GCAdapter rotation tracking and runs the PostGcodeLoad hook on completion.
| CommonGUIModule GcodeRecentBtn | ( | ) |
Button handler to open the Recent GCode file selector.
Logs the button press via w.OperatorLog(). If the EnableGCAdapter OEM parameter is "No", delegates to m.GcodeRecentNoCBtn() for the standard recent file dialog. Otherwise runs registered hooks via m.RunHooks("GcodeRecentConverter") and presents a custom Recent GCode dialog populated with up to 10 recently used files from the Mach4 profile (MRU1-MRU10). Provides OK and Cancel buttons and handles double-click selection. On selection, passes the chosen file through m.GCACaller.AdaptFiles() and resets GCAdapter rotation tracking. A timer monitors for Mach4 shutdown and closes the dialog if detected.
| CommonGUIModule GcodeRecentNoCBtn | ( | ) |
Button handler to open the recent G-code file list without the GC Adapter.
Logs the button press via w.OperatorLog(). Runs registered hooks via m.RunHooks("GcodeRecent"). Requires password level 1 via m.screen.CheckPassword(). Opens the standard Recent File dialog via h.DoFunctionName(). Resets GCAdapter rotation tracking via m.screen.ResetGCRotate(). Runs the PostGcodeRecent hook on completion.
| CommonGUIModule GcodeShortcut | ( | short_num | , |
| inst | ) |
Load a G-code shortcut file by index for the specified instance.
Reads up to three configured shortcut G-code file paths from OEM parameters (GCodeShorcut1, GCodeShorcut2, GCodeShorcut3). Selects the file corresponding to the provided short_num index and loads it via w.LoadGCodeFile(). Resets the GCAdapter rotation tracking via m.screen.ResetGCRotate() after loading.
| short_num | (number) The shortcut index (1, 2, or 3) selecting which configured file to load |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule GcodeShortcutBtn | ( | short_num | , |
| inst | ) |
Button handler to load a G-code shortcut file by index.
Logs the button press via w.OperatorLog() and delegates to m.GcodeShortcut() with the provided shortcut number and instance handle to perform the actual file load.
| short_num | (number) The shortcut index (1, 2, or 3) selecting which configured file to load |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule GenericGridDialog | ( | GridTable | ) |
Display a resizable modal grid dialog for viewing and editing tabular data.
Creates a wxGrid-based modal dialog populated with data from GridTable. Supports configurable column and row labels, font sizes, cell alignment, and format strings. Connects event handlers for cell changes, close button, dialog close, and a periodic timer that monitors for Mach4 shutdown. On close, returns the modified GridTable with any user edits reflected in GridTable.Data.
| GridTable | (table) Configuration and data table with keys:
|
| CommonGUIModule JobFile GetAllNotes | ( | ) |
Retrieve all notes from the job file's in-memory notes table.
Returns the entire jb.FileTable.Notes table. Returns nil and raises an error if FileTable or FileTable.Notes is nil.
| CommonGUIModule GetAndSortCutRecovery | ( | Sections | , |
| FileFilter | , | ||
| ZeroFilter | , | ||
| RotationFilter | ) |
Read and sort cut recovery position records from the Mach4 profile.
Reads cut recovery data from one or more profile sections (default: CutRecoveryCycleStop and CutRecoveryLostArc). Each record contains position, tool, unit system, line number, G-code line, filename, zero key, and rotation data. Applies optional filters: FileFilter (match current file), ZeroFilter (match current fixture zero key), and RotationFilter (match current G68 rotation). Records passing all active filters are collected and sorted in descending order by timestamp (most recent first). The returned table contains only matching, valid records.
| Sections | (table|string|nil) Profile section name(s) to read. Defaults to both CutRecoveryCycleStop and CutRecoveryLostArc |
| FileFilter | (boolean|nil) If true, only return records matching the currently loaded G-code file. Defaults to true |
| ZeroFilter | (boolean|nil) If true, only return records matching the current fixture zero key. Defaults to true if a zero key exists |
| RotationFilter | (boolean|nil) If true, only return records matching the current G68 rotation. Defaults to true |
| CommonGUIModule GetAxisLetterName | ( | AxisID | , |
| inst | ) |
Get the letter label for the specified axis, accounting for instance count and rotary configuration.
Returns a formatted axis letter string used next to axes and on homing or zero buttons. If multiple instances are active, prefixes the letter with the instance number (e.g., "0X", "1Z"). When the DefaultAxisLabels OEM parameter is "No", delegates to mc.mcAxisGetLabel() for the label. Otherwise uses default label logic: A/B/C axes return rotary or linear labels based on AXIS_IS_ROTARY_INST, and OB axes (AXIS6 and above) return "OB#" formatted strings. Calls the "GetAxisLetterName" hook first to allow user override.
| AxisID | (number) The axis index constant (e.g., mc.X_AXIS, mc.A_AXIS) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule GetAxisShortName | ( | AxisID | , |
| inst | ) |
Get the short display name for the specified axis, accounting for instance count and rotary configuration.
Returns a formatted axis name string used on longer messages describing the axes. If multiple instances are active, prefixes the name with the instance number (e.g., "0X", "1Y"). For A/B/C axes, checks AXIS_IS_ROTARY_INST to determine whether to return the rotary label (A/B/C) or linear label (U/V/W). For OB axes (AXIS6 and above), returns a formatted "OB#" string. Calls the "GetAxisShortName" hook first to allow user override of the returned name.
| AxisID | (number) The axis index constant (e.g., mc.X_AXIS, mc.A_AXIS) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule GetAxisVelocity | ( | AxisID | ) |
Get the current velocity of a single axis for the selected instance.
Reads the axis velocity via mc.mcAxisGetVel() for the selected instance. For non-rotary axes, converts from setup units to current machine units via w.ConvertUnits(). If a moving average filter is configured for the axis (AXIS_VELOCITY_AVERAGE_INST), applies the filter and returns the absolute (directionless) averaged velocity.
| AxisID | (number) The axis identifier (e.g., mc.X_AXIS, mc.Y_AXIS) |
| CommonGUIModule GetBlendedVelocity | ( | ) |
Calculate the blended (resultant) velocity across all enabled linear axes.
Reads the velocity for each enabled axis via mc.mcAxisGetVel() for the selected instance. For non-rotary axes, converts from setup units to current machine units via w.ConvertFromSetupUnits(). Computes the Euclidean (RMS) magnitude across all contributing axes. If a blended velocity moving average filter is configured (BLENDED_VELOCITY_AVERAGE_INST), applies the filter and returns the absolute averaged value.
| CommonGUIModule GetCheckPoint | ( | name | ) |
Return the module DbgCheckPoint object, creating a new one if it does not exist.
Checks if CommonGUIModule.__chk already exists and returns it if so. If the wrapper module (w) is available, creates a new DbgCheckPoint object via w.DbgCheckPoint:new() using the provided name (or 'Main GUI Module' as the default). Stores the result in CommonGUIModule.__chk for subsequent calls. Returns nil if w is not yet loaded.
| name | (string|nil) Optional name for the checkpoint object. Defaults to 'Main GUI Module' |
References name().
| CommonGUIModule GetCurrentGearRange | ( | ) |
Get the current spindle gear range from the PLC, register, or profile.
Reads the SpindleGearShifterType OEM parameter. If set to "Auto", calls user.UserGetCurrentGearRange() if defined; otherwise reads the gear range from the SpindleGearShifterRegister OEM parameter signal if mapped, or falls back to reading LastGearRange from the MachMotion profile. For non-Auto types, always reads LastGearRange from the profile. Returns 0 if the result is not a number.
| CommonGUIModule GetCurrentTool | ( | ) |
Get the current tool number from the PLC, file, or Mach4 tool changer memory.
Reads the ToolChangerMethod OEM parameter to determine how to retrieve the current tool. For "Auto" tool changers, uses CURRENT_TOOL_POCKET_NUMBER_INST to look up the tool by pocket assignment. Handles Lathe control mode, Random Memory ATC, and standard ATC differently. For "Manual" tool changers, reads the current tool from the tool change status file. Validates that the returned tool number is within range (0 to MaxTools). Returns 0 and an error if the tool number cannot be determined.
| UI GetCurrentToolSetterName | ( | ) |
Get the name of the currently active tool setter from the appropriate OEM register.
Reads the current tool setter name based on the OffsetTypes and FilterToolSetterTypes closure variables. For Fixture offset types, reads ManualSetterFixtureSelection or AutoSetterFixtureSelection. For Tool offset types, reads ManualSetterSelection or AutoSetterSelection via w.GetOEMRegValueString(). Logs errors via w.Error(). This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| CommonGUIModule GetDefaultSpindleNumber | ( | inst | ) |
Get the default spindle number for the specified Mach4 instance.
Reads the TC_DefaultSpindleNumber OEM parameter via w.eGetOEMParamValue() and returns the configured default spindle number for the instance.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| UI GetEndGoToPositionSelection | ( | ) |
Find the list index of the end GoTo position stored for the selected tool setter.
Searches UI.endgotoposition_choiceChoices for the string matching UI.tool_setters[name].EndGoToPosition. Returns the zero-based index of the matching entry, or 0 if no match is found. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule GetFeedrateOverride | ( | ) |
Get the current feedrate override percentage.
Reads the feedrate override from Mach4 via mc.mcCntlGetFRO() for the selected instance. Returns the raw value as reported by Mach4 (0-100 scale).
| CommonGUIModule JobFile GetFileName | ( | ) |
Get the file name (without path) of the currently loaded job file.
Return the file name of a path (the last item in the path, either file or directory).
Returns jb.FileName if it is non-nil, otherwise returns " " (a single space sentinel value indicating no file is loaded).
Return the file name of a path including its extension
Resolves the path to an absolute path first, then returns the last component of the path (file or directory name) with any extension intact. Delegates to the FileHelper module.
| path | (string) Full or relative path from which to extract the file name |
| CommonGUIModule JobFile GetFilePath | ( | ) |
Get the full file path of the currently loaded job file.
Returns jb.FileNamePath if it is non-nil, otherwise returns " " (a single space sentinel value indicating no file is loaded).
| CommonGUIModule JobFile GetFileVersion | ( | ) |
Read the job file version number from the CSV file header.
Reads the CSV file at jb.FileNamePath and searches each row for a key matching jb.EndOfHeader. When found, returns the corresponding value as a number (the file version). If the end-of-header marker cannot be found, logs a warning and returns 1 (version 1 default).
| CommonGUIModule GetGangSpindleCount | ( | ) |
Get the total number of configured gang spindles for the current instance.
Returns a cached value if available. Otherwise counts gang spindles by iterating from 1 upward and checking whether GangSpindleEngaged OEM parameter signals are mapped and contiguous. Stores the result in both m.__gang_spindle_count and the cache for subsequent calls.
| CommonGUIModule GetGangSpindleMaxRPM | ( | ) |
Get the maximum RPM for the gang spindle control source.
Returns a cached value if available. If the GangSpindleControlSource OEM parameter is not "Mach", reads the maximum RPM from the GangSpindleControlSourceAuxiliaryMaxRPM OEM parameter. Otherwise reads the motor maximum RPM from Mach via mc.mcSpindleGetMotorMaxRPM(). Caches and returns the result.
| UI GetGoToPositionSelection | ( | ) |
Find the list index of the start GoTo position stored for the selected tool setter.
Searches UI.gotoposition_choiceChoices for the string matching UI.tool_setters[name].GoToPosition. Returns the zero-based index of the matching entry, or 0 if no match is found. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule StackLight GetGreenStackLightState | ( | ) |
Get the desired state for the green stack light based on machine state and alarm conditions.
Calls the "UserGetGreenStackLightState" hook to allow user override. If not overridden, the green light is on when neither the red nor yellow light is active. The green light blinks (if GreenBlink is configured) when the machine is in a feed hold, macro hold, retract, or probe feed hold state, or when the machine is idle (mach_state < MC_STATE_FRUN).
| CommonGUIModule GetInhibitJoggingWhenNotHomedOverride | ( | inst | ) |
Get the current jog inhibit override state for the specified instance.
Retrieves the current value of INHIBIT_JOGGING_WHEN_NOT_HOMED_OVERRIDE_INST for the specified instance (resolved via w.GetUTI()). Returns true if the override is active (jogging allowed even when not homed), false otherwise.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule Scheduler GetItemData | ( | ) |
Retrieve the file path and quantity data for a specific item in the Schedule Editor list control.
Reads column 0 (file path) and column 1 (quantity) from the wxListCtrl (self.UI.m_listCtrl2) at the given zero-based index using wxListItem. Returns empty strings for both values if the index is out of bounds (< 0 or >= item count).
| index | (number) The zero-based index of the item to retrieve |
| CommonGUIModule GetLaserPointerOffsetVars | ( | ) |
Get the Mach4 pound variable indices used for laser pointer X and Y offsets.
Reads the LaserPointerOffsetType OEM register string. If the value is "Work Shift Offsets", returns mc.SV_WORK_SHIFT_X and mc.SV_WORK_SHIFT_Y. Otherwise defaults to mc.SV_HEAD_SHIFT_X and mc.SV_HEAD_SHIFT_Y. Logs an error via w.FunctionError() if the register read fails.
| CommonGUIModule Scheduler GetLastSchedule | ( | ) |
Load the schedule table with file data from the OEM register for a given instance.
Clears the in-memory schedule via self:ClearSchedule() (with leave_reg=true to preserve the register), then reads the serialized schedule string from the OEM parameter identified by self.FILE_REG. Splits the string by "/" to get individual file entries, then splits each entry by "|" to extract the path and quantity fields. Rebuilds the in-memory schedule table from the parsed data. Delegates the actual work to self:_GetLastSchedule() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule GetMDIHistoryFilename | ( | ) |
Get the full file path for the MDI history file.
Constructs the MDI history file path using the Mach4 installation directory and the current profile name. The file is located at: MACH_DIRECTORY/Profiles/MACH_PROFILE_NAME/MDIHistory.txt
| CommonGUIModule JobFile GetNote | ( | ) |
Retrieve a specific note line from the job file's in-memory notes table.
Looks up jb.FileTable.Notes[tostring(_lineno)] and returns its value. Returns an empty string and raises an error if FileTable or FileTable.Notes is nil.
| _lineno | (number) The 1-based line number of the note to retrieve |
| CommonGUIModule JobFile GetNotesCount | ( | ) |
Get the number of notes stored in the job file's in-memory notes table.
Calls jb:GetTableRecordCount() on jb.FileTable.Notes to count all entries. Returns "0" (as a string from w.Error) and raises an error if FileTable or FileTable.Notes is nil.
| CommonGUIModule GetPositionDisplayUnlocked | ( | ) |
Delegate to get whether the position display is unlocked.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.GetPositionDisplayUnlocked(). Use CommonGUIModule.screen.GetPositionDisplayUnlocked() in new code.
| CommonGUIModule JobFile GetPoundVarTable | ( | ) |
Retrieve the complete pound variable table from the job file's in-memory data.
Returns jb.FileTable.PoundVars directly. Raises an error via w.Error() if FileTable or FileTable.PoundVars is nil.
| CommonGUIModule JobFile GetPoundVarValue | ( | ) |
Retrieve a pound variable value from the job file's in-memory pound variable table.
Converts _poundvar to a string key and delegates to jb:_GetPoundVarValue(). The internal implementation looks up jb.FileTable.PoundVars[tostring(_poundvar)]. Returns nil and logs a warning if the pound variable is not found in the table. Raises an error if FileTable or FileTable.PoundVars is nil.
| _poundvar | (number|string) The pound variable number to look up |
| UI GetRawLuaString | ( | ) |
Return the raw, unmodified Lua text as typed by the user in the editor.
Calls UI._GetEditorText() which safely handles both wxTextCtrl and wxStyledTextCtrl editor controls. Returns an empty string if neither control is available.
| CommonGUIModule StackLight GetRedStackLightState | ( | ) |
Get the desired state for the red stack light based on alarm and machine enable conditions.
Calls the "UserGetRedStackLightState" hook to allow user override. If not overridden, the red light is on when a GMS alarm is present or the machine is disabled (MACH_ENABLED_INST[self._inst] == false). Blink behavior is enabled when RedBlink is configured and an alarm is active. Always sets light_cntl.active to true.
| CommonGUIModule JobFile GetRegisterValue | ( | ) |
Retrieve a register value from the job file's in-memory register table.
Looks up _register in jb.FileTable.Registers and returns its stored value. Returns "0" and raises an error if FileTable or FileTable.Registers is nil. Returns an empty string and logs a warning if the register key is not found.
| _register | (string) The register key in "Device/RegisterName" format |
| CommonGUIModule GetRemainingDwellTime | ( | inst | ) |
Get the remaining dwell time for the current dwell operation.
Reads the dwell target time via m.GetTargetDwellTime() and the current elapsed dwell time via mc.mcCntlGetValue() using mc.VAL_DWELL_TIME_CURRENT. Returns the difference (target - current). Returns 0 if either read fails.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule Scheduler GetSchedFiles | ( | ) |
Read all file entries from the Schedule Editor list control into a formatted table.
Iterates over all items in the wxListCtrl (self.UI.m_listCtrl2) using GetItemCount() and retrieves each item's path and quantity via self:GetItemData(). Returns the collected entries as an array of tables, each with fields 'path' and 'qty'.
| CommonGUIModule Scheduler GetSchedule | ( | ) |
Get the in-memory schedule table for a given instance.
Returns self.scheduled_files[_inst] where _inst is resolved via w.GetUTI(inst). This is the authoritative in-memory representation of the schedule for the given instance. Delegates the actual work to self:_GetSchedule() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule Scheduler GetSelectedItem | ( | ) |
Get the item data for the currently selected item in the Schedule Editor list control.
Retrieves the zero-based index of the currently selected item via GetNextItem() with wxLIST_STATE_SELECTED, then delegates to self:GetItemData() to retrieve the item's index, file path, and quantity.
| CommonGUIModule GetSelectedSpindleNumber | ( | inst | ) |
Get the currently selected spindle number for the specified Mach4 instance.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| UI GetSelectedToolSetter | ( | ) |
Get the name of the currently selected tool setter from the setter_list listbox.
If the setter_list UI element is not nil, returns the string selection from it via UI.setter_list:GetStringSelection(). Returns an empty string if the list is nil. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
If the setter_list UI element is not nil, returns the string selection from it via UI.setter_list:GetStringSelection(). Returns an empty string if the list is nil. This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| UI GetSelectedToolSetterIndex | ( | ) |
Get the zero-based index of the currently selected item in the setter_list listbox.
Returns the current selection index from the setter_list UI element via UI.setter_list:GetSelection(). This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
Returns the current selection index from the setter_list UI element via UI.setter_list:GetSelection(). This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| CommonGUIModule GetSpindleBrakeOutputSignalId | ( | ) |
Get the signal ID for the spindle brake output, or -1 if not enabled.
Reads the SpindleBrakeEnabled OEM parameter. If enabled ("Yes"), retrieves the IO signal object for SpindleBrakeOutput via w.GetOEMParamIOSigObject() and returns its sigid. If the spindle brake is not enabled, returns -1.
| CommonGUIModule GetSpindleOverride | ( | ) |
Get the current spindle override percentage.
Reads the spindle override from Mach4 via mc.mcSpindleGetOverride() for the selected instance. Converts from Mach4's internal representation to a 0-100 percentage scale by multiplying by 100.
| CommonGUIModule JobFile GetTableRecordCount | ( | ) |
Count the number of key-value pairs in a table.
Iterates over all keys in the provided table using pairs() and increments a counter for each entry. Works for both array-style and hash-style tables.
| _table | (table) The table whose entries are to be counted |
| CommonGUIModule GetTargetDwellTime | ( | inst | ) |
Get the target dwell time for the current dwell operation.
Reads the dwell target time via mc.mcCntlGetValue() using mc.VAL_DWELL_TIME_TARGET on axis 0. Returns 0 if the read fails.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule Scheduler GetTopFile | ( | ) |
Return the file path of the first (top) entry in the schedule for a given instance.
Reads self:GetSchedule(inst)[1].path if the schedule is non-empty. Returns an empty string if the schedule is empty. Delegates the actual work to self:_GetTopFile() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule StackLight GetWhiteStackLightState | ( | ) |
Get the desired state for the white stack light based on machine state transitions.
Calls the "UserGetWhiteStackLightState" hook to allow user override. If not overridden, activates the white light (light_cntl.active = true) only when the machine transitions away from MC_STATE_IDLE (i.e., OLD_MACH_STATE_INST was IDLE and current mach_state is not IDLE). State and blink are always set to false. Returns a light control table.
| CommonGUIModule StackLight GetYellowStackLightState | ( | ) |
Get the desired state for the yellow stack light based on warning conditions and machine state.
Calls the "UserGetYellowStackLightState" hook to allow user override. If not overridden, the yellow light is active when a GMS warning is present and the red light is not already on. The warning flag is also forced true when the machine is in a macro hold or macro hold jog state (MC_STATE_FRUN_MACROH, MC_STATE_FRUN_MACROH_JOG, MC_STATE_MRUN_MACROH, MC_STATE_MRUN_MACROH_JOG). Blink behavior is controlled by the YellowBlink OEM parameter.
| CommonGUIModule GoToLastLostCut | ( | ) |
Move to the position of the most recent lost cut or cycle stop event.
Retrieves the sorted list of cut recovery positions via CommonGUIModule.GetAndSortCutRecovery(). If a recovery position exists, adjusts the X and Y positions to account for any difference between the tool active when the cut was lost and the current tool (using tool offset and wear data). Converts the stored positions to the unit system that was active when the positions were captured, then delegates to CommonGUIModule.GoToLine() to perform a dry run and reposition. If no recovery position exists, goes to the current G-code line number via GoToLine().
| CommonGUIModule GoToLine | ( | LineNumber | , |
| IsMachineCoords | , | ||
| X | , | ||
| Y | , | ||
| Z | , | ||
| A | , | ||
| B | , | ||
| C | , | ||
| Tag | ) |
Move the machine to a specified G-code line number using a dry run.
--------------------— GoToLine -----------------------------------—
Performs a dry run to the specified line number to calculate axis positions, then repositions the machine to those coordinates. If cutter compensation (G41/G42) is active, cancels it via MDI before the dry run and restores it after repositioning. If no explicit axis positions are provided, reads them from the G-code interpreter via mc.mcCntlGcodeInterpGetPos(). If the tool number at the target line differs from the current tool, commands a tool change (or displays a notice for manual tool changers). Displays PleaseWaitDialogs during the dry run calculation. An optional Tag string can be prepended to the repositioning MDI command.
| LineNumber | (number) The G-code line number to move to |
| IsMachineCoords | (boolean) If true, positions are treated as machine coordinates (G53) |
| X | (number|nil) Target X position. If nil, uses interpreter position |
| Y | (number|nil) Target Y position. If nil, uses interpreter position |
| Z | (number|nil) Target Z position. If nil, uses interpreter position |
| A | (number|nil) Target A position. If nil, uses interpreter position |
| B | (number|nil) Target B position. If nil, uses interpreter position |
| C | (number|nil) Target C position. If nil, uses interpreter position |
| Tag | (string|nil) Optional G-code string to prepend to the repositioning move command |
| CommonGUIModule GoToPositionDialogBtn | ( | ) |
Open the GoTo Positions dialog allowing the operator to select and move to a named position.
Guards against opening while a feed hold retract is active or the dialog is already open (GOTO_POSITION_MODE > 0). Requests a cycle start hold via w.RequestCycleStartHold(). Checks manual mode. Reads configured GoTo position names via w.GetConfiguredGoToPositionNames(); if none are configured, returns an error. Builds a radio-box dialog with all position names and a Cancel button. A timer polls for cycle start release; on confirmation, posts m.MoveToGoToPosition() to the file queue.
| CommonGUIModule SearchGCode GoToSelectedLine | ( | ) |
Navigate to the G-code line selected in the GCode Search grid.
Retrieves the array of selected rows from the grid. If at least one row is selected, reads the line number from column 0 of the first selected row and calls CommonGUIModule.GoToLine() with that line number.
| CommonGUIModule HandleMachMessages | ( | inst | , |
| msg_type | , | ||
| param1 | , | ||
| param2 | ) |
Dispatch incoming Mach4 messages to all registered callback functions.
Looks up the registered message handlers in CommonGUIModule.MachMsg["Registered"] for the given instance and message type. For MSG_REG_CHANGED and MSG_IO_CHANGED, uses param1 as a handle key to find registered callbacks. For MSG_GCODE_VAR_CHANGED and MSG_PARAMETER_CHANGED, uses param1 as the pound variable or parameter key. Invokes each matching callback via w.pcall() with the message arguments. Logs errors via w.FunctionError() if any callback raises an exception.
| inst | (number) The Mach4 instance handle |
| msg_type | (number) The Mach4 message type constant (e.g., mc.MSG_REG_CHANGED) |
| param1 | (number|string) First message parameter (register handle, IO handle, or pound var index) |
| param2 | (number|string) Second message parameter (new value or state) |
| CommonGUIModule JobFile HasEdits | ( | ) |
Check whether the current Mach4 state differs from the values stored in the job file.
Compares all pound variables in jb.RangeString against jb.FileTable.PoundVars and all registers in jb.RegTable against jb.FileTable.Registers. Returns true as soon as any discrepancy is detected (pound variable difference > 0.000001 or register string mismatch). Returns false if all values match. Raises an error if any mc.mcCntlGetPoundVar() call fails.
| CommonGUIModule JobFile HasFileLoaded | ( | ) |
Check whether a job file is currently loaded.
Returns true if jb.FileName is non-nil and not equal to the sentinel value " " (a single space), which indicates no file is loaded.
| CommonGUIModule HideMachMenu | ( | ) |
Hide the Mach4 menu bar and persist the setting to the profile.
Calls scr.ShowMenu(false) to hide the menu and writes HideMachMenu=1 to the MachMotion profile section so the setting persists across restarts.
| CommonGUIModule HomeABtn | ( | ) |
Button handler to home the A axis.
Delegates to CommonGUIModule.HomeAxis() with mc.A_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeAll | ( | confirm_homing | , |
| only_dereferenced_axes | , | ||
| inst_list | ) |
Home all axes on one or more Mach4 instances with full precondition checks and hook support.
Iterates over the provided instance list and verifies each instance is in IDLE state and enabled before proceeding. Adjusts home order for axes with absolute encoders (sets home order to 0 if already homed). Optionally presents a CycleStartDialog for operator confirmation. Runs HomeAllStart and HomeSafety hook scripts. Checks for active limit switches and home switch validity via m.CheckHomeSwitchesForHoming(). Calls the motion controller's PreHoming() method. If only_dereferenced_axes is true, builds a bitmask of unhomed axes and calls mc.mcAxisHomeAllEx(); otherwise calls mc.mcAxisHomeAll(). Calls user.UserHomeAll() if defined. After homing, calls m.AutoEnableSoftlimits(), m.WaitForHoming(), m.HomeOverrideAxes(), and the motion controller's PostHoming() method. Restores home order for absolute encoder axes and runs the HomeAllEnd hook.
| confirm_homing | (boolean|nil) If true, presents a confirmation dialog before homing. Defaults based on operator panel mode |
| only_dereferenced_axes | (boolean|nil) If true, only homes axes that are not currently homed. Defaults to false |
| inst_list | (number|table|nil) Instance or list of instances to home. If not provided, homes all instances |
| CommonGUIModule HomeAllBtn | ( | ) |
Button handler to home all axes using the configured HomeAllBtnOptions parameter.
Logs the button press via w.OperatorLog(). Reads the HomeAllBtnOptions OEM parameter string to determine the homing scope. If "Home All Instances", calls m.HomeAll() for all instances. If "Home Selected Instance", calls m.HomeAllSelectedInstance() for the selected instance only. If the parameter is invalid, raises an error via w.Error(). The confirmation flag is derived from w.PretendCommandsAreFromOperatorPanels().
| CommonGUIModule HomeAllDereferencedAxes | ( | confirm_homing | , |
| selected_inst | ) |
Home all dereferenced (unhomed) axes only, with optional confirmation.
Delegates to CommonGUIModule.HomeAll() with the only_dereferenced_axes flag set to true, passing through the confirm_homing and selected_inst parameters.
| confirm_homing | (boolean|nil) If true, presents a confirmation dialog before homing |
| selected_inst | (number|nil) The instance to home. If not provided, homes all instances |
| CommonGUIModule HomeAllSelectedInstance | ( | confirm_homing | , |
| only_dereferenced_axes | ) |
Home all axes on the currently selected Mach4 instance with optional confirmation.
Logs the button press via w.OperatorLog(). Retrieves the currently selected instance via w.GetSelectedInstance() and delegates to CommonGUIModule.HomeAll() with the selected instance, passing through the confirm_homing and only_dereferenced_axes flags.
| confirm_homing | (boolean|nil) If true, presents a confirmation dialog before homing |
| only_dereferenced_axes | (boolean|nil) If true, only homes axes that are not currently homed |
| CommonGUIModule HomeAxis | ( | AxisID | , |
| use_confirmation | ) |
Home a single axis with optional confirmation dialog and comprehensive precondition checks.
Logs the operation via w.OperatorLog() and updates stop status. Verifies the machine is in IDLE state and enabled before proceeding. If the axis has no motors mapped or has an absolute encoder and is already homed, displays a warning and returns early. If use_confirmation is not false, presents a CycleStartDialog requiring the operator to confirm. Runs HomeSafety, PreHomeAxisStart, and axis-specific hook scripts. Calls user.UserHome{Axis}() if defined; otherwise calls mc.mcAxisHome(). After homing, calls m.AutoEnableSoftlimits(), CommonGUIModule.WaitForHoming(), m.HomeOverrideAxes(), and the motion controller's PostHoming() method. Runs HomeAxisEnd and axis-specific end hook scripts on completion.
| AxisID | (number) The axis identifier to home (e.g., mc.X_AXIS, mc.Z_AXIS, mc.AXIS6) |
| use_confirmation | (boolean|nil) If false, skips the cycle start confirmation dialog. Defaults to true |
| CommonGUIModule HomeBBtn | ( | ) |
Button handler to home the B axis.
Delegates to CommonGUIModule.HomeAxis() with mc.B_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeCBtn | ( | ) |
Button handler to home the C axis.
Delegates to CommonGUIModule.HomeAxis() with mc.C_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB1Btn | ( | ) |
Button handler to home the OB1 (AXIS6) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS6 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB2Btn | ( | ) |
Button handler to home the OB2 (AXIS7) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS7 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB3Btn | ( | ) |
Button handler to home the OB3 (AXIS8) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS8 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB4Btn | ( | ) |
Button handler to home the OB4 (AXIS9) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS9 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB5Btn | ( | ) |
Button handler to home the OB5 (AXIS10) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS10 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOB6Btn | ( | ) |
Button handler to home the OB6 (AXIS11) axis.
Delegates to CommonGUIModule.HomeAxis() with mc.AXIS11 and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeOverrideAxes | ( | main_axis | , |
| inst | ) |
Home override (OB/secondary) axes associated with the specified primary axis.
Reads all configured operator panel profile sections via w.GetConfiguredOperatorPanels(). For each panel, looks up the secondary axis mapping for the given main_axis via mc.mcProfileGetInt(). If main_axis is -1, iterates all primary axes (X through C) and homes any mapped OB axes (AXIS6 through AXIS11) that are enabled, skipping duplicates. If main_axis is a specific axis, homes only its mapped OB axis. Calls m.HomeAxis() for each identified secondary axis with use_confirmation set to false.
| main_axis | (number) The primary axis whose secondary OB axis should be homed, or -1 to home all secondary axes |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule HomeXBtn | ( | ) |
Button handler to home the X axis.
Delegates to CommonGUIModule.HomeAxis() with mc.X_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeYBtn | ( | ) |
Button handler to home the Y axis.
Delegates to CommonGUIModule.HomeAxis() with mc.Y_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule HomeZBtn | ( | ) |
Button handler to home the Z axis.
Delegates to CommonGUIModule.HomeAxis() with mc.Z_AXIS and a confirmation flag based on whether commands are being pretended to come from operator panels.
| CommonGUIModule IncludeCommentsInMessages | ( | on_off | ) |
Enable or disable inclusion of G-code comments in message output.
Writes a 1 to the Preferences/CommentsInMessages profile key if on_off is true, or a 0 if on_off is false, via mc.mcProfileWriteInt(). This setting controls whether parenthetical G-code comments are shown in the operator message area during program execution.
| on_off | (boolean) True to include comments in messages, false to suppress them |
| CommonGUIModule InhibitJoggingWhenNotHomed | ( | ) |
Update jogging inhibit state for all instances based on homing status.
Only active when the InhibitJoggingWhenNotHomed OEM parameter is "Yes". For each instance, checks the jog inhibit override via CommonGUIModule.GetInhibitJoggingWhenNotHomedOverride() and verifies all axes are homed via w.VerifyAllAxesAreHomedCached(). If any axis is unhomed and the override is not active, inhibits jogging on all axes via w.InhibitJogOnAllAxes() and sets the INHIBIT_JOGGING_WHEN_NOT_HOMED_INST flag. If all axes are homed or the override is active, releases the inhibit via w.ReleaseInhibitJogOnAllAxes() and clears the flag.
| CommonGUIModule InhibitJoggingWhenNotHomedOverrideToggle | ( | inst | ) |
Toggle the jog inhibit override state for the specified instance.
Reads the current override state via CommonGUIModule.GetInhibitJoggingWhenNotHomedOverride() and sets it to the opposite value via CommonGUIModule.SetInhibitJoggingWhenNotHomedOverride().
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| UI Initialize | ( | ) |
Populate the tool setter list and pre-select the currently configured setter.
Populate the tool setter selection list and pre-select the currently active setter.
Retrieves all configured tool setters via w.GetAllToolSetters() and appends each setter name to the setter_list listbox. Sets the list selection to the last item and calls UI.OnToolSetterListSelected() to populate the detail fields for the selected setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
Retrieves the current tool setter name via UI.GetCurrentToolSetterName(). Loads either all manual or all auto tool setters (depending on FilterToolSetterTypes) via w.GetAllManualToolSetters() or w.GetAllAutoToolSetters(). Appends each setter name to the setter_list listbox, tracking which entry matches the current setter name. Sets the list selection to the matching entry and calls UI.OnToolSetterListSelected() to sync the register. This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| CommonGUIModule SearchGCode Initialize | ( | inst | ) |
Initialize the GCode Search object, read the loaded file, and open the search dialog.
Clears the internal gcode_tbl, calls ReadLoadedFile() to populate it from the specified file, then calls CreateSearchDialog() to display the search UI.
| file_name | (string) The full path to the G-code file to search |
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule InitializeAllModules | ( | ) |
Initialize all hardware interface module objects for all Mach4 instances.
Performs the following initialization steps for each Mach4 instance:
| CommonGUIModule InitializeEnabledAxes | ( | GCodeParameterNumber | ) |
Write the enabled axis configuration to a G-code parameter bit field.
Iterates over all axes from mc.X_AXIS to mc.MC_MAX_AXES - 1. For each axis, reads the AXIS_ENABLED_INST table for the selected instance and sets the corresponding bit in the specified G-code parameter number to 1 (enabled) or 0 (disabled) via w.SetParameterBit().
| GCodeParameterNumber | (number) The G-code pound variable number to store the bit field in |
| CommonGUIModule SearchGCode InitializeGrid | ( | ) |
Set default settings and column labels for the GCode Search grid.
Sets the default cell alignment to center, assigns column labels ("Line Number" and "GCode Line"), and marks both cells in the first row as read-only.
| CommonGUIModule InitializeMachMenu | ( | ) |
Initialize the Mach4 menu bar visibility based on the saved profile setting.
Reads the 'HideMachMenu' profile key from the MachMotion section. If the value is 0, shows the menu; otherwise hides it.
| CommonGUIModule InitializeRotaryAxesFeedrateMode | ( | ) |
Initialize the feedrate mode for all configured rotary axes from OEM parameters.
Iterates over the rotary axis range (A through C) for the selected instance. For each axis that is configured as rotary (AXIS_IS_ROTARY_INST), reads the corresponding Axis{N}RotaryFeedrateMode OEM parameter string. Sets the feedrate mode to 1 if the parameter equals "Constant Surface Speed", or 0 otherwise, via m.SetRotaryAxisFeedrateMode().
| CommonGUIModule InitializeSelectedSpindle | ( | inst | ) |
Initialize the selected spindle to the configured default spindle number.
Reads the default spindle number via m.GetDefaultSpindleNumber() and sets it as the selected spindle via m.SetSelectedSpindleNumber(). Called during screen initialization to ensure the spindle selection starts at the configured default.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule InitializeSpindleRanges | ( | ) |
Initialize the spindle gear range for all Mach4 instances from the PLC or profile.
Saves the current instance via w.StoreInstance(). Iterates over all instances and for each calls m.GetCurrentGearRange() to read the gear range from the PLC or profile. If the range is valid, sets it via mc.mcSpindleSetRange(). Restores the original instance via w.RestoreInstance() after completion.
| CommonGUIModule InitializeToolPathZoomLimits | ( | ) |
Initialize the tool path zoom limits from OEM parameters.
Reads the 'ToolPathZoomLimitMax' and 'ToolPathZoomLimitMin' OEM parameter values and applies them to the Mach4 controller via mc.mcCntlSetValue() using the VAL_ZOOM_MIN and VAL_ZOOM_MAX value types on the X axis.
| CommonGUIModule InitializeTools | ( | ) |
Initialize tool and pocket tracking for all Mach4 instances on startup.
Iterates over all instances. For each idle instance, reads the current tool pocket via w.GetCurrentToolPocket() and calls w.SetCurrentToolPocket() to update the pocket register. Reads the current tool via m.GetCurrentTool() and, if valid, calls w.SetCurrentTool() to set the active tool. Updates the Mach4 pound variables SV_CUR_TOOL_NUMBER and SV_CUR_LENGTH_INDEX to reflect the current tool. Saves and restores the active instance via w.StoreInstance() and w.RestoreInstance().
| CommonGUIModule InitializeWorkLight | ( | ) |
Initialize the work light feature and restore its previous on/off state.
Checks if the work light feature is enabled via m.IsWorkLightEnabled(). If enabled, adds the WorkLightOutput signal to the ignore lists for disable, stop, and emergency stop events via w.AddOEMParamSignalToOutputIgnoreList(). Reads the WorkLightWasOn OEM parameter; if it equals 1, calls m.WorkLightOn() to restore the light to its previous on state.
| CommonGUIModule Scheduler InsertFiles | ( | ) |
Insert an array of file entries into the Schedule Editor list control.
Iterates over the provided files table and appends each entry to the wxListCtrl (self.UI.m_listCtrl2). If an entry has a 'path' field, inserts it with its 'qty' value in column 1; otherwise treats the entry itself as a plain file path string and sets quantity to "1". Does nothing if files is nil.
| files | (table) Array of file entries; each entry is either a plain file path string or a table with fields 'path' (string) and 'qty' (string|number) |
| CommonGUIModule InstallerUpdateModule | ( | ) |
Run the installer update module script if the MachMotion build number has changed.
Compares the LastRunMachMotionBuild value stored in the profile against the current revision from w.GetVersionInfo("revision"). If the stored build is less than the current revision and InstallerUpdateModule.mcs exists, loads and runs the module's RunUpdateModule() function. If the build matches and the file exists, deletes the update script. Always updates the LastRunBuild value in the profile to the current revision.
| CommonGUIModule IsAxisHomed | ( | AxisID | , |
| IgnoreSaftyCheck | , | ||
| inst | ) |
Check whether a specific axis is homed - delegates to the wrapper module implementation.
This function was moved to the wrapper module. Calls w.IsAxisHomed() with all provided arguments and returns the result.
| AxisID | (number) The axis identifier to check (e.g., mc.X_AXIS) |
| IgnoreSaftyCheck | (boolean|nil) If true, skips the safety interlock check |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsAxisHoming | ( | AxisID | ) |
Check whether a specific axis is currently in the process of homing.
Calls mc.mcAxisIsHoming() for the current instance and the specified axis ID. If the API call returns an error code, returns nil, false, and an error message. Otherwise returns true if the axis is homing (rc == 1), false if not.
| AxisID | (number) The axis identifier to check (e.g., mc.X_AXIS) |
| CommonGUIModule IsAxisJogging | ( | Axis | ) |
Check whether the specified axis is currently jogging.
| Axis | (number) The axis index to check (0-based, e.g., mc.X_AXIS) |
| CommonGUIModule IsAxisRotary | ( | AxisID | , |
| inst | ) |
Check whether a specified axis is configured as a rotary axis.
Runs registered hooks via m.RunHooks("IsAxisRotary", AxisID, inst). If hooks return false for the continue flag (a == false), returns the hook-provided rotary value directly. Otherwise delegates to w.IsAxisRotary() for the standard rotary axis check. Results are also cached in the AXIS_IS_ROTARY global array.
| AxisID | (number) The axis identifier to check (e.g., mc.X_AXIS, mc.A_AXIS) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsCannedReciprocatingAxisRunning | ( | axis_id | ) |
Check whether a canned reciprocating axis cycle is currently running.
| axis_id | (number) The axis identifier for the reciprocating axis to query |
| CommonGUIModule IsCapturingToolPathMousePositions | ( | ) |
Check whether the tool path panel is currently capturing mouse positions.
Iterates over all tool path panel names in TP_PANEL_NAMES (initializing the list via m.screen.GetToolPathPanelNames() if not already set). For each panel, reads the "MouseCapture Mode" property via h.GetObject(). Returns true as soon as any panel is found with capture mode set to "1". Returns false if no panels are capturing.
| CommonGUIModule IsCurrentTool | ( | toolIndex | , |
| inst | ) |
Check whether the specified tool index matches the currently loaded tool.
| toolIndex | (number) The tool number to compare against the current tool |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule IsCutterCompensationType_A | ( | ) |
Check whether cutter compensation type A is currently enabled.
Reads the PV_CCT_BIT_SUP bit (bit 0) from the PV_CCT parameter (5003) via w.GetParameterBitCached(). Returns true if the bit value is 0 (type A enabled), false otherwise. Initializes PV_CCT_BIT_SUP and PV_CCT to their default values if they are nil.
| CommonGUIModule IsCutterCompensationType_B | ( | ) |
Check whether cutter compensation type B is currently enabled.
Reads the PV_CCT_BIT_SUP bit (bit 0) from the PV_CCT parameter (5003) via w.GetParameterBitCached(). Returns true if the bit value is 1 (type B enabled), false otherwise. Initializes PV_CCT_BIT_SUP and PV_CCT to their default values if they are nil.
| CommonGUIModule IsCutterCompensationType_C | ( | ) |
Check whether cutter compensation type C is currently enabled.
Reads the PV_CCT_BIT_SUV bit (bit 1) from the PV_CCT parameter (5003) via w.GetParameterBitCached(). Returns true if the bit value is 1 (type C enabled), false otherwise. Initializes PV_CCT_BIT_SUV and PV_CCT to their default values if they are nil.
| CommonGUIModule IsDoorInterlockActive | ( | ) |
Check whether the door interlock is currently active.
Reads the DoorSwitchInterlockEnabled OEM parameter. If the interlock is not enabled, returns false immediately. If enabled, reads the DoorSwitchInterlockActive OEM register and returns true if its value equals 1, false otherwise.
| CommonGUIModule IsDryRunOn | ( | ) |
Check whether dry run mode is currently active for the selected instance.
Reads the DryRun OEM parameter string via w.eGetOEMParamValueString() for the selected instance. Returns true if the value equals "Yes", false otherwise.
| CommonGUIModule IsFeedHoldRetract | ( | ) |
Check whether the feed hold retract output signal is currently active.
Reads the OSIG_RETRACT output signal state via w.GetSignalState() for the current instance. Returns true if the retract signal is active, false otherwise.
| CommonGUIModule IsFileResumeActive | ( | ) |
Check whether a file resume or run-from-here operation is currently active.
Reads the mm_RunFromHereDialog register via w.GetRegValue() and the FileResumeIsActive OEM parameter via w.eGetOEMParamValue(). Returns true if either value is non-zero, indicating that a file resume or run-from-here dialog is currently in progress.
| CommonGUIModule IsFixtureOffset | ( | fixture | ) |
Check whether the specified fixture offset index is currently active.
Compares the provided fixture index against the ACTIVE_FIXTURE_OFFSET_INDEX_INST global for the currently selected instance. Returns true if they match, false otherwise.
| fixture | (number) The fixture offset index to compare against the active fixture |
| CommonGUIModule IsFloodOn | ( | ) |
Check whether the flood coolant output is currently active.
Reads the OSIG_COOLANTON output signal state via w.GetSignalState() for the selected instance. Returns true if flood coolant is on, false otherwise.
| CommonGUIModule IsGangSpindleControlSourceCommandTypeRPM | ( | ) |
Check whether the gang spindle control source command type is RPM.
Returns a cached value if available. Otherwise reads the GangSpindleControlSourceCommandType OEM parameter string. Returns true if the value equals "RPM", false otherwise. Caches the result for subsequent calls via w.SetCache().
| CommonGUIModule IsGangSpindleEnabled | ( | ) |
Check whether the gang spindle feature is enabled.
Returns a cached value if available. Otherwise reads the GangSpindleEnabled OEM parameter string. Returns true if the value equals "Yes", false otherwise. Logs errors via w.Error() if the parameter cannot be read. Caches the result via w.SetCache() for subsequent calls.
| CommonGUIModule IsGangSpindleEngaged | ( | idx | ) |
Check whether a specific gang spindle index is currently engaged.
Checks if the GangSpindleEngaged OEM parameter signal is mapped for the given index. If mapped, reads and returns the signal state via w.GetOEMParamSig(). If not mapped, returns true (assuming the spindle is always engaged when no engagement signal is configured).
| idx | (number) The 1-based gang spindle index to check |
| CommonGUIModule IsGangSpindleInGroup | ( | idx | ) |
Check whether a gang spindle at the given index is part of an active group.
Returns a cached result if available. Otherwise checks whether any of the three OEM parameter signals (GangSpindleCommandRPMRegister, GangSpindleForwardSig, GangSpindleReverseSig) are mapped for the given index. If in a group, also checks whether the spindle is currently engaged via m.IsGangSpindleEngaged(). Caches the in-group result for subsequent calls.
| idx | (number) The 1-based gang spindle index to check |
| CommonGUIModule IsGCodeFileRepeatEnabled | ( | ) |
Check whether the G-code file repeat feature is enabled in OEM parameters.
Reads the OEM parameter 'GCodeFileRepeatEnabled' for the current instance. Result is cached using w.SetCache() so subsequent calls avoid re-reading the parameter.
| CommonGUIModule IsGCodeFileRepeatOn | ( | ) |
Check whether the G-code file repeat mode is currently active.
Reads the OEM parameter 'GCodeFileRepeatActive' for the current instance and returns true if it equals 1. Returns false immediately if G-code file repeat is not enabled.
| CommonGUIModule IsHomeSwitchActive | ( | homing_axis | , |
| inst | ) |
Check whether any home switch (or a specific axis home switch) is currently active.
Thin wrapper that delegates directly to w.IsHomeSwitchActive(). Returns the same values as the underlying wrapper function.
| homing_axis | (number|nil) The axis index to check, or nil to check all axes |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsJogModeContinuous | ( | ) |
Check whether the current jog mode is continuous.
| CommonGUIModule IsJogModeIncremental | ( | ) |
Check whether the current jog mode is incremental.
| CommonGUIModule IsLaserPointerOn | ( | ) |
Check whether the laser pointer output signal is currently active.
If the LaserPointerOutput OEM parameter signal is mapped, reads its current state via w.GetOEMParamSig(). Returns false if the signal is not mapped or if it is inactive.
| CommonGUIModule IsLimitSwitchActive | ( | inst | ) |
Check whether any limit switch is currently active.
Thin wrapper that delegates directly to w.IsLimitSwitchActive(). Returns the same value as the underlying wrapper function.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsM00Active | ( | inst | ) |
Check whether a program stop (M00) is currently active at the current G-code line.
Reads the current G-code line number via mc.mcCntlGetGcodeLineNbr(). If m.M00LineNumber is nil or the current line has not advanced past the M00 line, returns false. Otherwise reads the OptionalStopActive OEM register and returns true if its value equals 1.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsMachEnabled | ( | inst | ) |
Check whether the machine is currently enabled and update global enable state variables.
For each Mach4 instance, reads the OSIG_MACHINE_ENABLED output signal state via w.GetSignalState() and stores the result in MACH_ENABLED_INST. Also updates the MACH_ENABLED global with the state of instance 0. Returns the enabled state for the resolved instance index.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsMistOn | ( | ) |
Check whether the mist coolant output is currently active.
Reads the OSIG_MISTON output signal state via w.GetSignalState() for the current instance. Returns true if mist coolant is on, false otherwise.
| CommonGUIModule IsMotionInhibitActive | ( | ) |
Check whether the motion inhibit signal is currently active.
First checks if the motion inhibit feature is enabled via m.IsMotionInhibitEnabled(). If enabled, reads the ISIG_MOTION_INHIBIT signal state via w.GetSignalState() and returns it. If the feature is not enabled, returns false.
| CommonGUIModule IsMotionInhibitEnabled | ( | ) |
Check whether the motion inhibit interlock feature is configured and enabled.
Reads the MotionInhibitInterlockEnabled OEM parameter string via w.GetOEMParamValueString(). Returns true only if the parameter equals "Yes" AND the MotionInhibitInterlockInput OEM parameter signal is mapped via w.IsOEMParamSigMapped().
| CommonGUIModule IsMSTAndDryRunActive | ( | ) |
Check whether MST lock or dry run is active and prompt the operator to confirm cycle start.
Reads the ConfirmationDialogs OEM parameter. If the current G-code line number is >= 1 and single block is on, returns true immediately (allows continuation). Otherwise, if ConfirmationDialogs is "Yes", reads the MSTLock and DryRun OEM registers. If either is active, builds a warning message string and presents a CycleStartDialog asking the operator to confirm. Returns the operator's response as the continue flag.
| CommonGUIModule IsMSTLockOn | ( | ) |
Check whether the M-S-T lock is currently active for the selected instance.
Reads the MSTLock OEM register string via w.GetOEMRegValueString() for the selected instance. Returns true if the value equals "Yes", false otherwise.
| CommonGUIModule IsOptionalStopOn | ( | ) |
Check whether the optional stop (M1) feature is currently enabled.
Reads the optional stop state via mc.mcCntlGetOptionalStop() for the current instance. Returns true if the value equals 1 (enabled), false otherwise.
| CommonGUIModule IsPartCounterQuotaReached | ( | ) |
Check whether the required part counter quota has been reached.
Reads the current parts-produced count via w.GetParameter(mc.PV_PRTSA) and the required parts count via w.GetParameter(mc.PV_PRTSN). If the required count is greater than zero and the current count is greater than or equal to the required count, returns true.
| CommonGUIModule _LuaProfiling IsProfiling | ( | ) |
Check whether the Lua profiler is currently active.
| CommonGUIModule IsRotaryAxisFeedrateModeConstantSurfaceSpeed | ( | axis_id | ) |
Check whether a rotary axis feedrate mode is set to Constant Surface Speed.
Reads the VAL_AXIS_VALTYPE value for the specified axis via mc.mcCntlGetValue() for the selected instance. Returns true if the value equals 1 (Constant Surface Speed mode), false otherwise.
| axis_id | (number) The axis identifier to check (typically mc.A_AXIS through mc.C_AXIS) |
| CommonGUIModule IsSafetyRelayCleared | ( | ) |
Check whether the safety relay circuit is currently in the cleared (OK) state.
If the SafetyRelayOKInput OEM parameter signal is mapped via w.IsOEMParamSigMapped(), reads its current state via w.GetOEMParamSig() and returns it. If the signal is not mapped, returns true (assumes cleared by default).
| CommonGUIModule IsSchedulerActive | ( | inst | ) |
Check whether the file scheduler is currently active.
Reads the OEM parameter register identified by CommonGUIModule.Scheduler.SCHED_STATE for the given instance. Returns true if the value equals 1, false otherwise.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule IsSelectedSpindleNumber | ( | inst | , |
| spindle | ) |
Check whether the specified spindle number is currently selected for the given instance.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| spindle | (number) The spindle number to compare against the currently selected spindle |
| CommonGUIModule IsSingleBlockOn | ( | inst | ) |
Check whether single block mode is currently active for the specified instance.
Reads the OSIG_SINGLE_BLOCK output signal state via w.GetSignalState() for the specified instance. Returns true if single block is active, false otherwise.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule IsSpindleOn | ( | inst | ) |
Check whether the spindle is currently running in any direction.
Reads the spindle direction via mc.mcSpindleGetDirection() for the selected instance. Returns true if the spindle direction is non-zero (i.e., forward or reverse), false if stopped.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule IsSpindleOriented | ( | ) |
Check whether the spindle is currently in the oriented position.
Reads the SpindleOrientCurrentState OEM register via w.GetOEMRegValue(). Returns true if the value equals 1, false otherwise.
| CommonGUIModule IsSpindleOrientedBtn | ( | ) |
Get the spindle orient state for use by a button indicator, including blink behavior.
Reads the SpindleOrientCurrentState OEM register. Returns true if the state is 1 (fully oriented), the value of BLINK_OBJECT_ACTIVE if the state is 2 (orienting in progress), or false if the state is any other value.
| CommonGUIModule IsSpindleWarmUpNeeded | ( | ) |
Check whether a spindle warm-up is currently needed.
Reads the SpindleWarmUpEnabled OEM parameter string from the cache via w.eGetOEMParamValueStringCached(). Returns true if the SpindleWarmUpNeeded OEM parameter equals 1 and the SpindleWarmUpEnabled parameter equals "Yes", false otherwise.
| CommonGUIModule IsStepIntoSubPrograms | ( | ) |
Check whether step-into sub-programs mode is currently active.
Reads the PV_CM1_SMB_BIT bit from the PV_CM1 Mach4 parameter via w.GetParameterBitCached(). Returns true if the bit value is 1 (step-into enabled), false otherwise.
| CommonGUIModule IsSubSpindleEnabled | ( | inst | ) |
Check whether the sub-spindle feature is enabled for the specified instance.
Uses the object cache (w.IsCached / w.GetCache / w.SetCache) keyed by "IsSubSpindleEnabled" and the untagged instance index to avoid repeated OEM register reads. On a cache miss, reads the SubSpindleEnabled OEM register string for the given instance and returns true if the value is "Yes".
| inst | (number) The Mach4 instance handle. If not provided, uses the selected instance |
| CommonGUIModule IsSubSpindleOn | ( | ) |
Check whether the sub-spindle is currently running in either direction.
If the sub-spindle is not enabled for the selected instance, returns false immediately. Otherwise reads the SubSpindleCW and SubSpindleCCW OEM parameter signals. Returns true if either signal is active, false if both are inactive.
| CommonGUIModule IsToolSizeEntryDiameterMode | ( | mode | ) |
Check if the tool size entry mode is configured for diameter mode.
Reads the ToolSizeEntryMode OEM parameter and returns true if the value is "diameter" (case-insensitive). If the parameter cannot be read, returns true as diameter is the default mode.
| mode | (string|nil) Unused parameter, accepted for compatibility |
| CommonGUIModule IsWorkLightEnabled | ( | ) |
Check whether the work light output signal is mapped and the feature is enabled.
Checks if the WorkLightOutput OEM parameter signal is mapped via w.IsOEMParamSigMapped(). Returns true if the signal is mapped (indicating the work light feature is configured), false otherwise.
| CommonGUIModule IsWorkLightOn | ( | ) |
Check whether the work light output signal is currently active.
First checks if the work light feature is enabled via m.IsWorkLightEnabled(). If enabled, reads the WorkLightOutput OEM parameter signal state via w.GetOEMParamSig() and returns it. If the feature is not enabled, returns false.
| CommonGUIModule JogOffHomeSwitchDialog | ( | homing_axis | , |
| inst | ) |
Display a modal dialog allowing the operator to jog an axis off its home switch.
Validates the homing_axis parameter (clamped to valid axis range). Checks whether any home switch is active via m.IsHomeSwitchActive(). If DIALOG_IS_OPEN[4] is already true, returns an error to prevent duplicate dialogs. Creates a dialog with Jog+/Jog- buttons, a jog rate slider, a limit override button, and an OK button. A timer (100ms) monitors the home switch state, updates button colors, and enables/disables controls based on switch activity. The dialog closes when all switches are inactive and the operator presses OK.
| homing_axis | (number|nil) The axis index to monitor, or nil to monitor all axes |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule JogToolMagazineToNearestPocket | ( | pocket_increment | , |
| spindle | , | ||
| inst | ) |
Move the tool magazine to the nearest pocket, optionally advancing by one pocket increment.
Guards against re-entrant calls using the JogToolMagazineActive flag. Calls m._JogToolMagazineToNearestPocket() via w.pcall() for error protection. Resets JogToolMagazineActive to false after completion. If the protected call fails, logs the error via w.FunctionError().
| pocket_increment | (number) Direction to move: 1 for next pocket, -1 for previous pocket, 0 to stay at nearest |
| spindle | (number|nil) The spindle index to use for pocket configuration. Defaults to selected spindle |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule JogToolMagazineToNextPocket | ( | spindle | ) |
Jog the tool magazine to the next pocket position.
Logs the button press via w.OperatorLog() and delegates to m.JogToolMagazineToNearestPocket() with a pocket increment of +1 to move to the next pocket.
| spindle | (number|nil) The spindle index to use for pocket configuration |
| CommonGUIModule JogToolMagazineToPreviousPocket | ( | spindle | ) |
Jog the tool magazine to the previous pocket position.
Logs the button press via w.OperatorLog() and delegates to m.JogToolMagazineToNearestPocket() with a pocket increment of -1 to move to the previous pocket.
| spindle | (number|nil) The spindle index to use for pocket configuration |
| CommonGUIModule LaserPointerCycleStartCheck | ( | ) |
Check if the laser pointer is active before cycle start and prompt the operator to confirm.
If the laser pointer is currently on (m.IsLaserPointerOn() returns true), displays a CycleStartDialog warning the operator that the laser pointer shifts X and Y offsets and asks them to confirm before continuing. If the operator cancels, returns a failure status. If the laser pointer is off, returns success immediately.
| CommonGUIModule LaserPointerInitialize | ( | ) |
Initialize the laser pointer by adding its output signal to the ignore lists.
If the LaserPointerOutput OEM parameter signal is mapped, calls w.AddOEMParamSignalToOutputIgnoreList() to register it in the IgnoreOutputsOnDisable, IgnoreOutputsOnStop, and IgnoreOutputsOnEmergencyStop ignore lists so the laser pointer output is not automatically cleared on those events.
| CommonGUIModule LaserPointerOff | ( | ) |
Turn the laser pointer output signal off and reset the laser pointer offsets.
Calls m.ResetLaserPointerOffset() to zero out the X and Y offset pound variables. Then sets the LaserPointerOutput OEM parameter signal to false via w.SetOEMParamSig(). Logs an error via w.FunctionError() if the signal write fails.
| CommonGUIModule LaserPointerOn | ( | ) |
Turn the laser pointer output signal on and apply the stored laser pointer offsets.
If the LaserPointerOutput OEM parameter signal is mapped, calls m.SetLaserPointerOffset() to apply the stored X and Y offsets to the corresponding pound variables, then sets the LaserPointerOutput OEM parameter signal to true via w.SetOEMParamSig(). Logs an error via w.FunctionError() if the signal write fails.
| CommonGUIModule LaserPointerToggle | ( | ) |
Toggle the laser pointer between on and off states.
If the laser pointer is currently on (m.IsLaserPointerOn() returns true), calls m.LaserPointerOff() to turn it off. Otherwise calls m.LaserPointerOn() to turn it on.
| CommonGUIModule LimitOverrideToggle | ( | ) |
Toggle the limit override signal on or off with password protection.
Logs the button press via w.OperatorLog(). Requires password level 2 via m.screen.CheckPassword(). If the OSIG_LIMITOVER signal is currently false, sets it to true. Otherwise sets it to false. This allows the operator to temporarily override hardware limit switches to jog an axis off a limit.
| CommonGUIModule JobFile Load | ( | ) |
Open a file browser dialog and return the selected G-code file paths for scheduling.
Load a job file from the specified file path and write its data to Mach4.
Shows a multi-file wxFileDialog for the user to select one or more G-code files. If the user confirms the dialog, returns the selected file paths. If the user cancels, logs a cancellation message and returns -1.
Checks whether the file exists via w.FileExists(). If it exists, sets jb.FileNamePath and jb.FileName and calls jb:WriteDataToMach() to apply the file's values. If the file does not exist, resets the file path and name to the sentinel value " ". Updates the JobFiles register with the current file name if jb.JobName is set.
| FilePath | (string) The full path to the job file CSV to load |
| CommonGUIModule LoadAllModules | ( | ) |
Load and initialize all required Lua modules for the CommonGUIModule screen environment.
Configures package.path and package.cpath to include all standard module directories (Modules, Addons, profile Macros/Scripts). Then loads modules in this order: int18n (with language catalog setup), WrapperModule (fatal if missing), GUIModule, ModbusModule, GCodeModule, GCACaller, lfs, winapi, LuaFileQueue, MotionController, VFD, ReciprocatingAxis, BarcodeRS232. Also loads optional modules: UserGUIModuleLoader, UserGUIModule, UserAuxModule (merged into user), LaserMeasureModule, MotionFilterModule, DataCollector, BridgeInterface, AzureLabelModule, ToolInfo, and version info. Runs the "LoadModules" hook and updates the ZeroBrane API maps.
| CommonGUIModule LoadConversational | ( | ) |
Open the conversational (mill wizard) dialog by setting the trigger register.
Sets the MachMotion register "mm_MillWizardDialog" to 1 via w.SetRegValue(), which signals the MachMotion plugin to open the conversational programming dialog.
| loader_handler | ( | err | ) |
Error handler for module loading that appends a stack traceback to the error message.
Formats a combined error string containing the original error message and the full Lua stack traceback from debug.traceback(). Used as the error handler in xpcall() calls during module loading so that load failures provide actionable context information.
| err | (string) The error message from the failed module load |
| CommonGUIModule LoadGCode | ( | GcodeFileName | ) |
Load a G-code file into the current Mach4 instance if it is not already loaded.
Compares GcodeFileName against the currently loaded G-code file via mc.mcCntlGetGcodeFileName(). If the file differs and exists on disk, loads it via w.LoadGCodeFile(), then runs ProcessGcodeHeaderParameters() and UserProcessGcodeHeaderParameters() if they are defined. After loading, rewinds the file via mc.mcCntlRewindFile() to handle files that finish inside a subroutine.
| GcodeFileName | (string) Full path to the G-code file to load |
| CommonGUIModule LoadNextSheduledFile | ( | inst | ) |
Load the next file in the schedule after the current G-code file finishes running.
Checks whether the scheduler is active via m.IsSchedulerActive(). If active, waits for the machine to reach MC_STATE_IDLE using w.WaitOnCondition() with a PleaseWaitDialog. Once idle, advances the schedule by calling m.Scheduler:PopSchedule().
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| UI LoadNotes | ( | ) |
Build the full notes string from the job file's in-memory notes table.
Reads notes from jb via jb:GetNotesCount() and jb:GetNote(). Returns an empty string if there are no notes. Otherwise, concatenates each note line with newline separators; the first line has no leading newline.
| CommonGUIModule loadrequire | ( | modulename | , |
| PrintError | ) |
Attempt to require a Lua module by name with optional error dialog on failure.
---------------—MODULE REQUIRE----------------—
Uses pcall() to safely call require() for the named module. If require() fails and PrintError is true, displays a warning message box via w.wxMessageBox() informing the user that the module could not be loaded. Silent failure occurs when PrintError is false.
| modulename | (string) The name of the Lua module to require |
| PrintError | (boolean) If true, displays a message box when the module fails to load |
| CommonGUIModule MachineCoordToggleBtn | ( | ) |
Toggle the machine coordinate display mode on or off.
Logs the button press (implicitly via caller). If the OSIG_MACHINE_CORD signal is currently false, sets it to true via w.SetSignalState(). Otherwise sets it to false. This controls whether the DRO displays machine coordinates or work coordinates.
| CommonGUIModule MachineLockToggleBtn | ( | ) |
Button handler placeholder for machine lock toggle.
Logs the button press via w.OperatorLog() and returns a successful completion status. This function is a placeholder stub - the machine lock feature is not fully implemented.
| CommonGUIModule MachMenuDialog | ( | ) |
Open the Mach menu configuration dialog.
Displays a modal-style dialog allowing the operator to show or hide the Mach4 menu bar and configure whether it is hidden on startup. Only opens if the machine is in IDLE state; otherwise shows a warning message. Includes Show Menu, Hide Menu, and Hide Menu On Startup toggle controls. Uses a timer to close automatically when Mach begins shutting down.
| CommonGUIModule ManagePartZeros | ( | ) |
Record the current fixture offsets to the profile as a rolling history of up to 10 entries.
Reads the current X, Y, Z, A, B, C origin offset pound variables (SV_ORIGIN_OFFSET_*) and the current G-code file name. Reads up to 10 previously saved part zero entries from the MachMotion profile section. Compares the new offsets against the most recent saved entry; if they differ, inserts the new entry at the front of the history and writes all entries back to the profile (PartZero{i}Axis{j}, PartZeroKey{i}, PartZeroFile{i}).
| CommonGUIModule ManualMode | ( | Active | ) |
Activate or deactivate manual mode for the current Mach4 instance.
Reads the ManualModeEnabled OEM parameter and ManualModeAxis OEM parameter to determine if the feature is supported. Checks via m.MotionController[_inst]:SupportsManualModeFeature() whether the motion controller supports manual mode.
When activating (Active == true): Verifies the machine is enabled and idle. Calls the motion controller's SetManualModeOn() method. Sets the ManualModeActive register to 1. Enables manual mode on each axis bit specified by ManualModeAxis. Displays a persistent "Manual Mode Active" warning.
When deactivating (Active == false): Waits for blended velocity to drop below 1 unit. Calls the motion controller's SetManualModeOff() method. Disables manual mode on each axis. Sets ManualModeActive to 0. Closes the warning notification.
| Active | (boolean) True to activate manual mode, false to deactivate it |
| CommonGUIModule ManualModeIsActive | ( | AutoMessage | ) |
Check whether manual mode is currently active and optionally display a warning.
Reads the ManualModeActive OEM register via w.GetOEMRegValue(). If manual mode is active (value == 1) and AutoMessage is true, displays a warning message via CommonGUIModule.SetWarningMessage() and logs the error via w.FunctionError(). Returns true as the first value if manual mode is active, false otherwise.
| AutoMessage | (boolean) If true, automatically displays a warning message when manual mode is active |
| CommonGUIModule ManualModeToggle | ( | ) |
Toggle manual mode on or off based on the current ManualModeActive register state.
Logs the button press via w.OperatorLog(). Reads the ManualModeActive OEM register via w.GetOEMRegValue(). If the register value is 0, calls CommonGUIModule.ManualMode(true) to activate manual mode. Otherwise calls CommonGUIModule.ManualMode(false) to deactivate it.
| CommonGUIModule ManualToolChangeDialog | ( | tool_number | , |
| auto_tc_override | , | ||
| inst | ) |
Display the manual tool change dialog prompting the operator to install the requested tool.
Shows a dialog instructing the operator to install the specified tool number (with optional description) and press Cycle Start to continue. The dialog background turns green for normal tool changes and neon blue for auto-tool-changer override step 1. If auto_tc_override is non-zero, hides the Z offset checkbox and modifies the displayed instructions based on the override step (1=remove current tool, 2=install new tool, 3=remove and install). A timer closes the dialog automatically when the machine leaves macro-hold states or Mach shuts down. On close, sends the Z offset checkbox value across a register via w.SendTableAcrossRegister() for the M-code to read.
| tool_number | (number) The tool number the operator must install |
| auto_tc_override | (number|nil) Auto tool changer override step: 0=normal, 1=remove only, 2=install only, 3=remove+install. Defaults to 0 |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule MDIBtn | ( | ) |
Button handler to execute MDI (Manual Data Input) G-code from the MDI input field.
Logs the MDI start action via w.OperatorLog(). Runs registered hooks via m.RunHooks("MDIStart"). Checks for active GMS alarms and warnings via w.GetGMSAlarms() and w.GetGMSWarnings(); if either is active, displays a warning message and returns. Checks manual mode via m.ManualModeIsActive(). If all preconditions pass, delegates to m.screen.ExecuteMDI() to execute the MDI command.
| CommonGUIModule MDIDialog | ( | ) |
Open the MDI (Manual Data Input) command dialog.
Delegates to CommonGUIModule._MDIDialog() via w.pcall() for error protection. The underlying implementation creates a dialog with a multi-line G-code editor, history navigation controls (up/down arrow buttons), and a timer that closes the dialog automatically when Mach shuts down. If the dialog is already open, calling this function closes it instead. Also runs "MDIDialog" hooks which can cancel the dialog opening.
| CommonGUIModule MistOff | ( | ) |
Turn off the mist coolant output for the selected instance.
Runs registered hooks via m.RunHooks("MistOff"). If hooks allow continuation, updates stop status and sets the OSIG_MISTON output signal to false via w.SetSignalState() for the selected instance.
| CommonGUIModule MistOn | ( | ) |
Turn on the mist coolant output for the selected instance.
Runs registered hooks via m.RunHooks("MistOn"). Checks the MSTLock and DryRun OEM registers; if either is active, displays a warning and skips the mist command. If neither lock is active, updates stop status and sets the OSIG_MISTON output signal to true via w.SetSignalState() for the selected instance.
| CommonGUIModule MistToggleBtn | ( | ) |
Button handler to toggle mist coolant on or off.
Logs the button press via w.OperatorLog(). Checks the current mist state via m.IsMistOn(). If mist is currently on, calls m.MistOff() to turn it off. Otherwise calls m.MistOn() to turn it on.
| CommonGUIModule ModifyAxisDROPosition | ( | AxisID | ) |
Delegate to modify the DRO position for the specified axis.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.ModifyAxisDROPosition(). Use CommonGUIModule.screen.ModifyAxisDROPosition() in new code.
| AxisID | (number) The axis identifier (e.g., mc.X_AXIS, mc.Y_AXIS, mc.Z_AXIS) |
| CommonGUIModule ModifyAxisPosition | ( | AxisID | , |
| Position | , | ||
| SkipUpdating | ) |
Modify an axis position by setting a new fixture offset value.
Runs registered hooks via m.RunHooks("ModifyAxisPosition", AxisID, Position). If the G68 rotation is active and the axis is X or Y, computes the rotated position using w.GetRotatedPartPos() and sets both X and Y via mc.mcAxisSetPos(). For Z-axis on Mill controls, optionally clears the ZHeadShiftOffset if TC_EnableModifyZOffsetsDuringToolChange is enabled. Converts A/B/C axis positions from current units if needed. Runs the "ModifyAxisPositionFinal" hook after setting the position.
| AxisID | (number) The axis identifier to modify (e.g., mc.X_AXIS, mc.Z_AXIS) |
| Position | (number) The new position value to set for the axis |
| SkipUpdating | (boolean|nil) If true, skips setting the OFFSETS_WERE_MODIFIED flag. Defaults to false |
| CommonGUIModule ModifyZOffsetsInToolChangeDialog | ( | inst | ) |
Display a dialog allowing the operator to choose a method for modifying Z head shift offsets during a tool change.
Creates and shows a modal-style dialog with radio-button options for how to set the Z head shift offset during a tool change. Options include: continue without modifying, set position manually by jogging, set with Manual Tool Setter (if enabled), and set with Auto Tool Setter (if enabled). Selecting an option other than "continue" shows sub-directions and enables a numeric position input. A timer monitors machine state and closes the dialog automatically if the machine leaves macro-hold states or if Mach is shutting down. When closed, the selection and position value are sent across a register via w.SendTableAcrossRegister() for the waiting M-code to read.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ModifyZOffsetsInToolChangeFinalDialog | ( | modify_type | , |
| inst | ) |
Display the final safety-check dialog after modifying Z offsets during a tool change.
Creates and shows a modal-style dialog prompting the operator to jog Z to a safe clearance height and ensure all axes are in a safe position before completing the tool change. The instructions displayed depend on modify_type: 2 = Manual Tool Setter, 3 = Auto Tool Setter, all other values show a generic safe-position message. A timer monitors machine state and closes the dialog automatically if the machine leaves macro-hold states or if Mach is shutting down. When closed, packages the modify_type value into a Lua table and sends it across a register via w.SendTableAcrossRegister() so the waiting M-code can read the result.
| modify_type | (number) The Z-offset modification method: 2 = Manual Tool Setter, 3 = Auto Tool Setter, other = generic |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule MonitorFixtureOffsets | ( | ) |
Save fixture offsets and optionally regenerate the tool path when offsets are modified.
Checks if OFFSETS_WERE_MODIFIED is true and MACH_STATE is IDLE. If both conditions are met, resets the flag, reads the ToolPathAutoRegen OEM parameter, and calls m.RegenerateToolPathDialog() if auto-regen is enabled. Then saves fixture offsets via m.SaveFixtureOffsets() and calls w.FunctionCompleted().
| CommonGUIModule MonitorMachFileRunTime | ( | ) |
Monitor the G-code file run time and update history when a part is completed.
Iterates over all Mach4 instances. For each instance, reads the current run time via mc.mcCntlGetRunTime() and updates MACH_FILE_RUN_TIME_INST if the machine is in a running state (MC_STATE_FRUN or above). Resets the tracked run time to 0 when the machine returns to IDLE. Compares the current part count (mc.PV_PRTST) against MACH_LAST_PART_COUNT_INST; when a new part is completed, calls m.UpdateMachFileRunTimeHistory() with the accumulated run time and resets the counter.
| CommonGUIModule MotionControllerInitialization | ( | ) |
Initialize all motion controller objects for each Mach4 instance.
Iterates over all Mach4 instances and calls the Initialization() method on each m.MotionController[_inst] object via w.pcall() for error protection. If initialization fails for any instance, creates a GMS Alarm message with title "Error In Motion Controller Initialization!" and the error description via w.CreateSystemGlobalMessage(), then returns a failure status.
| CommonGUIModule MotionControllerPreEnable | ( | ) |
Run the motion controller pre-enable sequence for all instances.
Iterates over all Mach4 instances and calls m.MotionController[_inst]:PreEnableReset() via w.pcall() for each. If the call fails, creates a GMS alarm notification with the error message via w.CreateSystemGlobalMessage() and returns an error. This function is called before enabling the machine to allow the motion controller to perform any required pre-enable checks or interlocks.
| CommonGUIModule MotionInhibitEnd | ( | ) |
Release an active motion inhibit and allow program execution to continue.
Only acts if the motion inhibit feature is enabled and currently active. If the MotionInhibitInterlockInput signal is still ON, displays a warning message and does not release the inhibit. Otherwise, if the machine is not idle, runs the MotionInhibitEnd hook scripts. Clears the ISIG_MOTION_INHIBIT signal via w.SetSignalState() to release the inhibit. Closes the active GMS motion inhibit notification if one is open.
| CommonGUIModule MotionInhibitStart | ( | ) |
Activate motion inhibit while the machine is running to pause program execution.
Only acts if the motion inhibit feature is enabled and not already active, and only if the machine is currently running (MACH_STATE >= mc.MC_STATE_FRUN). Sets the ISIG_MOTION_INHIBIT signal to true via w.SetSignalState() to trigger the inhibit. Runs the MotionInhibitStart hook scripts. Closes any previous motion inhibit GMS notification and creates a new persistent "Motion Inhibit Active!" warning notification via w.CreateGMSDialog(), storing the handle in CommonGUIModule.MotionInhibitGMSHandle.
| CommonGUIModule Scheduler MoveItemDown | ( | ) |
Move the currently selected scheduled item down one position in the schedule list.
Retrieves the currently selected item index via self:GetSelectedItem() and swaps it with the item at index + 1 via self:SwapItems().
| CommonGUIModule Scheduler MoveItemUp | ( | ) |
Move the currently selected scheduled item up one position in the schedule list.
Retrieves the currently selected item index via self:GetSelectedItem() and swaps it with the item at index - 1 via self:SwapItems().
| CommonGUIModule Scheduler MoveToBot | ( | ) |
Move the currently selected scheduled item to the bottom of the schedule list.
Retrieves the selected item's index, file path, and quantity via self:GetSelectedItem(). If a valid item is selected and the list is non-empty, inserts a copy at the bottom of the list via InsertItem(), sets its quantity column, then deletes the original entry via self:DeleteItem().
| CommonGUIModule MoveToGoToPosition | ( | goto_position_name | ) |
Move the machine to the named GoTo position using a configured G-code string.
Updates stop status for all instances. Checks that rapid override is >= 1%. Checks manual mode. If goto_position_name is a valid non-empty string, sets GOTO_POSITION_NAME to it. Looks up the G-code string via w.GetGoToPositionGcode() and executes it via w.MDICommand(). On success, applies any G68 patch G-code. Logs any canceled or failed moves to the operator log.
| goto_position_name | (string|nil) The name of the GoTo position to move to. If nil or empty, uses the current GOTO_POSITION_NAME global |
| CommonGUIModule Scheduler MoveToTop | ( | ) |
Move the currently selected scheduled item to the top of the schedule list.
Retrieves the selected item's index, file path, and quantity via self:GetSelectedItem(). If a valid item is selected and the list is non-empty, inserts a copy at index 0 (top) of the list via InsertItem(), sets its quantity column, then deletes the original entry via self:DeleteItem().
| CommonGUIModule MSTLockOff | ( | ) |
Turn off the M-S-T lock for the selected instance.
Logs the action via w.OperatorLog() and sets the MSTLock OEM register string to "No" via w.SetOEMRegValueString() for the selected instance. M-S-T lock controls whether M, S, and T commands are suppressed during program execution.
| CommonGUIModule MSTLockOn | ( | ) |
Turn on the M-S-T lock for the selected instance if the machine is idle.
Logs the action via w.OperatorLog(). Reads the current machine state via mc.mcCntlGetState(). If the machine is idle, sets the MSTLock OEM register string to "Yes" via w.SetOEMRegValueString(). If the machine is not idle, logs a cancellation message and returns without making any change.
| CommonGUIModule MSTLockToggleBtn | ( | ) |
Toggle the M-S-T lock on or off based on its current state.
Logs the button press via w.OperatorLog(). Checks the current M-S-T lock state via m.IsMSTLockOn(). If the lock is currently on, calls m.MSTLockOff() to disable it. Otherwise calls m.MSTLockOn() to enable it.
| myfunc_wrapper | ( | ) |
Example wrapper function showing how to profile a specific function call-tree.
Demonstrates the pattern for profiling a specific function by calling m._LuaProfiling.ResumeProfiler() before the target function and m._LuaProfiling.PauseProfiler() after it (even if the function raises an error via pcall). If the inner function raises an error, it is re-raised after pausing the profiler. This is an example/template and is not registered as a module function.
| DrawingModule Point New | ( | ) |
Create and initialize a new Scheduler object, disabling any previously active scheduler.
Create a new Point instance from a coordinate array.
Sets the scheduler state OEM parameter (self.SCHED_STATE) to 0 via w.SetOEMParamValue() to prevent issues after Compile Scripts. This ensures a clean scheduler state whenever a new Scheduler is instantiated.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
Constructs a Point object by extracting the first and second elements of the provided coordinate array as x_cord and y_cord respectively. Points are used by all shape classes to store vertex and center positions.
| coord | (table) A two-element array where coord[1] is the X coordinate and coord[2] is the Y coordinate |
| CommonGUIModule JobFile New | ( | job_name | ) |
Create and initialize a new JobFile object with the given configuration table and job name.
Constructs a new JobFile metatable instance with configuration from NewTable, including the pound variable range string, register table, header table, overwrite flag, password, default directory, and all open/close/save callback functions. If NewTable is nil, uses a set of default values. Registers the job name in the Mach4 profile and creates a register for it. Calls jb:ReLoad() to restore the last loaded file and jb:ReadDataFromMach(true) to initialize the in-memory data table.
| NewTable | (table|nil) Configuration table with keys: 'RangeString', 'RegTable', 'Overwrite', 'ShowNotesOnOpen', 'RegenToolPath', 'Password', 'DefaultDirectory', 'HeaderTable', 'OnOpenStart', 'OnOpenFinal', 'OnCloseStart', 'OnCloseFinal', 'OnSaveStart', 'OnSaveFinal', 'OnSaveAsStart', 'OnSaveAsFinal'. All keys are optional with defaults. |
| job_name | (string|nil) Optional name used to register this job file in the profile and the JobFiles register |
| CommonGUIModule StackLight NewStackLight | ( | ) |
Create and initialize a new StackLight object for the given Mach4 instance.
Constructs a new StackLight metatable instance. Loads the LightStackEnabled OEM parameter to determine whether the stack light is active. Checks which output signals are mapped (Red, Yellow, Green, White) and reads the blink configuration for each color from OEM parameters. Initializes the Light_Info table with default state, blink, and active values for each color.
| instance | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule NextPocketBtn | ( | use_confirmation | ) |
Change to the next tool pocket in the tool changer carousel.
Checks MST lock, feedrate override, and rapid override before proceeding. Checks manual mode. Reads the current pocket from CURRENT_TOOL_POCKET_NUMBER_INST and increments it, wrapping to pocket 1 if the maximum is exceeded. Sets the ChangePocket OEM register to "true" and looks up the tool number for the selected pocket. Builds the appropriate G-code string for the machine type and optionally presents a CycleStartDialog confirmation before executing via mc.mcCntlMdiExecute().
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule NextToolBtn | ( | use_confirmation | ) |
Change to the next tool number in the tool changer.
Checks MST lock, feedrate override, and rapid override before proceeding. Checks manual mode. Reads the currently selected tool and increments the tool number by 1, clamping to the maximum tool number. Builds the appropriate G-code string for the machine type (Lathe or Mill). Optionally presents a CycleStartDialog confirmation before executing via mc.mcCntlMdiExecute().
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule JobFile NotesDialog | ( | ) |
Open the Job Notes dialog for viewing and editing job file notes.
Delegates to CommonGUIModule._NotesDialog() via w.pcall() for error protection, passing the job file object (self) as the argument. If an error occurs, logs it via w.FunctionError(). The underlying implementation creates a resizable dialog with a multi-line text editor, OK and Cancel buttons, and a timer that closes the dialog when Mach shuts down.
| UI OkButtonClick | ( | ) |
Handle the OK button click in the Job Notes dialog.
Calls UI.StoreNotes() to capture the current editor content into the in-memory notes table, then calls UI.SaveNotesToFile() to persist the notes to the job file on disk.
| UI OnAddNewClick | ( | ) |
Add a new tool setter entry with default values to the list and in-memory table.
Prompts the user for a tool setter name via w.GenericTextEntry(). If the name is non-empty and does not already exist in UI.tool_setters, creates a new entry with default values (AutoSetter=false, ProbeInput=0, Height=1, ZPosition=0, etc.) and appends the name to the setter_list listbox. Sets the list selection to the new entry and calls UI.OnToolSetterListSelected() to populate the detail fields. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnCancel | ( | ) |
Stop the calibrate tool setters dialog timer and destroy the dialog window.
Stops the UI timer if it is active and destroys the toolsetter_dialog window. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnCaptureZPositionClick | ( | ) |
Capture the current Z machine position as the tool setter Z position.
Reads the current tool length offset from mc.SV_CUR_TOOL_ZLENGTH_REGISTER via mc.mcCntlGetPoundVar(). Reads the current Z machine position via mc.mcAxisGetMachinePos(). Computes the tool setter Z position as (Z machine pos - tool length - setter height) and updates the zpos_dro display. Calls UI.OnZPositionChanged() to store and normalize the value. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnClose | ( | ) |
Stop the tool setter selection dialog timer and destroy the dialog window.
Stops the UI timer if it is active and sets it to nil to prevent further timer events. Destroys the toolsetterselection_dialog window. This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| UI OnEndGoToPositionChanged | ( | ) |
Update the end GoTo position for the selected tool setter when the dropdown selection changes.
Reads the current dropdown selection index from UI.endgotoposition_choice and maps it to the corresponding name string in UI.endgotoposition_choiceChoices. Stores the result in UI.tool_setters[name].EndGoToPosition for the currently selected tool setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule OnFileQueueTimer | ( | ) |
Timer callback that processes the Lua file queue with function tracing.
Sets the FuncTracing flag for "m.OnFileQueueTimer" to true, then calls m.ProcessFileQueue() via w.pcall() for error protection. Clears the FuncTracing flag afterward. If an error occurs during processing, logs the error message via w.Log().
| UI OnFixtureOffsetModeChanged | ( | ) |
Update the fixture offset mode for the selected tool setter when the dropdown selection changes.
Reads the current selection index from UI.fixtureoffset_mode_choice and stores it as UI.tool_setters[name].FixtureOffsetMode for the currently selected tool setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnFixturesOffsetsChanged | ( | ) |
Update the fixture offsets toggle state for the selected tool setter and enable or disable the mode dropdown.
Reads the current boolean value from UI.fixturesoffsets and stores it in UI.tool_setters[name].FixturesOffsets. Enables or disables the fixtureoffset_mode_choice dropdown based on the new toggle value. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnGoToPositionChanged | ( | ) |
Update the start GoTo position for the selected tool setter when the dropdown selection changes.
Reads the current dropdown selection index from UI.gotoposition_choice and maps it to the corresponding name string in UI.gotoposition_choiceChoices. Stores the result in UI.tool_setters[name].GoToPosition for the currently selected tool setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnLaunchHeightWizardClick | ( | ) |
Launch the tool setter height wizard and apply the result to the selected setter.
Gets the currently selected tool setter name. Calls CommonGUIModule.RunToolSetterHeightWizard() with the setter's name. If the wizard completes successfully and returns a non-nil height, logs the result via w.Log(), stores it in UI.tool_setters[name].Height, updates the height_dro display, and calls UI.OnToolSetterHeightChanged() to normalize the value. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnLaunchZPosWizardClick | ( | ) |
Launch the tool setter Z position wizard and apply the result to the selected setter.
Gets the currently selected tool setter name. Calls CommonGUIModule.RunToolSetterZPositionWizard() with the setter name, AutoSetter flag, and current Height value. If the wizard completes successfully and returns a non-nil Z position, stores it in UI.tool_setters[name].ZPosition, updates the zpos_dro display, and calls UI.OnZPositionChanged() to normalize the value. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule OnlineManualsBtn | ( | ) |
Open the MachMotion online manuals web page in the default browser.
Attempts to open https://support.machmotion.com/ using the system's default browser. On Windows, uses cmd.exe with 'start' to avoid wxWidgets ShellExecute edge cases. On other platforms, falls back to w.OpenURL(). Displays a warning message box if the URL cannot be opened.
| UI OnProbeInputChanged | ( | ) |
Update the probe input selection for the selected tool setter when the dropdown changes.
Reads the current selection index from UI.probe_choice and stores it as UI.tool_setters[name].ProbeInput for the currently selected tool setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnRemoveClick | ( | ) |
Remove the currently selected tool setter from the list and the in-memory table.
Gets the currently selected tool setter name and its list index. Sets the corresponding entry in UI.tool_setters to nil and deletes the item from the setter_list listbox. Adjusts the list selection to the nearest remaining item and calls UI.OnToolSetterListSelected() to refresh the detail fields. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnRenameToolSetter | ( | ) |
Rename the currently selected tool setter via a modal rename dialog.
Gets the currently selected tool setter name and returns if none is selected. Creates a modal rename dialog with a text control pre-filled with the current name and OK/Cancel buttons. If the user confirms a new non-empty, non-duplicate name, copies the setter data to the new key, updates the setter name field, removes the old key, and updates any fixture setter OEM parameter references (ManualSetterFixtureSelection, AutoSetterFixtureSelection) if the renamed setter was the active one. Updates the listbox to reflect the new name and calls UI.OnToolSetterListSelected() to refresh the detail fields. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnSave | ( | ) |
Save all tool setter data and close the calibrate tool setters dialog.
Calls UI.Save() to persist all tool setter configurations to the profile, then calls UI.OnCancel() to stop the timer and destroy the dialog. If the screen has an InitializeToolSetters function (m.screen.InitializeToolSetters), calls it to reload the tool setter configuration. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule OnScreenJogButtonsOff | ( | ) |
Delegate to hide the on-screen jog buttons.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.OnScreenJogButtonsOff(). Use CommonGUIModule.screen.OnScreenJogButtonsOff() in new code.
| CommonGUIModule OnScreenJogButtonsOn | ( | ) |
Delegate to show the on-screen jog buttons.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.OnScreenJogButtonsOn(). Use CommonGUIModule.screen.OnScreenJogButtonsOn() in new code.
| CommonGUIModule SearchGCode OnSize | ( | ) |
Handle resize events for the Schedule Editor dialog.
Resize the GCode Search grid columns and rows to fit the current dialog size.
Called when the Schedule Editor dialog is resized. Delegates to self:SetColumnsWidth() to recalculate and apply the correct column widths based on the new dialog size.
Calculates the available width for the G-code column by subtracting the fixed line number column width from the total grid width. Calculates row height by dividing the available grid height by the number of rows. Applies the new sizes inside a BeginBatch/EndBatch block and then calls Layout() to refresh the dialog.
| UI OnSoftlimitsChanged | ( | ) |
Update the disable softlimits flag for the selected tool setter when the toggle changes.
Reads the current boolean value from UI.softlimits and stores it in UI.tool_setters[name].DisableSoftlimits for the currently selected tool setter. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnToolSetterHeightChanged | ( | ) |
Validate and store the tool setter height value from the height_dro text field.
Reads the string value from UI.height_dro. If it converts to a valid number, stores it in UI.tool_setters[name].Height for the currently selected tool setter. Formats the stored value to 4 decimal places and updates the height_dro text field if it differs from the raw input. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnToolSetterListSelected | ( | ) |
Populate all detail fields in the tool setter configuration panel for the selected setter.
Handle tool setter list selection by writing the selected name to the appropriate OEM register.
Reads the currently selected tool setter name from the setter_list listbox. If a valid name is found, updates all UI controls to reflect the stored values in UI.tool_setters[name]: sets the type radio buttons (manual/auto), probe input choice, height DRO, Z position DRO, softlimits toggle, fixture offsets toggle, fixture offset mode dropdown, and both GoTo position dropdowns. Enables or disables heightWizBtn, probe_choice, and fixtureoffset_mode_choice based on the auto setter flag and fixture offsets toggle state respectively. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
Reads the currently selected tool setter name from the setter_list listbox. Based on the OffsetTypes and FilterToolSetterTypes closure variables, writes the selected name to one of four OEM registers: ManualSetterFixtureSelection, AutoSetterFixtureSelection, ManualSetterSelection, or AutoSetterSelection via w.SetOEMRegValueString(). Logs any register write errors via w.Error(). This is a closure defined inside CommonGUIModule.ToolSetterSelection().
| UI OnToolSetterTypeChanged | ( | ) |
Update the tool setter type and enable or disable related controls when the radio button changes.
Reads the current boolean value from UI.type_auto and stores it as UI.tool_setters[name].AutoSetter for the currently selected tool setter. Enables or disables UI.heightWizBtn and UI.probe_choice based on whether the auto setter radio button is selected. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| UI OnZPositionChanged | ( | ) |
Validate and store the Z position value from the zpos_dro text field for the selected tool setter.
Reads the string value from UI.zpos_dro. If it converts to a valid number, stores it in UI.tool_setters[name].ZPosition. Formats the stored value to 4 decimal places and updates the zpos_dro text field if it differs from the raw input. This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
| CommonGUIModule JobFile Open | ( | ) |
Open a file browser dialog to select and load a job file, then apply it to Mach4.
Runs the OnOpenStart callback (if set); if it returns false, cancels the open. Shows a wxFileDialog for the user to choose a CSV job file. If a valid file is selected, sets jb.FileNamePath and jb.FileName, calls jb:WriteDataToMach() to apply the data, optionally shows the Notes dialog if ShowNotesOnOpen is true and notes exist, updates the JobFiles register, saves the path to the 'LastLoadedJobFilePath' register, and runs the OnOpenFinal callback (if set).
| CommonGUIModule OpenExternalApplication | ( | ) |
Open the external conversational assistant application.
Logs the button press via w.OperatorLog(). Launches the StartConversationalAssistant.exe application located in the Mach4 Tools directory via os.execute(). The application window will be visible when launched.
| CommonGUIModule OpenGCodeNesting | ( | ) |
Open the G-code nesting interface module.
Runs the "PreOpenGCodeNesting" hooks via m.RunHooks(). If any hook returns false as the primary value, cancels the operation. Otherwise forces a reload of the GCodeNesting module (setting package.loaded.GCodeNesting to nil), requires it, and calls GCNesting.Show() to display the nesting interface.
| CommonGUIModule OpenGCodeNestingBtn | ( | ) |
Log the operator action and open the G-code nesting interface.
Logs "Open GCode Nesting Pressed" via w.OperatorLog() for the current instance, then delegates to m.OpenGCodeNesting() to display the nesting interface.
| CommonGUIModule OpenGMSDiagnosticsDialog | ( | ) |
Open the GMS diagnostics dialog via the GMS plugin command interface.
Sends the "OpenDiagnostics" command with parameter "1" to the GMS plugin via w.SendGMSCommand(). If the command fails, logs the error via w.OperatorLog() and returns a failure status. Returns success if the command is sent successfully.
| CommonGUIModule OpenGMSPluginConfig | ( | ) |
Open the GMS plugin configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "OpenConfig" command with parameter "Config" to the GMS plugin via w.SendGMSCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenM00Notification | ( | message | , |
| line | , | ||
| inst | ) |
Open an M00/M01 program stop notification and record the stop line number.
Skips opening if the retract output (OSIG_RETRACT) is currently active. Sets the OptionalStopActive OEM register to 1 via w.SetOEMRegValue(). If a previous notification is open (m.M00_NotificationHandle is not nil), closes it first via m.CloseM00Notification(). Creates a new GMS notification via w.CreateGMSNotification() and stores the handle in m.M00_NotificationHandle. Records the G-code line number in m.M00LineNumber.
| message | (string) The message text to display in the stop notification |
| line | (number) The G-code line number at which the M00/M01 stop occurred |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule OpenMachineCalibrationPluginAutomaticConfig | ( | ) |
Open the MachineCalibration plugin automatic calibration configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "AutomaticConfig" command to the MachineCalibration plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMachineCalibrationPluginConfig | ( | ) |
Open the MachineCalibration plugin configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "Config" command to the MachineCalibration plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMachineCalibrationPluginManualConfig | ( | ) |
Open the MachineCalibration plugin manual calibration configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "ManualConfig" command to the MachineCalibration plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMachineCalibrationPluginScrewMappingConfig | ( | ) |
Open the MachineCalibration plugin screw mapping configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "ScrewMapping" command to the MachineCalibration plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMachMotionModbusPluginConfig | ( | ) |
Open the MachMotion Modbus plugin configuration dialog.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise sends the "Config" command to the MachMotionModbusDevice plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMachMotionPluginConfig | ( | ) |
Open the MachMotion plugin configuration dialog for the selected Mach4 instance.
If the machine is not in IDLE state, displays a warning via CommonGUIModule.SetWarningMessage(). Otherwise checks password level 3 via m.screen.CheckPassword(). If the password check passes, sends the "Config" command to the MachMotion plugin via w.RegSendCommand() for the selected instance. If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenMotionControllerConfig | ( | ) |
Open the motion controller configuration dialog for the selected Mach4 instance.
Entry point for the screen button. Uses w.pcall() to protect against errors in CommonGUIModule._OpenMotionControllerConfig(). If an error occurs, logs it via w.FunctionError(). Requires the machine to be in IDLE state and password level 3. Opens the motion controller configuration via m.MotionController[selected_instance]:OpenConfiguration().
| CommonGUIModule OpenSetupWizard | ( | ) |
Open the MachMotion setup wizard via the plugin command interface.
If the machine is not in IDLE state, displays a warning message via CommonGUIModule.SetWarningMessage(). Otherwise sends the "SetupWizard" command to the MachMotion plugin via w.RegSendCommand(). If the command fails, logs the error via w.OperatorLog().
| CommonGUIModule OpenToolPocketsDialogBtn | ( | ) |
Open the tool pockets dialog by setting the trigger register.
Sets the MachMotion register "mm_ToolPocketsDialog" to 1 via w.SetRegValue(), which signals the MachMotion plugin to open the tool pockets management dialog. Logs any errors via w.OperatorLog().
| CommonGUIModule OpenToolTable | ( | ) |
Open the tool table dialog if the screen is in edit mode.
Checks whether the screen is in edit mode via CommonGUIModule.screen.IsEditModeActive(). If not in edit mode, displays a warning dialog and returns an error. Otherwise sends the "ToolTable" command to the MachMotion plugin via w.RegSendCommand(). Logs any command errors via w.OperatorLog().
| w OperatorLog | ( | inst | , |
| "Run From Here Pressed" | ) |
Write an operator action message to the Mach4 operator log.
This is a reference to the w.OperatorLog() wrapper function used throughout CommonGUIModule to record operator-initiated actions. It writes timestamped messages to the Mach4 operator log for the specified instance.
| inst | (number) The Mach4 instance handle for which to log the message |
| message | (string) The message text to record in the operator log |
| CommonGUIModule OptionalStopOff | ( | ) |
Turn off the optional stop (M1) feature for the current instance.
Reads the current optional stop state via mc.mcCntlGetOptionalStop(). If optional stop is currently enabled (returns 1), disables it by calling mc.mcCntlSetOptionalStop() with 0.
| CommonGUIModule OptionalStopOn | ( | ) |
Turn on the optional stop (M1) feature for the current instance.
Reads the current optional stop state via mc.mcCntlGetOptionalStop(). If optional stop is currently disabled (returns 0), enables it by calling mc.mcCntlSetOptionalStop() with 1.
| CommonGUIModule OptionalStopToggleBtn | ( | ) |
Button handler to toggle the optional stop (M1) feature on or off.
Logs the button press via w.OperatorLog(). Checks the current optional stop state via m.IsOptionalStopOn(). If currently on, calls m.OptionalStopOff() to disable it. Otherwise calls m.OptionalStopOn() to enable it.
| CommonGUIModule JobFile OptSaveChanges | ( | ) |
Optionally prompt the user to save changes to the job file if any edits are detected.
Reads the job file CSV from jb.FileNamePath and compares each pound variable's stored value against the current value in Mach4 via mc.mcCntlGetPoundVar(). If any value differs by more than 0.000001, sets HasChanges=true and shows a wxMessageDialog asking whether to save. If the user confirms, calls jb:Save(). Returns false if no file is loaded. Returns HasChanges.
| CommonGUIModule OverrideLimits | ( | ) |
Validate and swap spindle and feedrate override min/max OEM parameters if inverted.
Reads SpindleOverrideMaxPercent and SpindleOverrideMinPercent OEM parameters. If the minimum value is greater than the maximum, swaps them. Performs the same check and swap for FeedrateOverrideMaxPercent and FeedrateOverrideMinPercent. This prevents inverted override ranges from causing unexpected behavior.
| CommonGUIModule ParkToolBtn | ( | use_confirmation | ) |
Park the current tool by changing to tool number 0.
Checks MST lock, feedrate override, and rapid override before proceeding. Checks manual mode. Sets the tool index to 0 (park position) and builds the appropriate G-code string for the machine type (Lathe or Mill). Optionally presents a CycleStartDialog confirmation before executing the park command via mc.mcCntlMdiExecute().
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule PartCounterDialog | ( | ) |
Open the Part Counter dialog for viewing and editing part count parameters.
Wraps the internal _PartCounterDialog() implementation via w.pcall() for error protection. If an error occurs during dialog creation or operation, displays the error message via w.wxMessageBox(). The dialog shows current program parts, total parts, required parts, M-code counter mode, and M-code number. All values are read from and written to the corresponding Mach4 parameters in real time.
| CommonGUIModule _LuaProfiling PauseProfiler | ( | logpath | ) |
Temporarily pause an active Lua profiling session without losing collected data.
Checks that the profiler module is loaded and that profiling is currently active via prof.IsProfiling(). If both conditions are met, calls prof.profiler.pause() to suspend data collection. The profiling session can be resumed later via ResumeProfiler(). Does nothing if the profiler is not loaded or profiling is not active.
| logpath | (string|nil) Unused parameter, accepted for API consistency with StopProfiler |
| CommonGUIModule PLCSequenceDialogBtn | ( | ) |
Open the PLC Sequence dialog allowing the operator to manually trigger PLC sequences.
Guards against duplicate opens via DIALOG_IS_OPEN["PLC_SEQ"]. Requires password level 3. Reads all 64 sequence descriptions via mb.GetSeqDescription() and populates a list box. Provides a debugging checkbox and a Start Sequence button. The machine must be enabled and idle before a sequence can be started via mb.SeqCall(). A timer updates the button background color based on the PLCSeqFB feedback bit for the selected sequence. Displays a prominent danger warning.
| CommonGUIModule Scheduler PopSchedule | ( | ) |
Decrement the quantity of the current top scheduled file and advance the schedule.
Retrieves the first entry in the schedule for the given instance and decrements its quantity by 1. If the quantity reaches 0 or below, removes the entry from the schedule via table.remove(). Otherwise updates the quantity in place. Then serializes the updated schedule to the OEM register via self:SendFilesToRegister() and calls self:Enable() to load the next file. Delegates the actual work to self:_PopSchedule() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule PositionDisplayDROMode | ( | ) |
Delegate to set the position display to DRO mode.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.PositionDisplayDROMode(). Use CommonGUIModule.screen.PositionDisplayDROMode() in new code.
| CommonGUIModule PositionDisplayLocked | ( | ) |
Delegate to lock the position display.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.PositionDisplayLocked(). Use CommonGUIModule.screen.PositionDisplayLocked() in new code.
| CommonGUIModule PositionDisplayUnLocked | ( | ) |
Delegate to unlock the position display.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.PositionDisplayUnLocked(). Use CommonGUIModule.screen.PositionDisplayUnLocked() in new code.
| CommonGUIModule PowerOff | ( | ) |
Save critical data and shut down the Windows operating system.
Saves the tool table via mc.mcToolSaveFile(), saves fixture offsets via mc.mcFixtureSaveFile(), then issues a Windows shutdown command with a 20-second delay (shutdown /s /t 20). Finally calls scr.Exit(true) to close Mach4 immediately.
| CommonGUIModule PowerOffBtn | ( | ) |
Button handler that delegates to CommonGUIModule.PowerOffControl().
Simple pass-through that calls CommonGUIModule.PowerOffControl() with no arguments, resulting in a confirmation dialog before powering off.
| CommonGUIModule PowerOffControl | ( | skip_confirmation | ) |
Prompt the user to confirm a power-off request and then shut down the control.
If skip_confirmation is false (default), shows a Yes/No confirmation dialog. If confirmed, calls m.PowerOff() immediately. If skip_confirmation is true, shows a 5-second countdown Please Wait dialog before calling m.PowerOff(). The countdown can be cancelled, in which case the power-off is aborted.
| skip_confirmation | (boolean|nil) If true, skips the Yes/No dialog and uses a 5-second delay instead. Defaults to false |
| CommonGUIModule PreviousPocketBtn | ( | use_confirmation | ) |
Change to the previous tool pocket in the tool changer carousel.
Checks MST lock, feedrate override, and rapid override before proceeding. Checks manual mode. Reads the current pocket from CURRENT_TOOL_POCKET_NUMBER_INST and decrements it, wrapping to the maximum pocket number if the result is less than 1. Sets the ChangePocket OEM register to "true" and looks up the tool number for the selected pocket. Builds the appropriate G-code string for the machine type and optionally presents a CycleStartDialog confirmation before executing via mc.mcCntlMdiExecute().
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule PreviousToolBtn | ( | use_confirmation | ) |
Change to the previous tool number in the tool changer.
Checks MST lock, feedrate override, and rapid override before proceeding. Checks manual mode. Reads the currently selected tool and decrements the tool number by 1, clamping to 0 at the minimum. Builds the appropriate G-code string for the machine type (Lathe or Mill). Optionally presents a CycleStartDialog confirmation before executing via mc.mcCntlMdiExecute().
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| UI print | ( | ... | ) |
Redirect Lua print() calls from executed scripts to the debug output window.
When user scripts are executed via UI.RunLuaCode(), the standard print() function is locally overridden with this function so that output appears in the dialog's Debug Output panel rather than the default Mach4 log. Accepts any number of arguments; each is converted via tostring() and concatenated with a tab separator before being passed to UI.DebugOutputAppend().
| ... | (any) Values to print, converted to strings and joined with tab separators |
| CommonGUIModule ProcessFileQueue | ( | ) |
Process one command from the Lua file queue, handling errors and stop status.
Sets the active instance to 0 and delegates to CommonGUIModule._ProcessFileQueue() via w.pcall(). If an error occurs, logs it and increments FQ_FAILURE_COUNT. If the failure count reaches FQ_MAX_FAILURE_COUNT, raises an alarm message via w.AlarmMessage() and returns without restarting the timer, permanently disabling the queue.
| CommonGUIModule JobFile ReadDataFromMach | ( | ) |
Read current Mach4 state (pound variables, registers, notes) and write to the job file on disk.
Builds the complete job file data table from the current Mach4 state. Iterates over all pound variables in jb.RangeString, all registers in jb.RegTable, and all notes in jb.FileTable.Notes. Assembles the full file structure including headers, data headers, pound vars, registers, and notes. If initialize_table is false, writes the assembled data to the job file CSV via w.WriteCSV(). If initialize_table is true, only populates the in-memory table without writing to disk.
| initialize_table | (boolean|nil) If true, skip writing to disk and only populate in-memory table. Defaults to false |
| CommonGUIModule ReadGcodeHeaderParameters | ( | ) |
Read G-code header parameters from the currently loaded G-code file.
Thin wrapper that delegates to w.ReadGcodeHeaderParameters(). The caller should prefer the wrapper function directly. Returns whatever w.ReadGcodeHeaderParameters() returns.
| CommonGUIModule SearchGCode ReadLoadedFile | ( | inst | ) |
Read the currently loaded G-code file line by line into an internal table.
Opens the specified file using io.lines() and inserts each line into self.gcode_tbl. Displays a progress dialog during loading. Calls w.Sleep(1) every 1000 lines to prevent UI freezing during large file loads.
| file_name | (string) The full path to the G-code file to read |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule RegenerateToolPathDialog | ( | ) |
Delegate to regenerate the tool path dialog via the wrapper module.
This is a deprecated forwarding function. It calls w.RegenerateToolPathDialog() directly. Use w.RegenerateToolPathDialog() in new code.
| CommonGUIModule RegisterForMachMessage | ( | inst | , |
| msg_type | , | ||
| callback_func | , | ||
| param1 | , | ||
| param2 | ) |
Register a callback function to be called when a specific Mach4 message event occurs.
Validates that msg_type is a supported message type from CommonGUIModule.MachMsg["Supported Types"]. For MSG_REG_CHANGED: requires param1 (device name string) and param2 (register name string); retrieves the register handle via w.GetRegHandle() and stores the callback keyed by handle. For MSG_IO_CHANGED: requires param1 (device name) and param2 (IO name); stores callback keyed by IO handle from w.GetIoHandle(). For MSG_GCODE_VAR_CHANGED: stores callback keyed by param1 (pound variable index). For MSG_PARAMETER_CHANGED: stores callback keyed by param1 (parameter index). Raises a Lua error via w.Error() if arguments are invalid or unsupported.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| msg_type | (number) The Mach4 message type constant (e.g., mc.MSG_REG_CHANGED) |
| callback_func | (function) The function to call when the message is received |
| param1 | (string|number) Device name (for REG/IO types) or pound var/parameter index |
| param2 | (string|nil) Register name or IO name (for REG/IO types); unused for others |
| CommonGUIModule JobFile ReLoad | ( | ) |
Reload the last loaded job file from the path stored in the MachMotionOEMParameters register.
Reads the 'LastLoadedJobFilePath' register value from the "MachMotionOEMParameters" device. If the value is non-empty and not the sentinel " ", calls jb:Load() with that path to restore the previously loaded job file on startup or after a script recompile.
| CommonGUIModule RemoteSupportBtn | ( | ) |
Open the MachMotion remote support tool.
Delegates to CommonGUIModule._RemoteSupportBtn() via w.ProtectedMsg() for error handling. The underlying implementation locates and executes the _MachMotionRemoteSupport.cmd script from the profile's ConfigTools directory.
| CommonGUIModule Reset | ( | ) |
Reset the Mach4 controller with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing["m.Reset"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._Reset() via w.pcall() for protected execution. On error, logs an alarm message via w.AlarmMessage() and returns a formatted error via w.FunctionError().
| CommonGUIModule ResetAllOverrideAxes | ( | inst | ) |
Reset all override (OB1-OB6) axes to zero position and restore their override mappings.
Checks if the machine is enabled via the OSIG_MACHINE_ENABLED signal. If enabled, iterates over all OB axes (OB1_AXIS through OB6_AXIS) and checks up to 4 override axis mappings per axis via mcAxisGetOverrideAxis(). For each mapped override axis that is not -1, removes the override via mcAxisRemoveOverrideAxis(), then jogs the axis to position 0 at maximum jog feedrate if the current position is more than 0.001 units from zero. After all axes are jogging, displays a PleaseWaitDialog until motion stops, then restores all override mappings via mcAxisSetOverrideAxis(). Always calls w.FunctionCompleted() on exit.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ResetBtn | ( | ) |
Button handler to reset the controller, running pre/post reset hooks.
Logs the button press via w.OperatorLog(). Runs the PreResetBtn hook scripts. Calls m.CycleStop(1) to ensure the machine is stopped before resetting. Reads GMS alarm status. Runs the ResetBtn and PostResetBtn hook scripts. Delegates to m.Reset() to perform the actual controller reset. Returns the result from m.Reset().
| CommonGUIModule ResetCurrentPocket | ( | ) |
Reset the current tool pocket number to a user-specified value.
Requires password level 3. Calls user.UserResetCurrentPocket() if defined, allowing a user script to override the default behavior. Reads the ToolChangerMemorySource OEM parameter to determine the pocket storage method. For PLC-sourced memory, pulses bit 2 of ContBitData via Modbus. For Mach-sourced memory, prompts the operator for a pocket number via a text dialog and stores it via w.SetToolChangeStatus(). Calls m.CompileScriptsBtn() after updating.
| IgnoreConfirmationDialogs | - not applicable; password check is always enforced |
| CommonGUIModule ResetEndOfProgramOutput | ( | inst | ) |
Reset the end-of-program output signal and clear the EndOfProgram register.
If the OEM parameter signal 'EndOfProgramOutput' is configured, sets it to false. Then resets the 'EndOfProgram' OEM register value to 0 to clear the end-of-program state.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ResetLaserPointerOffset | ( | ) |
Clear the laser pointer X and Y offset pound variables back to zero.
Retrieves the offset variable indices via m.GetLaserPointerOffsetVars(). Writes 0 to both the X and Y offset pound variables via mc.mcCntlSetPoundVar(). Logs errors via w.FunctionError() if either API call fails.
| MotionController ResetSafetyRelay | ( | ) |
Reset the safety relay circuit with re-entrancy protection.
Base implementation to reset the safety relay on the motion controller.
Guards against concurrent execution using w.FuncTracing["m.ResetSafetyRelay"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._ResetSafetyRelay() via w.pcall() for protected execution. On error, returns a formatted error message via w.FunctionError().
Does nothing in the base implementation. Subclasses (RapidPath) override this to send a 'ResetSafetyRelay' operation command to the plugin, which initializes the watchdog I/O for the safety relay circuit.
| CommonGUIModule RestoreHeadShiftOffsets | ( | ) |
Restore saved head shift offsets to all axes for all instances based on OEM parameter mode.
Iterates over all instances and all coordinate axes. For each instance whose 'HeadShiftOffsetsMode' OEM parameter equals "Restore Last Value" or "Restore Permanent Value", reads the saved offset from the 'HeadShiftOffset_<axis>' OEM parameter and applies it to the corresponding pound variable (5081 + axis index) via mc.mcCntlSetPoundVar(). Returns an error if any read or set operation fails.
| CommonGUIModule ReStoreMachOverrides | ( | ) |
Restore previously saved Mach4 speed overrides from the profile.
Reads the 'RetainMachOverrides' OEM parameter; if not "Yes", returns immediately. Otherwise, restores the Spindle Override via mc.mcSpindleSetOverride(), the Feedrate Override via mc.mcCntlSetFRO(), and the Rapid Rate Override via mc.mcCntlSetRRO(), reading each value from the MachMotion profile section. Returns an error if any profile read or set operation fails.
| CommonGUIModule RestoreWorkShiftOffsets | ( | ) |
Restore saved work shift offsets to all axes for all instances based on OEM parameter mode.
Iterates over all instances and all coordinate axes. For each instance whose 'WorkShiftOffsetsMode' OEM parameter equals "Restore Last Value" or "Restore Permanent Value", reads the saved offset from the 'WorkShiftOffset_<axis>' OEM parameter and applies it to the corresponding pound variable (5201 + axis index) via mc.mcCntlSetPoundVar(). Returns an error if any read or set operation fails.
| CommonGUIModule _LuaProfiling ResumeProfiler | ( | logpath | ) |
Resume a previously paused Lua profiling session.
Checks that the profiler module is loaded and that profiling is currently active via prof.IsProfiling(). If both conditions are met, calls prof.profiler.resume() to continue collecting profiling data from where it was paused. Does nothing if the profiler is not loaded or profiling is not active.
| logpath | (string|nil) Unused parameter, accepted for API consistency with StopProfiler |
| CommonGUIModule ReverseRunBtn | ( | ) |
Button handler to initiate a reverse run operation.
Logs the button press via w.OperatorLog() and updates the stop status. Checks manual mode via CommonGUIModule.ManualModeIsActive(). Returns a successful completion status. The actual reverse run signal toggling is commented out in the current implementation.
| CommonGUIModule Rewind | ( | ) |
Rewind the currently loaded G-code file to the beginning.
Runs registered hooks via m.RunHooks("Rewind"). If hooks allow continuation, calls mc.mcCntlRewindFile() to rewind the G-code file to line 1. Returns an error if the API call fails.
| CommonGUIModule RewindBtn | ( | ) |
Button handler to rewind the currently loaded G-code file to the beginning.
Logs the button press via w.OperatorLog() and delegates to m.Rewind() to perform the actual rewind operation.
| CommonGUIModule RunFromHereBtn | ( | ) |
Button handler to initiate a run-from-here operation at the current G-code line.
Logs the button press via w.OperatorLog(). Reads the current G-code file name and line number. If the line number is <= 1, logs a cancellation message and returns. Checks the mm_RunFromHereDialog register; if already set to 1, clears it and returns. If a file is loaded, updates stop status and checks manual mode. Calls the user UserRunFromHere script if defined; otherwise sets the mm_RunFromHereDialog register to 1 to trigger the built-in run-from-here dialog. If no file is loaded, logs a cancellation message.
| CommonGUIModule RunHooks | ( | hook_name | , |
| ... ) |
Run registered hook scripts for the specified hook event.
Delegates to CommonGUIModule._RunHooks() with the silent flag set to false. Checks hook functions in the following priority order: user module, user module with "User" prefix, m.screen with "Machine" prefix, m.screen with "MachineScreen" prefix, m.screen with no prefix, and m module with "Machine" prefix. Each hook can return (false, ...) to stop further processing or (true, ...) to allow subsequent hooks to run.
| hook_name | (string) The name of the hook to execute (e.g., "EnableBtn", "CycleStart") |
| ... | (any) Additional arguments passed through to each hook function |
| CommonGUIModule RunHooksSilent | ( | hook_name | , |
| ... ) |
Run registered hook scripts silently without logging completion messages.
Delegates to CommonGUIModule._RunHooks() with the silent flag set to true. When silent is true, hook completion messages are not passed through w.FunctionCompleted() and are returned as plain strings instead.
| hook_name | (string) The name of the hook to execute (e.g., "EnableBtn", "CycleStart") |
| ... | (any) Additional arguments passed through to each hook function |
| UI RunLuaCode | ( | ) |
Execute the Lua code currently in the Run Lua Script dialog editor.
Saves the current editor content to history, resets the error style, then builds the full execution string via UI.ConstructLuaString() and runs it with w.RunLuaString(). If a compile or load error is returned, the debug output background turns red and the error message is appended. On success, the background is restored and a success message with elapsed time is appended to the debug output window.
| CommonGUIModule RunLuaPrint | ( | ... | ) |
Convenience alias for AppendRunLuaDebugMessage.
Forwards all arguments to CommonGUIModule.AppendRunLuaDebugMessage(). Appends a message to the Run Lua Script dialog's Debug Output window if it is open. Has no effect if the dialog is not currently visible.
| ... | (any) One or more values to display in the debug output window |
| CommonGUIModule RunLuaScriptFromDialog | ( | ) |
Open the Run Lua Script dialog for interactive Lua code execution.
Creates and displays a resizable dialog containing a Lua script editor, a debug output panel, and history navigation controls. The editor supports both wxTextCtrl and wxStyledTextCtrl (with syntax highlighting if available). Script history is persisted to a .lua file in the profile directory and navigated with up/down arrow buttons. The splitter sash position between editor and debug output is saved and restored from the Mach4 profile. A timer monitors for Mach shutdown and closes the dialog automatically. The dialog exposes a debug print interface via CommonGUIModule._RunLuaUIRef and _G._RunLuaUIRef while open.
| CommonGUIModule RunLubeCycle | ( | ) |
Execute the lube system M-code script if the lube system is enabled and not already cycling.
Checks whether LUBE_SYSTEM_ENABLED is "Yes". If enabled, reads the LubeSystemInCycle OEM register; if not already in a cycle, checks that the LubeSystem.mcs M-code file exists and executes it via mc.mcScriptExecutePrivate(). Logs an error via w.FunctionError() if the file is not found or if the script execution fails.
| CommonGUIModule RunLubeCycleOnStartup | ( | ) |
Run the lube cycle once on startup if configured and not yet run.
Reads the LubeCycleOnStartup OEM register to determine if startup lube is enabled, and reads the LubeStartupFlag OEM register to determine if the cycle has already run this session. If LubeCycleOnStartup is "Yes" and LubeStartupFlag is not 1, executes m.RunLubeCycle() and sets LubeStartupFlag to 1 to prevent re-running on the same session.
| CommonGUIModule RunToolSetterHeightWizard | ( | settername | ) |
Run the tool setter height wizard to calculate and store the tool setter height.
Creates and runs a 4-page wizard that guides the operator through determining the height of an automatic tool setter. Page 1 captures the Z machine position while touching a solid surface. Page 2 instructs the operator to place the setter on the same surface. Page 3 uses a CycleStartHold and executes M903/M901/M1 G-code via w.MDICommand() to probe the tool setter; calculates setter height as (probe_position - surface_position). Page 4 displays the result and prompts the operator to finish. Returns the calculated height and whether the wizard completed.
| settername | (string) The name of the tool setter being calibrated |
| CommonGUIModule RunToolSetterZPositionWizard | ( | settername | , |
| auto_setter | , | ||
| manual_setter_height | ) |
Run the tool setter Z position wizard to calculate and store the tool setter Z machine position.
Creates and runs an 8-page wizard that guides the operator through determining the Z machine position of a tool setter or gauge block. The wizard adapts based on whether the operator has a calibrated tool loaded and whether the setter is automatic or manual. For auto setters, page 6 uses M903/M901/M1 G-code via MDI to probe the setter. For manual setters, page 7 guides the operator to touch off on a gauge block manually. Page navigation uses SetNext/SetPrev to dynamically route through the appropriate pages based on user selections. Supports CycleStartHold integration for the probe step. Returns the calculated setter position and whether the wizard completed.
| settername | (string) The name of the tool setter being calibrated |
| auto_setter | (boolean) True if the setter is an automatic probe-based setter, false for manual |
| manual_setter_height | (number) The known height of the manual setter or gauge block in current units |
| CommonGUIModule JobFile Save | ( | ) |
Persist all tool setter configurations to the Mach4 profile.
Save the job file to its current path, with password protection.
Iterates over all entries in UI.tool_setters. For each non-empty tool setter name, assigns a sequential SectionName (e.g., "ToolSetter0", "ToolSetter1") and writes the setter data via w.WriteToolSetter(). Writes the total count of tool setters to the MachMotion profile section via mc.mcProfileWriteInt(). This is a closure defined inside CommonGUIModule.CalibrateToolSetters().
Checks the password via jb:CheckPassword() before proceeding. If the password check passes, delegates to jb:_Save() which either calls jb:_SaveAs() (if no path is set) or reads current Mach4 data and writes to the existing file path. If the password check fails, logs a message and takes no action.
| CommonGUIModule JobFile SaveAs | ( | ) |
Save the job file to a new location chosen by the user, with password protection.
Checks the password via jb:CheckPassword() before proceeding. If the password check passes, delegates to jb:_SaveAs() which opens a wxFileDialog for the user to choose a save location. If the password check fails, logs a message and takes no action.
| CommonGUIModule SaveFixtureOffsets | ( | ) |
Save fixture offsets to disk for all idle Mach4 instances.
Calls m.ManagePartZeros() to record the current fixture offsets to the rolling history. Then iterates over all Mach4 instances. For each instance that is currently in IDLE state (MACH_STATE_INST[_inst] == mc.MC_STATE_IDLE), calls mc.mcFixtureSaveFile() to persist the fixture offset table to disk. Logs the save action via w.Log().
| UI SaveNotesToFile | ( | ) |
Save the current notes from the dialog to the job file on disk.
Delegates to jb:UpdateNotesOnlyToJobFile() which writes only the Notes section of the job file CSV while leaving all other fields (pound variables, registers, headers) unchanged.
| CommonGUIModule Scheduler SaveSchedule | ( | inst | ) |
Save a table of scheduled file entries to the in-memory schedule for a given instance.
Clears the existing schedule for the instance via self:ClearSchedule(), then inserts each entry from files_tbl into the schedule table via table.insert(self:GetSchedule(inst), file).
| files_tbl | (table) Array of file entry tables, each with fields 'path' (string) and 'qty' (string|number) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| UI SaveSettings | ( | ) |
Save the current block delete level checkbox states to the Mach4 profile and apply them.
Reads the checked state of each of the ten block delete level checkboxes (levels 0-9). For each level, writes the boolean value to the MachMotion profile section via mc.mcProfileWriteInt() and applies it immediately via mc.mcCntlSetBlockDelete(). After saving all levels, reads the ToolPathAutoRegen OEM parameter and regenerates the tool path dialog via m.RegenerateToolPathDialog() if the parameter is set to "Yes".
| CommonGUIModule SaveSysVars | ( | ) |
Save system variables to disk for all idle Mach4 instances.
Iterates over all Mach4 instances. For each instance that is currently in IDLE state (MACH_STATE_INST[_inst] == mc.MC_STATE_IDLE), calls mc.mcCntlSaveSysvars() to persist the system variables to disk. Logs the save action via w.Log().
| UI SaveToHistory | ( | ) |
Save the current editor content to the Lua script history file.
Delegates to UI._SaveToHistory() via w.Protected() for error safety. The raw editor text is appended to the history file, the in-memory history table is refreshed, and the current history index is updated to the most recent entry.
| UI SaveToHistory | ( | gcode | ) |
Save the current MDI command text to the MDI history file.
Retrieves the current MDI string via UI.ConstructMDIString() and, if non-empty, appends it to the history file via w.AddToListHistory(). Refreshes the in-memory history table and updates the current history index to the most recent entry. Also calls UI.UpdateHistoryBtns() to reflect the new navigation state.
| CommonGUIModule SaveToolOffsets | ( | ) |
Save tool offsets to disk for all idle Mach4 instances.
Iterates over all Mach4 instances. For each instance that is currently in IDLE state (MACH_STATE_INST[_inst] == mc.MC_STATE_IDLE), calls mc.mcToolSaveFile() to persist the tool offset table to disk. Logs the save action via w.Log().
| CommonGUIModule ScanWarningsAlarms | ( | ) |
Update the alarm dialog button icon based on current GMS alarm and warning state.
Reads active alarms via w.GetGMSAlarms() and warnings via w.GetGMSWarnings(). If either is active, alternates the AlarmDialogBtn icon between "alarm-icon.png" and "warning-icon.png" in sync with BLINK_OBJECT_ACTIVE to create a blinking effect. If neither alarms nor warnings are active, sets the icon to "ok-icon.png". Only updates the screen object when the icon actually changes to minimize unnecessary screen writes.
| CommonGUIModule ScreenConfigurationDialog | ( | ) |
Delegate to open the screen configuration dialog.
This is a deprecated forwarding function. It delegates to CommonGUIModule.screen.ScreenConfigurationDialog(). Use CommonGUIModule.screen.ScreenConfigurationDialog() in new code.
| CommonGUIModule ScreenIsLoadedScript | ( | ) |
Entry point called when the Mach4 screen has finished loading all controls.
Wraps CommonGUIModule._ScreenIsLoadedScript() via w.Protected() for error handling, then calls w.FunctionCompleted(). The inner function performs final post-load initialization: resizes the tool path panel height, yields to allow the GUI to process events, runs CommonStartUpScript(), sets the ScreenIsLoaded OEM register to 1, runs the "ScreenIsLoadedScript" hooks, and sets ENABLE_MAIN_PLC_SCRIPT to true to allow PLC execution.
| CommonGUIModule SearchGCode Search | ( | ) |
Search the loaded G-code file for lines matching a keyword.
Converts the keyword to lowercase and iterates over self.gcode_tbl, performing a case-insensitive pattern match on each line. Matching lines are collected into a result table with fields 'idx' (1-based line number) and 'gcode' (original line text).
| keyword | (string) The search term to look for (case-insensitive) |
| CommonGUIModule SearchGCodeBtn | ( | ) |
Open the G-code search dialog for the currently loaded G-code file.
Logs the button press via w.OperatorLog(). Reads the currently loaded G-code file name via mc.mcCntlGetGcodeFileName(). If a file is loaded, updates the stop status and checks manual mode via m.ManualModeIsActive(). If preconditions pass, initializes the SearchGCode dialog via CommonGUIModule.SearchGCode:Initialize(). If no file is loaded, logs a cancellation message.
| CommonGUIModule Scheduler SendFilesToRegister | ( | inst | ) |
Serialize all scheduled files to an OEM register string for persistence.
If from_gui is true, reads the current file list from the Schedule Editor UI via self:GetSchedFiles() and saves it to the in-memory schedule table via self:SaveSchedule(). If from_gui is false, reads directly from the in-memory schedule via self:GetSchedule(). Formats each file entry as "path|name|qty/" and writes the concatenated string to the OEM register identified by self.FILE_REG via w.SetOEMRegValueString().
| from_gui | (boolean) If true, reads file list from the UI list control; if false, reads from in-memory schedule |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule SendToolTable | ( | ) |
Serialize and send the tool name table to the MachMotion plugin via register command.
If TOOL_NAMES is nil or empty, calls w.CreateToolInfoFile() to populate it. If TOOL_NAMES is populated, builds a pipe-delimited command string encoding the count of tools, each tool index, and all non-table key-value pairs for each tool entry (table values are serialized as comma-separated lists). Sends the serialized string to the MachMotion plugin via w.RegSendCommand() on the "mm_ToolTable" register. Logs errors via w.FunctionError().
| CommonGUIModule Scheduler SetColumns | ( | ) |
Create and insert the column headers for the Schedule Editor list control.
Iterates over self.UI.cols ({"File", "Qty"}) and inserts each as a column into the wxListCtrl (self.UI.m_listCtrl2). The first column uses default left alignment; subsequent columns use center alignment (wxLIST_FORMAT_CENTER). Sets initial column widths with column 0 taking the available width minus 80 pixels and column 1 set to 80 pixels.
| CommonGUIModule Scheduler SetColumnsWidth | ( | ) |
Recalculate and apply column widths for the Schedule Editor list control.
Reads the current size of the wxListCtrl (self.UI.m_listCtrl2) and sets column 0 (file path) to the total width minus 80 pixels, and column 1 (quantity) to 80 pixels. Delegates the actual work to self:_SetColumnsWidth() via w.pcall() for error protection.
| CommonGUIModule SetCurrentFixtureOffset | ( | AxisID | , |
| value | , | ||
| inst | ) |
Set the current fixture offset value for the specified axis.
Reads the current fixture index via mc.mcFixtureGetCurrentIndex(). For older Mach4 versions (before build 4898), uses the SV_FIXTURE_G54 pound variable approach to set the offset. For newer versions, uses mc.mcFixtureSetOffset() to set the value directly.
| AxisID | (number) The axis identifier to set the offset for (e.g., mc.X_AXIS) |
| value | (number) The fixture offset value to set |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SetCurrentFixtureOffsetDRO | ( | value | , |
| AxisID | , | ||
| ... ) |
DRO callback to set the current fixture offset for the specified axis.
Converts the value to a number via w.tonumber() and delegates to CommonGUIModule.SetCurrentFixtureOffset() with the provided AxisID and current instance. Returns the original value string for the DRO display.
| value | (string) The new offset value entered in the DRO |
| AxisID | (number) The axis identifier to set the offset for (e.g., mc.X_AXIS) |
| ... | (any) Additional arguments passed by the DRO framework (ignored) |
| CommonGUIModule SetCurrentToolDRO | ( | selectedtool | , |
| ... ) |
Set the current tool number, updating pocket assignments and tool length offset as configured.
Reads ToolChangerMethod, AutoEnableToolLengthOffset, and ToolChangerType OEM parameters. For Auto tool changers (non-Random Memory ATC), prompts the operator to register the tool to a pocket number via a number input dialog. Calls w.SetCurrentTool() to set the tool, then updates pocket assignments in the tool table, removing the tool from any previously mapped pocket. For Random Memory ATC, clears the tool's pocket mapping. Updates the PreviousToolBeforeDrillBank status and optionally enables the tool length offset via mc.mcCntlSetOffsetIndex() if AutoEnableToolLengthOffset is "Yes".
| selectedtool | (number) The tool number to set as the current tool |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetDryRun | ( | on_off | ) |
Set the dry run mode on or off for the selected instance.
Checks manual mode via m.ManualModeIsActive(). If manual mode is active or the check fails, returns an error. If on_off is true, sets the DryRun OEM parameter string to "Yes" via w.eSetOEMParamValueString(). If on_off is false, sets it to "No".
| on_off | (boolean) True to enable dry run mode, false to disable it |
| UI SetErrorStyle | ( | is_error | ) |
Set the debug output background color to indicate error or normal state.
If is_error is true, sets the debug output text control background to a light red color to highlight that an error occurred. If false, restores the default background color. Calls Refresh() on the control to apply the change immediately. Has no effect if the dialog or debug output control is not available.
| is_error | (boolean) True to show error style (red background), false to restore normal |
| CommonGUIModule SetFeedrateDRO | ( | FeedRate | , |
| ... ) |
Set the active feedrate via MDI command when the machine is idle and enabled.
Updates the stop status via w.SetStopStatus(). If the machine state is IDLE and MACH_ENABLED is true, executes an "F<FeedRate>" MDI command via mc.mcCntlMdiExecute(). If the machine is not idle or not enabled, returns success without changing the feedrate.
| FeedRate | (number) The target feedrate value in current units per minute |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetFeedrateOverride | ( | percentage | ) |
Set the feedrate override percentage with hook support and bounds clamping.
Runs registered hooks via m.RunHooks("SetFeedrateOverride", percentage). Clamps the percentage to configured bounds via m.CheckFeedrateOverride(). Applies the override via mc.mcCntlSetFRO(). Returns the clamped percentage that was applied.
| percentage | (number) The desired feedrate override percentage (0-100 scale) |
| CommonGUIModule SetInhibitJoggingWhenNotHomedOverride | ( | on_off | , |
| inst | ) |
Set the jog inhibit override state for the specified instance.
Resolves the instance via w.GetUTI(). Validates on_off as a boolean (defaults to false if not boolean). Stores the value in INHIBIT_JOGGING_WHEN_NOT_HOMED_OVERRIDE_INST for the resolved instance index. When the override is true, jogging is permitted even when axes are not homed, bypassing the InhibitJoggingWhenNotHomed interlock.
| on_off | (boolean) True to enable the override (allow jogging when not homed), false to disable it |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SetJogModeContinuous | ( | ) |
Set the jog mode to continuous velocity jogging.
If continuous mode is not already active, stops all active jogging via m.StopJogging(-1), sets JOG_MODE_INC to false and JOG_MODE_CONT to true.
| CommonGUIModule SetJogModeIncremental | ( | ) |
Set the jog mode to incremental stepping.
If incremental mode is not already active, stops all active jogging via m.StopJogging(-1), sets JOG_MODE_INC to true and JOG_MODE_CONT to false.
| CommonGUIModule SetLaserPointerOffset | ( | ) |
Apply the stored laser pointer X and Y offsets to the corresponding pound variables.
Retrieves the offset variable indices via m.GetLaserPointerOffsetVars(). Reads the LaserPointerOffset_X and LaserPointerOffset_Y OEM register values via w.GetOEMRegValue() and writes them to the X and Y offset pound variables via mc.mcCntlSetPoundVar(). Logs errors via w.FunctionError() if any register read or API call fails.
| UI SetMCodeCounter | ( | ) |
Write the M-code counter enable/disable selection to the Mach4 parameter.
Reads the current selection index from UI.m_MCodeCounter and calls UI.SetParameter() to write it to mc.PV_PRTCNTL.
| UI SetMcodeNumber | ( | ) |
Write the M-code number value from the numeric control to the Mach4 parameter.
Reads the current value from UI.m_McodeNumber and calls UI.SetParameter() to write it to mc.PV_PRTINCM.
| UI SetParameter | ( | param | , |
| value | ) |
Set a Mach4 parameter to the specified value with logging.
Logs the parameter number and value via w.Log(), then calls w.SetParameter() to write the value to Mach4. Converts the value to a number via tonumber() before writing.
| param | (number) The Mach4 parameter constant (e.g., mc.PV_PRTSA) |
| value | (string|number) The value to set the parameter to |
| UI SetPartsCurrentProgram | ( | ) |
Write the current program parts value from the numeric control to the Mach4 parameter.
Reads the current value from UI.m_PartsCurrentProgram and calls UI.SetParameter() to write it to mc.PV_PRTSA.
| UI SetPartsRequired | ( | ) |
Write the parts required value from the numeric control to the Mach4 parameter.
Reads the current value from UI.m_PartsRequired and calls UI.SetParameter() to write it to mc.PV_PRTSN.
| UI SetPartsTotal | ( | ) |
Write the total parts value from the numeric control to the Mach4 parameter.
Reads the current value from UI.m_PartsTotal and calls UI.SetParameter() to write it to mc.PV_PRTST.
| CommonGUIModule SetRotaryAxisFeedrateMode | ( | axis_id | , |
| val | ) |
Set the feedrate mode for a rotary axis.
If the specified axis is a rotary axis (checked via AXIS_IS_ROTARY_INST), converts a boolean val to 0 or 1 if needed. Sets the VAL_AXIS_VALTYPE value for the axis via w.api("mcCntlSetValue") for the selected instance. A value of 0 sets normal feedrate mode; a value of 1 sets Constant Surface Speed mode.
| axis_id | (number) The axis identifier to configure (typically mc.A_AXIS through mc.C_AXIS) |
| val | (number|boolean) The feedrate mode value: 0 or false for normal, 1 or true for Constant Surface Speed |
| CommonGUIModule SetSelectedSpindleNumber | ( | inst | , |
| spindle | ) |
Set the selected spindle number for the specified Mach4 instance.
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| spindle | (number) The spindle number to set as selected |
| CommonGUIModule SetSelectedToolDRO | ( | SelectedTool | , |
| ... ) |
Set the currently selected tool number pound variable.
Writes the SelectedTool value to the mc.SV_CUR_SELECTED_TOOL pound variable via mc.mcCntlSetPoundVar(). Returns an error if the API call fails.
| SelectedTool | (number) The tool number to set as the selected tool |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetSpindleOverride | ( | percentage | ) |
Set the spindle override percentage with hook support and bounds clamping.
Runs registered hooks via m.RunHooks("SetSpindleOverride", percentage). Clamps the percentage to configured bounds via m.CheckSpindleOverride(). Converts from 0-100% scale to Mach4's internal representation and applies via mc.mcSpindleSetOverride(). Returns the clamped percentage that was applied.
| percentage | (number) The desired spindle override percentage (0-100 scale) |
| CommonGUIModule SetSpindleSpeedDRO | ( | Speed | , |
| ... ) |
Set the spindle speed via MDI command when the machine is idle and enabled.
Updates the stop status via w.SetStopStatus(). If the machine state is IDLE and MACH_ENABLED is true, executes an "S<Speed>" MDI command via mc.mcCntlMdiExecute(). If the machine is not idle, sets the commanded spindle RPM directly via w.api("mcSpindleSetCommandRPM").
| Speed | (number) The target spindle speed in RPM |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetToolDiameterDRO | ( | ToolDiameterOffset | , |
| ... ) |
Set the tool diameter (or radius) offset for the current tool and save the tool file.
Reads the current tool number via mc.mcToolGetCurrent(). If the screen is configured for diameter entry mode (m.IsToolSizeEntryDiameterMode()), divides the provided value by 2 to convert from diameter to radius before storing. Writes the radius value via mc.mcToolSetData() with MTOOL_MILL_RAD and saves the tool file via mc.mcToolSaveFile().
| ToolDiameterOffset | (number) The tool diameter or radius offset value to set in current units |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetToolLengthDRO | ( | ToolLengthOffset | , |
| ... ) |
Set the tool length offset for the current tool and optionally enable it.
Reads the AutoEnableToolLengthOffset OEM parameter. Sets the MTOOL_MILL_HEIGHT value for the current tool via mc.mcToolSetData() and saves the tool file via mc.mcToolSaveFile(). If AutoEnableToolLengthOffset is "Yes", also activates the tool length compensation by calling mc.mcCntlSetOffsetIndex() with the current tool number.
| ToolLengthOffset | (number) The tool length offset value to set in current units |
| ... | (any) Additional arguments accepted for screen DRO compatibility (unused) |
| CommonGUIModule SetToolSizeEntryMode | ( | mode | ) |
Configure the tool size entry mode for the Tool Offsets dialog and screen display.
Sets the tool size entry mode to either "radius" or "diameter". Validates the mode string and verifies a minimum Mach4 version (4.2.0.3230) is installed. Updates the Tool Offsets column definitions via mc.mcToolSetPropertyStr() to use the appropriate field names and types (MTOOL_MILL_RAD/MTOOL_MILL_DIA and their wear counterparts). Also updates the screen DRO label and DRO code for the ToolDiameterDRO(1) object to match the selected mode.
| mode | (string) The tool size entry mode - must be either "radius" or "diameter" |
| UI SetupDialog | ( | ) |
Initialize the block delete level checkboxes from the saved Mach4 profile values.
Reads the saved state for each of the ten block delete levels (0-9) from the MachMotion profile section via mc.mcProfileGetInt() and sets the corresponding checkbox value via SetValue(). This restores the previous block delete level selections when the dialog is opened.
| CommonGUIModule SetWarningMessage | ( | Message | , |
| TimeOut | , | ||
| EveryWhere | , | ||
| Title | , | ||
| Size | , | ||
| inst | ) |
Display a warning message - delegates to the wrapper module implementation.
This function was moved to the wrapper module. Calls w.SetWarningMessage() with all provided arguments and returns the result.
| Message | (string) The warning message text to display |
| TimeOut | (boolean) If true, the message will automatically time out and clear |
| EveryWhere | (boolean) If true, the message is displayed across all screens |
| Title | (string|nil) Optional title for the warning message |
| Size | (number|nil) Optional size hint for the message display |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ShowMachineStats | ( | ) |
Show machine statistics (currently commented out/disabled).
This function is currently disabled and not called. When active, it would read machine statistics from the Mach4 profile including total hours, spindle hours, distance traveled per axis, and M-code counts (M3, M4, M6), then display them in a message box.
| CommonGUIModule ShowMachMenu | ( | ) |
Show the Mach4 menu bar and persist the setting to the profile.
Calls scr.ShowMenu(true) to display the menu and writes HideMachMenu=0 to the MachMotion profile section so the setting persists across restarts.
| CommonGUIModule SingleBlockOff | ( | inst | ) |
Turn off single block mode for the specified instance.
Reads the current single block state via mc.mcCntlGetSingleBlock(). If single block is currently enabled (returns 1), disables it by calling mc.mcCntlSetSingleBlock() with 0.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SingleBlockOn | ( | inst | ) |
Turn on single block mode for the specified instance.
Reads the current single block state via mc.mcCntlGetSingleBlock(). If single block is currently disabled (returns 0), enables it by calling mc.mcCntlSetSingleBlock() with 1.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SingleBlockToggleBtn | ( | inst | ) |
Button handler to toggle single block mode on or off.
Logs the button press via w.OperatorLog(). Checks the current single block state via m.IsSingleBlockOn(). If currently on, calls m.SingleBlockOff() to disable it. Otherwise calls m.SingleBlockOn() to enable it.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SkipSpindleWarmUp | ( | ) |
Skip an active spindle warm-up cycle and mark warm-up as completed.
Requires password level 2. Executes registered hooks via m.RunHooks("SkipSpindleWarmUp"). If a warm-up is currently active (SpindleWarmUpActive == 1), sets the register to -1 to cancel it. Writes the current time to SpindleWarmUpOffTime and sets SpindleWarmUpCompleted to 2 to indicate the warm-up was skipped.
| (none) |
| CommonGUIModule SkipSpindleWarmUpBtn | ( | ) |
Button handler for skipping the spindle warm-up cycle.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SkipSpindleWarmUp() to perform the actual skip operation.
| CommonGUIModule SoftLimitToggleBtn | ( | ) |
Button handler to toggle software limits on or off.
Logs the button press via w.OperatorLog(). Requires the machine to be in IDLE state; returns an error if not idle. If software limits are currently disabled, enables them via w.SetSoftLimits(true). If software limits are currently enabled, disables them via w.SetSoftLimits(false).
| CommonGUIModule SpindleBrakeOff | ( | ) |
Release the spindle brake by executing the SpindleBrakeOff M-code script.
Runs registered hooks via m.RunHooks("SpindleBrakeOff"). If hooks allow continuation, executes the SpindleBrakeOff.mcs script via mc.mcScriptExecute() for the current instance. Updates the stop status before proceeding.
| CommonGUIModule SpindleBrakeOffBtn | ( | ) |
Button handler to release the spindle brake.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleBrakeOff() to perform the actual brake release.
| CommonGUIModule SpindleBrakeOn | ( | ) |
Apply the spindle brake by executing the SpindleBrakeOn M-code script.
Runs registered hooks via m.RunHooks("SpindleBrakeOn"). If hooks allow continuation, checks that the spindle is not currently running (mc.mcSpindleGetDirection must equal 0). If the spindle is running, logs the event and returns success without applying the brake. Clears the SpindleBrakeMacroDelay register, then executes SpindleBrakeOn.mcs via mc.mcScriptExecute(). Updates stop status before proceeding.
| CommonGUIModule SpindleBrakeOnBtn | ( | ) |
Button handler to apply the spindle brake.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleBrakeOn() to perform the actual brake application.
| CommonGUIModule SpindleFWD | ( | use_confirmation | ) |
Start the spindle in forward direction by executing the M3 M-code script.
Updates stop status and runs a spindle safety check via m.SpindleSafetyCheck(). Runs registered hooks via m.RunHooks("SpindleFWD"). Checks MST lock; if active, skips the command with a warning. Checks if SpindleDelayActive is already set to prevent duplicate commands. Optionally presents a CycleStartDialog confirmation before executing. If the machine is enabled, executes the m3.mcs script via mc.mcScriptExecutePrivate(). If the machine is not enabled, displays a warning message.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule SpindleFWDBtn | ( | use_confirmation | ) |
Button handler to start the spindle in forward direction.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleFWD() to perform the actual spindle forward operation.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule SpindleFWDWait | ( | use_confirmation | ) |
Start the spindle in forward direction and wait for it to reach speed.
Checks if the spindle is already running forward (MC_SPINDLE_FWD). If not, sets SpindleDelayActive to 2, calls m.SpindleFWD() to initiate forward rotation, then blocks via w.WaitOnCondition() until the SpindleDelayActive register returns to 0, indicating the spindle has reached the commanded speed.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before starting |
| CommonGUIModule SpindleOrient | ( | use_confirmation | ) |
Orient the spindle to its home position using M19.
Requires the machine to be enabled. Updates stop status and runs registered hooks via m.RunHooks("SpindleOrient"). If use_confirmation is true, presents a CycleStartDialog prompt before executing. Executes the orient command via mc.mcCntlMdiExecute(inst, "M19"). If the machine is not enabled, displays a warning message.
| use_confirmation | (boolean|nil) If true or nil (defaults to true), shows a cycle start confirmation dialog before executing |
| CommonGUIModule SpindleOrientBtn | ( | ) |
Button handler to orient the spindle.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleOrient() to perform the actual spindle orientation.
| CommonGUIModule SpindleOrientToggleBtn | ( | use_confirmation | ) |
Toggle spindle orient on or off based on current orient state.
If the spindle is currently oriented (m.IsSpindleOriented() returns true), calls m.SpindleStop() to stop the spindle. Otherwise calls m.SpindleOrient() with the provided confirmation flag to initiate spindle orientation.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before orienting |
| CommonGUIModule SpindleOverrideDecrement | ( | increment | ) |
Decrement the spindle override percentage by the configured or specified increment.
Reads the current spindle override and rounds it to the nearest integer. If no increment is provided, selects the SmallIncrement (<= 10%) or LargeIncrement (> 10%) from OEM parameters. Runs registered hooks via m.RunHooks("SpindleOverrideDecrement"). Subtracts the increment from the current percentage and delegates to m.SetSpindleOverride() to apply the clamped new value.
| increment | (number|nil) Amount to decrement. If nil, uses the configured small or large increment |
| CommonGUIModule SpindleOverrideIncrement | ( | increment | ) |
Increment the spindle override percentage by the configured or specified increment.
Reads the current spindle override and rounds it to the nearest integer. If no increment is provided, selects the SmallIncrement (< 10%) or LargeIncrement (>= 10%) from OEM parameters. Runs registered hooks via m.RunHooks("SpindleOverrideIncrement"). Adds the increment to the current percentage and delegates to m.SetSpindleOverride() to apply the clamped new value.
| increment | (number|nil) Amount to increment. If nil, uses the configured small or large increment |
| CommonGUIModule SpindleREV | ( | use_confirmation | ) |
Start the spindle in reverse direction by executing the M4 M-code script.
Updates stop status and runs a spindle safety check via m.SpindleSafetyCheck(). Runs registered hooks via m.RunHooks("SpindleREV"). Checks MST lock; if active, skips the command with a warning. Optionally presents a CycleStartDialog confirmation before executing. If the machine is enabled, executes the m4.mcs script via mc.mcScriptExecutePrivate(). If the machine is not enabled, displays a warning message.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule SpindleREVBtn | ( | use_confirmation | ) |
Button handler to start the spindle in reverse direction.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleREV() to perform the actual spindle reverse operation.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before executing |
| CommonGUIModule SpindleREVWait | ( | use_confirmation | ) |
Start the spindle in reverse and wait for it to reach speed.
Checks if the spindle is already running in reverse (MC_SPINDLE_REV). If not, sets SpindleDelayActive to 2, calls m.SpindleREV() to initiate reverse rotation, then blocks via w.WaitOnCondition() until the SpindleDelayActive register returns to 0, indicating the spindle has reached the commanded speed.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before starting |
| CommonGUIModule SpindleSafetyCheck | ( | inst | ) |
Verify that the machine is in a safe state to start the spindle.
Checks that the machine is currently enabled (MACH_ENABLED). If not enabled, displays a warning message and returns false. Reads the current GMS alarms and warnings via w.GetGMSAlarms() and w.GetGMSWarnings(). If any alarms or warnings are active, displays a warning prompting the operator to press Reset before starting the spindle.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule SpindleSpeedCheck | ( | ) |
Configure and apply the spindle speed check enable state and tolerance percentage.
Reads the SpindleSpeedCheckEnabled and SpindleSpeedCheckPercent OEM parameters for the selected instance. If SpindleSpeedCheckEnabled is "Yes", enables the spindle speed check via mc.mcSpindleSetSpeedCheckEnable(). Otherwise disables it. Clamps SpindleSpeedCheckPercent to a minimum of 1 if it is nil or less than 1, then applies it via mc.mcSpindleSetSpeedCheckPercent().
| CommonGUIModule SpindleStop | ( | ) |
Stop the spindle by executing the M5 M-code script.
Updates stop status and runs registered hooks via m.RunHooks("SpindleStop"). Checks MST lock; if active, skips the stop with a warning. Cancels any active spindle warm-up by setting SpindleWarmUpActive to -1. If a SpindleDelay is active, stops the spindle directly via mc.mcSpindleSetDirection(). Otherwise executes the m5.mcs script via mc.mcScriptExecutePrivate() to perform the full stop sequence.
| CommonGUIModule SpindleStopBtn | ( | ) |
Button handler to stop the spindle.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleStop() to perform the actual spindle stop.
| CommonGUIModule SpindleStopWait | ( | ) |
Stop the spindle and wait for the stop to complete.
Checks if the spindle is currently running (direction is not MC_SPINDLE_OFF). If running, sets SpindleDelayActive to 2, calls m.SpindleStop() to initiate the stop, then blocks via w.WaitOnCondition() until the SpindleDelayActive register returns to 0, indicating the stop sequence has completed.
| CommonGUIModule SpindleWarmUp | ( | ) |
Execute a spindle warm-up sequence at the configured idle speed.
Requires the machine to be enabled. Runs registered hooks via m.RunHooks("SpindleWarmUp"). Checks MST lock; if active, skips the warm-up with a warning. Reads SpindleWarmUpIdleSpeed and SpindleWarmUpMDIGCodeBeforeWarmUp OEM parameters to build the G-code command. If idle speed > 0, appends "M03 S{speed}"; otherwise appends "M03 M05". Presents a CycleStartDialog confirmation before executing the command via mc.mcCntlMdiExecute().
| CommonGUIModule SpindleWarmUpBtn | ( | ) |
Button handler to start the spindle warm-up sequence.
Logs the button press via w.OperatorLog() and delegates to CommonGUIModule.SpindleWarmUp() to perform the actual warm-up operation.
| CommonGUIModule SpindleWarmUpInterLockWithCycleStart | ( | ) |
Interlock spindle warm-up with cycle start to prevent running without completing warm-up.
Checks if the SpindleWarmUpInterLockWithCycleStart OEM parameter is set to "Yes". If so, and if a spindle warm-up is needed (IsSpindleWarmUpNeeded() returns true) and the machine is currently idle, calls CommonGUIModule.SpindleWarmUp() to initiate the warm-up and returns false to block cycle start. Returns true in all other cases to allow cycle start to proceed.
| CommonGUIModule StartCannedReciprocatingAxis | ( | axis_id | , |
| position_a | , | ||
| position_b | , | ||
| dwell | , | ||
| feedrate | ) |
Start a canned reciprocating axis cycle between two positions.
Starts a canned reciprocating cycle for the specified axis, oscillating between position_a and position_b with an optional dwell time and feedrate. Raises an error if the axis_id is not found in m.ReciprocatingAxes.
| axis_id | (number) The axis identifier for the reciprocating axis to start |
| position_a | (number) The first target position for the reciprocating cycle |
| position_b | (number) The second target position for the reciprocating cycle |
| dwell | (number) Dwell time in milliseconds between direction reversals |
| feedrate | (number) The feedrate to use during the reciprocating motion |
| CommonGUIModule StartCapturingToolPathMousePositions | ( | ) |
Start capturing tool path mouse positions on all tool path panels.
Initializes TP_PANEL_NAMES via m.screen.GetToolPathPanelNames() if not already set. Ensures the OSIG_TP_MOUSE_DN signal is set to false via w.SetSignalState(). For each panel in TP_PANEL_NAMES, sets "MouseCapture Mode" to "1" via h.SetObject() to enable mouse position reporting.
| CommonGUIModule StartDisableSequence | ( | ) |
Initiate the machine disable sequence with re-entrancy protection.
Guards against concurrent execution using w.FuncTracing["m.StartDisableSequence"]. If already in progress, logs a skip message and returns an error. Otherwise calls m._StartDisableSequence() via w.pcall() for protected execution. On error, returns a formatted error via w.FunctionError().
| CommonGUIModule StartEnableSequence | ( | async | ) |
Initiate the machine enable sequence with re-entrancy protection and jog inhibit management.
Runs the PreStartEnableSequence hook scripts. Guards against concurrent execution using w.FuncTracing["m.StartEnableSequence"]. If already in progress, logs a skip message and returns an error. Inhibits jogging on all axes via w.InhibitJogOnAllAxes() during the enable sequence, then releases the inhibit via w.ReleaseInhibitJogOnAllAxes() on completion. Calls m._StartEnableSequence() via w.pcall() for protected execution. Runs PostStartEnableSequence hook scripts on completion.
| async | (number|nil) If 1, runs the MachineEnable.mcs script asynchronously. Defaults to 1 |
| UI StartJog | ( | axis | , |
| direction | ) |
Start a velocity jog on the specified axis at the current slider rate and direction.
Reads the jog rate from the JogRateSlider UI element, applies it via mc.mcJogSetRate(), then starts a velocity jog on the specified axis in the specified direction via mc.mcJogVelocityStart(). This is a closure defined inside CommonGUIModule.JogOffHomeSwitchDialog().
| axis | (number) The axis index to jog (e.g., mc.X_AXIS) |
| direction | (number) The jog direction: 1 for positive, -1 for negative |
| CommonGUIModule StartJogging | ( | Axis | , |
| Direction | , | ||
| inst | ) |
Start jogging the specified axis in the given direction using external jog parameters.
Initializes the JOGGING_ACTIVE_AXIS table if not already set. If the axis is not already jogging, reads ExternalJogAccel, ExternalContJogRate, and ExternalJogIncremant from OEM parameters and applies them via mc.mcJogSetAccel(), mc.mcJogSetRate(), and mc.mcJogSetInc(). If JOG_MODE_CONT is active, starts velocity jogging via mc.mcJogVelocityStart(). If JOG_MODE_INC is active, starts incremental jogging via mc.mcJogIncStart(). Sets JOGGING_ACTIVE_AXIS[Axis] to true on success.
| Axis | (number) The axis index to jog (0-based, e.g., mc.X_AXIS) |
| Direction | (number) The jog direction: positive (1) or negative (-1) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule _LuaProfiling StartProfiler | ( | context | ) |
Start the Lua profiler with an optional context label.
Delegates to CommonGUIModule._LuaProfiling._StartProfiler() via pcall() for error protection. If an error occurs during profiler startup, displays the error via w.wxMessageBox(). The inner function replaces all mc.* functions with thin wrapper closures to enable call-level profiling of mc API usage, then starts the profiler module.
| context | (string|nil) Optional label to include in the generated profiling report filename |
| CommonGUIModule _LuaProfiling StartProfilerTimed | ( | context | , |
| seconds | ) |
Start the Lua profiler for a fixed duration in seconds.
Records the start time via os.clock() and calculates the end time as start + seconds. Sets the Timed flag to true so that UpdateTimedProfiling() will automatically stop the profiler when the duration expires. Then delegates to _StartProfiler() via pcall() to begin actual data collection. If an error occurs, displays it via w.wxMessageBox().
| context | (string|nil) Optional label to include in the generated profiling report filename |
| seconds | (number) Duration in seconds to run the profiler before automatically stopping |
| CommonGUIModule StartScreenTimers | ( | ) |
Start all screen-managed blink timers for normal and slow blink rates.
Stops and restarts the BlinkObjectNomal screen timer at 300ms and the BlinkObjectSlow screen timer at 600ms via scr.StopTimer() and scr.StartTimer(). Uses timer IDs from the SCREEN_TIMERS table.
| CommonGUIModule StepIntoSubPrograms | ( | ) |
Set single-block execution to step into sub-programs.
Sets the PV_CM1_SMB_BIT bit in the PV_CM1 Mach4 parameter to 1 via w.SetParameterBit(), causing single-block stepping to enter sub-program calls and execute each line of the sub-program individually.
| CommonGUIModule StepIntoSubProgramsToggle | ( | ) |
Toggle between step-into and step-over sub-program execution modes.
If step-into sub-programs is currently active (m.IsStepIntoSubPrograms() returns true), calls m.StepOverSubPrograms() to switch to step-over mode. Otherwise calls m.StepIntoSubPrograms() to switch to step-into mode.
| CommonGUIModule StepOverSubPrograms | ( | ) |
Set single-block execution to step over (not into) sub-programs.
Clears the PV_CM1_SMB_BIT bit in the PV_CM1 Mach4 parameter to 0 via w.SetParameterBit(), causing single-block stepping to treat sub-program calls as a single step rather than entering the sub-program.
| CommonGUIModule StopAuxiliaries | ( | ) |
Stop all auxiliary outputs and signals after a cycle stop or disable event.
Runs registered hooks via m.RunHooks("StopAuxiliaries"). Executes the MachineStop.mcs private script for the current instance. For each Mach4 instance, optionally turns off mist (OSIG_MISTON) and flood (OSIG_COOLANTON) based on MistOffCycleStop and FloodOffCycleStop OEM parameters. Resets the spindle-was-on flag. Resets the gear range if currently in range 19. Turns off all active output signals except the spindle brake output and any outputs listed in the IgnoreOutputsOnStop parameter. Also turns off any active auxiliary button outputs that are not listed in IgnoreAuxButtonsOnStop (for screen version 2).
| CommonGUIModule StopCannedReciprocatingAxis | ( | axis_id | , |
| stop_type | ) |
Stop a canned reciprocating axis cycle.
Stops the reciprocating cycle for the specified axis using the given stop type. Raises an error if the axis_id is not found in m.ReciprocatingAxes.
| axis_id | (number) The axis identifier for the reciprocating axis to stop |
| stop_type | (number) The stop mode to use when halting the axis cycle |
| CommonGUIModule StopCapturingToolPathMousePositions | ( | ) |
Stop capturing tool path mouse positions on all tool path panels.
Initializes TP_PANEL_NAMES via m.screen.GetToolPathPanelNames() if not already set. Ensures the OSIG_TP_MOUSE_DN signal is set to false. If mouse capture is currently active (as determined by m.IsCapturingToolPathMousePositions()), sets "MouseCapture Mode" to "0" on each panel in TP_PANEL_NAMES via h.SetObject().
| UI StopJog | ( | ) |
Stop all currently active jog motions on all axes.
Iterates over all axes from 0 to mc.MC_MAX_AXES. For each axis that is currently jogging (mc.mcJogIsJogging() returns 1), calls mc.mcJogVelocityStop() to halt the motion. This is a closure defined inside CommonGUIModule.JogOffHomeSwitchDialog().
| CommonGUIModule StopJogging | ( | Axis | ) |
Stop jogging on the specified axis or all axes.
If Axis is -1 and the jog mode is continuous, iterates over all axes and stops any that are actively jogging via mc.mcJogVelocityStop(), then clears JOGGING_ACTIVE_AXIS for all axes. If a specific axis is given, checks if it is jogging via mc.mcJogIsJogging() and stops it if so, then clears JOGGING_ACTIVE_AXIS for that axis.
| Axis | (number) The axis index to stop (0-based), or -1 to stop all axes |
| CommonGUIModule _LuaProfiling StopProfiler | ( | logpath | ) |
Stop the Lua profiler and generate a profiling report file.
Delegates the actual stop work to CommonGUIModule._LuaProfiling._StopProfiler() via w.pcall() for error protection. If an error occurs, displays it via w.wxMessageBox(). After stopping, restores the original mc table by swapping _G._orig_mc back to _G.mc (which was replaced with a wrapper table during profiling). The report is written to logpath, or a default path of the form 'screenprofiling{.<context>}.<timestamp>.log' if logpath is nil.
| logpath | (string|nil) Full path for the profiling report file. If nil, a default timestamped filename is used in the Mach directory |
| CommonGUIModule StopSpindleDuringToolPathRegen | ( | inst | ) |
Stop the spindle during a tool path regeneration operation.
Runs registered hooks via m.RunHooks("StopSpindleDuringToolPathRegen"). If hooks allow continuation, sets the spindle direction to MC_SPINDLE_OFF via mc.mcSpindleSetDirection(). This function is intended to be called before regenerating the tool path to ensure the spindle is safely stopped.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule StoreHeadShiftOffsets | ( | inst | ) |
Save the head shift offsets for all coordinate axes to OEM parameter storage.
Iterates from mc.X_AXIS to mc.MC_MAX_COORD_AXES - 1 and calls CommonGUIModule.StoreHeadShiftOffsetsAxis() for each axis with the given instance.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule StoreHeadShiftOffsetsAxis | ( | AxisID | , |
| inst | ) |
Save the head shift offset for a single axis to the OEM parameter store.
Reads the current head shift offset from pound variable (5081 + AxisID) via mc.mcCntlGetPoundVar(), then writes it to the OEM parameter 'HeadShiftOffset_<axis letter>' via w.SetOEMParamValue(). Returns an error if either the read or write fails.
| AxisID | (number) The axis index (e.g., mc.X_AXIS, mc.Y_AXIS, mc.Z_AXIS) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule StoreLastValueHeadShiftOffsets | ( | ) |
Save head shift offsets for all instances where the mode is "Restore Last Value".
Iterates over all instances and reads the 'HeadShiftOffsetsMode' OEM parameter for each. If the mode equals "Restore Last Value", calls CommonGUIModule.StoreHeadShiftOffsets() for that instance to persist the current offsets to OEM parameter storage.
| CommonGUIModule StoreLastValueWorkShiftOffsets | ( | ) |
Save work shift offsets for all instances where the mode is "Restore Last Value".
Iterates over all instances and reads the 'WorkShiftOffsetsMode' OEM parameter for each. If the mode equals "Restore Last Value", calls CommonGUIModule.StoreWorkShiftOffsets() for that instance to persist the current offsets to OEM parameter storage.
| CommonGUIModule StoreMachOverrides | ( | ) |
Save the current Mach4 speed overrides to the profile for later restoration.
Reads and stores the current Spindle Override via mc.mcSpindleGetOverride(), the Feedrate Override via mc.mcCntlGetFRO(), and the Rapid Rate Override via mc.mcCntlGetRRO(), writing each to the MachMotion section of the Mach4 profile via mc.mcProfileWriteDouble(). Returns an error triple if any read or write operation fails.
| UI StoreNotes | ( | ) |
Store the current notes from the dialog editor into the job file's in-memory notes table.
Clears jb.FileTable.Notes and repopulates it by iterating over all lines in the multi-line text control UI.notes_line using GetNumberOfLines() and GetLineText(). Each line is stored as jb.FileTable.Notes[tostring(i)].
| CommonGUIModule StoreWorkShiftOffsets | ( | inst | ) |
Save the work shift offsets for all coordinate axes to OEM parameter storage.
Iterates from mc.X_AXIS to mc.MC_MAX_COORD_AXES - 1 and calls CommonGUIModule.StoreWorkShiftOffsetsAxis() for each axis with the given instance.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule StoreWorkShiftOffsetsAxis | ( | AxisID | , |
| inst | ) |
Save the work shift offset for a single axis to the OEM parameter store.
Reads the current work shift offset from pound variable (5201 + AxisID) via mc.mcCntlGetPoundVar(), then writes it to the OEM parameter 'WorkShiftOffset_<axis letter>' via w.SetOEMParamValue(). Returns an error if either the read or write fails.
| AxisID | (number) The axis index (e.g., mc.X_AXIS, mc.Y_AXIS, mc.Z_AXIS) |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule SubSpindleForward | ( | use_confirmation | ) |
Run the sub-spindle in the forward direction, optionally prompting for confirmation.
Performs a spindle safety check via m.SpindleSafetyCheck(). If use_confirmation is true, displays a CycleStartDialog prompt asking the operator to confirm sub-spindle forward. If the operator cancels, returns success without running. On confirmation, executes the M103.mcs private script via mc.mcScriptExecutePrivate() to start the sub-spindle forward. Logs any script execution error via w.FunctionError().
| use_confirmation | (boolean) If true, displays a cycle start confirmation dialog before running |
| CommonGUIModule SubSpindleForwardToggle | ( | use_confirmation | ) |
Toggle the sub-spindle between forward and stopped states.
If the sub-spindle is currently on (m.IsSubSpindleOn() returns true), calls CommonGUIModule.SubSpindleStop() to stop it. Otherwise calls CommonGUIModule.SubSpindleForward() with the provided use_confirmation flag.
| use_confirmation | (boolean) If true, passes confirmation requirement to SubSpindleForward() |
| CommonGUIModule SubSpindleReverse | ( | use_confirmation | ) |
Run the sub-spindle in reverse direction, optionally prompting for confirmation.
Performs a spindle safety check via m.SpindleSafetyCheck(). If use_confirmation is true, displays a CycleStartDialog prompt asking the operator to confirm. If the operator cancels, returns success without running. On confirmation, executes the M104.mcs private script via mc.mcScriptExecutePrivate() to start the sub-spindle in reverse. Logs any script execution error via w.FunctionError().
| use_confirmation | (boolean) If true, displays a cycle start confirmation dialog before running |
| CommonGUIModule SubSpindleReverseToggle | ( | use_confirmation | ) |
Toggle the sub-spindle between reverse and stopped states.
If the sub-spindle is currently on (m.IsSubSpindleOn() returns true), calls CommonGUIModule.SubSpindleStop() to stop it. Otherwise calls CommonGUIModule.SubSpindleReverse() with the provided use_confirmation flag.
| use_confirmation | (boolean) If true, passes confirmation requirement to SubSpindleReverse() |
| CommonGUIModule SubSpindleStop | ( | ) |
Stop the sub-spindle by executing the M105 M-code script.
Retrieves the selected instance and its untagged instance index. Executes the M105.mcs private script file from the MCODE_DIRECTORY_INST path via mc.mcScriptExecutePrivate(). If the script execution fails, logs the error via w.FunctionError().
| CommonGUIModule SubSpindleUpdate | ( | ) |
Update sub-spindle analog output speed for all enabled instances.
Iterates over all Mach4 instances. For each instance where the sub-spindle is enabled, reads the SubSpindleCommandedRPM OEM register, SubSpindleScaleAnalog OEM register, and SubSpindleMaxRPM OEM parameter. If ScaleAnalog is "Yes", computes the analog output as (CommandedRPM / SubSpindleMaxRPM) * 10; otherwise clamps the commanded RPM to SubSpindleMaxRPM. Writes the computed speed to the SubSpindleAnalog OEM parameter register via w.SetOEMParamReg().
| CommonGUIModule SupportBtn | ( | ) |
Open the MachMotion support web page in the default browser.
Attempts to open https://machmotion.com/support-main using w.OpenURL(). Displays a warning message box if the page cannot be opened.
| CommonGUIModule Scheduler SwapItems | ( | idx2 | ) |
Swap the display data of two items in the Schedule Editor list control.
Exchanges all column values (file path and quantity) between the items at idx1 and idx2 in the wxListCtrl (self.UI.m_listCtrl2). After swapping, clears the current selection via self:ClearSelection() and sets the selection to idx2. Does nothing if idx1 == idx2 or either index is out of bounds.
| idx1 | (number) The zero-based index of the first item to swap |
| idx2 | (number) The zero-based index of the second item to swap |
| CommonGUIModule TeachLaserPointerOffsets | ( | ) |
Capture the current X and Y axis positions as the laser pointer offset values.
Reads the current X and Y axis work positions via mc.mcAxisGetPos(). Writes the X position to the LaserPointerOffset_X OEM register and the Y position to the LaserPointerOffset_Y OEM register via w.SetOEMRegValue(). Logs errors via w.FunctionError() if any register write fails. Then calls m.LaserPointerOn() to activate the laser pointer with the newly captured offsets.
| CommonGUIModule TeachWorkShiftOffsets | ( | AxisID | ) |
Teach the work shift offset for a single axis from the current machine position.
Reads the current tool offset for the specified axis from the appropriate pound variable (SV_CUR_TOOL_XLENGTH_REGISTER, YLENGTH, or ZLENGTH), then reads the current machine position via mc.mcAxisGetMachinePos(). Computes the work shift offset as (machine position - tool offset) and writes it to pound variable (5201 + AxisID) via mc.mcCntlSetPoundVar(). Returns an error if any read or write fails.
| AxisID | (number) The axis index (mc.X_AXIS, mc.Y_AXIS, or mc.Z_AXIS) |
| CommonGUIModule ToggleCapturingToolPathMousePositions | ( | ) |
Toggle tool path mouse position capture on or off.
Checks the current capture state via m.IsCapturingToolPathMousePositions(). If capture is active, stops it via m.StopCapturingToolPathMousePositions(). If capture is inactive, starts it via m.StartCapturingToolPathMousePositions(). Uses the selected instance from w.GetSelectedInstance().
| CommonGUIModule Scheduler ToggleEnable | ( | ) |
Toggle the scheduler active state when the machine is idle.
Checks the current machine state via mc.mcCntlGetState(). If the machine is in MC_STATE_IDLE, reads the current scheduler state from the OEM parameter identified by self.SCHED_STATE. If the scheduler is active (value == 1), deactivates it by setting the parameter to 0. If the scheduler is inactive, activates it via self:Enable(). Does nothing if the machine is not idle. Delegates the actual work to self:_ToggleEnable() via w.pcall() for error protection.
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule ToggleEnableBtn | ( | ) |
Button handler to toggle the machine enable state on or off.
Checks the current machine enable state via m.IsMachEnabled(). If the machine is currently enabled, calls m.DisableBtn() to disable it. Otherwise calls m.EnableBtn() to enable it.
| CommonGUIModule ToggleEnableResetBtn | ( | ) |
Button handler to toggle the enable/reset state based on current machine enable status.
Checks the current machine enable state via m.IsMachEnabled(). If the machine is currently enabled, calls m.DisableBtn() to disable it. Otherwise calls m.EnableReset() to perform the combined enable and reset sequence.
| CommonGUIModule ToggleMachMenu | ( | ) |
Toggle the Mach4 menu bar between hidden and visible.
Reads the 'HideMachMenu' profile value. If currently 0 (visible), hides the menu; if currently non-zero (hidden), shows the menu.
| CommonGUIModule ToggleOnScreenJogBtn | ( | ) |
Toggle the on-screen jog buttons panel on or off.
Checks the Enabled property of the JogButtonsGroup screen object. If the group is currently disabled (Enabled == "0"), calls m.OnScreenJogButtonsOn() to show the jog buttons. Otherwise calls m.OnScreenJogButtonsOff() to hide them.
| CommonGUIModule ToggleSpindleBrake | ( | inst | ) |
Toggle the spindle brake on or off based on its current state.
Reads the SpindleBrakeEnabled OEM parameter. If the feature is enabled, checks the current state of the SpindleBrakeOutput signal. If the brake is currently applied, calls m.SpindleBrakeOffBtn() to release it. Otherwise calls m.SpindleBrakeOnBtn() to apply it.
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule ToggleSpindleFWD | ( | use_confirmation | , |
| inst | ) |
Toggle the spindle between forward and stopped states.
If the spindle is currently on (m.IsSpindleOn() returns true), calls CommonGUIModule.SpindleStop() to stop it. Otherwise calls CommonGUIModule.SpindleFWDBtn() with the provided confirmation flag to start the spindle in forward direction.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before starting |
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule ToggleSpindleREV | ( | use_confirmation | , |
| inst | ) |
Toggle the spindle between reverse and stopped states.
If the spindle is currently on (m.IsSpindleOn() returns true), calls m.SpindleStop() to stop it. Otherwise calls m.SpindleREVBtn() with the provided confirmation flag to start the spindle in reverse.
| use_confirmation | (boolean|nil) If true, shows a cycle start confirmation dialog before starting |
| inst | (number) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule ToolChangeToTool | ( | toolIndex | , |
| inst | ) |
Execute a tool change to a specific tool number.
Checks MST lock, feedrate override, rapid override, and manual mode before proceeding. Builds the appropriate G-code string for the machine type (Lathe or Mill). Presents a CycleStartDialog confirmation and executes the tool change via mc.mcCntlMdiExecute().
| toolIndex | (number) The tool number to change to |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses selected instance |
| CommonGUIModule ToolLengthVerifyOff | ( | ) |
Disable tool length verification mode and reset the verify DRO display.
Sets TOOL_LENGTH_VERIFY to false, clears the ToolLengthVerifyDRO via CommonGUIModule.screen.SetToolLengthVerifyDRO("0"), and calls CommonGUIModule.screen.SetToolLengthVerifyButton(false) if that function exists.
| CommonGUIModule ToolLengthVerifyOn | ( | ) |
Enable tool length verification mode.
Sets the global TOOL_LENGTH_VERIFY flag to true, activating live tool length verification display via UpdateToolVerifyDRO().
| CommonGUIModule ToolLengthVerifyToggle | ( | ) |
Toggle tool length verification mode on or off.
If TOOL_LENGTH_VERIFY is currently true, calls CommonGUIModule.ToolLengthVerifyOff() to disable it. Otherwise calls CommonGUIModule.ToolLengthVerifyOn() to enable it.
| CommonGUIModule ToolSetterSelection | ( | FilterToolSetterTypes | , |
| OffsetTypes | ) |
Display the tool setter selection dialog for choosing the active manual or auto setter.
Creates and shows a non-modal dialog containing a list of tool setters filtered by FilterToolSetterTypes ("Manual" or "Auto") and OffsetTypes ("Tool" or "Fixture"). The selected tool setter name is written to the appropriate OEM register (ManualSetterSelection, AutoSetterSelection, ManualSetterFixtureSelection, or AutoSetterFixtureSelection) whenever the list selection changes. A timer (100ms) monitors for Mach shutdown and closes the dialog automatically if Mach is shutting down. An OK button closes the dialog and confirms the selection.
| FilterToolSetterTypes | (string) Filter type - "Manual" to show only manual setters, any other value for auto setters |
| OffsetTypes | (string|nil) Offset category - "Fixture" for fixture offsets, any other value (or nil) for tool offsets |
| CommonGUIModule UpdateAxesArrayCache | ( | ) |
Refresh the cached axis letter and short name arrays for all instances and axes.
Iterates over all Mach4 instances and all axes (X through MC_MAX_AXES-1). For each axis, calls m.GetAxisLetterName() and m.GetAxisShortName() to retrieve the current label strings and stores them in the AXIS_LETTER_ARRAY_TEXT_INST, AXIS_LETTER_ARRAY_TEXT_0_INST, AXIS_SHORT_NAME_ARRAY_INST, and AXIS_SHORT_NAME_ARRAY_0_INST per-instance cache tables. For instance 0, also updates the global AXIS_LETTER_ARRAY_TEXT, AXIS_LETTER_ARRAY_TEXT_0, AXIS_SHORT_NAME_ARRAY, and AXIS_SHORT_NAME_ARRAY_0 tables. Calls w.FunctionCompleted() on exit.
| CommonGUIModule UpdateCurrentToolAndPocketGlobals | ( | ) |
Update the global current tool number and tool pocket number arrays for all instances.
Iterates over all Mach4 instances and updates CURRENT_TOOL_NUMBER_INST and CURRENT_TOOL_POCKET_NUMBER_INST global arrays by calling w.GetCurrentTool() and w.GetCurrentToolPocket() for each instance.
| CommonGUIModule UpdateDoorInterlock | ( | ) |
Monitor and update the door interlock output based on machine state.
Reads the DoorSwitchInterlockEnabled OEM parameter and returns early if not enabled. Calls user.UserUpdateDoorInterlock() if defined, allowing user override. Reads the door switch input and output signals. Locks the door (deactivates output) when the machine is running (MC_STATE_FRUN or above, excluding macro hold and feed hold states) or when UserInterlock is true. Unlocks the door (activates output) after a configurable delay (DoorSwitchInterlockOutputDelay) once the machine returns to a non-running state.
| CommonGUIModule UpdateEnabledAxesCache | ( | ) |
Refresh the cached enabled state flags for all instances and axes.
Iterates over all Mach4 instances and all axes (X through MC_MAX_AXES-1). For each axis, calls mc.mcAxisIsEnabled() and stores the boolean result (enabled == 1) in AXIS_ENABLED_INST[_inst][axis]. For instance 0, also updates the global AXIS_ENABLED[axis] table. Calls w.FunctionCompleted() on exit.
| CommonGUIModule UpdateEndOfProgramTimeOn | ( | ) |
Check and reset the end-of-program output signal for all instances when its timer expires.
Iterates over all active instances and checks if the 'EndOfProgramTimeOn' OEM parameter is greater than 0 and a program-end start time has been recorded. If the elapsed time since end-of-program exceeds the configured duration and the 'EndOfProgramOutput' signal is configured, calls ResetEndOfProgramOutput() and clears the start time for that instance. Intended to be called periodically from a screen timer.
| CommonGUIModule UpdateGangSpindles | ( | ) |
Update all gang spindle command registers, feedback aggregation, and control signals.
Reads the commanded RPM from the gang spindle control source (either an auxiliary register or mc.mcSpindleGetMotorRPM()). For each gang spindle in the group, writes the commanded RPM (or percentage if command type is not RPM) to GangSpindleCommandRPMRegister. Aggregates load and RPM feedback from all engaged spindles using the configured averaging mode (Max, Min, or Average). Controls forward/reverse/stop signals for each spindle based on the current machine enable state and spindle direction. Publishes aggregated feedback values to GangSpindles registers and optionally feeds them back to Mach via mc.mcSpindleSetSensorRPM().
| UI UpdateGenericGridDialog | ( | ) |
Timer callback to keep the Generic Grid dialog alive and handle shutdown.
Checks whether Mach4 is shutting down via w.IsMachShuttingDown(). If shutting down, calls UI.CloseGenericGridDialog() to safely close the dialog. Returns true on normal execution to signal successful completion to the timer handler.
| CommonGUIModule UpdateGlobalWithActiveFixtureIndex | ( | ) |
Update the global active fixture offset index variables from the current Mach4 state.
Reads the current fixture index via w.GetCurrentFixtureIndex() for the selected instance and stores it in both the ACTIVE_FIXTURE_OFFSET_INDEX global and the per-instance ACTIVE_FIXTURE_OFFSET_INDEX_INST table.
| CommonGUIModule SearchGCode UpdateGrid | ( | ) |
Insert search matches into the GCode Search grid.
Iterates over the provided table of search results and populates the grid (self.UI.m_grid) with each match. The first row reuses the existing grid row; subsequent matches append new rows. Each row is set read-only and displays the line index in column 0 and the G-code text in column 1. Calls OnSize() after updating to resize columns.
| tbl | (table) Array of match tables, each with fields 'idx' (number) and 'gcode' (string) |
| UI UpdateHistoryBtns | ( | ) |
Update the enabled state of the MDI history navigation buttons.
Update the enabled state of the history navigation buttons.
Enables or disables the Previous (down arrow) and Next (up arrow) history navigation buttons based on the current position in the MDI history list. The Previous button is enabled when current_index > 1; the Next button is enabled when current_index < the total number of history entries.
Enables or disables the Previous (down arrow) and Next (up arrow) history navigation buttons based on the current position in the Lua script history list. The Previous button is enabled when current_index > 1; the Next button is enabled when current_index < the total number of history entries.
| CommonGUIModule UpdateHomedAxesCache | ( | ) |
Refresh the cached homed state flags for all instances and axes.
Iterates over all Mach4 instances and all axes (X through MC_MAX_AXES-1). For each axis, calls mc.mcAxisIsHomed() and stores the boolean result (homed == 1) in AXIS_IS_HOMED_INST[_inst][axis]. For instance 0, also updates the global AXIS_IS_HOMED[axis] table. Calls w.FunctionCompleted() on exit.
| CommonGUIModule UpdateLastGCodeFileName | ( | ) |
Monitor the loaded G-code filename and trigger header processing when the file changes.
For the currently selected instance, reads the LastGcodeFileName OEM register and compares it to the currently loaded G-code file via mc.mcCntlGetGcodeFileName(). If the filename has changed, is not empty, and is not a subroutine file, calls ProcessGcodeHeaderParameters() and UserProcessGcodeHeaderParameters() if defined, then updates the LastGcodeFileName register. Also tracks whether a G-code file has been opened (GCODE_FILE_WAS_OPEN_INST) and clears the register when the file is unloaded.
| CommonGUIModule UpdateLubeTimer | ( | ) |
Update the lube system timer and trigger lube cycles based on configured mode and action.
Handles two lube system modes based on LUBE_TYPE:
| CommonGUIModule UpdateMachFileRunTimeHistory | ( | run_time | ) |
Shift the G-code file run time history registers and store a new run time entry.
Iterates over all Mach4 instances. Shifts the existing history values stored in OEM registers MachFileRunTimeHistory_0 through MachFileRunTimeHistory_4 by one position (oldest entry is discarded). Writes the new run_time value to MachFileRunTimeHistory_0. If run_time is nil, uses the current run time from mc.mcCntlGetRunTime() for the instance.
| run_time | (number|nil) The run time value in milliseconds to record. If nil, uses the current Mach4 run time |
| CommonGUIModule UpdateMotionInhibit | ( | ) |
Release motion inhibit if the machine becomes idle.
Checks whether motion inhibit is currently active via m.IsMotionInhibitActive(). If active and the machine state has returned to IDLE (MACH_STATE == mc.MC_STATE_IDLE), calls m.MotionInhibitEnd() to release the inhibit signal.
| CommonGUIModule JobFile UpdateNotesOnlyToJobFile | ( | ) |
Write only the Notes section of the job file to disk, leaving all other fields unchanged.
Rebuilds the complete file data table from in-memory state (headers, data headers, pound variables from jb.FileTable.PoundVars, registers from jb.FileTable.Registers, and notes from jb.FileTable.Notes) and writes the result to the job file via w.WriteCSV(). If no file is loaded, prompts the user to save via jb:SaveAs(). This method preserves existing pound variable and register values rather than re-reading them from Mach4.
| UI UpdatePartCounters | ( | ) |
Refresh all Part Counter numeric controls with the current Mach4 parameter values.
Checks whether Mach4 is shutting down and closes the dialog if so. For each numeric control (current program parts, total parts, required parts, M-code number), updates the displayed value from the corresponding Mach4 parameter only if the control is not currently being edited by the user.
| CommonGUIModule UpdateRotaryAxesCache | ( | ) |
Refresh the cached rotary axis flags for all instances and axes.
Iterates over all Mach4 instances and all axes (X through MC_MAX_AXES-1). For each axis, calls m.IsAxisRotary() and stores the result in AXIS_IS_ROTARY_INST[_inst][axis]. For instance 0, also updates the global AXIS_IS_ROTARY[axis] table. Calls w.FunctionCompleted() on exit.
| UI UpdateRows | ( | MessageArray | , |
| RowNum | ) |
Populate the alarms grid with the provided alarm message array.
Iterates from 0 to RowNum-1, setting each grid cell value in column 0 to the corresponding string from MessageArray and marking each cell as read-only. This is a closure defined inside CommonGUIModule.CycleStartInhibitDialog().
| MessageArray | (table) Array of alarm message strings to display in the grid |
| RowNum | (number) The number of rows to populate in the alarms grid |
| CommonGUIModule UpdateScreenLayout | ( | ) |
Enforce single rotary axis constraint for V1 screens by disabling conflicting axes.
For non-V2 screens (SCREEN_VERSION != 2), checks which of A, B, or C axes is enabled via mc.mcAxisIsEnabled(). If the A axis is enabled, disables B and C. If B is enabled, disables A and C. If C is enabled, disables A and B. This ensures only one rotary axis is active at a time in the legacy screen layout. Returns an error if any axis disable API call fails.
| CommonGUIModule UpdateScreenWarningMessage | ( | ) |
Placeholder function stub for updating the screen warning message area (currently disabled).
This function is currently commented out and has no active implementation. It was intended to update the warning group, logo, alarm dialog button, and part info group screen objects based on the warning group width. No operation is performed when called.
| CommonGUIModule UpdateSignalLibraryArray | ( | ) |
Build the signal library arrays for limit switches, home signals, and special signals for all instances.
For each Mach4 instance, populates SIG_LIBRARY_INST[_inst] with callback functions keyed by signal ID. Registers handlers for:
| CommonGUIModule UpdateSpindleControls | ( | ) |
Update spindle control button states when spindle direction or delay state changes.
Reads SpindleDelayActive from OEM registers and SpindleDirection from mc.mcSpindleGetDirection() for the selected instance. If neither SpindleDirection nor SpindleDelayActive has changed since the last call, returns immediately to avoid unnecessary screen updates. Otherwise updates the cached values, calls m.screen.UpdateSpindleButtons() if available, and runs the "SpindleStateChanged" hooks via m.RunHooks().
| CommonGUIModule StackLight UpdateStackLight | ( | ) |
Update all configured stack light outputs based on current machine state and alarm conditions.
Returns early if the light stack is disabled or if user.UserUpdateStackLight() returns false. Updates self.Alarm and self.Warning from GMS, then updates self.mach_state and blink state from globals. For each configured color output (Red, Yellow, Green, White), retrieves the desired light state via the corresponding GetXxxStackLightState() method, applies blink logic if configured, and writes the output state via w.SetOEMParamSig().
| CommonGUIModule _LuaProfiling UpdateTimedProfiling | ( | ) |
Check whether a timed profiling session has expired and stop the profiler if so.
If the Timed flag is set to true, reads the current time via os.clock() and compares it against the EndTime set by StartProfilerTimed(). If the current time is at or past EndTime and the profiler is active, stops it via StopProfiler(). Resets StartTime, EndTime, and the Timed flag to their default values after stopping.
| CommonGUIModule UpdateToolVerifyDRO | ( | ) |
Update the tool length verify DRO display if tool length verification is active.
If TOOL_LENGTH_VERIFY is true and a manual tool setter is enabled, reads the ToolLengthVerifyMode OEM parameter. Computes the tool verify value from the current Z machine position minus the sum of the tool setter position and height. In "Verify Length" mode, sets the ToolLengthVerifyDRO to the raw ToolVerify value; otherwise sets it to the absolute difference between ToolVerify and the current tool length offset pound variable. Also enables the ToolLengthVerifyButton screen object if it exists.
| CommonGUIModule UPSPowerOffControl | ( | ) |
Initiate a delayed power-off sequence triggered by UPS loss of power.
Displays a 5-second countdown Please Wait dialog with a message indicating that the UPS has detected a loss of power. If the countdown completes without cancellation, calls m.PowerOff() to save data and shut down the OS. If the dialog is cancelled, logs an error via w.FunctionError().
| CommonGUIModule VerifyHoming | ( | IgnoreSaftyCheck | , |
| inst | ) |
Verify that all required axes are homed - delegates to the wrapper module implementation.
This function was moved to the wrapper module. Calls w.VerifyAllAxesAreHomed() with all provided arguments and returns the result.
| IgnoreSaftyCheck | (boolean|nil) If true, skips the safety interlock check |
| inst | (number|nil) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule WaitForHoming | ( | AxisID | , |
| inst | ) |
Wait for the machine to return to IDLE state after a homing operation.
Displays a "Machine is Homing..." PleaseWait dialog via w.PleaseWaitDialog() that waits for the machine state to reach MC_STATE_IDLE. If the wait is canceled or times out, displays a "Canceling Homing..." dialog and dereferences all non-absolute-encoder axes via m.DeReferenceAxis(). If AxisID is -1, dereferences all enabled coordinate axes; otherwise dereferences only the specified axis. After waiting, calls m.MotionController[_inst]:WaitForHomingToComplete() to allow the motion controller to finalize.
| AxisID | (number) The axis that was homed, or -1 if all axes were homed |
| inst | (number) The Mach4 instance handle. If not provided, uses current instance |
| CommonGUIModule WorkLightOff | ( | dontsaveoutputstate | ) |
Turn off the work light output signal and optionally save the off state.
Checks if the work light feature is enabled via m.IsWorkLightEnabled(). If enabled, sets the WorkLightOutput OEM parameter signal to false via w.SetOEMParamSig(). Unless dontsaveoutputstate is true, also sets the WorkLightWasOn OEM parameter to 0 to persist the off state across restarts.
| dontsaveoutputstate | (boolean|nil) If true, skips saving the off state to the WorkLightWasOn parameter |
| CommonGUIModule WorkLightOn | ( | ) |
Turn on the work light output signal and save the on state.
Checks if the work light feature is enabled via m.IsWorkLightEnabled(). If enabled, sets the WorkLightOutput OEM parameter signal to true via w.SetOEMParamSig(). Also sets the WorkLightWasOn OEM parameter to 1 so the light state is restored on the next startup.
| CommonGUIModule WorkLightToggle | ( | ) |
Toggle the work light on or off based on its current state.
Checks the current state via m.IsWorkLightOn(). If the work light is on, calls m.WorkLightOff() to turn it off. Otherwise calls m.WorkLightOn() to turn it on.
| CommonGUIModule JobFile WriteDataToMach | ( | ) |
Dispatch job file data writing to the appropriate version handler.
Reads the file version via jb:GetFileVersion(). If the version exceeds the current supported version (jb.FileVersion), shows a warning message and returns nil. Otherwise dispatches to jb:_WriteDataToMach_V2() for version 2 or jb:_WriteDataToMach_V1() for version 1.
| CommonGUIModule YesNoDialog | ( | yes_no_table | ) |
Display a modal Yes/No dialog with bitmap buttons for binary user decisions.
Creates a styled dialog with a question text, Yes and No bitmap buttons with optional note labels below each button, and optional custom action buttons displayed above the Yes/No buttons. The dialog is shown modally and returns the wxWidgets ID of the button pressed. Action buttons execute user-supplied callback functions without closing the dialog.
| yes_no_table | (table) Configuration table with keys:
|
| CommonGUIModule ZAxisLockToggleBtn | ( | ) |
Button handler placeholder for Z-axis lock toggle.
Logs the button press via w.OperatorLog() and returns a successful completion status. This function is a placeholder stub - the Z-axis lock feature is not fully implemented.
| CommonGUIModule ZeroABC | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Zero the A, B, and C axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroMultipleAxes() with an axis table of {mc.A_AXIS, mc.B_AXIS, mc.C_AXIS}, passing through the IgnoreConfirmationDialogs and IgnoreEditMode flags.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check |
| CommonGUIModule ZeroABCBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the A, B, and C axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroABC() with the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroABtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the A axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.A_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroAllBtn | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Button handler to zero all axis fixture offsets simultaneously.
Sets the instance to the selected instance. Checks edit mode (unless IgnoreEditMode is true) and requires the machine to be in IDLE state. Updates stop status. Calls user.UserZeroAllStart() hook if defined. If ConfirmationDialogs is "Yes" and IgnoreConfirmationDialogs is false, prompts for confirmation. Calls user.UserZeroAll() if defined (and saves fixture offsets); otherwise iterates over all coordinate axes and calls m.ModifyAxisPosition() to set each to 0.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog. Defaults to false |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check. Defaults to false |
| CommonGUIModule ZeroAllDROBtn | ( | ) |
Zero all axis DROs by computing offsets from current machine positions.
Logs the operation, then iterates over all coordinate axes (X through MC_MAX_COORD_AXES-1). For each axis, reads the current machine position via mc.mcAxisGetMachinePos() and converts it to current units via w.ConvertUnits(). Stores the negated value in DRO_MODE_OFFSET_ARRAY to make all displayed DRO values read zero.
| CommonGUIModule ZeroAxis | ( | AxisID | , |
| IgnoreConfirmationDialogs | , | ||
| IgnoreEditMode | ) |
Zero the fixture offset for a single axis with optional confirmation and edit mode checks.
Sets the instance to the selected instance. Checks edit mode (unless IgnoreEditMode is true) and requires the machine to be in IDLE state before zeroing. Updates stop status. Calls user.UserZero{Axis}Start() hook if defined. If ConfirmationDialogs is "Yes" and IgnoreConfirmationDialogs is false, prompts the operator for confirmation via w.MessageDialog(). Calls user.UserZero{Axis}() if defined; otherwise calls m.ModifyAxisPosition() to set the axis position to 0 and saves fixture offsets.
| AxisID | (number) The axis identifier to zero (e.g., mc.X_AXIS, mc.Z_AXIS) |
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog. Defaults to false |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check. Defaults to false |
| CommonGUIModule ZeroBBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the B axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.B_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroCBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the C axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.C_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroDROBtn | ( | Axis | ) |
Zero a single axis DRO by computing an offset from the current machine position.
Logs the operation, reads the current machine position for the specified axis via mc.mcAxisGetMachinePos(), converts it to current units via w.ConvertUnits(), and stores the negated value in DRO_MODE_OFFSET_ARRAY to make the displayed DRO value read zero.
| Axis | (number) The axis index constant (e.g., mc.X_AXIS, mc.Z_AXIS) |
| CommonGUIModule ZeroMultipleAxes | ( | AxisID | , |
| IgnoreConfirmationDialogs | , | ||
| IgnoreEditMode | ) |
Zero the fixture offset for one or more axes simultaneously.
Sets the instance to the selected instance and retrieves the selected instance handle. Accepts either a single axis ID or a table of axis IDs. For each axis, validates the axis ID and builds a combined short name string for display and logging. Checks edit mode (unless IgnoreEditMode is true) and requires the machine to be in IDLE state. Calls user.UserZeroMultipleAxesStart() if defined. If ConfirmationDialogs is "Yes" and IgnoreConfirmationDialogs is false, prompts the operator for confirmation. For each axis, calls user.UserZeroMultipleAxes() if defined, otherwise calls m.ModifyAxisPosition() to set the position to 0. Sets OFFSETS_WERE_MODIFIED to true on completion.
| AxisID | (number|table) A single axis identifier or a table of axis identifiers to zero (e.g., mc.X_AXIS or {mc.X_AXIS, mc.Y_AXIS}) |
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog. Defaults to false |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check. Defaults to false |
| CommonGUIModule ZeroXBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the X axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.X_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroXY | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Zero the X and Y axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroMultipleAxes() with an axis table of {mc.X_AXIS, mc.Y_AXIS}, passing through the IgnoreConfirmationDialogs and IgnoreEditMode flags.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check |
| CommonGUIModule ZeroXYBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the X and Y axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroXY() with the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroXYZ | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Zero the X, Y, and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroMultipleAxes() with an axis table of {mc.X_AXIS, mc.Y_AXIS, mc.Z_AXIS}, passing through the IgnoreConfirmationDialogs and IgnoreEditMode flags.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check |
| CommonGUIModule ZeroXYZBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the X, Y, and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroXYZ() with the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroXZ | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Zero the X and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroMultipleAxes() with an axis table of {mc.X_AXIS, mc.Z_AXIS}, passing through the IgnoreConfirmationDialogs and IgnoreEditMode flags.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check |
| CommonGUIModule ZeroXZBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the X and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroXZ() with the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroYBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the Y axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.Y_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroYZ | ( | IgnoreConfirmationDialogs | , |
| IgnoreEditMode | ) |
Zero the Y and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroMultipleAxes() with an axis table of {mc.Y_AXIS, mc.Z_AXIS}, passing through the IgnoreConfirmationDialogs and IgnoreEditMode flags.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| IgnoreEditMode | (boolean|nil) If true, skips the edit mode check |
| CommonGUIModule ZeroYZBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the Y and Z axes fixture offsets simultaneously.
Delegates to CommonGUIModule.ZeroYZ() with the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |
| CommonGUIModule ZeroZBtn | ( | IgnoreConfirmationDialogs | ) |
Button handler to zero the Z axis fixture offset.
Delegates to CommonGUIModule.ZeroAxis() with mc.Z_AXIS and the provided IgnoreConfirmationDialogs flag.
| IgnoreConfirmationDialogs | (boolean|nil) If true, skips the confirmation dialog |