public string StartSimulation(SimulationPara para) { //设置模型路径 PathSetting path = new PathSetting(para.Axis); //进行模型替换 ModelReplace modelReplace = new ModelReplace(path); modelReplace.ReplaceAll(para); string result = "ready"; return(result); }
/// <summary> /// 生成realpackage.mo文件 /// </summary> /// <param name="para">前端传入的数据</param> public void PrepareSimulationModel(SimulationPara para) { ReadTemplateFile(); //读取 Mworks/Template/X_axis/package.txt 这是一个模板文件 ReplaceInput(para.Setting); //替换模板中的输入信号和干扰 ReplaceMotor(para.Motor); ReplaceDriver(para.Driver); ReplaceBallscrew(para.Ballscrew, para.Worktable); ReplaceGuide(para.Guide, para.Worktable); ReplaceBearings(para.Bearings); ReplaceCoupling(para.Coupling); ReplaceWorktable(para.Worktable, para.Ballscrew); WriteModelFile();//生成realpackage.mo }
public void ReplaceAll(SimulationPara para) { ReadTemplateFile(); ReplaceInput(para.Setting); ReplaceMotor(para.Motor); ReplaceDriver(para.Driver); ReplaceBallscrew(para.Ballscrew, para.Worktable); ReplaceGuide(para.Guide, para.Worktable); ReplaceBearings(para.Bearings); ReplaceCoupling(para.Coupling); ReplaceWorktable(para.Worktable, para.Ballscrew); WriteModelFile(); }
public void ReplaceAll(SimulationPara para) { ReadTemplateFile(); ReplaceInput(para.Setting); ReplaceMotor(para.Motor); ReplaceDriver(para.Driver); ReplaceBallscrew(para.Ballscrew,para.Worktable); ReplaceGuide(para.Guide,para.Worktable); ReplaceBearings(para.Bearings); ReplaceCoupling(para.Coupling); ReplaceWorktable(para.Worktable,para.Ballscrew); WriteModelFile(); }
public async Task <IActionResult> StartSimulation([FromQuery] string fileID, [FromQuery] string userName, [FromBody] SimulationPara para) { if (string.IsNullOrEmpty(fileID) || fileID == "null") { return(BadRequest()); } if (string.IsNullOrEmpty(userName) || userName == "null") { return(BadRequest()); } //设置模型路径 PathSettings path = new PathSettings(_webRootPath, para.AxisID, userName, fileID); Simulator simulator = new Simulator(path); //进行模型替换 await Task.Run(() => { simulator.PrepareSimulationModel(para); //进行模型编译求解 simulator.PreprocessCompiler(para.Setting); simulator.CreateCompiler(); simulator.RunCompiler(); //进行结果转换 simulator.MsfToTxt(); }); return(Ok()); }