123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- ////////////////////////////////////////////////////////////////////////////
- // 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.
-
- });
- ui.list.table = [["阶数", "特征值", "频率"]];
- model.startLocalhost(()=>{
- ui.webview.value = "http://localhost:4000";
- parent.setTimeout(()=>{
- //ui.type.enable = true;
- //OnLoad();
- }, 100);
- });
- }
- //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 OnReturnMenu(){
- unit.form.mainfrm.menu(8);
- }
- function OnEnd(){
- unit.form.mainfrm.OnSend('endModel');
- }
- function OnPlay(){
- unit.form.mainfrm.OnSend('playModel ' + model.getCurrentDirectory());
- }
- function getChart1(val) {
- const xvalue = [];
- const yvalue = [];
- val.forEach((value, index) => {
- const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
- //res.push([index + 1, value, cubeRoot]);
- xvalue.push(`第${index + 1}阶`);
- yvalue.push(cubeRoot);
- // 在这里可以执行其他操作
- });
-
- return {
- xAxis: {
- type: 'category',
- //data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
- data: xvalue
- },
- yAxis: {
- type: 'value'
- },
- series: [
- {
- //data: [150, 230, 224, 218, 135, 147, 260],
- data: yvalue,
- type: 'line'
- }
- ]
- };
- }
- async function OnLoad(val){
- model.updateLineChart(getChart1(val));
- }
- function OnNextModel(){
- if(parseFloat(model.getOrder()) === 24){
- model.setOrder(5);
- }else{
- model.setOrder(model.getOrder() + 1);
- }
-
- unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
- unit.form.mainfrm.OnChangePicture(5, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
- unit.form.mainfrm.OnCueline(`当前阶数为${parseFloat(model.getOrder()) - 4}`, 'green');
- }
- function OnLastModel(){
- if(parseFloat(model.getOrder()) === 5){
- model.setOrder(24);
- }else{
- model.setOrder(model.getOrder() - 1);
- }
-
- unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
- unit.form.mainfrm.OnChangePicture(5, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
- unit.form.mainfrm.OnCueline(`当前阶数为${parseFloat(model.getOrder()) - 4}`, 'green');
- }
- function OnAnsys(){
- unit.form.mainfrm.OnSend('OnReadModelAnysy ' + model.getCurrentDirectory() + 'data/modelAnsys/unitfcm5-0-1e-10-451/eigenvalues.txt');
-
- unit.form.mainfrm.OnSend('ModelAnsys ' + model.getCurrentDirectory() + ' ' + model.getOrder());
- unit.form.mainfrm.OnChangePicture(5, 2);
- //unit.form.mainfrm.OnCueline('<h4 style="font-family:arial;color: green;font-size:20px;">模态分析结果加载成功!</h4>');
- unit.form.mainfrm.OnCueline('模态分析结果加载成功!', 'green');
- //OnLoad();
- }
- //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] = ...;
- });
- */
- function BLOCK_EVENT(cb) {
- ui.block_event = true;
-
- cb();
-
- ui.block_event = false;
- }
- //////////////////////////////////////////////////////////////////////////
- // template codes for cw callback js.
- CW_DeclareVariable("list",
- val => {
- //console.log(val);
- var res = [["阶数", "特征值", "频率"]];
- val.forEach((value, index) => {
- const cubeRoot = Math.sqrt(parseFloat(value)) / (2 * 3.1415926);
- res.push([index + 1, value, cubeRoot]);
- // 在这里可以执行其他操作
- });
-
- //console.log('Resulting Array:', res);
- ui.list.table = res;
- ui.list.head_size = [0, 0, 0];
-
- OnLoad(val);
- }, () => {});
- function CW_DeclareVariable(name, setter, getter) {
- if(typeof(__DeclareVariable) === 'function') {
- __DeclareVariable(name, setter, getter);
- }
- }
- function CW_DeclareOuterVariable(name) {
- if(typeof(__DeclareOuterVariable) === 'function') {
- __DeclareOuterVariable(name);
- }
- }
|