result_ModelAnsys_pane.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. ui.list.table = [["阶数", "特征值", "频率"]];
  12. model.startLocalhost(()=>{
  13. ui.webview.value = "http://localhost:4000";
  14. parent.setTimeout(()=>{
  15. //ui.type.enable = true;
  16. //OnLoad();
  17. }, 100);
  18. });
  19. }
  20. //Callback after UI is fully loaded and displayed.
  21. function OnReady(reload, preview) {
  22. PUI(()=>{
  23. //you can access the 'ui' namespace in the parent form using the variable 'pui' here.
  24. //The 'pui' variable is valid in all functions of this document.
  25. //For robustness, you'd better use 'PUI(cb);' to access 'pui' variable.
  26. });
  27. }
  28. function OnCloseForm() {
  29. }
  30. function OnException(err) {
  31. //ui.MessageBox('Error', '' + err, MessageBox.Icon.Critical, MessageBox.Button.Ok);
  32. }
  33. //////////////////////////////////////////////////////////////////////////
  34. // Callback Functions.
  35. // 641a254c-ef3e-11ea-bc8a-379bb908bdd7
  36. function OnReturnMenu(){
  37. unit.form.mainfrm.menu(8);
  38. }
  39. function OnEnd(){
  40. unit.form.mainfrm.OnSend('endModel');
  41. }
  42. function OnPlay(){
  43. unit.form.mainfrm.OnSend('playModel ' + model.getCurrentDirectory());
  44. }
  45. function getChart1(val) {
  46. const xvalue = [];
  47. const yvalue = [];
  48. val.forEach((value, index) => {
  49. const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
  50. //res.push([index + 1, value, cubeRoot]);
  51. xvalue.push(`第${index + 1}阶`);
  52. yvalue.push(cubeRoot);
  53. // 在这里可以执行其他操作
  54. });
  55. return {
  56. xAxis: {
  57. type: 'category',
  58. //data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  59. data: xvalue
  60. },
  61. yAxis: {
  62. type: 'value'
  63. },
  64. series: [
  65. {
  66. //data: [150, 230, 224, 218, 135, 147, 260],
  67. data: yvalue,
  68. type: 'line'
  69. }
  70. ]
  71. };
  72. }
  73. async function OnLoad(val){
  74. model.updateLineChart(getChart1(val));
  75. }
  76. function OnNextModel(){
  77. if(parseFloat(model.getOrder()) === 24){
  78. model.setOrder(5);
  79. }else{
  80. model.setOrder(model.getOrder() + 1);
  81. }
  82. unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
  83. unit.form.mainfrm.OnChangePicture(5, 2);
  84. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
  85. unit.form.mainfrm.OnCueline(`当前阶数为${parseFloat(model.getOrder()) - 4}`, 'green');
  86. }
  87. function OnLastModel(){
  88. if(parseFloat(model.getOrder()) === 5){
  89. model.setOrder(24);
  90. }else{
  91. model.setOrder(model.getOrder() - 1);
  92. }
  93. unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
  94. unit.form.mainfrm.OnChangePicture(5, 2);
  95. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
  96. unit.form.mainfrm.OnCueline(`当前阶数为${parseFloat(model.getOrder()) - 4}`, 'green');
  97. }
  98. function OnAnsys(){
  99. unit.form.mainfrm.OnSend('OnReadModelAnysy ' + model.getCurrentDirectory() + 'data/modelAnsys/unitfcm5-0-1e-10-451/eigenvalues.txt');
  100. unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
  101. unit.form.mainfrm.OnChangePicture(5, 2);
  102. //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
  103. unit.form.mainfrm.OnCueline('模态分析结果加载成功!', 'green');
  104. //OnLoad();
  105. }
  106. //The message corresponding callback executed by the docker pane.
  107. // when calling [side_pane].fireEvent(type,para) in the main form.
  108. function OnParentDockerMessage(type, para) {
  109. }
  110. //////////////////////////////////////////////////////////////////////////
  111. // Utils Functions.
  112. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  113. function onDragFile(filepath) {
  114. }
  115. function PUI(cb) {
  116. if(pui){cb();}
  117. }
  118. /*Usage of BLOCK_EVENT
  119. BLOCK_EVENT(()=>{
  120. ui.[name].[var] = ...;
  121. });
  122. */
  123. function BLOCK_EVENT(cb) {
  124. ui.block_event = true;
  125. cb();
  126. ui.block_event = false;
  127. }
  128. //////////////////////////////////////////////////////////////////////////
  129. // template codes for cw callback js.
  130. CW_DeclareVariable("list",
  131. val => {
  132. //console.log(val);
  133. var res = [["阶数", "特征值", "频率"]];
  134. val.forEach((value, index) => {
  135. const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
  136. res.push([index + 1, value, cubeRoot]);
  137. // 在这里可以执行其他操作
  138. });
  139. //console.log('Resulting Array:', res);
  140. ui.list.table = res;
  141. ui.list.head_size = [0, 0, 0];
  142. OnLoad(val);
  143. }, () => {});
  144. function CW_DeclareVariable(name, setter, getter) {
  145. if(typeof(__DeclareVariable) === 'function') {
  146. __DeclareVariable(name, setter, getter);
  147. }
  148. }
  149. function CW_DeclareOuterVariable(name) {
  150. if(typeof(__DeclareOuterVariable) === 'function') {
  151. __DeclareOuterVariable(name);
  152. }
  153. }