/// <summary> /// Retrieve a list of T commands from RepRap g-code. /// </summary> /// <returns></returns> public void UpdateRepRapIDList() { //Return parameter. _printViewModel.AvailibleRepRapIDList = new ObservableCollection <string>(); //Delimit the g-code string by lines then spaces. string[][] repRapGCodeArr = GCodeStringParsing.GCodeTo2DArr(_gCodeFileManagerModel.UploadedGCodeModel.GCodeStr); //Move through each g-code line. if (repRapGCodeArr != null) { for (int line = 0; (line < repRapGCodeArr.Length) && (repRapGCodeArr != null); line++) { if (repRapGCodeArr[line] != null && !String.IsNullOrWhiteSpace(repRapGCodeArr[line][0])) { //Remove comments from the g-code line. string[] uncommentedRepRapLine = GCodeStringParsing.RemoveGCodeComments(repRapGCodeArr[line]); if ((uncommentedRepRapLine != null) && (uncommentedRepRapLine.Length != 0) && (!String.IsNullOrWhiteSpace(uncommentedRepRapLine[0])) && (uncommentedRepRapLine[0][0] == 'T')) { _printViewModel.AvailibleRepRapIDList.Add(uncommentedRepRapLine[0]); } } } } _printViewModel.RepRapIDCount = _printViewModel.AvailibleRepRapIDList.Count; _printViewModel.UpdateAvailibleRepRapIDList(); }
/// <summary> /// Interpret a command series and return an array of commands /// </summary> /// <param name="commandSeries"></param> /// <returns></returns> public List <string> InterpretCommandSet(string commandSet) { //Remove comments before processing. commandSet = GCodeStringParsing.RemoveGCodeComments(commandSet); //The first character of the command set is reserved for the command set serial character. if ((commandSet.Length >= 7) && (commandSet.Substring(1, 6) == "Center")) { return(InterpretCenterAxes(commandSet)); } else if ((commandSet.Length >= 7) && (commandSet.Substring(1, 6) == "Origin")) { return(InterpretSetOrigin(commandSet)); } else if ((commandSet.Length >= 13) && (commandSet.Substring(1, 12) == "SetMinMaxPos")) { return(InterpretSetMinMaxPosition(commandSet)); } else if ((commandSet.Length >= 9) && (commandSet.Substring(1, 8) == "RetractZ")) { return(InterpretRetractZ(commandSet)); } else if ((commandSet.Length >= 6) && (commandSet.Substring(1, 5) == "Pause")) { return(InterpretPause(commandSet)); } else if ((commandSet.Length >= 11) && (commandSet.Substring(1, 10) == "PrintPause")) { return(InterpretPrintPause(commandSet)); } else if ((commandSet.Length >= 15) && (commandSet.Substring(1, 14) == "SwitchMaterial")) { return(InterpretSwitchMaterial(commandSet)); } return(null); }