Loading files
/*
* Copyright (C) 2021 Sienci Labs Inc.
*
* This file is part of gSender.
*
* gSender is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, under version 3 of the License.
*
* gSender is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with gSender. If not, see <https://www.gnu.org/licenses/>.
*
* Contact for information regarding this program and its license
* can be sent through gSender@sienci.com or mailed to the main office
* of Sienci Labs Inc. in Waterloo, Ontario, Canada.
*
*/
import _ from "lodash";
import GrblHalLineParserResultATCI from "server/controllers/Grblhal/GrblHalLineParserResultATCI";
import GrblHalLineParserResultAutoconfig from "server/controllers/Grblhal/GrblHalLineParserResultAutoconfig";
import GrblHalLineParserResultCompleteStatus from "server/controllers/Grblhal/GrblHalLineParserResultCompleteStatus";
import GrblHalLineParserResultJSON from "server/controllers/Grblhal/GrblHalLineParserResultJSON";
import GrblHalLineParserResultSettingDetails from "server/controllers/Grblhal/GrblHalLineParserResultSettingDetails";
import GrblHalLineParserResultSpindle from "server/controllers/Grblhal/GrblHalLineParserResultSpindle";
import GrblHalErrorDescription from "./GrblHalErrorDescription";
import LineParserResultAlarm from "../shared/LineParserResultAlarm";
import GrblHalLineParserResultAlarmDetails from "./GrblHalLineParserResultAlarmDetails";
import GrblHalLineParserResultAXS from "./GrblHalLineParserResultAXS";
import LineParserResultEcho from "../shared/LineParserResultEcho";
import LineParserResultError from "../shared/LineParserResultError";
import LineParserResultFeedback from "../shared/LineParserResultFeedback";
import GrblHalLineParserResultGroupDetail from "./GrblHalLineParserResultGroupDetail";
import LineParserResultHelp from "../shared/LineParserResultHelp";
//import GrblHalLineParserResultCode from './GrblHalLineParserResultCode';
import GrblHalLineParserResultInfo from "./GrblHalLineParserResultInfo";
import GrblHalLineParserResultOk from "./GrblHalLineParserResultOk";
import GrblHalLineParserResultParameters from "./GrblHalLineParserResultParameters";
import GrbHalLineParserResultParserState from "./GrblHalLineParserResultParserState";
import GbrlHalLineParserResultSDCard from "./GrblHalLineParserResultSDCard";
import GrblHalLineParserResultSettingDescription from "./GrblHalLineParserResultSettingDescription";
import LineParserResultSettings from "../shared/LineParserResultSettings";
import GrblHalLineParserResultStartup from "./GrblHalLineParserResultStartup";
import GrblHalLineParserResultStatus from "./GrblHalLineParserResultStatus";
import GrblHalLineParserResultTool from "./GrblHalLineParserResultTool";
import GrblHalLineParserResultVersion from "./GrblHalLineParserResultVersion";
class GrblHalLineParser {
parse(line) {
const parsers = [
// <Alarm:11|MPos:0.000,0.000,0.000|Bf:128,1024|FS:0,0|Pn:PXYZHS|WCO:10.000,0.000,0.000|WCS:G54|A:|Sc:|MPG:0|H:0|T:0|TLR:0|FW:grblHAL>
GrblHalLineParserResultCompleteStatus,
// <Alarm:#|[...]>
//GrblHalLineParserResultCode,
// <>
GrblHalLineParserResultStatus,
// ok
GrblHalLineParserResultOk,
// error:x
LineParserResultError,
// ALARM:
LineParserResultAlarm,
// [MSG:ATCI:key:value|another_key:value]
GrblHalLineParserResultATCI,
// [MSG:Info: Autoconfig: TLS=1, ATC=0]
GrblHalLineParserResultAutoconfig,
// [G38.2 G54 G17 G21 G91 G94 M0 M5 M9 T0 F20. S0.] (v0.9)
// [GC:G38.2 G54 G17 G21 G91 G94 M0 M5 M9 T0 F20. S0.] (v1.1)
GrbHalLineParserResultParserState,
// [G54:0.000,0.000,0.000]
// [G55:0.000,0.000,0.000]
// [G56:0.000,0.000,0.000]
// [G57:0.000,0.000,0.000]
// [G58:0.000,0.000,0.000]
// [G59:0.000,0.000,0.000]
// [G28:0.000,0.000,0.000]
// [G30:0.000,0.000,0.000]
// [G92:0.000,0.000,0.000]
// [TLO:0.000]
// [PRB:0.000,0.000,0.000:0]
GrblHalLineParserResultParameters,
// [HLP:] (v1.1)
LineParserResultHelp,
// [VER:] (v1.1)
GrblHalLineParserResultVersion,
// [AXS:]
GrblHalLineParserResultAXS,
// [SETTING:1|27|Step idle delay|milliseconds|5|####0||65535|0|0]
GrblHalLineParserResultSettingDescription,
// 7 - SLB_LASER, enabled as spindle 0, DLIRV, current
GrblHalLineParserResultSpindle,
// "120","X-axis acceleration","mm/sec^2","Acceleration. Used for motion planning to not exceed motor torque and lose steps.",
GrblHalLineParserResultSettingDetails,
//[SETTINGGROUP:5|0|Coolant]
GrblHalLineParserResultGroupDetail,
//[ALARMCODE:16||Power on selftest (POS) failed.]
GrblHalLineParserResultAlarmDetails,
// [ERRORCODE:62||Directory listing failed.]
GrblHalErrorDescription,
// Tool
GrblHalLineParserResultTool,
// [FILE:/test.gcode|SIZE:100]
GbrlHalLineParserResultSDCard,
// [XXXX:] (v1.1)
GrblHalLineParserResultInfo,
// [echo:] (v1.1)
LineParserResultEcho,
// [] (v0.9)
// [MSG:] (v1.1)
LineParserResultFeedback,
// $xx
LineParserResultSettings,
// Grbl X.Xx ['$' for help]
GrblHalLineParserResultStartup,
/// {...} json blob
GrblHalLineParserResultJSON,
];
for (const parser of parsers) {
const result = parser.parse(line);
if (result) {
_.set(result, "payload.raw", line);
return result;
}
}
return {
type: null,
payload: {
raw: line,
},
};
}
}
export default GrblHalLineParser;
6bc89d73dThis file is pinned to the selected release. Download the original to open it in your design tool.