openc3-cosmos-tool-docs 5.17.1 → 5.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/tools/staticdocs/404.html +4 -4
  3. data/tools/staticdocs/assets/css/{styles.8a0f1b26.css → styles.80ddca08.css} +1 -1
  4. data/tools/staticdocs/assets/js/{019369f3.34291acc.js → 019369f3.727d87f1.js} +1 -1
  5. data/tools/staticdocs/assets/js/{058ffc22.8d9049f4.js → 058ffc22.f2d69d72.js} +1 -1
  6. data/tools/staticdocs/assets/js/{0686a885.dde7b18b.js → 0686a885.83641127.js} +1 -1
  7. data/tools/staticdocs/assets/js/078dbab0.945c9f59.js +1 -0
  8. data/tools/staticdocs/assets/js/{0f5d161c.ca02c5b2.js → 0f5d161c.e26d88b8.js} +1 -1
  9. data/tools/staticdocs/assets/js/{0ff569c9.ad025a56.js → 0ff569c9.aa4daee5.js} +1 -1
  10. data/tools/staticdocs/assets/js/{103cc3be.6b6cd0fa.js → 103cc3be.78f97eb1.js} +1 -1
  11. data/tools/staticdocs/assets/js/{13196248.9e7794e3.js → 13196248.ca2e8950.js} +1 -1
  12. data/tools/staticdocs/assets/js/{13c1b4e4.cec67b9c.js → 13c1b4e4.22a0b1d4.js} +1 -1
  13. data/tools/staticdocs/assets/js/{2047b354.bdd2586a.js → 2047b354.25d11993.js} +1 -1
  14. data/tools/staticdocs/assets/js/22b3ac48.7a5ea984.js +1 -0
  15. data/tools/staticdocs/assets/js/{2bb7bf90.043455de.js → 2bb7bf90.fa05d998.js} +1 -1
  16. data/tools/staticdocs/assets/js/3917.1ec7d126.js +1 -0
  17. data/tools/staticdocs/assets/js/{3dd7ef3b.c7c1d93f.js → 3dd7ef3b.d55880a8.js} +1 -1
  18. data/tools/staticdocs/assets/js/{40365d27.7eb3f7b1.js → 40365d27.4b4b2ccd.js} +1 -1
  19. data/tools/staticdocs/assets/js/{411898ad.d5f62a27.js → 411898ad.1d6a609d.js} +1 -1
  20. data/tools/staticdocs/assets/js/{42170351.69a8ed02.js → 42170351.c68b85e1.js} +1 -1
  21. data/tools/staticdocs/assets/js/43652efd.d1e1add3.js +1 -0
  22. data/tools/staticdocs/assets/js/53ca7c5b.c3111020.js +1 -0
  23. data/tools/staticdocs/assets/js/{54d0d530.28ba5be7.js → 54d0d530.d3f9a4ac.js} +1 -1
  24. data/tools/staticdocs/assets/js/{5b233ba7.9c621552.js → 5b233ba7.6fdd6b6c.js} +1 -1
  25. data/tools/staticdocs/assets/js/{5bc719f6.7fa17221.js → 5bc719f6.daa2a049.js} +1 -1
  26. data/tools/staticdocs/assets/js/{5c6ce5ec.5e6ca46b.js → 5c6ce5ec.61a9cae2.js} +1 -1
  27. data/tools/staticdocs/assets/js/5e3ed378.2bee863a.js +1 -0
  28. data/tools/staticdocs/assets/js/5fe211ef.a9f21277.js +1 -0
  29. data/tools/staticdocs/assets/js/6831b732.185eb427.js +1 -0
  30. data/tools/staticdocs/assets/js/{696b4199.0335bd94.js → 696b4199.a5ae3d65.js} +1 -1
  31. data/tools/staticdocs/assets/js/{6b210247.2cbd59e6.js → 6b210247.e96f3982.js} +1 -1
  32. data/tools/staticdocs/assets/js/{6b65133b.87dc7da6.js → 6b65133b.4e84b1c2.js} +1 -1
  33. data/tools/staticdocs/assets/js/6f92e431.65aa0240.js +1 -0
  34. data/tools/staticdocs/assets/js/72c6d8a8.98daa27a.js +1 -0
  35. data/tools/staticdocs/assets/js/{75e64983.932fbc0e.js → 75e64983.6ef0928b.js} +1 -1
  36. data/tools/staticdocs/assets/js/{867640d5.ffd4cf4c.js → 867640d5.48133ad5.js} +1 -1
  37. data/tools/staticdocs/assets/js/{89e76475.97389cc5.js → 89e76475.13ce283b.js} +1 -1
  38. data/tools/staticdocs/assets/js/{8f7843ee.d1ffd5ee.js → 8f7843ee.7a68246a.js} +1 -1
  39. data/tools/staticdocs/assets/js/9424f0b3.61c6bd97.js +1 -0
  40. data/tools/staticdocs/assets/js/{97535711.fc45ced1.js → 97535711.5311ddd9.js} +1 -1
  41. data/tools/staticdocs/assets/js/{99581c43.8e571df8.js → 99581c43.527aab44.js} +1 -1
  42. data/tools/staticdocs/assets/js/{9fb6059a.42881e94.js → 9fb6059a.a5107afb.js} +1 -1
  43. data/tools/staticdocs/assets/js/{a507c363.04b98d2c.js → a507c363.d2cc5d72.js} +1 -1
  44. data/tools/staticdocs/assets/js/{a677c089.b2928bac.js → a677c089.abc52ace.js} +1 -1
  45. data/tools/staticdocs/assets/js/{a9987364.8f065f19.js → a9987364.5ef1644f.js} +1 -1
  46. data/tools/staticdocs/assets/js/{aa6b6c1b.d78e5212.js → aa6b6c1b.c51c044d.js} +1 -1
  47. data/tools/staticdocs/assets/js/{b4596165.6806d46b.js → b4596165.daa24b72.js} +1 -1
  48. data/tools/staticdocs/assets/js/b6d70f94.4923c793.js +1 -0
  49. data/tools/staticdocs/assets/js/b9f60ba6.e55cd937.js +1 -0
  50. data/tools/staticdocs/assets/js/{bd0034eb.b4e3d6c1.js → bd0034eb.6691ccc4.js} +1 -1
  51. data/tools/staticdocs/assets/js/c24eae19.251e0038.js +1 -0
  52. data/tools/staticdocs/assets/js/{cb8c3f08.a0ef4b5f.js → cb8c3f08.b82ad06f.js} +1 -1
  53. data/tools/staticdocs/assets/js/cd879be4.f956406f.js +1 -0
  54. data/tools/staticdocs/assets/js/d1b923aa.d6bafb72.js +1 -0
  55. data/tools/staticdocs/assets/js/{d1bfc316.2d823a88.js → d1bfc316.0a5ff560.js} +1 -1
  56. data/tools/staticdocs/assets/js/{d24bf9b6.53eca5e8.js → d24bf9b6.6c422113.js} +1 -1
  57. data/tools/staticdocs/assets/js/{d57a4b5d.aaa48891.js → d57a4b5d.8f23a506.js} +1 -1
  58. data/tools/staticdocs/assets/js/{d5d77c37.be6fe7b6.js → d5d77c37.70fdbbc6.js} +1 -1
  59. data/tools/staticdocs/assets/js/{d8ca4191.c6632184.js → d8ca4191.2349d796.js} +1 -1
  60. data/tools/staticdocs/assets/js/{d9b92eba.c6a2c7e5.js → d9b92eba.8f82360d.js} +1 -1
  61. data/tools/staticdocs/assets/js/{db8fa1d0.f078bc02.js → db8fa1d0.8f1b2c9f.js} +1 -1
  62. data/tools/staticdocs/assets/js/{dc5f7beb.a4afe7cd.js → dc5f7beb.e3a82d1e.js} +1 -1
  63. data/tools/staticdocs/assets/js/{e501b0d1.d108a8a9.js → e501b0d1.0b407477.js} +1 -1
  64. data/tools/staticdocs/assets/js/ebec1ccb.9bea92b0.js +1 -0
  65. data/tools/staticdocs/assets/js/f15615f1.5c433923.js +1 -0
  66. data/tools/staticdocs/assets/js/{fd886806.a21dd400.js → fd886806.4a41fa80.js} +1 -1
  67. data/tools/staticdocs/assets/js/main.b5390098.js +2 -0
  68. data/tools/staticdocs/assets/js/runtime~main.12d1e41d.js +1 -0
  69. data/tools/staticdocs/docs/configuration/command.html +96 -180
  70. data/tools/staticdocs/docs/configuration/format.html +25 -54
  71. data/tools/staticdocs/docs/configuration/interfaces.html +25 -80
  72. data/tools/staticdocs/docs/configuration/plugins.html +138 -178
  73. data/tools/staticdocs/docs/configuration/protocols.html +91 -110
  74. data/tools/staticdocs/docs/configuration/ssl-tls.html +33 -104
  75. data/tools/staticdocs/docs/configuration/table.html +67 -125
  76. data/tools/staticdocs/docs/configuration/target.html +23 -31
  77. data/tools/staticdocs/docs/configuration/telemetry-screens.html +194 -455
  78. data/tools/staticdocs/docs/configuration/telemetry.html +104 -187
  79. data/tools/staticdocs/docs/configuration.html +4 -4
  80. data/tools/staticdocs/docs/development/curl.html +17 -126
  81. data/tools/staticdocs/docs/development/developing.html +29 -80
  82. data/tools/staticdocs/docs/development/host-install.html +10 -23
  83. data/tools/staticdocs/docs/development/json-api.html +20 -32
  84. data/tools/staticdocs/docs/development/log-structure.html +14 -14
  85. data/tools/staticdocs/docs/development/roadmap.html +15 -15
  86. data/tools/staticdocs/docs/development/streaming-api.html +11 -83
  87. data/tools/staticdocs/docs/development/testing.html +17 -26
  88. data/tools/staticdocs/docs/development.html +4 -4
  89. data/tools/staticdocs/docs/getting-started/generators.html +35 -109
  90. data/tools/staticdocs/docs/getting-started/gettingstarted.html +26 -74
  91. data/tools/staticdocs/docs/getting-started/installation.html +24 -35
  92. data/tools/staticdocs/docs/getting-started/key_concepts.html +35 -35
  93. data/tools/staticdocs/docs/getting-started/podman.html +26 -57
  94. data/tools/staticdocs/docs/getting-started/requirements.html +21 -21
  95. data/tools/staticdocs/docs/getting-started/upgrading.html +12 -17
  96. data/tools/staticdocs/docs/getting-started.html +4 -4
  97. data/tools/staticdocs/docs/guides/bridges.html +19 -63
  98. data/tools/staticdocs/docs/guides/cfs.html +44 -184
  99. data/tools/staticdocs/docs/guides/custom-widgets.html +20 -47
  100. data/tools/staticdocs/docs/guides/little-endian-bitfields.html +5 -14
  101. data/tools/staticdocs/docs/guides/local-mode.html +16 -21
  102. data/tools/staticdocs/docs/guides/logging.html +12 -12
  103. data/tools/staticdocs/docs/guides/monitoring.html +22 -137
  104. data/tools/staticdocs/docs/guides/performance.html +18 -27
  105. data/tools/staticdocs/docs/guides/raspberrypi.html +10 -23
  106. data/tools/staticdocs/docs/guides/script-writing.html +85 -391
  107. data/tools/staticdocs/docs/guides/scripting-api.html +482 -1353
  108. data/tools/staticdocs/docs/guides.html +4 -4
  109. data/tools/staticdocs/docs/meta/contributing.html +14 -19
  110. data/tools/staticdocs/docs/meta/licenses.html +13 -31
  111. data/tools/staticdocs/docs/meta/philosophy.html +4 -4
  112. data/tools/staticdocs/docs/meta/xtce.html +15 -17
  113. data/tools/staticdocs/docs/meta.html +4 -4
  114. data/tools/staticdocs/docs/privacy.html +20 -20
  115. data/tools/staticdocs/docs/tools/autonomic.html +22 -22
  116. data/tools/staticdocs/docs/tools/bucket-explorer.html +13 -13
  117. data/tools/staticdocs/docs/tools/calendar.html +21 -21
  118. data/tools/staticdocs/docs/tools/cmd-sender.html +16 -16
  119. data/tools/staticdocs/docs/tools/cmd-tlm-server.html +23 -23
  120. data/tools/staticdocs/docs/tools/data-extractor.html +27 -27
  121. data/tools/staticdocs/docs/tools/data-viewer.html +13 -13
  122. data/tools/staticdocs/docs/tools/handbooks.html +7 -7
  123. data/tools/staticdocs/docs/tools/limits-monitor.html +19 -19
  124. data/tools/staticdocs/docs/tools/packet-viewer.html +16 -16
  125. data/tools/staticdocs/docs/tools/script-runner.html +36 -75
  126. data/tools/staticdocs/docs/tools/table-manager.html +13 -48
  127. data/tools/staticdocs/docs/tools/tlm-grapher.html +23 -23
  128. data/tools/staticdocs/docs/tools/tlm-viewer.html +18 -18
  129. data/tools/staticdocs/docs/tools.html +4 -4
  130. data/tools/staticdocs/docs.html +14 -14
  131. data/tools/staticdocs/index.html +4 -4
  132. data/tools/staticdocs/lunr-index-1724101625047.json +1 -0
  133. data/tools/staticdocs/lunr-index.json +1 -1
  134. data/tools/staticdocs/markdown-page.html +5 -5
  135. data/tools/staticdocs/search-doc-1724101625047.json +1 -0
  136. data/tools/staticdocs/search-doc.json +1 -1
  137. metadata +71 -71
  138. data/tools/staticdocs/assets/js/078dbab0.b275e04c.js +0 -1
  139. data/tools/staticdocs/assets/js/22b3ac48.0f4fbe9d.js +0 -1
  140. data/tools/staticdocs/assets/js/43652efd.be2c1d02.js +0 -1
  141. data/tools/staticdocs/assets/js/4650.292aca67.js +0 -1
  142. data/tools/staticdocs/assets/js/53ca7c5b.3f1245d5.js +0 -1
  143. data/tools/staticdocs/assets/js/5e3ed378.77db7b87.js +0 -1
  144. data/tools/staticdocs/assets/js/5fe211ef.71dc8326.js +0 -1
  145. data/tools/staticdocs/assets/js/6831b732.5714d508.js +0 -1
  146. data/tools/staticdocs/assets/js/6f92e431.300a9857.js +0 -1
  147. data/tools/staticdocs/assets/js/72c6d8a8.cfccace6.js +0 -1
  148. data/tools/staticdocs/assets/js/9424f0b3.29299bde.js +0 -1
  149. data/tools/staticdocs/assets/js/b6d70f94.f5514e8b.js +0 -1
  150. data/tools/staticdocs/assets/js/b9f60ba6.c3b3046d.js +0 -1
  151. data/tools/staticdocs/assets/js/c24eae19.6b084c7c.js +0 -1
  152. data/tools/staticdocs/assets/js/cd879be4.6f19050a.js +0 -1
  153. data/tools/staticdocs/assets/js/d1b923aa.3f3e186d.js +0 -1
  154. data/tools/staticdocs/assets/js/ebec1ccb.1ded1149.js +0 -1
  155. data/tools/staticdocs/assets/js/f15615f1.f9b655a6.js +0 -1
  156. data/tools/staticdocs/assets/js/main.c2e2b617.js +0 -2
  157. data/tools/staticdocs/assets/js/runtime~main.2bb31799.js +0 -1
  158. data/tools/staticdocs/lunr-index-1719505302032.json +0 -1
  159. data/tools/staticdocs/search-doc-1719505302032.json +0 -1
  160. /data/tools/staticdocs/assets/js/{main.c2e2b617.js.LICENSE.txt → main.b5390098.js.LICENSE.txt} +0 -0
