simulation_topmenu_pane.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 OnChangeStep(Idx){
  29. const difModel = {
  30. 'Control':() => {
  31. ui.control_btn.valid = true;
  32. ui.setup_btn.valid = false;
  33. ui.start_btn.valid = false;
  34. ui.log_btn.valid = false;
  35. unit.form.side_pane.OnChangeSimulationTopmenu(0);
  36. },
  37. 'Setup':() => {
  38. ui.control_btn.valid = false;
  39. ui.setup_btn.valid = true;
  40. ui.start_btn.valid = false;
  41. ui.log_btn.valid = false;
  42. unit.form.side_pane.OnChangeSimulationTopmenu(1);
  43. },
  44. 'Start':() => {
  45. ui.control_btn.valid = false;
  46. ui.setup_btn.valid = false;
  47. ui.start_btn.valid = true;
  48. ui.log_btn.valid = false;
  49. unit.form.side_pane.OnChangeSimulationTopmenu(2);
  50. },
  51. 'Log':() => {
  52. ui.control_btn.valid = false;
  53. ui.setup_btn.valid = false;
  54. ui.start_btn.valid = false;
  55. ui.log_btn.valid = true;
  56. unit.form.side_pane.OnChangeSimulationTopmenu(3);
  57. }
  58. };
  59. return difModel[Idx]();
  60. }
  61. //The message corresponding callback executed by the docker pane.
  62. // when calling [side_pane].fireEvent(type,para) in the main form.
  63. function OnParentDockerMessage(type, para) {
  64. }
  65. //////////////////////////////////////////////////////////////////////////
  66. // Utils Functions.
  67. // 6c165ad6-ef3e-11ea-987c-b761a131c2fe
  68. function onDragFile(filepath) {
  69. }
  70. function PUI(cb) {
  71. if(pui){cb();}
  72. }
  73. /*Usage of BLOCK_EVENT
  74. BLOCK_EVENT(()=>{
  75. ui.[name].[var] = ...;
  76. });
  77. */
  78. function BLOCK_EVENT(cb) {
  79. ui.block_event = true;
  80. cb();
  81. ui.block_event = false;
  82. }
  83. //////////////////////////////////////////////////////////////////////////
  84. // template codes for cw callback js.
  85. function CW_DeclareVariable(name, setter, getter) {
  86. if(typeof(__DeclareVariable) === 'function') {
  87. __DeclareVariable(name, setter, getter);
  88. }
  89. }
  90. function CW_DeclareOuterVariable(name) {
  91. if(typeof(__DeclareOuterVariable) === 'function') {
  92. __DeclareOuterVariable(name);
  93. }
  94. }