Mission Panel
The Mission Panel manages NC program loading, editing, and preparation for simulation in the geometry-only HiNC application.
Panel Layout
Left side:
NC Program Management PanelProgram Files SectionLoad NC FilebuttonNew NC Filebutton- List view of loaded NC programs
Removebutton (to remove selected program)
Program Properties Section- File name and path display
- Program description input field
- Program size and line count display
Program Association Section- Tool mapping controls:
- Dropdown to select T-code
- Dropdown to select corresponding tool from Tool House
Apply Mappingbutton
- Work offset mapping controls:
- Dropdown to select work offset code (G54, G55, etc.)
- X, Y, Z offset value inputs
Apply Offsetbutton
- Tool mapping controls:
Right side:
NC Program Editor/Viewer- Syntax-highlighted G-code editor
- Line numbers
SavebuttonValidatebutton- Validation results display area
Show Toolpath Previewtoggle button
Bottom:
Toolpath Preview Panel(shown when preview is toggled on)- 3D view of the toolpath
- Color-coded display based on operation type or feed rate
- Basic camera controls
Behavior
Loading NC Program Files
When the user clicks the Load NC File button:
- Open a file selection dialog showing NC files (*.nc, *.cnc, *.ngc, etc.)
- After selection, validate the file format
- Add the file to the list of NC programs
- Display the file in the editor/viewer
- Update program properties display
// Example code
public void LoadNCFile(string filePath)
{
if (File.Exists(filePath))
{
// Read and validate NC file
string programContent = File.ReadAllText(filePath);
// Create a new program object
NCProgram program = new NCProgram
{
FilePath = filePath,
FileName = Path.GetFileName(filePath),
Content = programContent,
LineCount = programContent.Split('\n').Length,
FileSize = new FileInfo(filePath).Length
};
// Add to the project's mission
machiningProject.MachiningMission.Programs.Add(program);
// Update the NC program list view
UpdateProgramListView();
// Select the newly added program
SelectProgram(program);
// Display the program in the editor
LoadProgramIntoEditor(program);
}
}
Creating a New NC Program
When the user clicks the New NC File button:
- Create a new empty NC program object
- Add it to the list of programs
- Load it into the editor with minimal template content
- Allow the user to start editing
public void CreateNewNCProgram()
{
// Create a basic template for a new NC program
string templateContent = "%\nO0001\n(NEW PROGRAM)\n\nG90 G40 G17\nG21 (MM)\n\n(PROGRAM BODY)\n\nM30\n%";
// Create a new program object
NCProgram program = new NCProgram
{
FileName = "NewProgram.nc",
Content = templateContent,
LineCount = templateContent.Split('\n').Length,
IsNew = true
};
// Add to the project's mission
machiningProject.MachiningMission.Programs.Add(program);
// Update the NC program list view
UpdateProgramListView();
// Select the newly added program
SelectProgram(program);
// Display the program in the editor
LoadProgramIntoEditor(program);
}
Tool Mapping
When the user sets up a tool mapping and clicks Apply Mapping:
- Extract the T-code from the selected dropdown
- Get the corresponding tool from the Tool House based on the selection
- Add or update the mapping in the mission's tool map
- Update the display to show the active mapping
public void ApplyToolMapping(string tCodeStr, int toolHousePosition)
{
if (int.TryParse(tCodeStr.Substring(1), out int tCode))
{
// Get the tool from the tool house
var tool = machiningProject.MachiningToolHouse[toolHousePosition];
if (tool != null)
{
// Update or add the mapping
machiningProject.MachiningMission.ToolMap[tCode] = toolHousePosition;
// Update the display
UpdateToolMappingDisplay();
}
}
}
Work Offset Mapping
When the user sets up a work offset and clicks Apply Offset:
- Extract the offset code (G54, G55, etc.)
- Create a vector from the X, Y, Z input values
- Add or update the offset in the mission's work offset map
- Update the display to show the active offset
public void ApplyWorkOffset(string offsetCode, double x, double y, double z)
{
// Create the offset vector
Vec3d offset = new Vec3d(x, y, z);
// Update or add the mapping
machiningProject.MachiningMission.WorkOffsetMap[offsetCode] = offset;
// Update the display
UpdateWorkOffsetDisplay();
}
Validating NC Program
When the user clicks the Validate button:
- Parse the current program content in the editor
- Check for syntax errors
- Verify tool references against the tool map
- Check for unsupported G/M codes
- Display validation results in the results area
public void ValidateProgram()
{
// Get the current content from the editor
string programContent = GetEditorContent();
// Create a validator
NCProgramValidator validator = new NCProgramValidator(machiningProject);
// Perform validation
ValidationResult result = validator.Validate(programContent);
// Display results
ClearValidationResultsDisplay();
if (result.IsValid)
{
DisplayValidationSuccess("Program validation successful.");
}
else
{
foreach (var error in result.Errors)
{
DisplayValidationError(error);
}
}
}
Displaying Toolpath Preview
When the user toggles the Show Toolpath Preview:
- If toggled on: a. Parse the NC program b. Generate a toolpath using the geometry-only simulation engine c. Render the toolpath in the preview panel d. Show the preview panel
- If toggled off: a. Hide the preview panel
public void ToggleToolpathPreview(bool showPreview)
{
if (showPreview)
{
// Get the current program
NCProgram program = GetSelectedProgram();
// Generate toolpath (simplified for geometry-only)
Toolpath toolpath = ToolpathGenerator.GenerateFromNCProgram(
program.Content,
machiningProject.MachiningMission.ToolMap,
machiningProject.MachiningMission.WorkOffsetMap,
machiningProject.MachiningEquipment);
// Render the toolpath
RenderToolpathPreview(toolpath);
// Show the preview panel
toolpathPreviewPanel.Visibility = Visibility.Visible;
}
else
{
// Hide the preview panel
toolpathPreviewPanel.Visibility = Visibility.Collapsed;
}
}
Data Structure
The panel operates primarily on the MachiningMission of the MachiningProject:
public class MachiningMission
{
public List<NCProgram> Programs { get; set; } = new List<NCProgram>();
public Dictionary<int, int> ToolMap { get; set; } = new Dictionary<int, int>();
public Dictionary<string, Vec3d> WorkOffsetMap { get; set; } = new Dictionary<string, Vec3d>();
// Other mission-related properties
}
public class NCProgram
{
public string FilePath { get; set; }
public string FileName { get; set; }
public string Content { get; set; }
public long FileSize { get; set; }
public int LineCount { get; set; }
public bool IsNew { get; set; }
public string Description { get; set; }
// Other program-related properties
}
Integration with Main Application
The Mission Panel is activated when the user selects the Mission item in the Navigation Menu. It accesses and modifies the MachiningMission component of the current MachiningProject instance.
When changes are made in this panel, the following notifications should be sent:
ProgramListChanged- When programs are added or removedProgramContentChanged- When program content is editedToolMapChanged- When tool mappings are updatedWorkOffsetMapChanged- When work offsets are updated
These notifications allow other components (particularly the Player panel) to update their behavior accordingly when preparing for or executing the simulation.