solve_setup_pane.js 11 KB

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