New Cnc/Mazak/ machine integration mirroring the Fagor/Mitsubishi FTP pattern: MazakConnectionConfig, IMazakFtpClient, MazakFtpClient, MazakMachine (ICncMachine). Transfers EIA/ISO G-code text over FTP to Smooth-family controllers. Mazatrol CMT (proprietary binary) out of scope. Design (verified against Mazak Matrix EIA manual + field reports): - Filenames preserved verbatim; no O#### rename, no extension append. - Symmetric ResolvePath for Read/Write/Delete (avoids ISS-020 class; Delete resolved too, unlike copied Mitsubishi source). - Validator = full passthrough for Mazak (EIA permits ';' EOB, '[ ]', '#'; restrictive Fanuc checks would false-reject valid programs). - Port 21 default, -porta=23 for Smooth Ai IIS variant. - ProgramDirectory site-specific, no default. Wiring: CncManufacturer.Mazak, ArgParser 'mazak' token, CncMachineFactory. Tests: MazakMachineTests (unit), MazakMachineIntegrationTests (FTP-stub roundtrip + symmetry guard), Mazak cases in validator/factory tests. Docs: README Controller Mazak section + table row; ISS-021 (constraints, EIA-option requirement), ISS-022 (Mitsubishi delete asymmetry logged). NOT build-verified (no .NET toolchain in build env) — verify on Windows. Projects: NcProgramManager, NcProgramManager.Tests Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
93 lines
4.6 KiB
C#
93 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using NcProgramManager.Cnc.Models;
|
|
|
|
namespace NcProgramManager
|
|
{
|
|
internal static class ArgParser
|
|
{
|
|
public static InputArgs Parse(string[] args)
|
|
{
|
|
var inputArgs = new InputArgs();
|
|
var arguments = new List<string>(args);
|
|
|
|
var help = arguments.Find(it => new Regex("-help.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(help))
|
|
{
|
|
inputArgs.mostraHelp = true;
|
|
return inputArgs;
|
|
}
|
|
|
|
var azione = arguments.Find(it => new Regex("-azione=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
inputArgs.azione = azione.Substring(8);
|
|
|
|
var manufacturer = arguments.Find(it => new Regex("-manufacturer=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(manufacturer))
|
|
{
|
|
string mfgVal = manufacturer.Substring(14).Trim().ToLowerInvariant();
|
|
switch (mfgVal)
|
|
{
|
|
case "heidenhain": inputArgs.manufacturer = CncManufacturer.Heidenhain; break;
|
|
case "siemens": inputArgs.manufacturer = CncManufacturer.Siemens; break;
|
|
case "mitsubishi": inputArgs.manufacturer = CncManufacturer.Mitsubishi; break;
|
|
case "fagor": inputArgs.manufacturer = CncManufacturer.Fagor; break;
|
|
case "mazak": inputArgs.manufacturer = CncManufacturer.Mazak; break;
|
|
default: inputArgs.manufacturer = CncManufacturer.Fanuc; break;
|
|
}
|
|
}
|
|
|
|
string tipo = arguments.Find(it => new Regex("-tipo=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
inputArgs.tipo = !string.IsNullOrEmpty(tipo) ? Int32.Parse(tipo.Substring(6)) : 3;
|
|
|
|
var ip = arguments.Find(it => new Regex("-ip=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(ip))
|
|
inputArgs.ip = ip.Substring(4);
|
|
|
|
var porta = arguments.Find(it => new Regex("-porta=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(porta))
|
|
inputArgs.porta = porta.Substring(7);
|
|
|
|
var nodo = arguments.Find(it => new Regex("-nodo=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
inputArgs.nodoHssb = !string.IsNullOrEmpty(nodo) ? Int32.Parse(nodo.Substring(6)) : -1;
|
|
|
|
var username = arguments.Find(it => new Regex("-username=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(username))
|
|
inputArgs.username = username.Substring(10);
|
|
|
|
var password = arguments.Find(it => new Regex("-password=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(password))
|
|
inputArgs.password = password.Substring(10);
|
|
|
|
var compatibility = arguments.Find(it => new Regex("-compatibility.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(compatibility))
|
|
inputArgs.compatibilityMode = true;
|
|
|
|
var commento = arguments.Find(it => new Regex("-commento=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(commento))
|
|
inputArgs.commentoProgramma = commento.Substring(10);
|
|
|
|
var path = arguments.Find(it => new Regex("-path=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(path))
|
|
inputArgs.pathCNC = Int16.Parse(path.Substring(6));
|
|
|
|
var pathprogramma = arguments.Find(it => new Regex("-pathprogramma=.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(pathprogramma))
|
|
inputArgs.pathLocaleProgramma = pathprogramma.Substring(15);
|
|
|
|
var hasToolOffsetData = arguments.Find(it => new Regex("-tooloffset.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(hasToolOffsetData))
|
|
inputArgs.hasToolOffsetData = true;
|
|
|
|
var hasWorkZeroOffsetData = arguments.Find(it => new Regex("-workzero.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(hasWorkZeroOffsetData))
|
|
inputArgs.hasWorkZeroOffsetData = true;
|
|
|
|
var debugMode = arguments.Find(it => new Regex("-debug.*", RegexOptions.IgnoreCase).IsMatch(it));
|
|
if (!string.IsNullOrEmpty(debugMode))
|
|
inputArgs.debugMode = true;
|
|
|
|
return inputArgs;
|
|
}
|
|
}
|
|
}
|