//////////////////////////////////////////////////////////////////////////// // System Pre-define Functions // 95099372-ef3e-11ea-9c81-bf848405c62e //Callback of data preparation stage before UI is fully loaded. function OnInitializeData(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } //Callback after UI is fully loaded and displayed. function OnReady(reload, preview) { PUI(()=>{ //you can access the 'ui' namespace in the parent form using the variable 'pui' here. //The 'pui' variable is valid in all functions of this document. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable. }); } function OnCloseForm() { } function OnException(err) { //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok); } ////////////////////////////////////////////////////////////////////////// // Callback Functions. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7 function setExec(index){ ui.pb_exec.value = index; } function OnMoTai(){ var mes = '$ address' + '\n' + model.getStepPath() + '\n\n' + '$ material' + '\n' + model.getMat() + ' ' + model.getPoi() + ' ' + model.getMidu() + '\n\n' + '$ noe' + '\n' + model.getOrder() + '\n\n' + '$ BPP' + '\n' + model.getBpp1() + ' ' + model.getBpp2(); model.write(mes, model.getCurrentDirectory() + 'data/mpreFiles.txt'); } function OnChangeValue(){ if(parseFloat(ui.pb_exec.value) <= 0){ unit.form.mainfrm.OnChangePicture(4, 3); //unit.form.mainfrm.OnCueline('

非常抱歉,您输入的数据不在范围内!

'); unit.form.mainfrm.OnCueline('您输入的数据不在范围内!', 'red'); }else{ unit.form.mainfrm.OnChangePicture(4, 1); //unit.form.mainfrm.OnCueline('

恭喜您,您输入了正确的数据!

'); unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green'); } } function OnModelAnsys(){ unit.form.mainfrm.OnCueline('求解中...', 'blue'); model.execs(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel2.js" + ' ' + ui.pb_exec.value, flag => { //unit.form.mainfrm.OnCueline('

' + cb + '

'); /*if(flag) {unit.form.mainfrm.OnCueline('

ok!

');} if(!flag){unit.form.mainfrm.OnCueline('

fail!

');}*/ unit.form.mainfrm.OnCueline(flag); if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');} if(!flag){unit.form.mainfrm.OnCueline('fail!', 'red');} }); /* var mes = model.getCurrentDirectory() + 'src/ssh/ssh-txt.exe ' + model.getStepPath() + ' ' + model.getOrder() + ' ' + model.getMat() + ' ' + model.getPoi() + ' ' + model.getMidu() + ' ' + model.getNums() + ' ' + //model.getCurrentDirectory() + 'data/modelAnsys'; //var mes = 'openSSh ' + model.getStepPath() + ' ' + model.getOrder() + ' ' + model.getMat() + ' ' + model.getPoi() + ' ' + model.getMidu() + ' ' + model.getNums() + ' ' + model.getCurrentDirectory() + '/data/modelAnsys'; //console.log(mes); model.execs(mes, flag => { // console.log(cb); if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');} if(!flag){unit.form.mainfrm.OnCueline('fail!', 'green');} }); //unit.form.mainfrm.OnSend(mes);*/ } function OnFile(){ unit.form.tree.GenerateFile(); //unit.form.mainfrm.OnSend('preFiles ' + model.getCurrentDirectory()); //unit.form.mainfrm.OnChangePicture(4, 1); //unit.form.mainfrm.OnCueline('

恭喜您,文件数据已生成!

'); unit.form.mainfrm.OnCueline('文件数据已生成!', 'green'); } function OnSolvePei(){ //unit.form.mainfrm.OnSend('SolveModel'); //unit.form.mainfrm.OnCueline('

solve......

'); unit.form.mainfrm.OnCueline('求解中...', 'blue'); model.execs(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value, flag => { //unit.form.mainfrm.OnCueline('

' + cb + '

'); /*if(flag) {unit.form.mainfrm.OnCueline('

ok!

');} if(!flag){unit.form.mainfrm.OnCueline('

fail!

');}*/ unit.form.mainfrm.OnCueline(flag); if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');} if(!flag){unit.form.mainfrm.OnCueline('fail!', 'red');} }); //console.log(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value); //unit.form.mainfrm.OnCueline('

ok!

