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

Go to the source code of this file.

Functions

TurnScreenV01 MachineScreenLoadScript ()
 Initialize signal handlers for the Turn screen on load.
TurnScreenV01 MachineScreenPLCScript ()
 PLC script update function for the Turn screen.
TurnScreenV01 MachineScreenLowPriorityLoop ()
 Periodic low-priority screen update loop for the Turn screen.
TurnScreenV01 PositionDisplayUnLocked ()
 Switch the position display to Unlocked mode on the Turn screen.
TurnScreenV01 PositionDisplayLocked ()
 Switch the position display to Locked mode on the Turn screen.
TurnScreenV01 PositionDisplayDROMode ()
 Switch the position display to DRO mode on the Turn screen.
TurnScreenV01 UpdateDROPostions ()
 Update the DRO mode axis position displays on the Turn screen.
TurnScreenV01 UpdateFeedrateDROLabels ()
 Update the feedrate mode label and current velocity DRO on the Turn screen.
TurnScreenV01 OperatorPanelInitialization ()
 Initialize operator panel controls and configure DRO editability based on connected hardware.
TurnScreenV01 OnCannedCyclesPost ()
 Handle post-processing actions after a canned cycle is executed.
TurnScreenV01 UpdateDRODecimalCount ()
 Update the decimal precision format of all DRO controls on the Turn screen.
TurnScreenV01 UpdateOperatorPanelControls ()
 Update operator panel controls with current jog rate values.
TurnScreenV01 UpdateToolOffsetsTab ()
 Update the Tool Offsets tab UI controls based on OEM configuration parameters.
TurnScreenV01 UpdateToolPathPanels (Panel)
 Update the visibility of tool path display panels on the Turn screen.
TurnScreenV01 UpdateAxisDROs ()
 Placeholder for axis DRO updates on the Turn screen.
TurnScreenV01 UpdateMBSequenceBitData ()
 Update PLC-controlled button states from Modbus sequence bit data.

Function Documentation

◆ MachineScreenLoadScript()

TurnScreenV01 MachineScreenLoadScript ( )

Initialize signal handlers for the Turn screen on load.