@@ -2,17 +2,17 @@
2
2
  <html lang="en" dir="ltr" class="docs-wrapper plugin-docs plugin-id-default docs-version-current docs-doc-page docs-doc-id-guides/script-writing" data-has-hydrated="false">
3
3
  <head>
4
4
  <meta charset="UTF-8">
5
- <meta name="generator" content="Docusaurus v3.4.0">
6
- <title data-rh="true">Script Writing Guide | OpenC3 Docs</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Script Writing Guide | OpenC3 Docs"><meta data-rh="true" name="description" content="Introduction"><meta data-rh="true" property="og:description" content="Introduction"><link data-rh="true" rel="icon" href="/tools/staticdocs/img/favicon.png"><link data-rh="true" rel="canonical" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing"><link data-rh="true" rel="alternate" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing" hreflang="en"><link data-rh="true" rel="alternate" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing" hreflang="x-default"><link rel="stylesheet" href="/tools/staticdocs/assets/css/styles.8a0f1b26.css">
7
- <script src="/tools/staticdocs/assets/js/runtime~main.2bb31799.js" defer="defer"></script>
8
- <script src="/tools/staticdocs/assets/js/main.c2e2b617.js" defer="defer"></script>
5
+ <meta name="generator" content="Docusaurus v3.5.2">
6
+ <title data-rh="true">Script Writing Guide | OpenC3 Docs</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="Script Writing Guide | OpenC3 Docs"><meta data-rh="true" name="description" content="Introduction"><meta data-rh="true" property="og:description" content="Introduction"><link data-rh="true" rel="icon" href="/tools/staticdocs/img/favicon.png"><link data-rh="true" rel="canonical" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing"><link data-rh="true" rel="alternate" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing" hreflang="en"><link data-rh="true" rel="alternate" href="https://docs.openc3.com/tools/staticdocs/docs/guides/script-writing" hreflang="x-default"><link rel="stylesheet" href="/tools/staticdocs/assets/css/styles.80ddca08.css">
7
+ <script src="/tools/staticdocs/assets/js/runtime~main.12d1e41d.js" defer="defer"></script>
8
+ <script src="/tools/staticdocs/assets/js/main.b5390098.js" defer="defer"></script>
9
9
  </head>
10
10
  <body class="navigation-with-keyboard">