'); //model.spawn("node " + model.getCurrentDirectory() + "src/internel/parallel.js"); /*model.spawn(model.getCurrentDirectory() + "src/internel/run.bat", cb => { //console.log(cb); //unit.form.tree.OnMessage(cb); if (cb.indexOf("10") !== -1) { unit.form.mainfrm.OnSetProp(10); } if (cb.indexOf("20") !== -1) { unit.form.mainfrm.OnSetProp(20); } if (cb.indexOf("30") !== -1) { unit.form.mainfrm.OnSetProp(30); } if (cb.indexOf("40") !== -1) { unit.form.mainfrm.OnSetProp(40); } if (cb.indexOf("50") !== -1) { unit.form.mainfrm.OnSetProp(50); } if (cb.indexOf("60") !== -1) { unit.form.mainfrm.OnSetProp(60); } if (cb.indexOf("70") !== -1) { unit.form.mainfrm.OnSetProp(70); } if (cb.indexOf("80") !== -1) { unit.form.mainfrm.OnSetProp(80); } if (cb.indexOf("90") !== -1) { unit.form.mainfrm.OnSetProp(90); } if (cb.indexOf("100") !== -1) { unit.form.mainfrm.OnSetProp(100); } });*/ /* model.spawn(model.getCurrentDirectory() + "src/solve/demo1.exe", model.getCurrentDirectory() + 'data', cb => { console.log(cb); if (cb.indexOf("Apply nueman boundary condition...") !== -1) { console.log(33); unit.form.mainfrm.OnSetProp(20); } if (cb.indexOf("Assemble global system...") !== -1) { unit.form.mainfrm.OnSetProp(40); } if (cb.indexOf("Apply nueman boundary condition...") !== -1) { unit.form.mainfrm.OnSetProp(60); } if (cb.indexOf("Assemble global system...") !== -1) { unit.form.mainfrm.OnSetProp(80); } });*/ /* var id = parent.setTimeout(() => { unit.form.mainfrm.OnSetProp(10); }, 100); var id = parent.setTimeout(() => { unit.form.mainfrm.OnSetProp(20); }, 8000); var id = parent.setTimeout(() => { unit.form.mainfrm.OnSetProp(40); }, 30000); var id = parent.setTimeout(() => { unit.form.mainfrm.OnSetProp(60); }, 60000); var id = parent.setTimeout(() => { unit.form.mainfrm.OnSetProp(100); ui.pb_pass.enable = true; }, 120000);*/ } function OnReturnMenu(){ unit.form.mainfrm.menu(6); } function OnSolve() { //model.write('打开' + model.getCurrentDirectory() + 'data文件夹,点击assemble_face_pei.exe进行求解', model.getCurrentDirectory() + 'src/note/note.txt'); model.spawn(model.getCurrentDirectory() + "data/assemble_face_pei.exe", model.getCurrentDirectory() + 'data', cb => { console.log(cb); }); } function OnSave() { model.spawn(model.getCurrentDirectory() + "srcX/generateBrep.exe", model.getCurrentDirectory(), cb => { console.log(cb); }); model.spawn(model.getCurrentDirectory() + "src/staticStruct/staticStruct.exe", model.getCurrentDirectory() + 'data', cb => { console.log(cb); }); } //The message corresponding callback executed by the docker pane. // when calling [side_pane].fireEvent(type,para) in the main form. function OnParentDockerMessage(type, para) { } ////////////////////////////////////////////////////////////////////////// // Utils Functions. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe function onDragFile(filepath) { } function PUI(cb) { if(pui){cb();} } /*Usage of BLOCK_EVENT BLOCK_EVENT(()=>{ ui.[name].[var] = ...; }); */ CW_DeclareVariable("exec", val => { ui.pb_exec.value = parseInt(val) - 2; }, () => {}); function BLOCK_EVENT(cb) { ui.block_event = true; cb(); ui.block_event = false; } ////////////////////////////////////////////////////////////////////////// // template codes for cw callback js. function CW_DeclareVariable(name, setter, getter) { if(typeof(__DeclareVariable) === 'function') { __DeclareVariable(name, setter, getter); } } function CW_DeclareOuterVariable(name) { if(typeof(__DeclareOuterVariable) === 'function') { __DeclareOuterVariable(name); } }