solve_setup_pane.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. unit.form.mainfrm.OnSend('preFiles ' + model.getCurrentDirectory());
  69. unit.form.mainfrm.OnChangePicture(4, 1);
  70. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">恭喜您,文件数据已生成!</h4>');
  71. unit.form.mainfrm.OnCueline('文件数据已生成!', 'green');
  72. }
  73. function OnSolvePei(){
  74. //unit.form.mainfrm.OnSend('SolveModel');
  75. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">solve......</h4>');
  76. unit.form.mainfrm.OnCueline('求解中...', 'blue');
  77. model.execs(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value, flag => {
  78. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: Blue;font-size:20px;">' + cb + '</h4>');
  79. /*if(flag) {unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">ok!</h4>');}
  80. if(!flag){unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">fail!</h4>');}*/
  81. unit.form.mainfrm.OnCueline(flag);
  82. if(flag) {unit.form.mainfrm.OnCueline('ok!', 'green');}
  83. if(!flag){unit.form.mainfrm.OnCueline('fail!', 'red');}
  84. });
  85. //console.log(model.getNodePath() + ' ' + model.getCurrentDirectory() + "src/internel/parallel.js" + ' ' + ui.pb_exec.value);
  86. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">ok!</h4>');
  87. //model.spawn("node " + model.getCurrentDirectory() + "src/internel/parallel.js");
  88. /*model.spawn(model.getCurrentDirectory() + "src/internel/run.bat", cb => {
  89. //console.log(cb);
  90. //unit.form.tree.OnMessage(cb);
  91. if (cb.indexOf("10") !== -1) {
  92. unit.form.mainfrm.OnSetProp(10);
  93. }
  94. if (cb.indexOf("20") !== -1) {
  95. unit.form.mainfrm.OnSetProp(20);
  96. }
  97. if (cb.indexOf("30") !== -1) {
  98. unit.form.mainfrm.OnSetProp(30);
  99. }
  100. if (cb.indexOf("40") !== -1) {
  101. unit.form.mainfrm.OnSetProp(40);
  102. }
  103. if (cb.indexOf("50") !== -1) {
  104. unit.form.mainfrm.OnSetProp(50);
  105. }
  106. if (cb.indexOf("60") !== -1) {
  107. unit.form.mainfrm.OnSetProp(60);
  108. }
  109. if (cb.indexOf("70") !== -1) {
  110. unit.form.mainfrm.OnSetProp(70);
  111. }
  112. if (cb.indexOf("80") !== -1) {
  113. unit.form.mainfrm.OnSetProp(80);
  114. }
  115. if (cb.indexOf("90") !== -1) {
  116. unit.form.mainfrm.OnSetProp(90);
  117. }
  118. if (cb.indexOf("100") !== -1) {
  119. unit.form.mainfrm.OnSetProp(100);
  120. }
  121. });*/
  122. /*
  123. model.spawn(model.getCurrentDirectory() + "src/solve/demo1.exe", model.getCurrentDirectory() + 'data', cb => {
  124. console.log(cb);
  125. if (cb.indexOf("Apply nueman boundary condition...") !== -1) {
  126. console.log(33);
  127. unit.form.mainfrm.OnSetProp(20);
  128. }
  129. if (cb.indexOf("Assemble global system...") !== -1) {
  130. unit.form.mainfrm.OnSetProp(40);
  131. }
  132. if (cb.indexOf("Apply nueman boundary condition...") !== -1) {
  133. unit.form.mainfrm.OnSetProp(60);
  134. }
  135. if (cb.indexOf("Assemble global system...") !== -1) {
  136. unit.form.mainfrm.OnSetProp(80);
  137. }
  138. });*/
  139. /*
  140. var id = parent.setTimeout(() => {
  141. unit.form.mainfrm.OnSetProp(10);
  142. }, 100);
  143. var id = parent.setTimeout(() => {
  144. unit.form.mainfrm.OnSetProp(20);
  145. }, 8000);
  146. var id = parent.setTimeout(() => {
  147. unit.form.mainfrm.OnSetProp(40);
  148. }, 30000);
  149. var id = parent.setTimeout(() => {
  150. unit.form.mainfrm.OnSetProp(60);
  151. }, 60000);
  152. var id = parent.setTimeout(() => {
  153. unit.form.mainfrm.OnSetProp(100);
  154. ui.pb_pass.enable = true;
  155. }, 120000);*/
  156. }
  157. function OnReturnMenu(){
  158. unit.form.mainfrm.menu(6);
  159. }
  160. function OnSolve() {
  161. //model.write('打开' + model.getCurrentDirectory() + 'data文件夹,点击assemble_face_pei.exe进行求解', model.getCurrentDirectory() + 'src/note/note.txt');
  162. model.spawn(model.getCurrentDirectory() + "data/assemble_face_pei.exe", model.getCurrentDirectory() + 'data', cb => {
  163. console.log(cb);
  164. });
  165. }
  166. function OnSave() {
  167. model.spawn(model.getCurrentDirectory() + "srcX/generateBrep.exe", model.getCurrentDirectory(), cb => {
  168. console.log(cb);
  169. });
  170. model.spawn(model.getCurrentDirectory() + "src/staticStruct/staticStruct.exe", model.getCurrentDirectory() + 'data', cb => {
  171. console.log(cb);
  172. });
  173. }
  174. //The message corresponding callback executed by the docker pane.
  175. // when calling [side_pane].fireEvent(type,para) in the main form.
  176. function OnParentDockerMessage(type, para) {
  177. }
  178. //////////////////////////////////////////////////////////////////////////
  179. // Utils Functions.
  180. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  181. function onDragFile(filepath) {
  182. }
  183. function PUI(cb) {
  184. if(pui){cb();}
  185. }
  186. /*Usage of BLOCK_EVENT
  187. BLOCK_EVENT(()=>{
  188. ui.[name].[var] = ...;
  189. });
  190. */
  191. CW_DeclareVariable("exec",
  192. val => {
  193. ui.pb_exec.value = parseInt(val) - 2;
  194. }, () => {});
  195. function BLOCK_EVENT(cb) {
  196. ui.block_event = true;
  197. cb();
  198. ui.block_event = false;
  199. }
  200. //////////////////////////////////////////////////////////////////////////
  201. // template codes for cw callback js.
  202. function CW_DeclareVariable(name, setter, getter) {
  203. if(typeof(__DeclareVariable) === 'function') {
  204. __DeclareVariable(name, setter, getter);
  205. }
  206. }
  207. function CW_DeclareOuterVariable(name) {
  208. if(typeof(__DeclareOuterVariable) === 'function') {
  209. __DeclareOuterVariable(name);
  210. }
  211. }