Table of Contents

Session Message Panel

The model is MachiningProject.SessionMessageHost.

MachiningProject is assigned from the Player Panel.

Layout

  • Top Message Filter ToolBar
    • Message Type Filter SubMenu
      • NC CheckBox
      • Progress CheckBox
      • Error CheckBox
    • Message Text Filter Input
      • Message Text Filter Input Text Area
      • Message Text Filter Reset Button
    • Export Button
  • Central Message Table

Central Message Table

The model of Central Message Table is SessionMessageHost.MessageCollection.

Only take last 1000 filtered elements in the MessageCollection by GetFliteredList(FilterFlag, string) to show for user experience. Find the usage example in the code:

internal static void DemoUseSessionMessageHost(MachiningProject project)
{
    SessionMessageHost sessionMessageHost = project.SessionMessageHost;

    SessionMessageHost.FilterFlag filterFlags =
        SessionMessageHost.FilterFlag.NC |
        SessionMessageHost.FilterFlag.Progress |
        SessionMessageHost.FilterFlag.Error;
    string filterText = null;
    var filteredSessionMessageList = sessionMessageHost
        .GetFliteredList(filterFlags, filterText);

    foreach (var sessionMessage in filteredSessionMessageList)
    {
        //M.I.: Message Index.
        Console.Write($"M.I.: {sessionMessage.Index}; Role: {sessionMessage.MessageRoleText}");

        // For SessionMessageHost.FilterFlag.NC
        var nc = sessionMessage.DirectInstantSourceCommand;
        if (nc != null)
            Console.Write($"Message/NC: {nc.Line}; File: {nc.FilePath}; LineNo: {nc.GetLineNo()}; ");

        // For SessionMessageHost.FilterFlag.Progress or Error.
        var multiTagMessage = sessionMessage.MultiTagMessage;
        if (multiTagMessage != null)
            Console.WriteLine($"Message/NC: {multiTagMessage.Message}");
        var exception = sessionMessage.Exception;
        if (exception != null)
            Console.WriteLine($"Message/NC: {exception.Message}");
    }
    File.WriteAllLines("output-session-messages.txt",
        filteredSessionMessageList.Select(m =>
        $"Msg[{m.Index}][{m.MessageRoleText}]: {m}"));
}

In the table, show the columns: Role, NC/Message.

Add update table event to CollectionItemChanged. The updating process has to be called by Loose Manner for user experience.

Tip

On window desktop application (WPF), consider use textarea instead of datagrid to MessageTable for better performance. Use padding to show the different columns. And use the font in the textarea that with consistent width.

Note

The message display should be real-time.

Behavior of Export Button

Export ALL filtered elements in the MessageCollection by GetFliteredList(FilterFlag, string).

SignalR Implementation (Webapi Only)

SessionMessageHub provides real-time message updates with method GetSessionMessages(string filterFlags, string filterText, int limit) and event SessionMessagesUpdated. SessionMessageService monitors SessionMessageHost_CollectionItemChanged and broadcasts updates. The service uses LooseRunner for non-blocking async operations. The JavaScript component connects to /sessionMessageHub to receive real-time message updates.

Source Code Path

See this page for git repository.

WPF Application Source Code Path

  • Play/SessionMessagePanel

Web Page Application Source Code Path

  • wwwroot/player/session-message-panel.js (Vue component)
  • Players/PlayerController.cs (REST API - GetSessionMessages endpoint)
  • Players/SessionMessageService.cs (Business logic)
  • Players/SessionMessageHub.cs (SignalR Hub for real-time updates)