11
- <script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"dark")}(),function(){try{const n=new URLSearchParams(window.location.search).entries();for(var[t,e]of n)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_G6ar" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/tools/staticdocs/"><div class="navbar__logo"><img src="/tools/staticdocs/img/logo.svg" alt="OpenC3 Logo" class="themedComponent_DHUr themedComponent--light_DIHH"><img src="/tools/staticdocs/img/logo.svg" alt="OpenC3 Logo" class="themedComponent_DHUr themedComponent--dark_Bv2M"></div><b class="navbar__title text--truncate">OpenC3 Docs</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/tools/staticdocs/docs">Documentation</a><a href="https://openc3.com/enterprise/" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Enterprise</a></div><div class="navbar__items navbar__items--right"><div class="navbarSearchContainer_bmvg"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input id="search_input_react" type="search" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_UyTV"><div class="docsWrapper_XLvK"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_z1FD" type="button"></button><div class="docRoot_HciC"><aside class="theme-doc-sidebar-container docSidebarContainer_e5ai"><div class="sidebarViewport_N8x0"><div class="sidebar_vJCc"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_qiME"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/tools/staticdocs/docs">Introduction</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/getting-started">Getting Started</a><button aria-label="Expand sidebar category &#x27;Getting Started&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/configuration">Configuration</a><button aria-label="Expand sidebar category &#x27;Configuration&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/tools">Tools</a><button aria-label="Expand sidebar category &#x27;Tools&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" href="/tools/staticdocs/docs/guides">Guides</a><button aria-label="Collapse sidebar category &#x27;Guides&#x27;" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/bridges">Bridges</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/cfs">COSMOS and NASA cFS</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/custom-widgets">Custom Widgets</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/little-endian-bitfields">Little Endian Bitfields</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/local-mode">Local Mode</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/logging">Logging</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/monitoring">Monitoring</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/performance">Performance</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/raspberrypi">Raspberry Pi</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/tools/staticdocs/docs/guides/script-writing">Script Writing Guide</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/scripting-api">Scripting API Guide</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/development">Development</a><button aria-label="Expand sidebar category &#x27;Development&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/meta">Meta</a><button aria-label="Expand sidebar category &#x27;Meta&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/tools/staticdocs/docs/privacy">OpenC3, Inc. Privacy Policy</a></li></ul></nav></div></div></aside><main class="docMainContainer_namt"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_YAwJ"><div class="docItemContainer_Rv5Z"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_zCmv" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/tools/staticdocs/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_JFrk"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/tools/staticdocs/docs/guides"><span itemprop="name">Guides</span></a><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Script Writing Guide</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_O_Qc theme-doc-toc-mobile tocMobile_tjDr"><button type="button" class="clean-btn tocCollapsibleButton_htYj">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Script Writing Guide</h1></header><h2 id="introduction">Introduction</h2>
11
+ <script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return window.localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"dark")}(),function(){try{const n=new URLSearchParams(window.location.search).entries();for(var[t,e]of n)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_G6ar" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/tools/staticdocs/"><div class="navbar__logo"><img src="/tools/staticdocs/img/logo.svg" alt="OpenC3 Logo" class="themedComponent_DHUr themedComponent--light_DIHH"><img src="/tools/staticdocs/img/logo.svg" alt="OpenC3 Logo" class="themedComponent_DHUr themedComponent--dark_Bv2M"></div><b class="navbar__title text--truncate">OpenC3 Docs</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/tools/staticdocs/docs">Documentation</a><a href="https://openc3.com/enterprise/" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">Enterprise</a></div><div class="navbar__items navbar__items--right"><div class="navbarSearchContainer_bmvg"><div class="navbar__search"><span aria-label="expand searchbar" role="button" class="search-icon" tabindex="0"></span><input id="search_input_react" type="search" placeholder="Loading..." aria-label="Search" class="navbar__search-input search-bar" disabled=""></div></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_UyTV"><div class="docsWrapper_XLvK"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_z1FD" type="button"></button><div class="docRoot_HciC"><aside class="theme-doc-sidebar-container docSidebarContainer_e5ai"><div class="sidebarViewport_N8x0"><div class="sidebar_vJCc"><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_qiME"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/tools/staticdocs/docs">Introduction</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/getting-started">Getting Started</a><button aria-label="Expand sidebar category &#x27;Getting Started&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/configuration">Configuration</a><button aria-label="Expand sidebar category &#x27;Configuration&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/tools">Tools</a><button aria-label="Expand sidebar category &#x27;Tools&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" href="/tools/staticdocs/docs/guides">Guides</a><button aria-label="Collapse sidebar category &#x27;Guides&#x27;" aria-expanded="true" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/bridges">Bridges</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/cfs">COSMOS and NASA cFS</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/custom-widgets">Custom Widgets</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/little-endian-bitfields">Little Endian Bitfields</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/local-mode">Local Mode</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/logging">Logging</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/monitoring">Monitoring</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/performance">Performance</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/raspberrypi">Raspberry Pi</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/tools/staticdocs/docs/guides/script-writing">Script Writing Guide</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/tools/staticdocs/docs/guides/scripting-api">Scripting API Guide</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/development">Development</a><button aria-label="Expand sidebar category &#x27;Development&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" href="/tools/staticdocs/docs/meta">Meta</a><button aria-label="Expand sidebar category &#x27;Meta&#x27;" aria-expanded="false" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/tools/staticdocs/docs/privacy">OpenC3, Inc. Privacy Policy</a></li></ul></nav></div></div></aside><main class="docMainContainer_namt"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_YAwJ"><div class="docItemContainer_Rv5Z"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_zCmv" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/tools/staticdocs/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_JFrk"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/tools/staticdocs/docs/guides"><span itemprop="name">Guides</span></a><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">Script Writing Guide</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_O_Qc theme-doc-toc-mobile tocMobile_tjDr"><button type="button" class="clean-btn tocCollapsibleButton_htYj">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>Script Writing Guide</h1></header><h2 class="anchor anchorWithStickyNavbar_fF9Z" id="introduction">Introduction<a href="#introduction" class="hash-link" aria-label="Direct link to Introduction" title="Direct link to Introduction">​</a></h2>
12
12
  <p>This guide aims to provide the best practices for using the scripting capabilities provided by COSMOS. Scripts are used to automate a series of activities for operations or testing. The goal of this document is to ensure scripts are written that are simple, easy to understand, maintainable, and correct. Guidance on some of the key details of using the COSMOS Script Runner is also provided.</p>
13
- <h2 id="concepts">Concepts</h2>
13
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="concepts">Concepts<a href="#concepts" class="hash-link" aria-label="Direct link to Concepts" title="Direct link to Concepts">​</a></h2>
14
14
  <p>COSMOS supports both Ruby and Python for writing scripts. Ruby and Python are very similar scripting languages and most of this guide applies directly to both. Where examples are used, both a Ruby and Python example are given.</p>
15
- <h3 id="ruby-vs-python-in-cosmos">Ruby vs Python in COSMOS</h3>
15
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="ruby-vs-python-in-cosmos">Ruby vs Python in COSMOS<a href="#ruby-vs-python-in-cosmos" class="hash-link" aria-label="Direct link to Ruby vs Python in COSMOS" title="Direct link to Ruby vs Python in COSMOS">​</a></h3>
16
16
  <p>There are many similarities and a few key differences between Ruby and Python when it comes to writing COSMOS scripts.</p>
17
17
  <ol>
18
18
  <li>There is no 80 character limit on line length. Lines can be as long as you like, but be careful to not make them too long as it makes printed reviews of scripts more difficult.</li>
@@ -55,451 +55,161 @@
55
55
  </ul>
56
56
  <div style="clear:both"></div>
57
57
  <p>The following is an example of good Ruby style:</p>
58
- <pre><code class="language-ruby">load &#x27;TARGET/lib/upload_utility.rb&#x27; # library we do NOT want to show executing
59
- load_utility &#x27;TARGET/lib/helper_utility.rb&#x27; # library we do want to show executing
60
-
61
- # Declare constants
62
- OUR_TARGETS = [&#x27;INST&#x27;,&#x27;INST2&#x27;]
63
-
64
- # Clear the collect counter of the passed in target name
65
- def clear_collects(target)
66
- cmd(&quot;#{target} CLEAR&quot;)
67
- wait_check(&quot;#{target} HEALTH_STATUS COLLECTS == 0&quot;, 5)
68
- end
69
-
70
- ######################################
71
- # START
72
- ######################################
73
- helper = HelperUtility.new
74
- helper.setup
75
-
76
- # Perform collects on all the targets
77
- OUR_TARGETS.each do |target|
78
- collects = tlm(&quot;#{target} HEALTH_STATUS COLLECTS&quot;)
79
- cmd(&quot;#{target} COLLECT with TYPE SPECIAL&quot;)
80
- wait_check(&quot;#{target} HEALTH_STATUS COLLECTS == #{collects + 1}&quot;, 5)
81
- end
82
-
83
- clear_collects(&#x27;INST&#x27;)
84
- clear_collects(&#x27;INST2&#x27;)
85
- </code></pre>
58
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">load </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;TARGET/lib/upload_utility.rb&#x27;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># library we do NOT want to show executing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">load_utility </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;TARGET/lib/helper_utility.rb&#x27;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># library we do want to show executing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Declare constants</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token constant" style="color:rgb(130, 170, 255)">OUR_TARGETS</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST2&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Clear the collect counter of the passed in target name</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">target</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> CLEAR&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS == 0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">######################################</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># START</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">######################################</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">helper </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">HelperUtility</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">helper</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">setup</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Perform collects on all the targets</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token constant" style="color:rgb(130, 170, 255)">OUR_TARGETS</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">each</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">do</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain">target</span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> collects </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> COLLECT with TYPE SPECIAL&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS == </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">collects </span><span class="token string-literal interpolation content operator" style="color:rgb(127, 219, 202)">+</span><span class="token string-literal interpolation content"> </span><span class="token string-literal interpolation content number" style="color:rgb(247, 140, 108)">1</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST2&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
86
59
  <p>The following is an example of good Python style:</p>
87
- <pre><code class="language-python">from openc3.script import *
88
-
89
- import TARGET.lib.upload_utility # library we do NOT want to show executing
90
- load_utility(&#x27;TARGET/lib/helper_utility.rb&#x27;) # library we do want to show executing
91
-
92
- # Declare constants
93
- OUR_TARGETS = [&#x27;INST&#x27;,&#x27;INST2&#x27;]
94
-
95
- # Clear the collect counter of the passed in target name
96
- def clear_collects(target):
97
- cmd(f&quot;{target} CLEAR&quot;)
98
- wait_check(f&quot;{target} HEALTH_STATUS COLLECTS == 0&quot;, 5)
99
-
100
- ######################################
101
- # START
102
- ######################################
103
- helper = HelperUtility()
104
- helper.setup()
105
-
106
- # Perform collects on all the targets
107
- for target in OUR_TARGETS:
108
- collects = tlm(f&quot;{target} HEALTH_STATUS COLLECTS&quot;)
109
- cmd(f&quot;{target} COLLECT with TYPE SPECIAL&quot;)
110
- wait_check(f&quot;{target} HEALTH_STATUS COLLECTS == {collects + 1}&quot;, 5)
111
-
112
- clear_collects(&#x27;INST&#x27;)
113
- clear_collects(&#x27;INST2&#x27;)
114
- </code></pre>
60
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">from</span><span class="token plain"> openc3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">script </span><span class="token keyword" style="color:rgb(127, 219, 202)">import</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">import</span><span class="token plain"> TARGET</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">lib</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">upload_utility </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># library we do NOT want to show executing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">load_utility</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;TARGET/lib/helper_utility.rb&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># library we do want to show executing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Declare constants</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">OUR_TARGETS </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST2&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Clear the collect counter of the passed in target name</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">target</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> CLEAR&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS == 0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">######################################</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># START</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">######################################</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">helper </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> HelperUtility</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">helper</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">setup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Perform collects on all the targets</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">for</span><span class="token plain"> target </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> OUR_TARGETS</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> collects </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> COLLECT with TYPE SPECIAL&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> HEALTH_STATUS COLLECTS == </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">collects </span><span class="token string-interpolation interpolation operator" style="color:rgb(127, 219, 202)">+</span><span class="token string-interpolation interpolation"> </span><span class="token string-interpolation interpolation number" style="color:rgb(247, 140, 108)">1</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">clear_collects</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST2&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
115
61
  <p>Both examples shows several features of COSMOS scripting in action. Notice the difference between &#x27;load&#x27; or &#x27;import&#x27; and &#x27;load_utility&#x27;. The first is to load additional scripts which will NOT be shown in Script Runner when executing. This is a good place to put code which takes a long time to run such as image analysis or other looping code where you just want the output. &#x27;load_utility&#x27; will visually execute the code line by line to show the user what is happening.</p>
116
62
  <p>Next we declare our constants and create an array of strings which we store in OUR_TARGETS. Notice the constant is all uppercase with underscores.</p>
117
63
  <p>Then we declare our local methods of which we have one called clear_collects. Please provide a comment at the beginning of each method describing what it does and the parameters that it takes.</p>
118
64
  <p>The &#x27;helper_utility&#x27; is then created. Note the similarity in the class name and the file name we loaded.</p>
119
65
  <p>The collect example shows how you can iterate over the array of strings we previously created and use variables when commanding and checking telemetry. The Ruby pound bracket #<!-- --> notation and python f-string f&quot;<!-- --> notation puts whatever the variable holds into the string. You can even execute additional code inside the brackets like we do when checking for the collect count to increment.</p>
120
66
  <p>Finally we call our &#x27;clear_collects&#x27; method on each target by passing the target name.</p>
121
- <h2 id="scripting-philosophy">Scripting Philosophy</h2>
122
- <h3 id="a-super-basic-script-example">A Super Basic Script Example</h3>
67
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="scripting-philosophy">Scripting Philosophy<a href="#scripting-philosophy" class="hash-link" aria-label="Direct link to Scripting Philosophy" title="Direct link to Scripting Philosophy">​</a></h2>
68
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="a-super-basic-script-example">A Super Basic Script Example<a href="#a-super-basic-script-example" class="hash-link" aria-label="Direct link to A Super Basic Script Example" title="Direct link to A Super Basic Script Example">​</a></h3>
123
69
  <p>Most COSMOS scripts can be broken down into the simple pattern of sending a command to a system/subsystem and then verifying that the command worked as expected. This pattern is most commonly implemented with cmd() followed by wait_check(), like the following:</p>
124
- <pre><code class="language-ruby">cmd(&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;)
125
- wait_check(&quot;INST HEALTH_STATUS TYPE == &#x27;NORMAL&#x27;&quot;, 5)
126
- </code></pre>
70
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS TYPE == &#x27;NORMAL&#x27;&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
127
71
  <p>or similarly with a counter that is sampled before the command.</p>
128
72
  <p>Ruby:</p>
129
- <pre><code class="language-ruby">count = tlm(&quot;INST HEALTH_STATUS COLLECTS&quot;)
130
- cmd(&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;)
131
- wait_check(&quot;INST HEALTH_STATUS COLLECTS &gt;= #{count + 1}&quot;, 5)
132
- </code></pre>
73
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">count </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS COLLECTS&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS COLLECTS &gt;= </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">count </span><span class="token string-literal interpolation content operator" style="color:rgb(127, 219, 202)">+</span><span class="token string-literal interpolation content"> </span><span class="token string-literal interpolation content number" style="color:rgb(247, 140, 108)">1</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
133
74
  <p>Python:</p>
134
- <pre><code class="language-python">count = tlm(&quot;INST HEALTH_STATUS COLLECTS&quot;)
135
- cmd(&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;)
136
- wait_check(f&quot;INST HEALTH_STATUS COLLECTS &gt;= {count + 1}&quot;, 5)
137
- </code></pre>
75
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">count </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS COLLECTS&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;INST COLLECT with TYPE NORMAL, TEMP 10.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;INST HEALTH_STATUS COLLECTS &gt;= </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">count </span><span class="token string-interpolation interpolation operator" style="color:rgb(127, 219, 202)">+</span><span class="token string-interpolation interpolation"> </span><span class="token string-interpolation interpolation number" style="color:rgb(247, 140, 108)">1</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
138
76
  <p>90% of the COSMOS scripts you write should be the simple patterns shown above except that you may need to check more than one item after each command to make sure the command worked as expected.</p>
139
- <h3 id="kiss-keep-it-simple-stupid">KISS (Keep It Simple Stupid)</h3>
77
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="kiss-keep-it-simple-stupid">KISS (Keep It Simple Stupid)<a href="#kiss-keep-it-simple-stupid" class="hash-link" aria-label="Direct link to KISS (Keep It Simple Stupid)" title="Direct link to KISS (Keep It Simple Stupid)">​</a></h3>
140
78
  <p>Ruby and Python are very powerful languages with many ways to accomplish the same thing. Given that, always choose the method that is easiest to understand for yourself and others. While it is possible to create complex one liners or obtuse regular expressions, you&#x27;ll thank yourself later by expanding complex one liners and breaking up and documenting regular expressions.</p>
141
- <h3 id="keep-things-dry-dont-repeat-yourself">Keep things DRY (Don&#x27;t Repeat Yourself)</h3>
79
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="keep-things-dry-dont-repeat-yourself">Keep things DRY (Don&#x27;t Repeat Yourself)<a href="#keep-things-dry-dont-repeat-yourself" class="hash-link" aria-label="Direct link to Keep things DRY (Don&#x27;t Repeat Yourself)" title="Direct link to Keep things DRY (Don&#x27;t Repeat Yourself)">​</a></h3>
142
80
  <p>A widespread problem in scripts written for any command and control system is large blocks of code that are repeated multiple times. In extreme cases, this has led to 100,000+ line scripts that are impossible to maintain and review.</p>
143
81
  <p>There are two common ways repetition presents itself: exact blocks of code to perform a common action such as powering on a subsystem, and blocks of code that only differ in the name of the mnemonic being checked or the values checked against. Both are solved by removing the repetition using methods (or functions).</p>
144
82
  <p>For example, a script that powers on a subsystem and ensures correct telemetry would become:</p>
145
83
  <p>Ruby:</p>
146
- <pre><code class="language-ruby">def power_on_subsystem
147
- # 100 lines of cmd(), wait_check(), etc
148
- end
149
- </code></pre>
84
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">power_on_subsystem</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># 100 lines of cmd(), wait_check(), etc</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
150
85
  <p>Python:</p>
151
- <pre><code class="language-python">def power_on_subsystem():
152
- # 100 lines of cmd(), wait_check(), etc
153
- </code></pre>
86
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">power_on_subsystem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># 100 lines of cmd(), wait_check(), etc</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
154
87
  <p>Ideally, the above methods would be stored in another file where it could be used by other scripts. If it is truly only useful in the one script, then it could be at the top of the file. The updated script would then look like:</p>
155
- <pre><code class="language-ruby">power_on_subsystem()
156
- # 150 lines operating the subsystem (e.g.)
157
- # cmd(...)
158
- # wait_check(...)
159
- #...
160
- power_off_subystem()
161
- # Unrelated activities
162
- power_on_subsystem()
163
- # etc.
164
- </code></pre>
88
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">power_on_subsystem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># 150 lines operating the subsystem (e.g.)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># cmd(...)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># wait_check(...)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">#...</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">power_off_subystem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Unrelated activities</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">power_on_subsystem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># etc.</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
165
89
  <p>Blocks of code where only the only variation is the mnemonics or values checked can be replaced by methods with arguments.</p>
166
90
  <p>Ruby:</p>
167
- <pre><code class="language-ruby">def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp)
168
- cmd(&quot;TARGET #{enable_cmd_name} with ENABLE TRUE&quot;)
169
- wait_check(&quot;TARGET #{enable_tlm} == &#x27;TRUE&#x27;&quot;, 5)
170
- wait_check(&quot;TARGET #{temp_tlm} &gt;= #{expected_temp}&quot;, 50)
171
- end
172
- </code></pre>
91
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">test_minimum_temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">enable_cmd_name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> enable_tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> temp_tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> expected_temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;TARGET </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">enable_cmd_name</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> with ENABLE TRUE&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;TARGET </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">enable_tlm</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> == &#x27;TRUE&#x27;&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;TARGET </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">temp_tlm</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> &gt;= </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">expected_temp</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">50</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
173
92
  <p>Python:</p>
174
- <pre><code class="language-python">def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp):
175
- cmd(f&quot;TARGET {enable_cmd_name} with ENABLE TRUE&quot;)
176
- wait_check(f&quot;TARGET {enable_tlm} == &#x27;TRUE&#x27;&quot;, 5)
177
- wait_check(f&quot;TARGET {temp_tlm} &gt;= {expected_temp}&quot;, 50)
178
- </code></pre>
179
- <h3 id="use-comments-appropriately">Use Comments Appropriately</h3>
93
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">test_minimum_temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">enable_cmd_name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> enable_tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> temp_tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> expected_temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;TARGET </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">enable_cmd_name</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> with ENABLE TRUE&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;TARGET </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">enable_tlm</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> == &#x27;TRUE&#x27;&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;TARGET </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">temp_tlm</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> &gt;= </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">expected_temp</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">50</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
94
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="use-comments-appropriately">Use Comments Appropriately<a href="#use-comments-appropriately" class="hash-link" aria-label="Direct link to Use Comments Appropriately" title="Direct link to Use Comments Appropriately">​</a></h3>
180
95
  <p>Use comments when what you are doing is unclear or there is a higher-level purpose to a set of lines. Try to avoid putting numbers or other details in a comment as they can become out of sync with the underlying code. Ruby and Python comments start with a # pound symbol and can be anywhere on a line.</p>
181
- <pre><code class="language-ruby"># This line sends an abort command - BAD COMMENT, UNNECCESSARY
182
- cmd(&quot;INST ABORT&quot;)
183
- # Rotate the gimbal to look at the calibration target - GOOD COMMENT
184
- cmd(&quot;INST ROTATE with ANGLE 180.0&quot;) # Rotate 180 degrees - BAD COMMENT
185
- </code></pre>
186
- <h3 id="script-runner">Script Runner</h3>
96
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># This line sends an abort command - BAD COMMENT, UNNECCESSARY</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST ABORT&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Rotate the gimbal to look at the calibration target - GOOD COMMENT</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST ROTATE with ANGLE 180.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Rotate 180 degrees - BAD COMMENT</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
97
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="script-runner">Script Runner<a href="#script-runner" class="hash-link" aria-label="Direct link to Script Runner" title="Direct link to Script Runner">​</a></h3>
187
98
  <p>COSMOS provides two unique ways to run scripts (also known as procedures). Script Runner provides both a script execution environment and a script editor. The script editor includes code completion for both COSMOS methods and command/telemetry item names. It is also a great environment to develop and test scripts. Script Runner provides a framework for users that are familiar with a traditional scripting model with longer style procedures, and for users that want to be able to edit their scripts in place.</p>
188
99
  <p>When opening a suite file (named with &#x27;suite&#x27;) Script Runner provides a more formal, but also more powerful, environment for running scripts. Suite files breaks scripts down into suites, groups, and scripts (individual methods). Suites are the highest-level concept and would typically cover a large procedure such as a thermal vacuum test, or a large operations scenario such as performing on orbit checkout. Groups capture a related set of scripts such as all the scripts regarding a specific mechanism. A Group might be a collection of scripts all related to a subsystem, or a specific series of tests such as an RF checkout. Scripts capture individual activities that can either pass or fail. Script Runner allows for running an entire suite, one or more groups, or one or more scripts easily. It also automatically produces reports containing timing, pass / fail counts, etc.</p>
189
100
  <p>The correct environment for the job is up to individual users, and many programs will use both script formats to complete their goals.</p>
190
- <h3 id="looping-vs-unrolled-loops">Looping vs Unrolled Loops</h3>
101
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="looping-vs-unrolled-loops">Looping vs Unrolled Loops<a href="#looping-vs-unrolled-loops" class="hash-link" aria-label="Direct link to Looping vs Unrolled Loops" title="Direct link to Looping vs Unrolled Loops">​</a></h3>
191
102
  <p>Loops are powerful constructs that allow you to perform the same operations multiple times without having to rewrite the same code over and over (See the DRY Concept). However, they can make restarting a COSMOS script at the point of a failure difficult or impossible. If there is a low probability of something failing, then loops are an excellent choice. If a script is running a loop over a list of telemetry points, it may be a better choice to “unroll” the loop by making the loop body into a method, and then calling that method directly for each iteration of a loop that would have occurred.</p>
192
103
  <p>Ruby:</p>
193
- <pre><code class="language-ruby">10.times do |temperature_number|
194
- check_temperature(temperature_number + 1)
195
- end
196
- </code></pre>
104
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token number" style="color:rgb(247, 140, 108)">10.</span><span class="token plain">times </span><span class="token keyword" style="color:rgb(127, 219, 202)">do</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain">temperature_number</span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">temperature_number </span><span class="token operator" style="color:rgb(127, 219, 202)">+</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
197
105
  <p>Python:</p>
198
- <pre><code class="language-python">for temperature_number in range(1, 11):
199
- check_temperature(temperature_number)
200
- </code></pre>
106
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">for</span><span class="token plain"> temperature_number </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> </span><span class="token builtin" style="color:rgb(130, 170, 255)">range</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">11</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">temperature_number</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
201
107
  <p>If the above script was stopped after temperature number 3, there would be no way to restart the loop at temperature number 4. A better solution for small loop counts is to unroll the loop.</p>
202
- <pre><code class="language-ruby">check_temperature(1)
203
- check_temperature(2)
204
- check_temperature(3)
205
- check_temperature(4)
206
- check_temperature(5)
207
- check_temperature(6)
208
- check_temperature(7)
209
- check_temperature(8)
210
- check_temperature(9)
211
- check_temperature(10)
212
- </code></pre>
108
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">4</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">6</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">7</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">8</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">9</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">check_temperature</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">10</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
213
109
  <p>In the unrolled version above, the COSMOS “Start script at selected line” feature can be used to resume the script at any point.</p>
214
- <h2 id="script-organization">Script Organization</h2>
110
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="script-organization">Script Organization<a href="#script-organization" class="hash-link" aria-label="Direct link to Script Organization" title="Direct link to Script Organization">​</a></h2>
215
111
  <p>All scripts must be part of a <a href="/tools/staticdocs/docs/configuration/plugins">Plugin</a>. You can create a simple plugin called SCRIPTS or PROCEDURES that only contains lib and procedures directories to store scripts. If COSMOS detects a plugin without defined cmd/tlm it will not spawn microservices for telemetry processing.</p>
216
- <h3 id="organizing-your-scripts-into-a-plugin">Organizing Your Scripts into a Plugin</h3>
112
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="organizing-your-scripts-into-a-plugin">Organizing Your Scripts into a Plugin<a href="#organizing-your-scripts-into-a-plugin" class="hash-link" aria-label="Direct link to Organizing Your Scripts into a Plugin" title="Direct link to Organizing Your Scripts into a Plugin">​</a></h3>
217
113
  <p>As your scripts become large with many methods, it makes sense to break them up into multiple files within a plugin. Here is a recommended organization for your plugin&#x27;s scripts/procedures.</p>
218
114
  <table><thead><tr><th>Folder</th><th>Description</th></tr></thead><tbody><tr><td>targets/TARGET_NAME/lib</td><td>Place script files containing reusable target specific methods here</td></tr><tr><td>targets/TARGET_NAME/procedures</td><td>Place simple procedures that are centered around one specific target here</td></tr></tbody></table>
219
115
  <p>In your main procedure you will usually bring in the other files with instrumentation using load_utility.</p>
220
- <pre><code class="language-ruby"># Ruby:
221
- load_utility(&#x27;TARGET/lib/my_other_script.rb&#x27;)
222
- # Python:
223
- load_utility(&#x27;TARGET/procedures/my_other_script.py&#x27;)
224
- </code></pre>
225
- <h3 id="organize-scripts-into-methods">Organize Scripts into Methods</h3>
116
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Ruby:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">load_utility</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;TARGET/lib/my_other_script.rb&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Python:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">load_utility</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;TARGET/procedures/my_other_script.py&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
117
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="organize-scripts-into-methods">Organize Scripts into Methods<a href="#organize-scripts-into-methods" class="hash-link" aria-label="Direct link to Organize Scripts into Methods" title="Direct link to Organize Scripts into Methods">​</a></h3>
226
118
  <p>Put each activity into a distinct method. Putting your scripts into methods makes organization easy and gives a great high-level overview of what the overall script does (assuming you name the methods well). There are no bonus points for vague, short method names. Make your method names long and clear.</p>
227
119
  <p>Ruby:</p>
228
- <pre><code class="language-ruby">def test_1_heater_zone_control
229
- puts &quot;Verifies requirements 304, 306, and 310&quot;
230
- # Test code here
231
- end
232
-
233
- def script_1_heater_zone_control
234
- puts &quot;Verifies requirements 304, 306, and 310&quot;
235
- # Test code here
236
- end
237
- </code></pre>
120
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">test_1_heater_zone_control</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, and 310&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Test code here</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">script_1_heater_zone_control</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, and 310&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Test code here</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
238
121
  <p>Python:</p>
239
- <pre><code class="language-python">def test_1_heater_zone_control():
240
- print(&quot;Verifies requirements 304, 306, and 310&quot;)
241
- # Test code here
242
-
243
- def script_1_heater_zone_control():
244
- print(&quot;Verifies requirements 304, 306, and 310&quot;)
245
- # Test code here
246
- </code></pre>
247
- <h3 id="using-classes-vs-unscoped-methods">Using Classes vs Unscoped Methods</h3>
122
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">test_1_heater_zone_control</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, and 310&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Test code here</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">script_1_heater_zone_control</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, and 310&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Test code here</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
123
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="using-classes-vs-unscoped-methods">Using Classes vs Unscoped Methods<a href="#using-classes-vs-unscoped-methods" class="hash-link" aria-label="Direct link to Using Classes vs Unscoped Methods" title="Direct link to Using Classes vs Unscoped Methods">​</a></h3>
248
124
  <p>Classes in object-oriented programing allow you to organize a set of related methods and some associated state. The most important aspect is that the methods work on some shared state. For example, if you have code that moves a gimbal around, and need to keep track of the number of moves, or steps, performed across methods, then that is a wonderful place to use a class. If you just need a helper method to do something that happens multiple times in a script without copy and pasting, it probably does not need to be in a class.</p>
249
125
  <p>NOTE: The convention in COSMOS is to have a TARGET/lib/target.[rb/py] file which is named after the TARGET name and contains a class called Target. This discussion refers to scripts in the TARGET/procedures directory.</p>
250
126
  <p>Ruby:</p>
251
- <pre><code class="language-ruby">class Gimbal
252
- attr_accessor :gimbal_steps
253
- def initialize()
254
- @gimbal_steps = 0
255
- end
256
- def move(steps_to_move)
257
- # Move the gimbal
258
- @gimbal_steps += steps_to_move
259
- end
260
- def home_gimbal
261
- # Home the gimbal
262
- @gimbal_steps = 0
263
- end
264
- end
265
-
266
- def perform_common_math(x, y)
267
- x + y
268
- end
269
-
270
- gimbal = Gimbal.new
271
- gimbal.home_gimbal
272
- gimbal.move(100)
273
- gimbal.move(200)
274
- puts &quot;Moved gimbal #{gimbal.gimbal_steps}&quot;
275
- result = perform_common_math(gimbal.gimbal_steps, 10)
276
- puts &quot;Math:#{result}&quot;
277
- </code></pre>
127
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">Gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> attr_accessor </span><span class="token symbol">:gimbal_steps</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">initialize</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token variable" style="color:rgb(214, 222, 235)">@gimbal_steps</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">steps_to_move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Move the gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token variable" style="color:rgb(214, 222, 235)">@gimbal_steps</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> steps_to_move</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">home_gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Home the gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token variable" style="color:rgb(214, 222, 235)">@gimbal_steps</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">perform_common_math</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">x</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> y</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> x </span><span class="token operator" style="color:rgb(127, 219, 202)">+</span><span class="token plain"> y</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">Gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">home_gimbal</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">100</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">200</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Moved gimbal </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">gimbal</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token string-literal interpolation content">gimbal_steps</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">result </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> perform_common_math</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">gimbal_steps</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Math:</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">result</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
278
128
  <p>Python:</p>
279
- <pre><code class="language-python">class Gimbal:
280
- def __init__(self):
281
- self.gimbal_steps = 0
282
-
283
- def move(self, steps_to_move):
284
- # Move the gimbal
285
- self.gimbal_steps += steps_to_move
286
-
287
- def home_gimbal(self):
288
- # Home the gimbal
289
- self.gimbal_steps = 0
290
-
291
- def perform_common_math(x, y):
292
- return x + y
293
-
294
- gimbal = Gimbal()
295
- gimbal.home_gimbal()
296
- gimbal.move(100)
297
- gimbal.move(200)
298
- print(f&quot;Moved gimbal {gimbal.gimbal_steps}&quot;)
299
- result = perform_common_math(gimbal.gimbal_steps, 10)
300
- print(f&quot;Math:{result}&quot;)
301
- </code></pre>
302
- <h3 id="instrumented-vs-uninstrumented-lines-require-vs-load">Instrumented vs Uninstrumented Lines (require vs load)</h3>
303
- <p>COSMOS scripts are normally “instrumented”. This means that each line has some extra code added behind the scenes that primarily highlights the current executing line and catches exceptions if things fail such as a wait_check. If your script needs to use code in other files, there are a few ways to bring in that code. Some techniques bring in instrumented code and others bring in uninstrumented code. There are reasons to use both.</p>
129
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">Gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">__init__</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">gimbal_steps </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> steps_to_move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Move the gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">gimbal_steps </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> steps_to_move</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">home_gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Home the gimbal</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> self</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">gimbal_steps </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">perform_common_math</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">x</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> y</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token plain"> x </span><span class="token operator" style="color:rgb(127, 219, 202)">+</span><span class="token plain"> y</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> Gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">home_gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">100</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">move</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">200</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;Moved gimbal </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">gimbal</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token string-interpolation interpolation">gimbal_steps</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">result </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> perform_common_math</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">gimbal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">gimbal_steps</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;Math:</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">result</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
130
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="instrumented-vs-uninstrumented-lines-require-vs-load">Instrumented vs Uninstrumented Lines (require vs load)<a href="#instrumented-vs-uninstrumented-lines-require-vs-load" class="hash-link" aria-label="Direct link to Instrumented vs Uninstrumented Lines (require vs load)" title="Direct link to Instrumented vs Uninstrumented Lines (require vs load)">​</a></h3>
131
+ <p>COSMOS scripts are normally “instrumented”. This means that each line has some extra code added behind the scenes that primarily highlights the current executing line and catches exceptions if things fail such as a wait_check. If your script needs to use code in other files, there are a few ways to bring in that code. Some techniques bring in instrumented code and others bring in uninstrumented code. There are reasons to use both.</p>
304
132
  <p>load_utility (and the deprecated require_utility), bring in instrumented code from other files. When COSMOS runs the code in the other file, Script Runner will dive into the other file and show each line highlighted as it executes. This should be the default way to bring in other files, as it allows continuing if something fails, and provides better visibility to operators.</p>
305
133
  <p>However, sometimes you don&#x27;t want to display code executing from other files. Externally developed libraries generally do not like to be instrumented, and code that contains large loops or that just takes a long time to execute when highlighting lines, will be much faster if included in a method that does not instrument lines. Ruby provides two ways to bring in uninstrumented code. The first is the “load” keyword. Load will bring in the code from another file and will bring in any changes to the file if it is updated on the next call to load. “require” is like load but is optimized to only bring in the code from another file once. Therefore, if you use require and then change the file it requires, you must restart Script Runner to re-require the file and bring in the changes. In general, load is recommended over require for COSMOS scripting. One gotcha with load is that it requires the full filename including extension, while the require keyword does not.</p>
306
134
  <p>In Python, libraries are included using the import syntax. Any code imported using import is not instrumented. Only the code imported using load_utility is instrumented.</p>
307
135
  <p>Finally, COSMOS scripting has a special syntax for disabling instrumentation in the middle of an instrumented script, with the disable_instrumentation method. This allows you to disable instrumentation for large loops and other activities that are too slow when running instrumented.</p>
308
136
  <p>Ruby:</p>
309
- <pre><code class="language-ruby">temp = 0
310
- disable_instrumentation do
311
- # Make sure nothing in here will raise exceptions!
312
- 5000000.times do
313
- temp += 1
314
- end
315
- end
316
- puts temp
317
- </code></pre>
137
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">disable_instrumentation </span><span class="token keyword" style="color:rgb(127, 219, 202)">do</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Make sure nothing in here will raise exceptions!</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5000000.</span><span class="token plain">times </span><span class="token keyword" style="color:rgb(127, 219, 202)">do</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">puts temp</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
318
138
  <p>Python:</p>
319
- <pre><code class="language-python">temp = 0
320
- with disable_instrumentation():
321
- # Make sure nothing in here will raise exceptions!
322
- for x in range(0,5000000):
323
- temp += 1
324
- print(temp)
325
- </code></pre>
326
- <admonition title="When Running Uninstrumented Code" type="warning"><p>Make sure that the code will not raise any exceptions or have any check failures. If an exception is raised from uninstrumented code, then your entire script will stop.</p></admonition>
327
- <h2 id="debugging-and-auditing">Debugging and Auditing</h2>
328
- <h3 id="built-in-debugging-capabilities">Built-In Debugging Capabilities</h3>
139
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">with</span><span class="token plain"> disable_instrumentation</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Make sure nothing in here will raise exceptions!</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">for</span><span class="token plain"> x </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> </span><span class="token builtin" style="color:rgb(130, 170, 255)">range</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token number" style="color:rgb(247, 140, 108)">5000000</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">temp</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
140
+ <div class="theme-admonition theme-admonition-warning admonition_IZjC alert alert--warning"><div class="admonitionHeading_uVvU"><span class="admonitionIcon_HiR3"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>When Running Uninstrumented Code</div><div class="admonitionContent_bl22"><p>Make sure that the code will not raise any exceptions or have any check failures. If an exception is raised from uninstrumented code, then your entire script will stop.</p></div></div>
141
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="debugging-and-auditing">Debugging and Auditing<a href="#debugging-and-auditing" class="hash-link" aria-label="Direct link to Debugging and Auditing" title="Direct link to Debugging and Auditing">​</a></h2>
142
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="built-in-debugging-capabilities">Built-In Debugging Capabilities<a href="#built-in-debugging-capabilities" class="hash-link" aria-label="Direct link to Built-In Debugging Capabilities" title="Direct link to Built-In Debugging Capabilities">​</a></h3>
329
143
  <p>Script Runner has built in debugging capabilities that can be useful in determining why your script is behaving in a certain way. Of primary importance is the ability to inspect and set script variables.</p>
330
144
  <p>To use the debugging functionality, first select the “Toggle Debug” option from the Script Menu. This will add a small Debug: prompt to the bottom of the tool. Any code entered in this prompt will be executed when Enter is pressed. To inspect variables in a running script, pause the script and then type the variable name to print out the value of the variable in the debug prompt.</p>
331
- <pre><code class="language-ruby">variable_name
332
- </code></pre>
145
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">variable_name</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
333
146
  <p>Variables can also be set simply by using equals.</p>
334
- <pre><code class="language-ruby">variable_name = 5
335
- </code></pre>
147
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">variable_name </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">5</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
336
148
  <p>If necessary, you can also inject commands from the debug prompt using the normal commanding methods. These commands will be logged to the Script Runner message log, which may be advantageous over using a different COSMOS tool like CmdSender (where the command would only be logged in the CmdTlmServer message log).</p>
337
- <pre><code class="language-ruby">cmd(&quot;INST COLLECT with TYPE NORMAL&quot;)
338
- </code></pre>
149
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST COLLECT with TYPE NORMAL&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
339
150
  <p>Note that the debug prompt keeps the command history and you can scroll through the history by using the up and down arrows.</p>
340
- <h3 id="breakpoints">Breakpoints</h3>
151
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="breakpoints">Breakpoints<a href="#breakpoints" class="hash-link" aria-label="Direct link to Breakpoints" title="Direct link to Breakpoints">​</a></h3>
341
152
  <p>You can click the line number (left side gutter) in Script Runner to add a breakpoint. The script will automatically pause when it hits the breakpoint. Once stopped at the breakpoint, you can evaluate variables using the Debug line.</p>
342
- <h3 id="using-disconnect-mode">Using Disconnect Mode</h3>
153
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="using-disconnect-mode">Using Disconnect Mode<a href="#using-disconnect-mode" class="hash-link" aria-label="Direct link to Using Disconnect Mode" title="Direct link to Using Disconnect Mode">​</a></h3>
343
154
  <p>Disconnect mode is a feature of Script Runner that allows testing scripts in an environment without real hardware in the loop. Disconnect mode is started by selecting Script -&gt; Toggle Disconnect. Once selected, the user is prompted to select which targets to disconnect. By default, all targets are disconnected, which allows for testing scripts without any real hardware. Optionally, only a subset of targets can be selected which can be useful for trying out scripts in partially integrated environments.</p>
344
155
  <p>While in disconnect mode, commands to the disconnected targets always succeed. Additionally, all checks of disconnected targets&#x27; telemetry are immediately successful. This allows for a quick run-through of procedures for logic errors and other script specific errors without having to worry about the behavior and proper functioning of hardware.</p>
345
- <h3 id="auditing-your-scripts">Auditing your Scripts</h3>
156
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="auditing-your-scripts">Auditing your Scripts<a href="#auditing-your-scripts" class="hash-link" aria-label="Direct link to Auditing your Scripts" title="Direct link to Auditing your Scripts">​</a></h3>
346
157
  <p>Script Runner includes several tools to help audit your scripts both before and after execution.</p>
347
- <h4 id="ruby-syntax-check">Ruby Syntax Check</h4>
158
+ <h4 class="anchor anchorWithStickyNavbar_fF9Z" id="ruby-syntax-check">Ruby Syntax Check<a href="#ruby-syntax-check" class="hash-link" aria-label="Direct link to Ruby Syntax Check" title="Direct link to Ruby Syntax Check">​</a></h4>
348
159
  <p>The Ruby Syntax Check tool is found under the Script Menu. This tool uses the ruby executable with the -c flag to run a syntax check on your script. If any syntax errors are found the exact message presented by the Ruby interpreter is shown to the user. These can be cryptic, but the most common faults are not closing a quoted string, forgetting an “end” keyword, or using a block but forgetting the proceeding “do” keyword.</p>
349
- <h2 id="common-scenarios">Common Scenarios</h2>
350
- <h3 id="user-input-best-practices">User Input Best Practices</h3>
160
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="common-scenarios">Common Scenarios<a href="#common-scenarios" class="hash-link" aria-label="Direct link to Common Scenarios" title="Direct link to Common Scenarios">​</a></h2>
161
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="user-input-best-practices">User Input Best Practices<a href="#user-input-best-practices" class="hash-link" aria-label="Direct link to User Input Best Practices" title="Direct link to User Input Best Practices">​</a></h3>
351
162
  <p>COSMOS provides several different methods to gather manual user input in scripts. When using user input methods that allow for arbitrary values (like ask() and ask_string()), it is very important to validate the value given in your script before moving on. When asking for text input, it is extra important to handle different casing possibilities and to ensure that invalid input will either re-prompt the user or take a safe path.</p>
352
163
  <p>Ruby:</p>
353
- <pre><code class="language-ruby">answer = ask_string(&quot;Do you want to continue (y/n)?&quot;)
354
- if answer != &#x27;y&#x27; and answer != &#x27;Y&#x27;
355
- raise &quot;User entered: #{answer}&quot;
356
- end
357
-
358
- temp = 0.0
359
- while temp &lt; 10.0 or temp &gt; 50.0
360
- temp = ask(&quot;Enter the desired temperature between 10.0 and 50.0&quot;)
361
- end
362
- </code></pre>
164
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">answer </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask_string</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Do you want to continue (y/n)?&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> answer </span><span class="token operator" style="color:rgb(127, 219, 202)">!=</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;y&#x27;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">and</span><span class="token plain"> answer </span><span class="token operator" style="color:rgb(127, 219, 202)">!=</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;Y&#x27;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">raise</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;User entered: </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">answer</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">while</span><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">&lt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10.0</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">or</span><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">50.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Enter the desired temperature between 10.0 and 50.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
363
165
  <p>Python:</p>
364
- <pre><code class="language-python">answer = ask_string(&quot;Do you want to continue (y/n)?&quot;)
365
- if answer != &#x27;y&#x27; and answer != &#x27;Y&#x27;:
366
- raise RuntimeError(f&quot;User entered: {answer}&quot;)
367
-
368
- temp = 0.0
369
- while temp &lt; 10.0 or temp &gt; 50.0:
370
- temp = ask(&quot;Enter the desired temperature between 10.0 and 50.0&quot;)
371
- </code></pre>
166
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">answer </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask_string</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Do you want to continue (y/n)?&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> answer </span><span class="token operator" style="color:rgb(127, 219, 202)">!=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;y&#x27;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">and</span><span class="token plain"> answer </span><span class="token operator" style="color:rgb(127, 219, 202)">!=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;Y&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">raise</span><span class="token plain"> RuntimeError</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;User entered: </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">answer</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">while</span><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">&lt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10.0</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">or</span><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">50.0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Enter the desired temperature between 10.0 and 50.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
372
167
  <p>When possible, always use one of the other user input methods that has a constrained list of choices for your users (message_box, vertical_message_box, combo_box).</p>
373
168
  <p>Note that all these user input methods provide the user the option to “Cancel”. When cancel is clicked, the script is paused but remains at the user input line. When hitting “Go” to the continue, the user will be re-prompted to enter the value.</p>
374
- <h3 id="conditionally-require-manual-user-input-steps">Conditionally Require Manual User Input Steps</h3>
169
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="conditionally-require-manual-user-input-steps">Conditionally Require Manual User Input Steps<a href="#conditionally-require-manual-user-input-steps" class="hash-link" aria-label="Direct link to Conditionally Require Manual User Input Steps" title="Direct link to Conditionally Require Manual User Input Steps">​</a></h3>
375
170
  <p>When possible, a useful design pattern is to write your scripts such that they can run without prompting for any user input. This allows the scripts to be more easily tested and provides a documented default value for any user input choices or values. To implement this pattern, all manual steps such as ask(), prompt(), and infinite wait() statements need to be wrapped with an if statement that checks the value of $manual in Ruby or RunningScript.manual in Python. If the variable is set, then the manual steps should be executed. If not, then a default value should be used.</p>
376
171
  <p>Ruby Example:</p>
377
- <pre><code class="language-ruby">if $manual
378
- temp = ask(&quot;Please enter the temperature&quot;)
379
- else
380
- temp = 20.0
381
- end
382
- if !$manual
383
- puts &quot;Skipping infinite wait in auto mode&quot;
384
- else
385
- wait
386
- end
387
- </code></pre>
172
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token variable" style="color:rgb(214, 222, 235)">$manual</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Please enter the temperature&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">20.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">!</span><span class="token variable" style="color:rgb(214, 222, 235)">$manual</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Skipping infinite wait in auto mode&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
388
173
  <p>Python Example:</p>
389
- <pre><code class="language-python">if RunningScript.manual:
390
- temp = ask(&quot;Please enter the temperature&quot;)
391
- else:
392
- temp = 20.0
393
- if not RunningScript.manual:
394
- print(&quot;Skipping infinite wait in auto mode&quot;)
395
- else:
396
- wait()
397
- </code></pre>
174
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> RunningScript</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">manual</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> ask</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Please enter the temperature&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> temp </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">20.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">not</span><span class="token plain"> RunningScript</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">manual</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Skipping infinite wait in auto mode&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
398
175
  <p>When running suites, there is a checkbox at the top of the tool called “Manual” that affects this $manual variable directly.</p>
399
- <h3 id="outputing-extra-information-to-a-report">Outputing Extra Information to a Report</h3>
176
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="outputing-extra-information-to-a-report">Outputing Extra Information to a Report<a href="#outputing-extra-information-to-a-report" class="hash-link" aria-label="Direct link to Outputing Extra Information to a Report" title="Direct link to Outputing Extra Information to a Report">​</a></h3>
400
177
  <p>COSMOS Script Runner operating on a script suite automatically generates a report that shows the PASS/FAILED/SKIPPED state for each script. You can also inject arbitrary text into this report using the example as follows. Alternatively, you can simply use print text into the Script Runner message log.</p>
401
178
  <p>Ruby:</p>
402
- <pre><code class="language-ruby">class MyGroup &lt; OpenC3::Group
403
- def script_1
404
- # The following text will be placed in the report
405
- OpenC3::Group.puts &quot;Verifies requirements 304, 306, 310&quot;
406
- # This puts line will show up in the sr_messages log file
407
- puts &quot;script_1 complete&quot;
408
- end
409
- end
410
- </code></pre>
179
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">MyGroup</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">&lt;</span><span class="token plain"> OpenC3</span><span class="token double-colon punctuation" style="color:rgb(199, 146, 234)">::</span><span class="token plain">Group</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">script_1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># The following text will be placed in the report</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> OpenC3</span><span class="token double-colon punctuation" style="color:rgb(199, 146, 234)">::</span><span class="token plain">Group</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, 310&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># This puts line will show up in the sr_messages log file</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;script_1 complete&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
411
180
  <p>Python:</p>
412
- <pre><code class="language-python">from openc3.script.suite import Group
413
- class MyGroup(Group):
414
- def script_1():
415
- # The following text will be placed in the report
416
- Group.print(&quot;Verifies requirements 304, 306, 310&quot;)
417
- # This puts line will show up in the sr_messages log file
418
- print(&quot;script_1 complete&quot;)
419
- </code></pre>
420
- <h3 id="getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets">Getting the Most Recent Value of a Telemetry Point from Multiple Packets</h3>
181
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">from</span><span class="token plain"> openc3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">script</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">suite </span><span class="token keyword" style="color:rgb(127, 219, 202)">import</span><span class="token plain"> Group</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">MyGroup</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Group</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">script_1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># The following text will be placed in the report</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> Group</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;Verifies requirements 304, 306, 310&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># This puts line will show up in the sr_messages log file</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;script_1 complete&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
182
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets">Getting the Most Recent Value of a Telemetry Point from Multiple Packets<a href="#getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets" class="hash-link" aria-label="Direct link to Getting the Most Recent Value of a Telemetry Point from Multiple Packets" title="Direct link to Getting the Most Recent Value of a Telemetry Point from Multiple Packets">​</a></h3>
421
183
  <p>Some systems include high rate data points with the same name in every packet. COSMOS supports getting the most recent value of a telemetry point that is in multiple packets using a special packet name of LATEST. Assume the target INST has two packets, PACKET1 and PACKET2. Both packets have a telemetry point called TEMP.</p>
422
- <pre><code class="language-ruby"># Get the value of TEMP from the most recently received PACKET1
423
- value = tlm(&quot;INST PACKET1 TEMP&quot;)
424
- # Get the value of TEMP from the most recently received PACKET2
425
- value = tlm(&quot;INST PACKET2 TEMP&quot;)
426
- # Get the value of TEMP from the most recently received PACKET1 or PACKET2
427
- value = tlm(&quot;INST LATEST TEMP&quot;)
428
- </code></pre>
429
- <h3 id="checking-every-single-sample-of-a-telemetry-point">Checking Every Single Sample of a Telemetry Point</h3>
184
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Get the value of TEMP from the most recently received PACKET1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">value </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST PACKET1 TEMP&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Get the value of TEMP from the most recently received PACKET2</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">value </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST PACKET2 TEMP&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Get the value of TEMP from the most recently received PACKET1 or PACKET2</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">value </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST LATEST TEMP&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
185
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="checking-every-single-sample-of-a-telemetry-point">Checking Every Single Sample of a Telemetry Point<a href="#checking-every-single-sample-of-a-telemetry-point" class="hash-link" aria-label="Direct link to Checking Every Single Sample of a Telemetry Point" title="Direct link to Checking Every Single Sample of a Telemetry Point">​</a></h3>
430
186
  <p>When writing COSMOS scripts, checking the most recent value of a telemetry point normally gets the job done. The tlm(), tlm_raw(), etc methods all retrieve the most recent value of a telemetry point. Sometimes you need to perform analysis on every single sample of a telemetry point. This can be done using the COSMOS packet subscription system. The packet subscription system lets you choose one or more packets and receive them all from a queue. You can then pick out the specific telemetry points you care about from each packet.</p>
431
187
  <p>Ruby:</p>
432
- <pre><code class="language-ruby">id = subscribe_packets([[&#x27;INST&#x27;, &#x27;HEALTH_STATUS&#x27;], [&#x27;INST&#x27;, &#x27;ADCS&#x27;]])
433
- wait 1.5
434
- id, packets = get_packets(id)
435
- packets.each do |packet|
436
- puts &quot;#{packet[&#x27;PACKET_TIMESECONDS&#x27;]}: #{packet[&#x27;target_name&#x27;]} #{packet[&#x27;packet_name&#x27;]}&quot;
437
- end
438
- # Wait for some time later and re-use the last returned ID
439
- id, packets = get_packets(id)
440
- </code></pre>
188
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">id </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> subscribe_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;HEALTH_STATUS&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;ADCS&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait </span><span class="token number" style="color:rgb(247, 140, 108)">1.5</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> packets </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> get_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">each</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">do</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain">packet</span><span class="token operator" style="color:rgb(127, 219, 202)">|</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> puts </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">packet</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal interpolation content string-literal string" style="color:rgb(173, 219, 103)">&#x27;PACKET_TIMESECONDS&#x27;</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">: </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">packet</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal interpolation content string-literal string" style="color:rgb(173, 219, 103)">&#x27;target_name&#x27;</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">packet</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-literal interpolation content string-literal string" style="color:rgb(173, 219, 103)">&#x27;packet_name&#x27;</span><span class="token string-literal interpolation content punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Wait for some time later and re-use the last returned ID</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> packets </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> get_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
441
189
  <p>Python:</p>
442
- <pre><code class="language-python">id = subscribe_packets([[&#x27;INST&#x27;, &#x27;HEALTH_STATUS&#x27;], [&#x27;INST&#x27;, &#x27;ADCS&#x27;]])
443
- wait(1.5)
444
- id, packets = get_packets(id)
445
- for packet in packets:
446
- print(f&quot;{packet[&#x27;PACKET_TIMESECONDS&#x27;]}: {packet[&#x27;target_name&#x27;]} {packet[&#x27;packet_name&#x27;]}&quot;)
447
- # Wait for some time later and re-use the last returned ID
448
- id, packets = get_packets(id)
449
- </code></pre>
450
- <h3 id="using-variables-in-mnemonics">Using Variables in Mnemonics</h3>
190
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token builtin" style="color:rgb(130, 170, 255)">id</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> subscribe_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;HEALTH_STATUS&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;INST&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">&#x27;ADCS&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">1.5</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token builtin" style="color:rgb(130, 170, 255)">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> packets </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> get_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token builtin" style="color:rgb(130, 170, 255)">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">for</span><span class="token plain"> packet </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">print</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">packet</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-interpolation interpolation string" style="color:rgb(173, 219, 103)">&#x27;PACKET_TIMESECONDS&#x27;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">: </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">packet</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-interpolation interpolation string" style="color:rgb(173, 219, 103)">&#x27;target_name&#x27;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> </span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">packet</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token string-interpolation interpolation string" style="color:rgb(173, 219, 103)">&#x27;packet_name&#x27;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Wait for some time later and re-use the last returned ID</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token builtin" style="color:rgb(130, 170, 255)">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> packets </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> get_packets</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token builtin" style="color:rgb(130, 170, 255)">id</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
191
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="using-variables-in-mnemonics">Using Variables in Mnemonics<a href="#using-variables-in-mnemonics" class="hash-link" aria-label="Direct link to Using Variables in Mnemonics" title="Direct link to Using Variables in Mnemonics">​</a></h3>
451
192
  <p>Because command and telemetry mnemonics are just strings in COSMOS scripts, you can make use of variables in some contexts to make reusable code. For example, a method can take a target name as an input to support multiple instances of a target. You could also pass in the value for a set of numbered telemetry points.</p>
452
193
  <p>Ruby:</p>
453
- <pre><code class="language-ruby">def example(target_name, temp_number)
454
- cmd(&quot;#{target_name} COLLECT with TYPE NORMAL&quot;)
455
- wait_check(&quot;#{target_name} TEMP#{temp_number} &gt; 50.0&quot;)
456
- end
457
- </code></pre>
194
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">example</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">target_name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> temp_number</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target_name</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> COLLECT with TYPE NORMAL&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">target_name</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> TEMP</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">temp_number</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)"> &gt; 50.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
458
195
  <p>Python:</p>
459
- <pre><code class="language-python">def example(target_name, temp_number):
460
- cmd(f&quot;{target_name} COLLECT with TYPE NORMAL&quot;)
461
- wait_check(f&quot;{target_name} TEMP{temp_number} &gt; 50.0&quot;)
462
- </code></pre>
196
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">example</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">target_name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> temp_number</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> cmd</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target_name</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> COLLECT with TYPE NORMAL&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> wait_check</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)">f&quot;</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">target_name</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> TEMP</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token string-interpolation interpolation">temp_number</span><span class="token string-interpolation interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-interpolation string" style="color:rgb(173, 219, 103)"> &gt; 50.0&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
463
197
  <p>This can also be useful when looping through a numbered set of telemetry points but be considerate of the downsides of looping as discussed in the <a href="#looping-vs-unrolled-loops">Looping vs Unrolled Loops</a> section.</p>
464
- <h3 id="using-custom-wait_check_expression">Using Custom wait_check_expression</h3>
198
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="using-custom-wait_check_expression">Using Custom wait_check_expression<a href="#using-custom-wait_check_expression" class="hash-link" aria-label="Direct link to Using Custom wait_check_expression" title="Direct link to Using Custom wait_check_expression">​</a></h3>
465
199
  <p>The COSMOS wait_check_expression (and check_expression) allow you to perform more complicated checks and still stop the script with a CHECK error message if something goes wrong. For example, you can check variables against each other or check a telemetry point against a range. The exact string of text passed to wait_check_expression is repeatedly evaluated until it passes, or a timeout occurs. It is important to not use string interpolation within the actual expression or the values inside of the string interpolation syntax will only be evaluated once when it is converted into a string.</p>
466
200
  <p>Ruby:</p>
467
- <pre><code class="language-ruby">one = 1
468
- two = 2
469
-
470
- wait_check_expression(&quot;one == two&quot;, 1)
471
- # ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds
472
-
473
- # Checking an integer range
474
- wait_check_expression(&quot;one &gt; 0 and one &lt; 10 # init value one = #{one}&quot;, 1)
475
- </code></pre>
201
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">one </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">two </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check_expression</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;one == two&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Checking an integer range</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check_expression</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;one &gt; 0 and one &lt; 10 # init value one = </span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">#{</span><span class="token string-literal interpolation content">one</span><span class="token string-literal interpolation delimiter punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
476
202
  <p>Python:</p>
477
- <pre><code class="language-python">one = 1
478
- two = 2
479
-
480
- wait_check_expression(&quot;one == two&quot;, 1, 0.25, locals())
481
- # ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds
482
-
483
- # Checking an integer range
484
- wait_check_expression(&quot;one &gt; 0 and one &lt; 10&quot;, 1, 0.25, locals())
485
- </code></pre>
486
- <h3 id="cosmos-scripting-differences-from-regular-ruby-scripting">COSMOS Scripting Differences from Regular Ruby Scripting</h3>
487
- <h4 id="do-not-use-single-line-if-statements">Do not use single line if statements</h4>
203
+ <div class="language-python codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-python codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">one </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">two </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">2</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check_expression</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;one == two&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.25</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token builtin" style="color:rgb(130, 170, 255)">locals</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># Checking an integer range</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">wait_check_expression</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">&quot;one &gt; 0 and one &lt; 10&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.25</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token builtin" style="color:rgb(130, 170, 255)">locals</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
204
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="cosmos-scripting-differences-from-regular-ruby-scripting">COSMOS Scripting Differences from Regular Ruby Scripting<a href="#cosmos-scripting-differences-from-regular-ruby-scripting" class="hash-link" aria-label="Direct link to COSMOS Scripting Differences from Regular Ruby Scripting" title="Direct link to COSMOS Scripting Differences from Regular Ruby Scripting">​</a></h3>
205
+ <h4 class="anchor anchorWithStickyNavbar_fF9Z" id="do-not-use-single-line-if-statements">Do not use single line if statements<a href="#do-not-use-single-line-if-statements" class="hash-link" aria-label="Direct link to Do not use single line if statements" title="Direct link to Do not use single line if statements">​</a></h4>
488
206
  <p>COSMOS scripting instruments each line to catch exceptions if things go wrong. With single line if statements the exception handling doesn&#x27;t know which part of the statement failed and cannot properly continue. If an exception is raised in a single line if statement, then the entire script will stop and not be able to continue. Do not use single line if statements in COSMOS scripts. (However, they are fine to use in interfaces and other Ruby code, just not COSMOS scripts).</p>
489
207
  <p>Don&#x27;t do this:</p>
490
- <pre><code class="language-ruby">run_method() if tlm(&quot;INST HEALTH_STATUS TEMP1&quot;) &gt; 10.0
491
- </code></pre>
208
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token plain">run_method</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS TEMP1&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10.0</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
492
209
  <p>Do this instead:</p>
493
- <pre><code class="language-ruby"># It is best not to execute any code that could fail in an if statement, ie
494
- # tlm() could fail if the CmdTlmServer was not running or a mnemonic
495
- # was misspelled
496
- temp1 = tlm(&quot;INST HEALTH_STATUS TEMP1&quot;)
497
- if temp1 &gt; 10.0
498
- run_method()
499
- end
500
- </code></pre>
501
- <h2 id="when-things-go-wrong">When Things Go Wrong</h2>
502
- <h3 id="common-reasons-checks-fail">Common Reasons Checks Fail</h3>
210
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># It is best not to execute any code that could fail in an if statement, ie</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># tlm() could fail if the CmdTlmServer was not running or a mnemonic</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic"># was misspelled</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">temp1 </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> tlm</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&quot;INST HEALTH_STATUS TEMP1&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> temp1 </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">10.0</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> run_method</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
211
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="when-things-go-wrong">When Things Go Wrong<a href="#when-things-go-wrong" class="hash-link" aria-label="Direct link to When Things Go Wrong" title="Direct link to When Things Go Wrong">​</a></h2>
212
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="common-reasons-checks-fail">Common Reasons Checks Fail<a href="#common-reasons-checks-fail" class="hash-link" aria-label="Direct link to Common Reasons Checks Fail" title="Direct link to Common Reasons Checks Fail">​</a></h3>
503
213
  <p>There are three common reasons that checks fail in COSMOS scripts:</p>
504
214
  <ol>
505
215
  <li>
@@ -515,7 +225,7 @@ end
515
225
  <p>Of course, sometimes there are real failures. See the next section for how to handle them and recover.</p>
516
226
  </li>
517
227
  </ol>
518
- <h3 id="how-to-recover-from-anomalies">How to Recover from Anomalies</h3>
228
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="how-to-recover-from-anomalies">How to Recover from Anomalies<a href="#how-to-recover-from-anomalies" class="hash-link" aria-label="Direct link to How to Recover from Anomalies" title="Direct link to How to Recover from Anomalies">​</a></h3>
519
229
  <p>Once something has failed, and your script has stopped with a pink highlighted line, how can you recover? Fortunately, COSMOS provides several mechanisms that can be used to recover after something in your script fails.</p>
520
230
  <ol>
521
231
  <li>
@@ -535,32 +245,16 @@ end
535
245
  <p>By clicking into a script, and right clicking to select &quot;Run from here&quot;, users can restart a script at an arbitrary point. This works well if no required variable definitions exist earlier in the script.</p>
536
246
  </li>
537
247
  </ol>
538
- <h2 id="advanced-topics">Advanced Topics</h2>
539
- <h3 id="advanced-script-configuration-with-csv-or-excel">Advanced Script Configuration with CSV or Excel</h3>
248
+ <h2 class="anchor anchorWithStickyNavbar_fF9Z" id="advanced-topics">Advanced Topics<a href="#advanced-topics" class="hash-link" aria-label="Direct link to Advanced Topics" title="Direct link to Advanced Topics">​</a></h2>
249
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="advanced-script-configuration-with-csv-or-excel">Advanced Script Configuration with CSV or Excel<a href="#advanced-script-configuration-with-csv-or-excel" class="hash-link" aria-label="Direct link to Advanced Script Configuration with CSV or Excel" title="Direct link to Advanced Script Configuration with CSV or Excel">​</a></h3>
540
250
  <p>Using a spreadsheet to store the values for use by a script can be a great option if you have a CM-controlled script but need to be able to tweak some values for a test or if you need to use different values for different serial numbers.</p>
541
251
  <p>The Ruby CSV class be used to easily read data from CSV files (recommended for cross platform projects).</p>
542
- <pre><code class="language-ruby">require &#x27;csv&#x27;
543
- values = CSV.read(&#x27;test.csv&#x27;)
544
- puts values[0][0]
545
- </code></pre>
252
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">require</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;csv&#x27;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">values </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token constant" style="color:rgb(130, 170, 255)">CSV</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">read</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;test.csv&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">puts values</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
546
253
  <p>If you are only using Windows, COSMOS also contains a library for reading Excel files.</p>
547
- <pre><code class="language-ruby">require &#x27;openc3/win32/excel&#x27;
548
- ss = ExcelSpreadsheet.new(&#x27;C:/git/cosmos/test.xlsx&#x27;)
549
- puts ss[0][0][0]
550
- </code></pre>
551
- <h3 id="when-to-use-ruby-modules">When to use Ruby Modules</h3>
254
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">require</span><span class="token plain"> </span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;openc3/win32/excel&#x27;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">ss </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">ExcelSpreadsheet</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string-literal string" style="color:rgb(173, 219, 103)">&#x27;C:/git/cosmos/test.xlsx&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">puts ss</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
255
+ <h3 class="anchor anchorWithStickyNavbar_fF9Z" id="when-to-use-ruby-modules">When to use Ruby Modules<a href="#when-to-use-ruby-modules" class="hash-link" aria-label="Direct link to When to use Ruby Modules" title="Direct link to When to use Ruby Modules">​</a></h3>
552
256
  <p>Modules in Ruby have two purposes: namespacing and mixins. Namespacing allows having classes and methods with the same name, but with different meanings. For example, if they are namespaced, COSMOS can have a Packet class and another Ruby library can have a Packet class. This isn&#x27;t typically useful for COSMOS scripting though.</p>
553
257
  <p>Mixins allow adding common methods to classes without using inheritance. Mixins can be useful to add common functionality to some classes but not others, or to break up classes into multiple files.</p>
554
- <pre><code class="language-ruby">module MyModule
555
- def module_method
556
- end
557
- end
558
- class MyTest &lt; OpenC3::Group
559
- include MyModule
560
- def test_1
561
- module_method()
562
- end
563
- end
564
- </code></pre></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="row margin-top--sm theme-doc-footer-edit-meta-row"><div class="col"><a href="https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/script-writing.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_UohW" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_g62E"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/tools/staticdocs/docs/guides/raspberrypi"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Raspberry Pi</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/tools/staticdocs/docs/guides/scripting-api"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Scripting API Guide</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_TN1Q thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#introduction">Introduction</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#concepts">Concepts</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#ruby-vs-python-in-cosmos">Ruby vs Python in COSMOS</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#scripting-philosophy">Scripting Philosophy</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#a-super-basic-script-example">A Super Basic Script Example</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#kiss-keep-it-simple-stupid">KISS (Keep It Simple Stupid)</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#keep-things-dry-dont-repeat-yourself">Keep things DRY (Don&#39;t Repeat Yourself)</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#use-comments-appropriately">Use Comments Appropriately</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#script-runner">Script Runner</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#looping-vs-unrolled-loops">Looping vs Unrolled Loops</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#script-organization">Script Organization</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#organizing-your-scripts-into-a-plugin">Organizing Your Scripts into a Plugin</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#organize-scripts-into-methods">Organize Scripts into Methods</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#using-classes-vs-unscoped-methods">Using Classes vs Unscoped Methods</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#instrumented-vs-uninstrumented-lines-require-vs-load">Instrumented vs Uninstrumented Lines (require vs load)</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#debugging-and-auditing">Debugging and Auditing</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#built-in-debugging-capabilities">Built-In Debugging Capabilities</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#breakpoints">Breakpoints</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#using-disconnect-mode">Using Disconnect Mode</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#auditing-your-scripts">Auditing your Scripts</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#ruby-syntax-check">Ruby Syntax Check</a></li></ul></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#common-scenarios">Common Scenarios</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#user-input-best-practices">User Input Best Practices</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#conditionally-require-manual-user-input-steps">Conditionally Require Manual User Input Steps</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#outputing-extra-information-to-a-report">Outputing Extra Information to a Report</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets">Getting the Most Recent Value of a Telemetry Point from Multiple Packets</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#checking-every-single-sample-of-a-telemetry-point">Checking Every Single Sample of a Telemetry Point</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#using-variables-in-mnemonics">Using Variables in Mnemonics</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#using-custom-wait_check_expression">Using Custom wait_check_expression</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#cosmos-scripting-differences-from-regular-ruby-scripting">COSMOS Scripting Differences from Regular Ruby Scripting</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#do-not-use-single-line-if-statements">Do not use single line if statements</a></li></ul></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#when-things-go-wrong">When Things Go Wrong</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#common-reasons-checks-fail">Common Reasons Checks Fail</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#how-to-recover-from-anomalies">How to Recover from Anomalies</a></li></ul></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#advanced-topics">Advanced Topics</a><ul><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#advanced-script-configuration-with-csv-or-excel">Advanced Script Configuration with CSV or Excel</a></li><li><a class="table-of-contents__link toc-highlight" href="/tools/staticdocs/docs/guides/script-writing#when-to-use-ruby-modules">When to use Ruby Modules</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Homepage</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://openc3.com" target="_blank" rel="noopener noreferrer" class="footer__link-item">Home</a></li></ul></div><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/tools/staticdocs/docs">Documentation</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://www.linkedin.com/company/openc3" target="_blank" rel="noopener noreferrer" class="footer__link-item">LinkedIn<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_awgD"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://github.com/OpenC3/cosmos" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_awgD"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a class="footer__link-item" href="/tools/staticdocs/docs/privacy">Privacy</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2024 OpenC3, Inc.</div></div></div></footer></div>
258
+ <div class="language-ruby codeBlockContainer_ZGJx theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_qZBB"><pre tabindex="0" class="prism-code language-ruby codeBlock_TAPP thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_AdAo"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">module</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">MyModule</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">module_method</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">MyTest</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">&lt;</span><span class="token plain"> OpenC3</span><span class="token double-colon punctuation" style="color:rgb(199, 146, 234)">::</span><span class="token plain">Group</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">include</span><span class="token plain"> MyModule</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">def</span><span class="token plain"> </span><span class="token method-definition function" style="color:rgb(130, 170, 255)">test_1</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> module_method</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">end</span><br></span></code></pre><div class="buttonGroup_TNwR"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_MVhB" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_yxgH"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_QJLJ"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="row margin-top--sm theme-doc-footer-edit-meta-row"><div class="col"><a href="https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/script-writing.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_UohW" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_g62E"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages"><a class="pagination-nav__link pagination-nav__link--prev" href="/tools/staticdocs/docs/guides/raspberrypi"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">Raspberry Pi</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/tools/staticdocs/docs/guides/scripting-api"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Scripting API Guide</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_TN1Q thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#introduction" class="table-of-contents__link toc-highlight">Introduction</a></li><li><a href="#concepts" class="table-of-contents__link toc-highlight">Concepts</a><ul><li><a href="#ruby-vs-python-in-cosmos" class="table-of-contents__link toc-highlight">Ruby vs Python in COSMOS</a></li></ul></li><li><a href="#scripting-philosophy" class="table-of-contents__link toc-highlight">Scripting Philosophy</a><ul><li><a href="#a-super-basic-script-example" class="table-of-contents__link toc-highlight">A Super Basic Script Example</a></li><li><a href="#kiss-keep-it-simple-stupid" class="table-of-contents__link toc-highlight">KISS (Keep It Simple Stupid)</a></li><li><a href="#keep-things-dry-dont-repeat-yourself" class="table-of-contents__link toc-highlight">Keep things DRY (Don&#39;t Repeat Yourself)</a></li><li><a href="#use-comments-appropriately" class="table-of-contents__link toc-highlight">Use Comments Appropriately</a></li><li><a href="#script-runner" class="table-of-contents__link toc-highlight">Script Runner</a></li><li><a href="#looping-vs-unrolled-loops" class="table-of-contents__link toc-highlight">Looping vs Unrolled Loops</a></li></ul></li><li><a href="#script-organization" class="table-of-contents__link toc-highlight">Script Organization</a><ul><li><a href="#organizing-your-scripts-into-a-plugin" class="table-of-contents__link toc-highlight">Organizing Your Scripts into a Plugin</a></li><li><a href="#organize-scripts-into-methods" class="table-of-contents__link toc-highlight">Organize Scripts into Methods</a></li><li><a href="#using-classes-vs-unscoped-methods" class="table-of-contents__link toc-highlight">Using Classes vs Unscoped Methods</a></li><li><a href="#instrumented-vs-uninstrumented-lines-require-vs-load" class="table-of-contents__link toc-highlight">Instrumented vs Uninstrumented Lines (require vs load)</a></li></ul></li><li><a href="#debugging-and-auditing" class="table-of-contents__link toc-highlight">Debugging and Auditing</a><ul><li><a href="#built-in-debugging-capabilities" class="table-of-contents__link toc-highlight">Built-In Debugging Capabilities</a></li><li><a href="#breakpoints" class="table-of-contents__link toc-highlight">Breakpoints</a></li><li><a href="#using-disconnect-mode" class="table-of-contents__link toc-highlight">Using Disconnect Mode</a></li><li><a href="#auditing-your-scripts" class="table-of-contents__link toc-highlight">Auditing your Scripts</a><ul><li><a href="#ruby-syntax-check" class="table-of-contents__link toc-highlight">Ruby Syntax Check</a></li></ul></li></ul></li><li><a href="#common-scenarios" class="table-of-contents__link toc-highlight">Common Scenarios</a><ul><li><a href="#user-input-best-practices" class="table-of-contents__link toc-highlight">User Input Best Practices</a></li><li><a href="#conditionally-require-manual-user-input-steps" class="table-of-contents__link toc-highlight">Conditionally Require Manual User Input Steps</a></li><li><a href="#outputing-extra-information-to-a-report" class="table-of-contents__link toc-highlight">Outputing Extra Information to a Report</a></li><li><a href="#getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets" class="table-of-contents__link toc-highlight">Getting the Most Recent Value of a Telemetry Point from Multiple Packets</a></li><li><a href="#checking-every-single-sample-of-a-telemetry-point" class="table-of-contents__link toc-highlight">Checking Every Single Sample of a Telemetry Point</a></li><li><a href="#using-variables-in-mnemonics" class="table-of-contents__link toc-highlight">Using Variables in Mnemonics</a></li><li><a href="#using-custom-wait_check_expression" class="table-of-contents__link toc-highlight">Using Custom wait_check_expression</a></li><li><a href="#cosmos-scripting-differences-from-regular-ruby-scripting" class="table-of-contents__link toc-highlight">COSMOS Scripting Differences from Regular Ruby Scripting</a><ul><li><a href="#do-not-use-single-line-if-statements" class="table-of-contents__link toc-highlight">Do not use single line if statements</a></li></ul></li></ul></li><li><a href="#when-things-go-wrong" class="table-of-contents__link toc-highlight">When Things Go Wrong</a><ul><li><a href="#common-reasons-checks-fail" class="table-of-contents__link toc-highlight">Common Reasons Checks Fail</a></li><li><a href="#how-to-recover-from-anomalies" class="table-of-contents__link toc-highlight">How to Recover from Anomalies</a></li></ul></li><li><a href="#advanced-topics" class="table-of-contents__link toc-highlight">Advanced Topics</a><ul><li><a href="#advanced-script-configuration-with-csv-or-excel" class="table-of-contents__link toc-highlight">Advanced Script Configuration with CSV or Excel</a></li><li><a href="#when-to-use-ruby-modules" class="table-of-contents__link toc-highlight">When to use Ruby Modules</a></li></ul></li></ul></div></div></div></div></main></div></div></div><footer class="footer footer--dark"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Homepage</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://openc3.com" target="_blank" rel="noopener noreferrer" class="footer__link-item">Home</a></li></ul></div><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/tools/staticdocs/docs">Documentation</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://www.linkedin.com/company/openc3" target="_blank" rel="noopener noreferrer" class="footer__link-item">LinkedIn<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_awgD"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://github.com/OpenC3/cosmos" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_awgD"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a class="footer__link-item" href="/tools/staticdocs/docs/privacy">Privacy</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Copyright © 2024 OpenC3, Inc.</div></div></div></footer></div>
565
259
  </body>
566
260
  </html>