Registers screen signal library callbacks for all configured Mach4 instances. Currently registers a handler for mc.OSIG_TOOL_CHANGE which:

  • Sets the "ToolChangeActiveText" label LED to yellow when active
  • Sets the "ToolChangeLED" state
  • Changes the "ToolNumberText" background to yellow (#FFFF00) when tool change is active, or grey (#DDDDDD) when inactive
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenLowPriorityLoop()

TurnScreenV01 MachineScreenLowPriorityLoop ( )

Periodic low-priority screen update loop for the Turn screen.

Called repeatedly at low priority to refresh Turn-specific screen elements:

  • Tool offset DROs (X, Z, X wear, Z wear, tip radius, tip direction, tool slide side)
  • Tool tip direction image (updates only when direction changes from TIP_DIRECTION_LAST)
  • Spindle mode text and commanded speed DRO (G97 RPM mode vs CSS mode)
  • Spindle range min/max label showing current pulley range and RPM limits
  • G50 speed limit label with yellow highlight when limit is below max RPM
    Note
    Documentation generated by AI on 2026-03-03

◆ MachineScreenPLCScript()

TurnScreenV01 MachineScreenPLCScript ( )

PLC script update function for the Turn screen.

Called on every PLC cycle to perform Turn-specific PLC updates. Invokes TurnScreenV01.UpdateMBSequenceBitData() to refresh the state of PLC-controlled buttons such as Chuck and Tailstock.

Note
Documentation generated by AI on 2026-03-03

◆ OnCannedCyclesPost()

TurnScreenV01 OnCannedCyclesPost ( )

Handle post-processing actions after a canned cycle is executed.

Switches the main window tab to the first tab (index 0), then displays a "Please Wait" dialog with a 500ms time delay while showing a "Refreshing Controls..." message. After the delay, refreshes all button-type controls on the screen.

Note
Documentation generated by AI on 2026-03-03

◆ OperatorPanelInitialization()

TurnScreenV01 OperatorPanelInitialization ( )

Initialize operator panel controls and configure DRO editability based on connected hardware.

Detects which operator panels are configured via w.GetConfiguredOperatorPanels() and sets up the Rapid Override, Spindle Override, and Feedrate Override DROs as either editable or read-only accordingly:

  • Panel X15-10-01 (oprs[1]): Rapid override editable unless m_enablerro is set; spindle override editable
  • Panel X15-10-04 (oprs[4] or oprs[23]): Both rapid and spindle overrides read-only
  • No panel: All overrides editable When an operator panel is present, the screen jog rate control is disabled and feedrate override DRO is set to read-only. Without a panel, jog rate maps to "Jog Rate %" (code 391).
    Note
    Documentation generated by AI on 2026-03-03

◆ PositionDisplayDROMode()

TurnScreenV01 PositionDisplayDROMode ( )

Switch the position display to DRO mode on the Turn screen.

Hides the Unlocked and Locked position display groups and shows the DRO position display group. Disables all tool offset, fixture offset, G52, and work shift offset UI groups. Sets the DRO mode button to green and clears other button colors. All axis and tool DROs are set to editable (Editor = "1"). Calls m.screen.InitializeAxisPositionGroup() to reinitialize axis display elements.

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

◆ PositionDisplayLocked()

TurnScreenV01 PositionDisplayLocked ( )

Switch the position display to Locked mode on the Turn screen.

Hides the Unlocked and DRO position display groups and shows the Locked position display group. Disables all tool offset, fixture offset, G52, and work shift offset UI groups. Sets all axis and tool DROs to read-only (Editor = "3"). Sets the Locked button to green and clears other button colors. After updating the UI, saves the tool file via mc.mcToolSaveFile() and saves fixture offsets via m.SaveFixtureOffsets(). Calls the optional user.UserPositionDisplayLocked hook if defined.

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

◆ PositionDisplayUnLocked()

TurnScreenV01 PositionDisplayUnLocked ( )

Switch the position display to Unlocked mode on the Turn screen.

Hides the Locked and DRO position display groups and shows the Unlocked position display group. Enables tool offset, fixture offset, G52, and work shift offset UI groups. Sets the Unlocked button to green and the position display mode button to yellow. The X axis DRO is locked (Editor = "3") while all other axis and tool DROs are set to editable (Editor = "1"). Enables the CalculateToolLengthBtn if the ToolSetterPositionType is "Fixed", or if CALCULATE_SETTER_POSITION is true for non-fixed types. Calls m.screen.InitializeAxisPositionGroup() and the optional user.UserPositionDisplayUnLocked hook.

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

◆ UpdateAxisDROs()

TurnScreenV01 UpdateAxisDROs ( )

Placeholder for axis DRO updates on the Turn screen.

This function is intentionally left empty as axis DRO updates are not required for the Turn screen configuration. It exists to satisfy the interface contract defined by the common screen module.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateDRODecimalCount()

TurnScreenV01 UpdateDRODecimalCount ( )

Update the decimal precision format of all DRO controls on the Turn screen.

Reads decimal count preferences from the Mach4 profile and applies format strings to feedrate, tool offset, and axis position DRO controls. Feedrate DROs use the "DecimalCountFeedrate" preference, tool DROs use "DecimalCountTool", and axis DROs (position, to-go, DRO mode, and machine position) use per-axis precision from mc.mcAxisGetPrecision(). Defaults to "4" if axis precision is nil or empty.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateDROPostions()

TurnScreenV01 UpdateDROPostions ( )

Update the DRO mode axis position displays on the Turn screen.

When the DROPositionDisplayGroup is visible (Hidden == "0"), iterates over all coordinate axes and reads the machine position via mc.mcAxisGetMachinePos(). Applies the following transformations before displaying:

  • Diameter mode: X axis value is doubled when CURRENT_DIAMETER_MODE == 1
  • Unit conversion: scales by 25.4 or divides by 25.4 when default and current units differ
  • Applies per-axis DRO_MODE_OFFSET_ARRAY offset and rounds to 4 decimal places
    Note
    Documentation generated by AI on 2026-03-03

◆ UpdateFeedrateDROLabels()

TurnScreenV01 UpdateFeedrateDROLabels ( )

Update the feedrate mode label and current velocity DRO on the Turn screen.

Reads the current feedrate mode (G98/G99) from modal group 5 and updates the velocity unit label and current velocity DRO accordingly:

  • G98 (per minute): Displays blended velocity directly; label shows "inch/min" or "mm/min"
  • G99 (per revolution): Computes units-per-revolution from blended velocity and true spindle RPM; label shows "inch/rev" or "mm/rev". Displays 0 if spindle or velocity is not positive. The unit prefix (inch or mm) is determined by MACHINE_CURRENT_UNITS.
    Note
    Documentation generated by AI on 2026-03-03

◆ UpdateMBSequenceBitData()

TurnScreenV01 UpdateMBSequenceBitData ( )

Update PLC-controlled button states from Modbus sequence bit data.

Reads OEM parameter values for M10, M11, M25, and M26 PLC sequence numbers, then queries the Modbus device for the current bit state of each sequence. Updates the Chuck and Tailstock button colors and labels based on the retrieved bit states. If the mb.GetBit function is not available, no updates are performed.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateOperatorPanelControls()

TurnScreenV01 UpdateOperatorPanelControls ( )

Update operator panel controls with current jog rate values.

If an operator panel is detected (OPERATOR_PANEL_STATUS == true), reads the "mm_JogRateCont" register from the MachMotion device and updates the JogSpeed screen control with the retrieved value.

Note
Documentation generated by AI on 2026-03-03

◆ UpdateToolOffsetsTab()

TurnScreenV01 UpdateToolOffsetsTab ( )

Update the Tool Offsets tab UI controls based on OEM configuration parameters.

Reads several OEM parameters (ToolSetterType, ManualGageBlockHeight, ToolSetterHeight, ToolSetterPositionType, ToolChangerMethod) and configures the visibility and enabled state of tool offset UI groups accordingly.

  • Manual vs Auto tool setter: toggles manual/auto offset groups and gage block visibility
  • Auto vs Manual tool changer: toggles auto/manual tool change groups and related buttons
  • Fixed vs Random tool setter position: toggles fixed/random offset groups and calculate button
    Returns
    (nil) No meaningful primary return value
    (boolean) Success flag - true if all parameters retrieved and UI updated successfully
    (string) Status message from w.FunctionCompleted() or w.FunctionError()
    Note
    Documentation generated by AI on 2026-03-03

◆ UpdateToolPathPanels()

TurnScreenV01 UpdateToolPathPanels ( Panel )

Update the visibility of tool path display panels on the Turn screen.

Controls which tool path view panels are shown or hidden based on the specified panel number. Supports configurations of 0 (no panel), 1, 2, 3, or 4 simultaneous tool path views. If probing mode is active, forces Panel to 0 and shows the probing group. Sets the tool path view mode to "5" for ToolPathA(1).

Parameters
Panel(number) The panel layout to display (0 = none, 1 = single, 2 = dual, 3 = triple, 4 = quad)
Returns
(nil) No meaningful primary return value
(boolean) Success flag - true if operation completed successfully
(string) Status message from w.FunctionCompleted()
Note
Documentation generated by AI on 2026-03-03