public bool G_Check(string g_str, int row_index, ref DataStore step_compile_data, ref ModalCode_Fanuc_M modal_state) { _errorMessage = ""; if(satisfactoryG_M.IndexOf(g_str) == -1) { _errorMessage = "(Line:" + row_index + "): " + "系统中不存在该G指令: " + g_str; return false; } else { try { float g_value = (float)Convert.ToDouble(g_str.Trim('G')); if(g_value < 10f) g_str = "G0" + g_value.ToString(); } catch { _errorMessage = "(Line:" + row_index + "): " + "系统中不存在该G指令: " + g_str; return false; } int modal_index = modal_state.ModalIndex(g_str); //立即执行G代码(非模态G代码) if(modal_index == -1) { switch(g_str) { case "G04": step_compile_data.ImmediateAdd((char)ImmediateMotionType.Pause); break; case "G28": step_compile_data.ImmediateAdd((char)ImmediateMotionType.AutoReturnRP); break; default: //Todo: 有很多未完成的功能 _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持该G代码: " + g_str; return false; } } //模态代码 else {//1 level switch(modal_index) { case 0: if(g_str == "G00") step_compile_data.motion_type = (int)MotionType.DryRunning; else if(g_str == "G01") step_compile_data.motion_type = (int)MotionType.Line; else if(g_str == "G02") step_compile_data.motion_type = (int)MotionType.Circular02; else step_compile_data.motion_type = (int)MotionType.Circular03; break; case 1: if(g_str != "G94") { _errorMessage = "(Line:" + row_index + "): " + "目前系统只支持G94(每分钟进给),暂不支持" + g_str; return false; } break; case 2: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持09组G代码"; return false; case 3: if(g_str != "G17") { _errorMessage = "(Line:" + row_index + "): " + "目前系统只支持G17(XY平面选择),暂不支持" + g_str; return false; } break; case 4: if(g_str != "G21") { _errorMessage = "(Line:" + row_index + "): " + "目前系统只支持G21(公制输入),暂不支持" + g_str; return false; } break; case 5: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持10组固定循环G代码"; return false; case 6: //G90、G91 绝对、增量 //Todo: break; case 7: //G40, G41, G42 刀具半径补偿 //Todo: 坐标会发生一些变化 if(g_str == "G40") step_compile_data.ImmediateAdd((char)ImmediateMotionType.RadiusCompensationCancel); else if(g_str == "G41") step_compile_data.ImmediateAdd((char)ImmediateMotionType.RadiusCompensationLeft); else step_compile_data.ImmediateAdd((char)ImmediateMotionType.RadiusCompensationRight); break; case 8: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持11组比例缩放G代码"; return false; case 9: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持04组存储形成检测功能G代码"; return false; case 10: //G43, G44, G49 刀具长度补偿 //Todo: 坐标会发生一些变化 if(g_str == "G43") step_compile_data.ImmediateAdd((char)ImmediateMotionType.LengthCompensationPositive); else if(g_str == "G44") step_compile_data.ImmediateAdd((char)ImmediateMotionType.LengthCompensationNegative); else step_compile_data.ImmediateAdd((char)ImmediateMotionType.LengthCompensationCancel); break; case 11: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持12组宏模态调用G代码"; return false; case 12: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持13组周速恒定控制G代码"; return false; case 13: //G54, G54.1, G55, G56, G57, G58, G59 //Todo: 坐标会发生一些变化 if(g_str == "G54.1") { _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持G54.1追加工件坐标系功能"; return false; } else if(g_str == "G54") step_compile_data.ImmediateAdd((char)ImmediateMotionType.G54); else if(g_str == "G55") step_compile_data.ImmediateAdd((char)ImmediateMotionType.G55); else if(g_str == "G56") step_compile_data.ImmediateAdd((char)ImmediateMotionType.G56); else if(g_str == "G57") step_compile_data.ImmediateAdd((char)ImmediateMotionType.G57); else if(g_str == "G58") step_compile_data.ImmediateAdd((char)ImmediateMotionType.G58); else step_compile_data.ImmediateAdd((char)ImmediateMotionType.G59); break; case 14: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持15组G代码"; return false; case 15: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持16组坐标旋转方式G代码"; return false; case 16: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持17组极坐标指令G代码"; return false; case 17: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持18组法线方向控制G代码"; return false; case 18: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持G25代码"; return false; case 19: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持20组横向进磨控制(磨床用)G代码"; return false; case 20: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持G13.1代码"; return false; case 21: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持22组可编程镜像G代码"; return false; case 22: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持G54.2代码"; return false; case 23: _errorMessage = "(Line:" + row_index + "): " + "目前系统暂不支持G80.5代码"; return false; default: break; } //模态代码改变 if(modal_state.Modal_Code[modal_index] != g_str) { step_compile_data.modal_index.Add(modal_index); step_compile_data.modal_string.Add(g_str); modal_state.SetModalCode(g_str, modal_index); } step_compile_data.G_code.Add(g_str); }//1 level return true; } }
public bool M_Check(string m_str, int row_index, ref DataStore step_compile_data) { _errorMessage = ""; if(satisfactoryM.IndexOf(m_str) == -1) { _errorMessage = "(Line:" + row_index + "): " + "系统中不存在该M指令: " + m_str; return false; } else { try { float m_value = (float)Convert.ToDouble(m_str.Trim('M')); if(m_value < 10f) m_str = "M0" + m_value.ToString(); } catch { _errorMessage = "(Line:" + row_index + "): " + "系统中不存在该M指令: " + m_str; return false; } switch(m_str) { case "M00": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M00); break; case "M01": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M01); break; case "M02": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M02); break; case "M03": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M03); break; case "M04": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M04); break; case "M05": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M05); break; case "M06": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M06); break; case "M08": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M08); break; case "M09": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M09); break; case "M30": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M30); break; case "M99": step_compile_data.ImmediateAdd((char)ImmediateMotionType.M99); break; default: _errorMessage = "(Line:" + row_index + "): " + "系统暂不支持该M指令: " + m_str; return false; } return true; } }