Table of Contents

Glossary: Session Progress (Messages)

What Is SessionProgress?

SessionProgress (SessionProgress) is the message host object that manages all messages generated during a HiNC scripting session. It serves as the central hub for logging, filtering, and exporting diagnostic information.

Note

The older name SessionMessageHost is marked [Obsolete]. Use SessionProgress instead.


Message Types

HiNC provides four message types, each with a distinct severity and typical display behavior:

Type Command Description Typical Display
Message Message General informational message Message panel
ProgressMessage ProgressMessage Progress-related status update Progress bar / status area
WarningMessage WarningMessage Warning (does not interrupt execution) Message panel (yellow)
ErrorMessage ErrorMessage Error (may affect execution flow) Message panel (red)

Usage Examples

Message("Starting simulation");
ProgressMessage("Loading workpiece...");
WarningMessage("No cutting engagement detected in this segment");
ErrorMessage("Workpiece does not exist");

Message Tags

Messages can be tagged for filtering. Standard tags include "Error" and "Warning". When exporting messages, you can filter by one or more tags.


Displaying Messages

All messages are automatically recorded in the session message host and appear in the HiNC UI message panel. Progress messages additionally update the progress bar.

Accessing the Message Host

var messageHost = SessionProgress;

Exporting Messages

AppendMessagesToFile writes messages to a text file, with optional tag-based filtering:

// Export all messages
AppendMessagesToFile("Output/messages.txt");

// Export only errors and warnings
AppendMessagesToFile("Output/errors.txt", "Error", "Warning");
Tip

Export messages after simulation to create a persistent log for debugging or reporting.


Common Patterns

Logging Simulation Progress

Message("Simulation started");
PlayNcFile("NC/file1.nc");
Message($"Simulation complete. Total steps: {StepCount}");
AppendMessagesToFile("Output/log.txt");

Conditional Warnings

if (StepCount == 0)
{
    WarningMessage("No steps were executed");
}

Error Guard

if (Workpiece == null)
{
    ErrorMessage("Workpiece does not exist");
    return;
}

Per-Step Logging via Events

SessionStepBuilt += (preStep, curStep) => {
    if (curStep != null)
        Message($"Step {curStep.StepIndex}: ToolId={curStep.ToolId}");
};
PlayNcFile("NC/file1.nc");

Step Selection Logging

MachiningStepSelected += (step) => {
    if (step != null && step.ToolId == 1)
        ProgressMessage($"Tool 1 step selected at line {step.LineNo}");
};

Message Lifecycle

  1. Messages are generated during script execution via the four message commands
  2. All messages are stored in the SessionProgress host object
  3. Messages persist until the session ends or the runtime is reset
  4. ResetRuntime() clears event handlers but does not clear previously recorded messages
  5. Messages can be exported at any point using AppendMessagesToFile

See Also