solve_setup_pane.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. ////////////////////////////////////////////////////////////////////////////
  2. // System Pre-define Functions
  3. // 95099372-ef3e-11ea-9c81-bf848405c62e
  4. //Callback of data preparation stage before UI is fully loaded.
  5. function OnInitializeData(reload, preview) {
  6. PUI(()=>{
  7. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  8. //The 'pui' variable is valid in all functions of this document.
  9. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  10. });
  11. }
  12. //Callback after UI is fully loaded and displayed.
  13. function OnReady(reload, preview) {
  14. PUI(()=>{
  15. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  16. //The 'pui' variable is valid in all functions of this document.
  17. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  18. });
  19. }
  20. function OnCloseForm() {
  21. }
  22. function OnException(err) {
  23. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  24. }
  25. //////////////////////////////////////////////////////////////////////////
  26. // Callback Functions.
  27. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  28. function setExec(index){
  29. ui.pb_exec.value = index;
  30. }
  31. function OnMoTai(){
  32. 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();
  33. model.write(mes, model.getCurrentDirectory() + 'data/mpreFiles.txt');
  34. }
  35. function OnChangeValue(){
  36. if(parseFloat(ui.pb_exec.value) <= 0){
  37. unit.form.mainfrm.OnChangePicture(4, 3);
  38. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: red;font-size:20px;">非常抱歉,您输入的数据不在范围内!</h4>');
  39. unit.form.mainfrm.OnCueline('您输入的数据不在范围内!', 'red');
  40. }else{
  41. unit.form.mainfrm.OnChangePicture(4, 1);
  42. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,您输入了正确的数据!</h4>');
  43. unit.form.mainfrm.OnCueline('您输入了正确的数据!', 'green');
  44. }
  45. }
  46. function OnModelAnsys(){
  47. unit.form.mainfrm.OnCueline('求解中...', 'blue');
  48. model.execs(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel2.js" + ' ' + ui.pb_exec.value, flag => {
  49. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">' + cb + '</h4>');
  50. /*if(flag) {unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">ok!</h4>');}
  51. if(!flag){unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">fail!</h4>');}*/
  52. unit.form.mainfrm.OnCueline(flag);
  53. if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');}
  54. if(!flag){unit.form.mainfrm.OnCueline('fail!', 'red');}
  55. });
  56. /*
  57. 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';
  58. //var mes = 'openSSh ' + model.getStepPath() + ' ' + model.getOrder() + ' ' + model.getMat() + ' ' + model.getPoi() + ' ' + model.getMidu() + ' ' + model.getNums() + ' ' + model.getCurrentDirectory() + '/data/modelAnsys';
  59. //console.log(mes);
  60. model.execs(mes, flag => {
  61. // console.log(cb);
  62. if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');}
  63. if(!flag){unit.form.mainfrm.OnCueline('fail!', 'green');}
  64. });
  65. //unit.form.mainfrm.OnSend(mes);*/
  66. }
  67. function OnFile(){
  68. if(!model.global_ctrl[0] || !model.global_ctrl[1] || !model.global_ctrl[2] || !model.global_ctrl[3] || !model.global_ctrl[4] ||!model.global_ctrl[5]) {
  69. unit.form.mainfrm.OnCueline('未完成求解设置', 'red');
  70. return;
  71. }
  72. unit.form.tree.GenerateFile();
  73. unit.form.mainfrm.OnCueline('文件数据已生成!', 'green');
  74. }
  75. function OnSolvePei(){
  76. //unit.form.mainfrm.OnSend('SolveModel');
  77. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">solve......</h4>');
  78. unit.form.mainfrm.OnCueline('求解中...', 'blue');
  79. model.execs(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value, flag => {
  80. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">' + cb + '</h4>');
  81. /*if(flag) {unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">ok!</h4>');}
  82. if(!flag){unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">fail!</h4>');}*/
  83. unit.form.mainfrm.OnCueline(flag);
  84. if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');}
  85. if(!flag){unit.form.mainfrm.OnCueline('fail!', 'red');}
  86. });
  87. //console.log(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value);
  88. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">ok!</h4>');
  89. //model.spawn("node " + model.getCurrentDirectory() + "src/internel/parallel.js");
  90. /*model.spawn(model.getCurrentDirectory() + "src/internel/run.bat", cb => {
  91. //console.log(cb);
  92. //unit.form.tree.OnMessage(cb);
  93. if (cb.indexOf("10") !== -1) {
  94. unit.form.mainfrm.OnSetProp(10);
  95. }
  96. if (cb.indexOf("20") !== -1) {
  97. unit.form.mainfrm.OnSetProp(20);
  98. }
  99. if (cb.indexOf("30") !== -1) {
  100. unit.form.mainfrm.OnSetProp(30);
  101. }
  102. if (cb.indexOf("40") !== -1) {
  103. unit.form.mainfrm.OnSetProp(40);
  104. }
  105. if (cb.indexOf("50") !== -1) {
  106. unit.form.mainfrm.OnSetProp(50);
  107. }
  108. if (cb.indexOf("60") !== -1) {
  109. unit.form.mainfrm.OnSetProp(60);
  110. }
  111. if (cb.indexOf("70") !== -1) {
  112. unit.form.mainfrm.OnSetProp(70);
  113. }
  114. if (cb.indexOf("80") !== -1) {
  115. unit.form.mainfrm.OnSetProp(80);
  116. }
  117. if (cb.indexOf("90") !== -1) {
  118. unit.form.mainfrm.OnSetProp(90);
  119. }
  120. if (cb.indexOf("100") !== -1) {
  121. unit.form.mainfrm.OnSetProp(100);
  122. }
  123. });*/
  124. /*
  125. model.spawn(model.getCurrentDirectory() + "src/solve/demo1.exe", model.getCurrentDirectory() + 'data', cb => {
  126. console.log(cb);
  127. if (cb.indexOf("Apply nueman boundary condition...") !== -1) {
  128. console.log(33);
  129. unit.form.mainfrm.OnSetProp(20);
  130. }
  131. if (cb.indexOf("Assemble global system...") !== -1) {
  132. unit.form.mainfrm.OnSetProp(40);
  133. }
  134. if (cb.indexOf("Apply nueman boundary condition...") !== -1) {
  135. unit.form.mainfrm.OnSetProp(60);
  136. }
  137. if (cb.indexOf("Assemble global system...") !== -1) {
  138. unit.form.mainfrm.OnSetProp(80);
  139. }
  140. });*/
  141. /*
  142. var id = parent.setTimeout(() => {
  143. unit.form.mainfrm.OnSetProp(10);
  144. }, 100);
  145. var id = parent.setTimeout(() => {
  146. unit.form.mainfrm.OnSetProp(20);
  147. }, 8000);
  148. var id = parent.setTimeout(() => {
  149. unit.form.mainfrm.OnSetProp(40);
  150. }, 30000);
  151. var id = parent.setTimeout(() => {
  152. unit.form.mainfrm.OnSetProp(60);
  153. }, 60000);
  154. var id = parent.setTimeout(() => {
  155. unit.form.mainfrm.OnSetProp(100);
  156. ui.pb_pass.enable = true;
  157. }, 120000);*/
  158. }
  159. function OnReturnMenu(){
  160. unit.form.mainfrm.menu(6);
  161. }
  162. function OnSolve() {
  163. //model.write('打开' + model.getCurrentDirectory() + 'data文件夹,点击assemble_face_pei.exe进行求解', model.getCurrentDirectory() + 'src/note/note.txt');
  164. model.spawn(model.getCurrentDirectory() + "data/assemble_face_pei.exe", model.getCurrentDirectory() + 'data', cb => {
  165. console.log(cb);
  166. });
  167. }
  168. function OnSave() {
  169. model.spawn(model.getCurrentDirectory() + "srcX/generateBrep.exe", model.getCurrentDirectory(), cb => {
  170. console.log(cb);
  171. });
  172. model.spawn(model.getCurrentDirectory() + "src/staticStruct/staticStruct.exe", model.getCurrentDirectory() + 'data', cb => {
  173. console.log(cb);
  174. });
  175. }
  176. //The message corresponding callback executed by the docker pane.
  177. // when calling [side_pane].fireEvent(type,para) in the main form.
  178. function OnParentDockerMessage(type, para) {
  179. }
  180. //////////////////////////////////////////////////////////////////////////
  181. // Utils Functions.
  182. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  183. function onDragFile(filepath) {
  184. }
  185. function PUI(cb) {
  186. if(pui){cb();}
  187. }
  188. /*Usage of BLOCK_EVENT
  189. BLOCK_EVENT(()=>{
  190. ui.[name].[var] = ...;
  191. });
  192. */
  193. CW_DeclareVariable("exec",
  194. val => {
  195. ui.pb_exec.value = parseInt(val) - 2;
  196. }, () => {});
  197. function BLOCK_EVENT(cb) {
  198. ui.block_event = true;
  199. cb();
  200. ui.block_event = false;
  201. }
  202. //////////////////////////////////////////////////////////////////////////
  203. // template codes for cw callback js.
  204. function CW_DeclareVariable(name, setter, getter) {
  205. if(typeof(__DeclareVariable) === 'function') {
  206. __DeclareVariable(name, setter, getter);
  207. }
  208. }
  209. function CW_DeclareOuterVariable(name) {
  210. if(typeof(__DeclareOuterVariable) === 'function') {
  211. __DeclareOuterVariable(name);
  212. }
  213. }