openc3-cosmos-tool-docs 5.16.1 → 5.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/tools/staticdocs/404.html +4 -4
  3. data/tools/staticdocs/assets/css/styles.8a0f1b26.css +1 -0
  4. data/tools/staticdocs/assets/js/{0f5d161c.dda04dbb.js → 0f5d161c.3dbf9f60.js} +1 -1
  5. data/tools/staticdocs/assets/js/3b6e6f8d.3eef0a1d.js +1 -0
  6. data/tools/staticdocs/assets/js/{42170351.15f2f1e3.js → 42170351.24db3d9a.js} +1 -1
  7. data/tools/staticdocs/assets/js/4650.292aca67.js +1 -0
  8. data/tools/staticdocs/assets/js/5e3ed378.77db7b87.js +1 -0
  9. data/tools/staticdocs/assets/js/{2923e883.ed90d0a7.js → 75897369.7b31b03e.js} +1 -1
  10. data/tools/staticdocs/assets/js/767ae34d.4ab04b1e.js +1 -0
  11. data/tools/staticdocs/assets/js/adf499b4.f7df5738.js +1 -0
  12. data/tools/staticdocs/assets/js/{d797a795.5725bf2b.js → c5388ca4.f526bb0c.js} +1 -1
  13. data/tools/staticdocs/assets/js/ca2c0ac4.adbecf86.js +1 -0
  14. data/tools/staticdocs/assets/js/{d1b923aa.e7ee188a.js → d1b923aa.dcb1dede.js} +1 -1
  15. data/tools/staticdocs/assets/js/d1bfc316.feddf1f3.js +1 -0
  16. data/tools/staticdocs/assets/js/d394346f.e3f500eb.js +1 -0
  17. data/tools/staticdocs/assets/js/d52d6961.1d15c902.js +1 -0
  18. data/tools/staticdocs/assets/js/dc5f7beb.291f4b91.js +1 -0
  19. data/tools/staticdocs/assets/js/eb3c311a.1b6ccdde.js +1 -0
  20. data/tools/staticdocs/assets/js/fd886806.dc7cdf8e.js +1 -0
  21. data/tools/staticdocs/assets/js/main.eec2a1b0.js +2 -0
  22. data/tools/staticdocs/assets/js/runtime~main.14022dc5.js +1 -0
  23. data/tools/staticdocs/docs/configuration/command.html +6 -6
  24. data/tools/staticdocs/docs/configuration/format.html +6 -6
  25. data/tools/staticdocs/docs/configuration/interfaces.html +6 -6
  26. data/tools/staticdocs/docs/configuration/plugins.html +6 -6
  27. data/tools/staticdocs/docs/configuration/protocols.html +6 -6
  28. data/tools/staticdocs/docs/configuration/ssl-tls.html +6 -6
  29. data/tools/staticdocs/docs/configuration/table.html +6 -6
  30. data/tools/staticdocs/docs/configuration/target.html +6 -6
  31. data/tools/staticdocs/docs/configuration/telemetry-screens.html +6 -6
  32. data/tools/staticdocs/docs/configuration/telemetry.html +6 -6
  33. data/tools/staticdocs/docs/configuration.html +5 -5
  34. data/tools/staticdocs/docs/development/curl.html +6 -6
  35. data/tools/staticdocs/docs/development/developing.html +6 -6
  36. data/tools/staticdocs/docs/development/host-install.html +6 -6
  37. data/tools/staticdocs/docs/development/json-api.html +6 -6
  38. data/tools/staticdocs/docs/development/log-structure.html +6 -6
  39. data/tools/staticdocs/docs/development/roadmap.html +6 -6
  40. data/tools/staticdocs/docs/development/streaming-api.html +6 -6
  41. data/tools/staticdocs/docs/development/testing.html +6 -6
  42. data/tools/staticdocs/docs/development.html +5 -5
  43. data/tools/staticdocs/docs/getting-started/generators.html +6 -6
  44. data/tools/staticdocs/docs/getting-started/gettingstarted.html +6 -6
  45. data/tools/staticdocs/docs/getting-started/installation.html +6 -6
  46. data/tools/staticdocs/docs/getting-started/key_concepts.html +6 -6
  47. data/tools/staticdocs/docs/getting-started/podman.html +6 -6
  48. data/tools/staticdocs/docs/getting-started/requirements.html +6 -6
  49. data/tools/staticdocs/docs/getting-started/upgrading.html +6 -6
  50. data/tools/staticdocs/docs/getting-started.html +5 -5
  51. data/tools/staticdocs/docs/guides/bridges.html +6 -6
  52. data/tools/staticdocs/docs/guides/cfs.html +6 -6
  53. data/tools/staticdocs/docs/guides/custom-widgets.html +6 -6
  54. data/tools/staticdocs/docs/guides/little-endian-bitfields.html +6 -6
  55. data/tools/staticdocs/docs/guides/local-mode.html +6 -6
  56. data/tools/staticdocs/docs/guides/logging.html +6 -6
  57. data/tools/staticdocs/docs/guides/monitoring.html +6 -6
  58. data/tools/staticdocs/docs/guides/performance.html +7 -6
  59. data/tools/staticdocs/docs/guides/raspberrypi.html +6 -6
  60. data/tools/staticdocs/docs/guides/script-writing.html +19 -16
  61. data/tools/staticdocs/docs/guides/scripting-api.html +6 -6
  62. data/tools/staticdocs/docs/guides.html +5 -5
  63. data/tools/staticdocs/docs/meta/contributing.html +6 -6
  64. data/tools/staticdocs/docs/meta/licenses.html +6 -6
  65. data/tools/staticdocs/docs/meta/philosophy.html +6 -6
  66. data/tools/staticdocs/docs/meta/xtce.html +6 -6
  67. data/tools/staticdocs/docs/meta.html +5 -5
  68. data/tools/staticdocs/docs/privacy.html +6 -6
  69. data/tools/staticdocs/docs/tools/autonomic.html +6 -6
  70. data/tools/staticdocs/docs/tools/bucket-explorer.html +6 -6
  71. data/tools/staticdocs/docs/tools/calendar.html +6 -6
  72. data/tools/staticdocs/docs/tools/cmd-sender.html +6 -6
  73. data/tools/staticdocs/docs/tools/cmd-tlm-server.html +6 -6
  74. data/tools/staticdocs/docs/tools/data-extractor.html +6 -6
  75. data/tools/staticdocs/docs/tools/data-viewer.html +6 -6
  76. data/tools/staticdocs/docs/tools/handbooks.html +6 -6
  77. data/tools/staticdocs/docs/tools/limits-monitor.html +6 -6
  78. data/tools/staticdocs/docs/tools/packet-viewer.html +6 -6
  79. data/tools/staticdocs/docs/tools/script-runner.html +9 -9
  80. data/tools/staticdocs/docs/tools/table-manager.html +6 -6
  81. data/tools/staticdocs/docs/tools/tlm-grapher.html +6 -6
  82. data/tools/staticdocs/docs/tools/tlm-viewer.html +6 -6
  83. data/tools/staticdocs/docs/tools.html +5 -5
  84. data/tools/staticdocs/docs.html +6 -6
  85. data/tools/staticdocs/index.html +4 -4
  86. data/tools/staticdocs/lunr-index-1716490741709.json +1 -0
  87. data/tools/staticdocs/lunr-index.json +1 -1
  88. data/tools/staticdocs/markdown-page.html +4 -4
  89. data/tools/staticdocs/search-doc-1716490741709.json +1 -0
  90. data/tools/staticdocs/search-doc.json +1 -1
  91. metadata +25 -25
  92. data/tools/staticdocs/assets/css/styles.a9c55efa.css +0 -1
  93. data/tools/staticdocs/assets/js/07876b9c.b8d12431.js +0 -1
  94. data/tools/staticdocs/assets/js/1b2b4b61.2556cd65.js +0 -1
  95. data/tools/staticdocs/assets/js/3df159b4.ff98bfab.js +0 -1
  96. data/tools/staticdocs/assets/js/55cdbca5.695875ea.js +0 -1
  97. data/tools/staticdocs/assets/js/5e3ed378.91d6735f.js +0 -1
  98. data/tools/staticdocs/assets/js/64630c4f.a229ae1d.js +0 -1
  99. data/tools/staticdocs/assets/js/75373ac0.6a0a4fa2.js +0 -1
  100. data/tools/staticdocs/assets/js/7918.25ec42db.js +0 -1
  101. data/tools/staticdocs/assets/js/99b59eea.d4dd9989.js +0 -1
  102. data/tools/staticdocs/assets/js/d1bfc316.963c2477.js +0 -1
  103. data/tools/staticdocs/assets/js/dc5f7beb.88b0f00b.js +0 -1
  104. data/tools/staticdocs/assets/js/fd886806.57eeb84b.js +0 -1
  105. data/tools/staticdocs/assets/js/main.1b0c8317.js +0 -2
  106. data/tools/staticdocs/assets/js/runtime~main.49989116.js +0 -1
  107. data/tools/staticdocs/lunr-index-1715219995308.json +0 -1
  108. data/tools/staticdocs/search-doc-1715219995308.json +0 -1
  109. /data/tools/staticdocs/assets/js/{main.1b0c8317.js.LICENSE.txt → main.eec2a1b0.js.LICENSE.txt} +0 -0
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[3440],{3012:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>h,frontMatter:()=>r,metadata:()=>o,toc:()=>c});var i=t(1085),s=t(1184);const r={title:"Script Writing Guide"},a=void 0,o={id:"guides/script-writing",title:"Script Writing Guide",description:"Introduction",source:"@site/docs/guides/script-writing.md",sourceDirName:"guides",slug:"/guides/script-writing",permalink:"/tools/staticdocs/docs/guides/script-writing",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/script-writing.md",tags:[],version:"current",frontMatter:{title:"Script Writing Guide"},sidebar:"defaultSidebar",previous:{title:"Raspberry Pi",permalink:"/tools/staticdocs/docs/guides/raspberrypi"},next:{title:"Scripting API Guide",permalink:"/tools/staticdocs/docs/guides/scripting-api"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Concepts",id:"concepts",level:2},{value:"Ruby vs Python in COSMOS",id:"ruby-vs-python-in-cosmos",level:3},{value:"Scripting Philosophy",id:"scripting-philosophy",level:2},{value:"A Super Basic Script Example",id:"a-super-basic-script-example",level:3},{value:"KISS (Keep It Simple Stupid)",id:"kiss-keep-it-simple-stupid",level:3},{value:"Keep things DRY (Don&#39;t Repeat Yourself)",id:"keep-things-dry-dont-repeat-yourself",level:3},{value:"Use Comments Appropriately",id:"use-comments-appropriately",level:3},{value:"Script Runner",id:"script-runner",level:3},{value:"Looping vs Unrolled Loops",id:"looping-vs-unrolled-loops",level:3},{value:"Script Organization",id:"script-organization",level:2},{value:"Organizing Your Scripts into a Plugin",id:"organizing-your-scripts-into-a-plugin",level:3},{value:"Organize Scripts into Methods",id:"organize-scripts-into-methods",level:3},{value:"Using Classes vs Unscoped Methods",id:"using-classes-vs-unscoped-methods",level:3},{value:"Instrumented vs Uninstrumented Lines (require vs load)",id:"instrumented-vs-uninstrumented-lines-require-vs-load",level:3},{value:"Debugging and Auditing",id:"debugging-and-auditing",level:2},{value:"Built-In Debugging Capabilities",id:"built-in-debugging-capabilities",level:3},{value:"Breakpoints",id:"breakpoints",level:3},{value:"Using Disconnect Mode",id:"using-disconnect-mode",level:3},{value:"Auditing your Scripts",id:"auditing-your-scripts",level:3},{value:"Ruby Syntax Check",id:"ruby-syntax-check",level:4},{value:"Common Scenarios",id:"common-scenarios",level:2},{value:"User Input Best Practices",id:"user-input-best-practices",level:3},{value:"Conditionally Require Manual User Input Steps",id:"conditionally-require-manual-user-input-steps",level:3},{value:"Outputing Extra Information to a Report",id:"outputing-extra-information-to-a-report",level:3},{value:"Getting the Most Recent Value of a Telemetry Point from Multiple Packets",id:"getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets",level:3},{value:"Checking Every Single Sample of a Telemetry Point",id:"checking-every-single-sample-of-a-telemetry-point",level:3},{value:"Using Variables in Mnemonics",id:"using-variables-in-mnemonics",level:3},{value:"Using Custom wait_check_expression",id:"using-custom-wait_check_expression",level:3},{value:"COSMOS Scripting Differences from Regular Ruby Scripting",id:"cosmos-scripting-differences-from-regular-ruby-scripting",level:3},{value:"Do not use single line if statements",id:"do-not-use-single-line-if-statements",level:4},{value:"When Things Go Wrong",id:"when-things-go-wrong",level:2},{value:"Common Reasons Checks Fail",id:"common-reasons-checks-fail",level:3},{value:"How to Recover from Anomalies",id:"how-to-recover-from-anomalies",level:3},{value:"Advanced Topics",id:"advanced-topics",level:2},{value:"Advanced Script Configuration with CSV or Excel",id:"advanced-script-configuration-with-csv-or-excel",level:3},{value:"When to use Ruby Modules",id:"when-to-use-ruby-modules",level:3}];function d(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h2,{id:"concepts",children:"Concepts"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"ruby-vs-python-in-cosmos",children:"Ruby vs Python in COSMOS"}),"\n",(0,i.jsx)(n.p,{children:"There are many similarities and a few key differences between Ruby and Python when it comes to writing COSMOS scripts."}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"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."}),"\n",(0,i.jsxs)(n.li,{children:["Indentation white space:","\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Ruby: Not significant. Ruby uses the ",(0,i.jsx)(n.code,{children:"end"})," keyword to determine indented code blocks with a standard of 2 spaces."]}),"\n",(0,i.jsx)(n.li,{children:"Python: Significant. Python uses indentation to determine code blocks with a standard of 4 spaces."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"Variables do not have to be declared ahead of time and can be reassigned later, i.e. Ruby and Python are dynamically typed."}),"\n",(0,i.jsxs)(n.li,{children:["Variable interpolation:","\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Ruby: Variable values can be placed into strings using the ",(0,i.jsx)(n.code,{children:'"#{variable}"'})," syntax."]}),"\n",(0,i.jsxs)(n.li,{children:["Python: Variable values can be placed into f-strings using the ",(0,i.jsx)(n.code,{children:'f"{variable}"'})," syntax."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"A variable declared inside of a block or loop will not exist outside of that block unless it was already declared."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"Both languages provides a script writer a lot of power. But with great power comes great responsibility. Remember when writing your scripts that you or someone else will come along later and need to understand them. Therefore use the following style guidelines:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Use consistent spacing for indentation and do NOT use tabs"}),"\n",(0,i.jsxs)(n.li,{children:["Constants should be all caps with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"SPEED_OF_LIGHT = 299792458 # meters per s"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["Variable names and method names should be in lowercase with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:'last_name = "Smith"'})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"perform_setup_operation()"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["Class names (when used) should be camel case and the files which contain them should match but be lowercase with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"class DataUploader # in 'data_uploader.rb'"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"class CcsdsUtility: # in 'ccsds_utility.py'"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"Don't add useless comments but instead describe intent"}),"\n"]}),"\n",(0,i.jsx)("div",{style:{clear:"both"}}),"\n",(0,i.jsx)(n.p,{children:"The following is an example of good Ruby style:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"load 'TARGET/lib/upload_utility.rb' # library we do NOT want to show executing\nload_utility 'TARGET/lib/helper_utility.rb' # library we do want to show executing\n\n# Declare constants\nOUR_TARGETS = ['INST','INST2']\n\n# Clear the collect counter of the passed in target name\ndef clear_collects(target)\n cmd(\"#{target} CLEAR\")\n wait_check(\"#{target} HEALTH_STATUS COLLECTS == 0\", 5)\nend\n\n######################################\n# START\n######################################\nhelper = HelperUtility.new\nhelper.setup\n\n# Perform collects on all the targets\nOUR_TARGETS.each do |target|\n collects = tlm(\"#{target} HEALTH_STATUS COLLECTS\")\n cmd(\"#{target} COLLECT with TYPE SPECIAL\")\n wait_check(\"#{target} HEALTH_STATUS COLLECTS == #{collects + 1}\", 5)\nend\n\nclear_collects('INST')\nclear_collects('INST2')\n"})}),"\n",(0,i.jsx)(n.p,{children:"The following is an example of good Python style:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"from openc3.script import *\n\nimport TARGET.lib.upload_utility # library we do NOT want to show executing\nload_utility('TARGET/lib/helper_utility.rb') # library we do want to show executing\n\n# Declare constants\nOUR_TARGETS = ['INST','INST2']\n\n# Clear the collect counter of the passed in target name\ndef clear_collects(target):\n cmd(f\"{target} CLEAR\")\n wait_check(f\"{target} HEALTH_STATUS COLLECTS == 0\", 5)\n\n######################################\n# START\n######################################\nhelper = HelperUtility()\nhelper.setup()\n\n# Perform collects on all the targets\nfor target in OUR_TARGETS:\n collects = tlm(f\"{target} HEALTH_STATUS COLLECTS\")\n cmd(f\"{target} COLLECT with TYPE SPECIAL\")\n wait_check(f\"{target} HEALTH_STATUS COLLECTS == {collects + 1}\", 5)\n\nclear_collects('INST')\nclear_collects('INST2')\n"})}),"\n",(0,i.jsx)(n.p,{children:"Both examples shows several features of COSMOS scripting in action. Notice the difference between 'load' or 'import' and 'load_utility'. 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. 'load_utility' will visually execute the code line by line to show the user what is happening."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"The 'helper_utility' is then created. Note the similarity in the class name and the file name we loaded."}),"\n",(0,i.jsxs)(n.p,{children:["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"'," 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."]}),"\n",(0,i.jsx)(n.p,{children:"Finally we call our 'clear_collects' method on each target by passing the target name."}),"\n",(0,i.jsx)(n.h2,{id:"scripting-philosophy",children:"Scripting Philosophy"}),"\n",(0,i.jsx)(n.h3,{id:"a-super-basic-script-example",children:"A Super Basic Script Example"}),"\n",(0,i.jsx)(n.p,{children:"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:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'cmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check("INST HEALTH_STATUS TYPE == \'NORMAL\'", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"or similarly with a counter that is sampled before the command."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'count = tlm("INST HEALTH_STATUS COLLECTS")\ncmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check("INST HEALTH_STATUS COLLECTS >= #{count + 1}", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'count = tlm("INST HEALTH_STATUS COLLECTS")\ncmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check(f"INST HEALTH_STATUS COLLECTS >= {count + 1}", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"kiss-keep-it-simple-stupid",children:"KISS (Keep It Simple Stupid)"}),"\n",(0,i.jsx)(n.p,{children:"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'll thank yourself later by expanding complex one liners and breaking up and documenting regular expressions."}),"\n",(0,i.jsx)(n.h3,{id:"keep-things-dry-dont-repeat-yourself",children:"Keep things DRY (Don't Repeat Yourself)"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.p,{children:"For example, a script that powers on a subsystem and ensures correct telemetry would become:"}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"def power_on_subsystem\n # 100 lines of cmd(), wait_check(), etc\nend\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"def power_on_subsystem():\n # 100 lines of cmd(), wait_check(), etc\n"})}),"\n",(0,i.jsx)(n.p,{children:"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:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"power_on_subsystem()\n# 150 lines operating the subsystem (e.g.)\n# cmd(...)\n# wait_check(...)\n#...\npower_off_subystem()\n# Unrelated activities\npower_on_subsystem()\n# etc.\n"})}),"\n",(0,i.jsx)(n.p,{children:"Blocks of code where only the only variation is the mnemonics or values checked can be replaced by methods with arguments."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp)\n cmd("TARGET #{enable_cmd_name} with ENABLE TRUE")\n wait_check("TARGET #{enable_tlm} == \'TRUE\'", 5)\n wait_check("TARGET #{temp_tlm} >= #{expected_temp}", 50)\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp):\n cmd(f"TARGET {enable_cmd_name} with ENABLE TRUE")\n wait_check(f"TARGET {enable_tlm} == \'TRUE\'", 5)\n wait_check(f"TARGET {temp_tlm} >= {expected_temp}", 50)\n'})}),"\n",(0,i.jsx)(n.h3,{id:"use-comments-appropriately",children:"Use Comments Appropriately"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# This line sends an abort command - BAD COMMENT, UNNECCESSARY\ncmd("INST ABORT")\n# Rotate the gimbal to look at the calibration target - GOOD COMMENT\ncmd("INST ROTATE with ANGLE 180.0") # Rotate 180 degrees - BAD COMMENT\n'})}),"\n",(0,i.jsx)(n.h3,{id:"script-runner",children:"Script Runner"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"When opening a suite file (named with 'suite') 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."}),"\n",(0,i.jsx)(n.p,{children:"The correct environment for the job is up to individual users, and many programs will use both script formats to complete their goals."}),"\n",(0,i.jsx)(n.h3,{id:"looping-vs-unrolled-loops",children:"Looping vs Unrolled Loops"}),"\n",(0,i.jsx)(n.p,{children:"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 \u201cunroll\u201d 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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"10.times do |temperature_number|\n check_temperature(temperature_number + 1)\nend\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"for temperature_number in range(1, 11):\n check_temperature(temperature_number)\n"})}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"check_temperature(1)\ncheck_temperature(2)\ncheck_temperature(3)\ncheck_temperature(4)\ncheck_temperature(5)\ncheck_temperature(6)\ncheck_temperature(7)\ncheck_temperature(8)\ncheck_temperature(9)\ncheck_temperature(10)\n"})}),"\n",(0,i.jsx)(n.p,{children:"In the unrolled version above, the COSMOS \u201cStart script at selected line\u201d feature can be used to resume the script at any point."}),"\n",(0,i.jsx)(n.h2,{id:"script-organization",children:"Script Organization"}),"\n",(0,i.jsxs)(n.p,{children:["All scripts must be part of a ",(0,i.jsx)(n.a,{href:"/tools/staticdocs/docs/configuration/plugins",children:"Plugin"}),". 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."]}),"\n",(0,i.jsx)(n.h3,{id:"organizing-your-scripts-into-a-plugin",children:"Organizing Your Scripts into a Plugin"}),"\n",(0,i.jsx)(n.p,{children:"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's scripts/procedures."}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Folder"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"targets/TARGET_NAME/lib"}),(0,i.jsx)(n.td,{children:"Place script files containing reusable target specific methods here"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"targets/TARGET_NAME/procedures"}),(0,i.jsx)(n.td,{children:"Place simple procedures that are centered around one specific target here"})]})]})]}),"\n",(0,i.jsx)(n.p,{children:"In your main procedure you will usually bring in the other files with instrumentation using load_utility."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"# Ruby:\nload_utility('TARGET/lib/my_other_script.rb')\n# Python:\nload_utility('TARGET/procedures/my_other_script.py')\n"})}),"\n",(0,i.jsx)(n.h3,{id:"organize-scripts-into-methods",children:"Organize Scripts into Methods"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def test_1_heater_zone_control\n puts "Verifies requirements 304, 306, and 310"\n # Test code here\nend\n\ndef script_1_heater_zone_control\n puts "Verifies requirements 304, 306, and 310"\n # Test code here\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def test_1_heater_zone_control():\n print("Verifies requirements 304, 306, and 310")\n # Test code here\n\ndef script_1_heater_zone_control():\n print("Verifies requirements 304, 306, and 310")\n # Test code here\n'})}),"\n",(0,i.jsx)(n.h3,{id:"using-classes-vs-unscoped-methods",children:"Using Classes vs Unscoped Methods"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'class Gimbal\n attr_accessor :gimbal_steps\n def initialize()\n @gimbal_steps = 0\n end\n def move(steps_to_move)\n # Move the gimbal\n @gimbal_steps += steps_to_move\n end\n def home_gimbal\n # Home the gimbal\n @gimbal_steps = 0\n end\nend\n\ndef perform_common_math(x, y)\n x + y\nend\n\ngimbal = Gimbal.new\ngimbal.home_gimbal\ngimbal.move(100)\ngimbal.move(200)\nputs "Moved gimbal #{gimbal.gimbal_steps}"\nresult = perform_common_math(gimbal.gimbal_steps, 10)\nputs "Math:#{result}"\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Gimbal:\n def __init__(self):\n self.gimbal_steps = 0\n\n def move(self, steps_to_move):\n # Move the gimbal\n self.gimbal_steps += steps_to_move\n\n def home_gimbal(self):\n # Home the gimbal\n self.gimbal_steps = 0\n\ndef perform_common_math(x, y):\n return x + y\n\ngimbal = Gimbal()\ngimbal.home_gimbal()\ngimbal.move(100)\ngimbal.move(200)\nprint(f"Moved gimbal {gimbal.gimbal_steps}")\nresult = perform_common_math(gimbal.gimbal_steps, 10)\nprint(f"Math:{result}")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"instrumented-vs-uninstrumented-lines-require-vs-load",children:"Instrumented vs Uninstrumented Lines (require vs load)"}),"\n",(0,i.jsx)(n.p,{children:"COSMOS scripts are normally \u201cinstrumented\u201d. 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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"However, sometimes you don'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 \u201cload\u201d 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. \u201crequire\u201d 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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"temp = 0\ndisable_instrumentation do\n # Make sure nothing in here will raise exceptions!\n 5000000.times do\n temp += 1\n end\nend\nputs temp\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"temp = 0\nwith disable_instrumentation():\n # Make sure nothing in here will raise exceptions!\n for x in range(0,5000000):\n temp += 1\nprint(temp)\n"})}),"\n",(0,i.jsx)(n.admonition,{title:"When Running Uninstrumented Code",type:"warning",children:(0,i.jsx)(n.p,{children:"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."})}),"\n",(0,i.jsx)(n.h2,{id:"debugging-and-auditing",children:"Debugging and Auditing"}),"\n",(0,i.jsx)(n.h3,{id:"built-in-debugging-capabilities",children:"Built-In Debugging Capabilities"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"To use the debugging functionality, first select the \u201cToggle Debug\u201d 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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"variable_name\n"})}),"\n",(0,i.jsx)(n.p,{children:"Variables can also be set simply by using equals."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"variable_name = 5\n"})}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'cmd("INST COLLECT with TYPE NORMAL")\n'})}),"\n",(0,i.jsx)(n.p,{children:"Note that the debug prompt keeps the command history and you can scroll through the history by using the up and down arrows."}),"\n",(0,i.jsx)(n.h3,{id:"breakpoints",children:"Breakpoints"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"using-disconnect-mode",children:"Using Disconnect Mode"}),"\n",(0,i.jsx)(n.p,{children:"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 -> 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."}),"\n",(0,i.jsx)(n.p,{children:"While in disconnect mode, commands to the disconnected targets always succeed. Additionally, all checks of disconnected targets' 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."}),"\n",(0,i.jsx)(n.h3,{id:"auditing-your-scripts",children:"Auditing your Scripts"}),"\n",(0,i.jsx)(n.p,{children:"Script Runner includes several tools to help audit your scripts both before and after execution."}),"\n",(0,i.jsx)(n.h4,{id:"ruby-syntax-check",children:"Ruby Syntax Check"}),"\n",(0,i.jsx)(n.p,{children:"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 \u201cend\u201d keyword, or using a block but forgetting the proceeding \u201cdo\u201d keyword."}),"\n",(0,i.jsx)(n.h2,{id:"common-scenarios",children:"Common Scenarios"}),"\n",(0,i.jsx)(n.h3,{id:"user-input-best-practices",children:"User Input Best Practices"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'answer = ask_string("Do you want to continue (y/n)?")\nif answer != \'y\' and answer != \'Y\'\n raise "User entered: #{answer}"\nend\n\ntemp = 0.0\nwhile temp < 10.0 or temp > 50.0\n temp = ask("Enter the desired temperature between 10.0 and 50.0")\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'answer = ask_string("Do you want to continue (y/n)?")\nif answer != \'y\' and answer != \'Y\':\n raise RuntimeError(f"User entered: {answer}")\n\ntemp = 0.0\nwhile temp < 10.0 or temp > 50.0:\n temp = ask("Enter the desired temperature between 10.0 and 50.0")\n'})}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.p,{children:"Note that all these user input methods provide the user the option to \u201cCancel\u201d. When cancel is clicked, the script is paused but remains at the user input line. When hitting \u201cGo\u201d to the continue, the user will be re-prompted to enter the value."}),"\n",(0,i.jsx)(n.h3,{id:"conditionally-require-manual-user-input-steps",children:"Conditionally Require Manual User Input Steps"}),"\n",(0,i.jsx)(n.p,{children:"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 the $manual variable. If $manual is set, then the manual steps should be executed. If not, then a default value should be used."}),"\n",(0,i.jsx)(n.p,{children:"Ruby Only:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# Set the $manual variable \u2013 Only needed outside of suites\nanswer = ask("Prompt for manual entry (Y/n)?")\nif answer == \'n\' or answer == \'N\'\n $manual = false\nelse\n $manual = true\nend\nif $manual\n temp = ask("Please enter the temperature")\nelse\n temp = 20.0\nend\nif !$manual\n puts "Skipping infinite wait in auto mode"\nelse\n wait\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"When running suites, there is a checkbox at the top of the tool called \u201cManual\u201d that affects this $manual variable directly."}),"\n",(0,i.jsx)(n.h3,{id:"outputing-extra-information-to-a-report",children:"Outputing Extra Information to a Report"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'class MyGroup < OpenC3::Group\n def script_1\n # The following text will be placed in the report\n OpenC3::Group.puts "Verifies requirements 304, 306, 310"\n # This puts line will show up in the sr_messages log file\n puts "script_1 complete"\n end\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'from openc3.script.suite import Group\nclass MyGroup(Group):\n def script_1():\n # The following text will be placed in the report\n Group.print("Verifies requirements 304, 306, 310")\n # This puts line will show up in the sr_messages log file\n print("script_1 complete")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets",children:"Getting the Most Recent Value of a Telemetry Point from Multiple Packets"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# Get the value of TEMP from the most recently received PACKET1\nvalue = tlm("INST PACKET1 TEMP")\n# Get the value of TEMP from the most recently received PACKET2\nvalue = tlm("INST PACKET2 TEMP")\n# Get the value of TEMP from the most recently received PACKET1 or PACKET2\nvalue = tlm("INST LATEST TEMP")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"checking-every-single-sample-of-a-telemetry-point",children:"Checking Every Single Sample of a Telemetry Point"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])\nwait 1.5\nid, packets = get_packets(id)\npackets.each do |packet|\n puts \"#{packet['PACKET_TIMESECONDS']}: #{packet['target_name']} #{packet['packet_name']}\"\nend\n# Wait for some time later and re-use the last returned ID\nid, packets = get_packets(id)\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])\nwait(1.5)\nid, packets = get_packets(id)\nfor packet in packets:\n print(f\"{packet['PACKET_TIMESECONDS']}: {packet['target_name']} {packet['packet_name']}\")\n# Wait for some time later and re-use the last returned ID\nid, packets = get_packets(id)\n"})}),"\n",(0,i.jsx)(n.h3,{id:"using-variables-in-mnemonics",children:"Using Variables in Mnemonics"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def example(target_name, temp_number)\n cmd("#{target_name} COLLECT with TYPE NORMAL")\n wait_check("#{target_name} TEMP#{temp_number} > 50.0")\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def example(target_name, temp_number):\n cmd(f"{target_name} COLLECT with TYPE NORMAL")\n wait_check(f"{target_name} TEMP{temp_number} > 50.0")\n'})}),"\n",(0,i.jsxs)(n.p,{children:["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 ",(0,i.jsx)(n.a,{href:"#looping-vs-unrolled-loops",children:"Looping vs Unrolled Loops"})," section."]}),"\n",(0,i.jsx)(n.h3,{id:"using-custom-wait_check_expression",children:"Using Custom wait_check_expression"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'one = 1\ntwo = 2\n\nwait_check_expression("one == two", 1)\n# ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds\n\n# Checking an integer range\nwait_check_expression("one > 0 and one < 10 # init value one = #{one}", 1)\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'one = 1\ntwo = 2\n\nwait_check_expression("one == two", 1, 0.25, locals())\n# ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds\n\n# Checking an integer range\nwait_check_expression("one > 0 and one < 10", 1, 0.25, locals())\n'})}),"\n",(0,i.jsx)(n.h3,{id:"cosmos-scripting-differences-from-regular-ruby-scripting",children:"COSMOS Scripting Differences from Regular Ruby Scripting"}),"\n",(0,i.jsx)(n.h4,{id:"do-not-use-single-line-if-statements",children:"Do not use single line if statements"}),"\n",(0,i.jsx)(n.p,{children:"COSMOS scripting instruments each line to catch exceptions if things go wrong. With single line if statements the exception handling doesn'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)."}),"\n",(0,i.jsx)(n.p,{children:"Don't do this:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'run_method() if tlm("INST HEALTH_STATUS TEMP1") > 10.0\n'})}),"\n",(0,i.jsx)(n.p,{children:"Do this instead:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# It is best not to execute any code that could fail in an if statement, ie\n# tlm() could fail if the CmdTlmServer was not running or a mnemonic\n# was misspelled\ntemp1 = tlm("INST HEALTH_STATUS TEMP1")\nif temp1 > 10.0\n run_method()\nend\n'})}),"\n",(0,i.jsx)(n.h2,{id:"when-things-go-wrong",children:"When Things Go Wrong"}),"\n",(0,i.jsx)(n.h3,{id:"common-reasons-checks-fail",children:"Common Reasons Checks Fail"}),"\n",(0,i.jsx)(n.p,{children:"There are three common reasons that checks fail in COSMOS scripts:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The delay given was too short"}),"\n",(0,i.jsx)(n.p,{children:"The wait_check() method takes a timeout that indicates how long to wait for the referenced telemetry point to pass the check. The timeout needs to be large enough for the system under test to finish its action and for updated telemetry to be received. Note that the script will continue as soon as the check completes successfully. Thus, the only penalty for a longer timeout is the additional wait time in a failure condition."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The range or value checked against was incorrect or too stringent"}),"\n",(0,i.jsx)(n.p,{children:"Often the actual telemetry value is ok, but the expected value checked against was too tight. Loosen the ranges on checks when it makes sense. Ensure your script is using the wait_check_tolerance() routine when checking floating point numbers and verify you're using an appropriate tolerance value."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The check really failed"}),"\n",(0,i.jsx)(n.p,{children:"Of course, sometimes there are real failures. See the next section for how to handle them and recover."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"how-to-recover-from-anomalies",children:"How to Recover from Anomalies"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Retry"}),"\n",(0,i.jsx)(n.p,{children:"After a failure, the Script Runner \u201cPause\u201d button changes to \u201cRetry\u201d. Clicking on the Retry button will re-execute the line the failed. For failures due to timing issues, this will often resolve the issue and allow the script to continue. Make note of the failure and be sure to update your script prior to the next run."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Use the Debug Prompt"}),"\n",(0,i.jsx)(n.p,{children:"By selecting Script -> Toggle Debug, you can perform arbitrary actions that may be needed to correct the situation without stopping the running script. You can also inspect variables to help determine why something failed."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Execute Selection"}),"\n",(0,i.jsx)(n.p,{children:'If only a small section of a script needs to be run, then \u201cExecute Selection" can be used to execute only a small portion of the script. This can also be used when a script is paused or stopped in error.'}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Run from here"}),"\n",(0,i.jsx)(n.p,{children:'By clicking into a script, and right clicking to select "Run from here", users can restart a script at an arbitrary point. This works well if no required variable definitions exist earlier in the script.'}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"advanced-topics",children:"Advanced Topics"}),"\n",(0,i.jsx)(n.h3,{id:"advanced-script-configuration-with-csv-or-excel",children:"Advanced Script Configuration with CSV or Excel"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"The Ruby CSV class be used to easily read data from CSV files (recommended for cross platform projects)."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"require 'csv'\nvalues = CSV.read('test.csv')\nputs values[0][0]\n"})}),"\n",(0,i.jsx)(n.p,{children:"If you are only using Windows, COSMOS also contains a library for reading Excel files."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"require 'openc3/win32/excel'\nss = ExcelSpreadsheet.new('C:/git/cosmos/test.xlsx')\nputs ss[0][0][0]\n"})}),"\n",(0,i.jsx)(n.h3,{id:"when-to-use-ruby-modules",children:"When to use Ruby Modules"}),"\n",(0,i.jsx)(n.p,{children:"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't typically useful for COSMOS scripting though."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"module MyModule\n def module_method\n end\nend\nclass MyTest < OpenC3::Group\n include MyModule\n def test_1\n module_method()\n end\nend\n"})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},1184:(e,n,t)=>{t.d(n,{R:()=>a});var i=t(4041);const s={},r=i.createContext(s);function a(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}}}]);
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[3440],{3012:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>l,contentTitle:()=>a,default:()=>h,frontMatter:()=>r,metadata:()=>o,toc:()=>c});var i=t(1085),s=t(1184);const r={title:"Script Writing Guide"},a=void 0,o={id:"guides/script-writing",title:"Script Writing Guide",description:"Introduction",source:"@site/docs/guides/script-writing.md",sourceDirName:"guides",slug:"/guides/script-writing",permalink:"/tools/staticdocs/docs/guides/script-writing",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/script-writing.md",tags:[],version:"current",frontMatter:{title:"Script Writing Guide"},sidebar:"defaultSidebar",previous:{title:"Raspberry Pi",permalink:"/tools/staticdocs/docs/guides/raspberrypi"},next:{title:"Scripting API Guide",permalink:"/tools/staticdocs/docs/guides/scripting-api"}},l={},c=[{value:"Introduction",id:"introduction",level:2},{value:"Concepts",id:"concepts",level:2},{value:"Ruby vs Python in COSMOS",id:"ruby-vs-python-in-cosmos",level:3},{value:"Scripting Philosophy",id:"scripting-philosophy",level:2},{value:"A Super Basic Script Example",id:"a-super-basic-script-example",level:3},{value:"KISS (Keep It Simple Stupid)",id:"kiss-keep-it-simple-stupid",level:3},{value:"Keep things DRY (Don&#39;t Repeat Yourself)",id:"keep-things-dry-dont-repeat-yourself",level:3},{value:"Use Comments Appropriately",id:"use-comments-appropriately",level:3},{value:"Script Runner",id:"script-runner",level:3},{value:"Looping vs Unrolled Loops",id:"looping-vs-unrolled-loops",level:3},{value:"Script Organization",id:"script-organization",level:2},{value:"Organizing Your Scripts into a Plugin",id:"organizing-your-scripts-into-a-plugin",level:3},{value:"Organize Scripts into Methods",id:"organize-scripts-into-methods",level:3},{value:"Using Classes vs Unscoped Methods",id:"using-classes-vs-unscoped-methods",level:3},{value:"Instrumented vs Uninstrumented Lines (require vs load)",id:"instrumented-vs-uninstrumented-lines-require-vs-load",level:3},{value:"Debugging and Auditing",id:"debugging-and-auditing",level:2},{value:"Built-In Debugging Capabilities",id:"built-in-debugging-capabilities",level:3},{value:"Breakpoints",id:"breakpoints",level:3},{value:"Using Disconnect Mode",id:"using-disconnect-mode",level:3},{value:"Auditing your Scripts",id:"auditing-your-scripts",level:3},{value:"Ruby Syntax Check",id:"ruby-syntax-check",level:4},{value:"Common Scenarios",id:"common-scenarios",level:2},{value:"User Input Best Practices",id:"user-input-best-practices",level:3},{value:"Conditionally Require Manual User Input Steps",id:"conditionally-require-manual-user-input-steps",level:3},{value:"Outputing Extra Information to a Report",id:"outputing-extra-information-to-a-report",level:3},{value:"Getting the Most Recent Value of a Telemetry Point from Multiple Packets",id:"getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets",level:3},{value:"Checking Every Single Sample of a Telemetry Point",id:"checking-every-single-sample-of-a-telemetry-point",level:3},{value:"Using Variables in Mnemonics",id:"using-variables-in-mnemonics",level:3},{value:"Using Custom wait_check_expression",id:"using-custom-wait_check_expression",level:3},{value:"COSMOS Scripting Differences from Regular Ruby Scripting",id:"cosmos-scripting-differences-from-regular-ruby-scripting",level:3},{value:"Do not use single line if statements",id:"do-not-use-single-line-if-statements",level:4},{value:"When Things Go Wrong",id:"when-things-go-wrong",level:2},{value:"Common Reasons Checks Fail",id:"common-reasons-checks-fail",level:3},{value:"How to Recover from Anomalies",id:"how-to-recover-from-anomalies",level:3},{value:"Advanced Topics",id:"advanced-topics",level:2},{value:"Advanced Script Configuration with CSV or Excel",id:"advanced-script-configuration-with-csv-or-excel",level:3},{value:"When to use Ruby Modules",id:"when-to-use-ruby-modules",level:3}];function d(e){const n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",h4:"h4",li:"li",ol:"ol",p:"p",pre:"pre",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,s.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.h2,{id:"introduction",children:"Introduction"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h2,{id:"concepts",children:"Concepts"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"ruby-vs-python-in-cosmos",children:"Ruby vs Python in COSMOS"}),"\n",(0,i.jsx)(n.p,{children:"There are many similarities and a few key differences between Ruby and Python when it comes to writing COSMOS scripts."}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsx)(n.li,{children:"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."}),"\n",(0,i.jsxs)(n.li,{children:["Indentation white space:","\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Ruby: Not significant. Ruby uses the ",(0,i.jsx)(n.code,{children:"end"})," keyword to determine indented code blocks with a standard of 2 spaces."]}),"\n",(0,i.jsx)(n.li,{children:"Python: Significant. Python uses indentation to determine code blocks with a standard of 4 spaces."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"Variables do not have to be declared ahead of time and can be reassigned later, i.e. Ruby and Python are dynamically typed."}),"\n",(0,i.jsxs)(n.li,{children:["Variable interpolation:","\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["Ruby: Variable values can be placed into strings using the ",(0,i.jsx)(n.code,{children:'"#{variable}"'})," syntax."]}),"\n",(0,i.jsxs)(n.li,{children:["Python: Variable values can be placed into f-strings using the ",(0,i.jsx)(n.code,{children:'f"{variable}"'})," syntax."]}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"A variable declared inside of a block or loop will not exist outside of that block unless it was already declared."}),"\n"]}),"\n",(0,i.jsx)(n.p,{children:"Both languages provides a script writer a lot of power. But with great power comes great responsibility. Remember when writing your scripts that you or someone else will come along later and need to understand them. Therefore use the following style guidelines:"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:"Use consistent spacing for indentation and do NOT use tabs"}),"\n",(0,i.jsxs)(n.li,{children:["Constants should be all caps with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"SPEED_OF_LIGHT = 299792458 # meters per s"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["Variable names and method names should be in lowercase with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:'last_name = "Smith"'})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"perform_setup_operation()"})}),"\n"]}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["Class names (when used) should be camel case and the files which contain them should match but be lowercase with underscores","\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"class DataUploader # in 'data_uploader.rb'"})}),"\n",(0,i.jsx)(n.li,{children:(0,i.jsx)(n.code,{children:"class CcsdsUtility: # in 'ccsds_utility.py'"})}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.li,{children:"Don't add useless comments but instead describe intent"}),"\n"]}),"\n",(0,i.jsx)("div",{style:{clear:"both"}}),"\n",(0,i.jsx)(n.p,{children:"The following is an example of good Ruby style:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"load 'TARGET/lib/upload_utility.rb' # library we do NOT want to show executing\nload_utility 'TARGET/lib/helper_utility.rb' # library we do want to show executing\n\n# Declare constants\nOUR_TARGETS = ['INST','INST2']\n\n# Clear the collect counter of the passed in target name\ndef clear_collects(target)\n cmd(\"#{target} CLEAR\")\n wait_check(\"#{target} HEALTH_STATUS COLLECTS == 0\", 5)\nend\n\n######################################\n# START\n######################################\nhelper = HelperUtility.new\nhelper.setup\n\n# Perform collects on all the targets\nOUR_TARGETS.each do |target|\n collects = tlm(\"#{target} HEALTH_STATUS COLLECTS\")\n cmd(\"#{target} COLLECT with TYPE SPECIAL\")\n wait_check(\"#{target} HEALTH_STATUS COLLECTS == #{collects + 1}\", 5)\nend\n\nclear_collects('INST')\nclear_collects('INST2')\n"})}),"\n",(0,i.jsx)(n.p,{children:"The following is an example of good Python style:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"from openc3.script import *\n\nimport TARGET.lib.upload_utility # library we do NOT want to show executing\nload_utility('TARGET/lib/helper_utility.rb') # library we do want to show executing\n\n# Declare constants\nOUR_TARGETS = ['INST','INST2']\n\n# Clear the collect counter of the passed in target name\ndef clear_collects(target):\n cmd(f\"{target} CLEAR\")\n wait_check(f\"{target} HEALTH_STATUS COLLECTS == 0\", 5)\n\n######################################\n# START\n######################################\nhelper = HelperUtility()\nhelper.setup()\n\n# Perform collects on all the targets\nfor target in OUR_TARGETS:\n collects = tlm(f\"{target} HEALTH_STATUS COLLECTS\")\n cmd(f\"{target} COLLECT with TYPE SPECIAL\")\n wait_check(f\"{target} HEALTH_STATUS COLLECTS == {collects + 1}\", 5)\n\nclear_collects('INST')\nclear_collects('INST2')\n"})}),"\n",(0,i.jsx)(n.p,{children:"Both examples shows several features of COSMOS scripting in action. Notice the difference between 'load' or 'import' and 'load_utility'. 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. 'load_utility' will visually execute the code line by line to show the user what is happening."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"The 'helper_utility' is then created. Note the similarity in the class name and the file name we loaded."}),"\n",(0,i.jsxs)(n.p,{children:["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"'," 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."]}),"\n",(0,i.jsx)(n.p,{children:"Finally we call our 'clear_collects' method on each target by passing the target name."}),"\n",(0,i.jsx)(n.h2,{id:"scripting-philosophy",children:"Scripting Philosophy"}),"\n",(0,i.jsx)(n.h3,{id:"a-super-basic-script-example",children:"A Super Basic Script Example"}),"\n",(0,i.jsx)(n.p,{children:"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:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'cmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check("INST HEALTH_STATUS TYPE == \'NORMAL\'", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"or similarly with a counter that is sampled before the command."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'count = tlm("INST HEALTH_STATUS COLLECTS")\ncmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check("INST HEALTH_STATUS COLLECTS >= #{count + 1}", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'count = tlm("INST HEALTH_STATUS COLLECTS")\ncmd("INST COLLECT with TYPE NORMAL, TEMP 10.0")\nwait_check(f"INST HEALTH_STATUS COLLECTS >= {count + 1}", 5)\n'})}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"kiss-keep-it-simple-stupid",children:"KISS (Keep It Simple Stupid)"}),"\n",(0,i.jsx)(n.p,{children:"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'll thank yourself later by expanding complex one liners and breaking up and documenting regular expressions."}),"\n",(0,i.jsx)(n.h3,{id:"keep-things-dry-dont-repeat-yourself",children:"Keep things DRY (Don't Repeat Yourself)"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.p,{children:"For example, a script that powers on a subsystem and ensures correct telemetry would become:"}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"def power_on_subsystem\n # 100 lines of cmd(), wait_check(), etc\nend\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"def power_on_subsystem():\n # 100 lines of cmd(), wait_check(), etc\n"})}),"\n",(0,i.jsx)(n.p,{children:"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:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"power_on_subsystem()\n# 150 lines operating the subsystem (e.g.)\n# cmd(...)\n# wait_check(...)\n#...\npower_off_subystem()\n# Unrelated activities\npower_on_subsystem()\n# etc.\n"})}),"\n",(0,i.jsx)(n.p,{children:"Blocks of code where only the only variation is the mnemonics or values checked can be replaced by methods with arguments."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp)\n cmd("TARGET #{enable_cmd_name} with ENABLE TRUE")\n wait_check("TARGET #{enable_tlm} == \'TRUE\'", 5)\n wait_check("TARGET #{temp_tlm} >= #{expected_temp}", 50)\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def test_minimum_temp(enable_cmd_name, enable_tlm, temp_tlm, expected_temp):\n cmd(f"TARGET {enable_cmd_name} with ENABLE TRUE")\n wait_check(f"TARGET {enable_tlm} == \'TRUE\'", 5)\n wait_check(f"TARGET {temp_tlm} >= {expected_temp}", 50)\n'})}),"\n",(0,i.jsx)(n.h3,{id:"use-comments-appropriately",children:"Use Comments Appropriately"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# This line sends an abort command - BAD COMMENT, UNNECCESSARY\ncmd("INST ABORT")\n# Rotate the gimbal to look at the calibration target - GOOD COMMENT\ncmd("INST ROTATE with ANGLE 180.0") # Rotate 180 degrees - BAD COMMENT\n'})}),"\n",(0,i.jsx)(n.h3,{id:"script-runner",children:"Script Runner"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"When opening a suite file (named with 'suite') 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."}),"\n",(0,i.jsx)(n.p,{children:"The correct environment for the job is up to individual users, and many programs will use both script formats to complete their goals."}),"\n",(0,i.jsx)(n.h3,{id:"looping-vs-unrolled-loops",children:"Looping vs Unrolled Loops"}),"\n",(0,i.jsx)(n.p,{children:"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 \u201cunroll\u201d 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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"10.times do |temperature_number|\n check_temperature(temperature_number + 1)\nend\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"for temperature_number in range(1, 11):\n check_temperature(temperature_number)\n"})}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"check_temperature(1)\ncheck_temperature(2)\ncheck_temperature(3)\ncheck_temperature(4)\ncheck_temperature(5)\ncheck_temperature(6)\ncheck_temperature(7)\ncheck_temperature(8)\ncheck_temperature(9)\ncheck_temperature(10)\n"})}),"\n",(0,i.jsx)(n.p,{children:"In the unrolled version above, the COSMOS \u201cStart script at selected line\u201d feature can be used to resume the script at any point."}),"\n",(0,i.jsx)(n.h2,{id:"script-organization",children:"Script Organization"}),"\n",(0,i.jsxs)(n.p,{children:["All scripts must be part of a ",(0,i.jsx)(n.a,{href:"/tools/staticdocs/docs/configuration/plugins",children:"Plugin"}),". 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."]}),"\n",(0,i.jsx)(n.h3,{id:"organizing-your-scripts-into-a-plugin",children:"Organizing Your Scripts into a Plugin"}),"\n",(0,i.jsx)(n.p,{children:"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's scripts/procedures."}),"\n",(0,i.jsxs)(n.table,{children:[(0,i.jsx)(n.thead,{children:(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.th,{children:"Folder"}),(0,i.jsx)(n.th,{children:"Description"})]})}),(0,i.jsxs)(n.tbody,{children:[(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"targets/TARGET_NAME/lib"}),(0,i.jsx)(n.td,{children:"Place script files containing reusable target specific methods here"})]}),(0,i.jsxs)(n.tr,{children:[(0,i.jsx)(n.td,{children:"targets/TARGET_NAME/procedures"}),(0,i.jsx)(n.td,{children:"Place simple procedures that are centered around one specific target here"})]})]})]}),"\n",(0,i.jsx)(n.p,{children:"In your main procedure you will usually bring in the other files with instrumentation using load_utility."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"# Ruby:\nload_utility('TARGET/lib/my_other_script.rb')\n# Python:\nload_utility('TARGET/procedures/my_other_script.py')\n"})}),"\n",(0,i.jsx)(n.h3,{id:"organize-scripts-into-methods",children:"Organize Scripts into Methods"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def test_1_heater_zone_control\n puts "Verifies requirements 304, 306, and 310"\n # Test code here\nend\n\ndef script_1_heater_zone_control\n puts "Verifies requirements 304, 306, and 310"\n # Test code here\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def test_1_heater_zone_control():\n print("Verifies requirements 304, 306, and 310")\n # Test code here\n\ndef script_1_heater_zone_control():\n print("Verifies requirements 304, 306, and 310")\n # Test code here\n'})}),"\n",(0,i.jsx)(n.h3,{id:"using-classes-vs-unscoped-methods",children:"Using Classes vs Unscoped Methods"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'class Gimbal\n attr_accessor :gimbal_steps\n def initialize()\n @gimbal_steps = 0\n end\n def move(steps_to_move)\n # Move the gimbal\n @gimbal_steps += steps_to_move\n end\n def home_gimbal\n # Home the gimbal\n @gimbal_steps = 0\n end\nend\n\ndef perform_common_math(x, y)\n x + y\nend\n\ngimbal = Gimbal.new\ngimbal.home_gimbal\ngimbal.move(100)\ngimbal.move(200)\nputs "Moved gimbal #{gimbal.gimbal_steps}"\nresult = perform_common_math(gimbal.gimbal_steps, 10)\nputs "Math:#{result}"\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'class Gimbal:\n def __init__(self):\n self.gimbal_steps = 0\n\n def move(self, steps_to_move):\n # Move the gimbal\n self.gimbal_steps += steps_to_move\n\n def home_gimbal(self):\n # Home the gimbal\n self.gimbal_steps = 0\n\ndef perform_common_math(x, y):\n return x + y\n\ngimbal = Gimbal()\ngimbal.home_gimbal()\ngimbal.move(100)\ngimbal.move(200)\nprint(f"Moved gimbal {gimbal.gimbal_steps}")\nresult = perform_common_math(gimbal.gimbal_steps, 10)\nprint(f"Math:{result}")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"instrumented-vs-uninstrumented-lines-require-vs-load",children:"Instrumented vs Uninstrumented Lines (require vs load)"}),"\n",(0,i.jsx)(n.p,{children:"COSMOS scripts are normally \u201cinstrumented\u201d. 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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"However, sometimes you don'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 \u201cload\u201d 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. \u201crequire\u201d 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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"temp = 0\ndisable_instrumentation do\n # Make sure nothing in here will raise exceptions!\n 5000000.times do\n temp += 1\n end\nend\nputs temp\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"temp = 0\nwith disable_instrumentation():\n # Make sure nothing in here will raise exceptions!\n for x in range(0,5000000):\n temp += 1\nprint(temp)\n"})}),"\n",(0,i.jsx)(n.admonition,{title:"When Running Uninstrumented Code",type:"warning",children:(0,i.jsx)(n.p,{children:"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."})}),"\n",(0,i.jsx)(n.h2,{id:"debugging-and-auditing",children:"Debugging and Auditing"}),"\n",(0,i.jsx)(n.h3,{id:"built-in-debugging-capabilities",children:"Built-In Debugging Capabilities"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"To use the debugging functionality, first select the \u201cToggle Debug\u201d 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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"variable_name\n"})}),"\n",(0,i.jsx)(n.p,{children:"Variables can also be set simply by using equals."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"variable_name = 5\n"})}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'cmd("INST COLLECT with TYPE NORMAL")\n'})}),"\n",(0,i.jsx)(n.p,{children:"Note that the debug prompt keeps the command history and you can scroll through the history by using the up and down arrows."}),"\n",(0,i.jsx)(n.h3,{id:"breakpoints",children:"Breakpoints"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.h3,{id:"using-disconnect-mode",children:"Using Disconnect Mode"}),"\n",(0,i.jsx)(n.p,{children:"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 -> 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."}),"\n",(0,i.jsx)(n.p,{children:"While in disconnect mode, commands to the disconnected targets always succeed. Additionally, all checks of disconnected targets' 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."}),"\n",(0,i.jsx)(n.h3,{id:"auditing-your-scripts",children:"Auditing your Scripts"}),"\n",(0,i.jsx)(n.p,{children:"Script Runner includes several tools to help audit your scripts both before and after execution."}),"\n",(0,i.jsx)(n.h4,{id:"ruby-syntax-check",children:"Ruby Syntax Check"}),"\n",(0,i.jsx)(n.p,{children:"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 \u201cend\u201d keyword, or using a block but forgetting the proceeding \u201cdo\u201d keyword."}),"\n",(0,i.jsx)(n.h2,{id:"common-scenarios",children:"Common Scenarios"}),"\n",(0,i.jsx)(n.h3,{id:"user-input-best-practices",children:"User Input Best Practices"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'answer = ask_string("Do you want to continue (y/n)?")\nif answer != \'y\' and answer != \'Y\'\n raise "User entered: #{answer}"\nend\n\ntemp = 0.0\nwhile temp < 10.0 or temp > 50.0\n temp = ask("Enter the desired temperature between 10.0 and 50.0")\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'answer = ask_string("Do you want to continue (y/n)?")\nif answer != \'y\' and answer != \'Y\':\n raise RuntimeError(f"User entered: {answer}")\n\ntemp = 0.0\nwhile temp < 10.0 or temp > 50.0:\n temp = ask("Enter the desired temperature between 10.0 and 50.0")\n'})}),"\n",(0,i.jsx)(n.p,{children:"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)."}),"\n",(0,i.jsx)(n.p,{children:"Note that all these user input methods provide the user the option to \u201cCancel\u201d. When cancel is clicked, the script is paused but remains at the user input line. When hitting \u201cGo\u201d to the continue, the user will be re-prompted to enter the value."}),"\n",(0,i.jsx)(n.h3,{id:"conditionally-require-manual-user-input-steps",children:"Conditionally Require Manual User Input Steps"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby Example:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'if $manual\n temp = ask("Please enter the temperature")\nelse\n temp = 20.0\nend\nif !$manual\n puts "Skipping infinite wait in auto mode"\nelse\n wait\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python Example:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'if RunningScript.manual:\n temp = ask("Please enter the temperature")\nelse:\n temp = 20.0\nif not RunningScript.manual:\n print("Skipping infinite wait in auto mode")\nelse:\n wait()\n'})}),"\n",(0,i.jsx)(n.p,{children:"When running suites, there is a checkbox at the top of the tool called \u201cManual\u201d that affects this $manual variable directly."}),"\n",(0,i.jsx)(n.h3,{id:"outputing-extra-information-to-a-report",children:"Outputing Extra Information to a Report"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'class MyGroup < OpenC3::Group\n def script_1\n # The following text will be placed in the report\n OpenC3::Group.puts "Verifies requirements 304, 306, 310"\n # This puts line will show up in the sr_messages log file\n puts "script_1 complete"\n end\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'from openc3.script.suite import Group\nclass MyGroup(Group):\n def script_1():\n # The following text will be placed in the report\n Group.print("Verifies requirements 304, 306, 310")\n # This puts line will show up in the sr_messages log file\n print("script_1 complete")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"getting-the-most-recent-value-of-a-telemetry-point-from-multiple-packets",children:"Getting the Most Recent Value of a Telemetry Point from Multiple Packets"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# Get the value of TEMP from the most recently received PACKET1\nvalue = tlm("INST PACKET1 TEMP")\n# Get the value of TEMP from the most recently received PACKET2\nvalue = tlm("INST PACKET2 TEMP")\n# Get the value of TEMP from the most recently received PACKET1 or PACKET2\nvalue = tlm("INST LATEST TEMP")\n'})}),"\n",(0,i.jsx)(n.h3,{id:"checking-every-single-sample-of-a-telemetry-point",children:"Checking Every Single Sample of a Telemetry Point"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])\nwait 1.5\nid, packets = get_packets(id)\npackets.each do |packet|\n puts \"#{packet['PACKET_TIMESECONDS']}: #{packet['target_name']} #{packet['packet_name']}\"\nend\n# Wait for some time later and re-use the last returned ID\nid, packets = get_packets(id)\n"})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:"id = subscribe_packets([['INST', 'HEALTH_STATUS'], ['INST', 'ADCS']])\nwait(1.5)\nid, packets = get_packets(id)\nfor packet in packets:\n print(f\"{packet['PACKET_TIMESECONDS']}: {packet['target_name']} {packet['packet_name']}\")\n# Wait for some time later and re-use the last returned ID\nid, packets = get_packets(id)\n"})}),"\n",(0,i.jsx)(n.h3,{id:"using-variables-in-mnemonics",children:"Using Variables in Mnemonics"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'def example(target_name, temp_number)\n cmd("#{target_name} COLLECT with TYPE NORMAL")\n wait_check("#{target_name} TEMP#{temp_number} > 50.0")\nend\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'def example(target_name, temp_number):\n cmd(f"{target_name} COLLECT with TYPE NORMAL")\n wait_check(f"{target_name} TEMP{temp_number} > 50.0")\n'})}),"\n",(0,i.jsxs)(n.p,{children:["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 ",(0,i.jsx)(n.a,{href:"#looping-vs-unrolled-loops",children:"Looping vs Unrolled Loops"})," section."]}),"\n",(0,i.jsx)(n.h3,{id:"using-custom-wait_check_expression",children:"Using Custom wait_check_expression"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"Ruby:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'one = 1\ntwo = 2\n\nwait_check_expression("one == two", 1)\n# ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds\n\n# Checking an integer range\nwait_check_expression("one > 0 and one < 10 # init value one = #{one}", 1)\n'})}),"\n",(0,i.jsx)(n.p,{children:"Python:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-python",children:'one = 1\ntwo = 2\n\nwait_check_expression("one == two", 1, 0.25, locals())\n# ERROR: CHECK: one == two is FALSE after waiting 1.017035 seconds\n\n# Checking an integer range\nwait_check_expression("one > 0 and one < 10", 1, 0.25, locals())\n'})}),"\n",(0,i.jsx)(n.h3,{id:"cosmos-scripting-differences-from-regular-ruby-scripting",children:"COSMOS Scripting Differences from Regular Ruby Scripting"}),"\n",(0,i.jsx)(n.h4,{id:"do-not-use-single-line-if-statements",children:"Do not use single line if statements"}),"\n",(0,i.jsx)(n.p,{children:"COSMOS scripting instruments each line to catch exceptions if things go wrong. With single line if statements the exception handling doesn'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)."}),"\n",(0,i.jsx)(n.p,{children:"Don't do this:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'run_method() if tlm("INST HEALTH_STATUS TEMP1") > 10.0\n'})}),"\n",(0,i.jsx)(n.p,{children:"Do this instead:"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:'# It is best not to execute any code that could fail in an if statement, ie\n# tlm() could fail if the CmdTlmServer was not running or a mnemonic\n# was misspelled\ntemp1 = tlm("INST HEALTH_STATUS TEMP1")\nif temp1 > 10.0\n run_method()\nend\n'})}),"\n",(0,i.jsx)(n.h2,{id:"when-things-go-wrong",children:"When Things Go Wrong"}),"\n",(0,i.jsx)(n.h3,{id:"common-reasons-checks-fail",children:"Common Reasons Checks Fail"}),"\n",(0,i.jsx)(n.p,{children:"There are three common reasons that checks fail in COSMOS scripts:"}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The delay given was too short"}),"\n",(0,i.jsx)(n.p,{children:"The wait_check() method takes a timeout that indicates how long to wait for the referenced telemetry point to pass the check. The timeout needs to be large enough for the system under test to finish its action and for updated telemetry to be received. Note that the script will continue as soon as the check completes successfully. Thus, the only penalty for a longer timeout is the additional wait time in a failure condition."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The range or value checked against was incorrect or too stringent"}),"\n",(0,i.jsx)(n.p,{children:"Often the actual telemetry value is ok, but the expected value checked against was too tight. Loosen the ranges on checks when it makes sense. Ensure your script is using the wait_check_tolerance() routine when checking floating point numbers and verify you're using an appropriate tolerance value."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"The check really failed"}),"\n",(0,i.jsx)(n.p,{children:"Of course, sometimes there are real failures. See the next section for how to handle them and recover."}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h3,{id:"how-to-recover-from-anomalies",children:"How to Recover from Anomalies"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsxs)(n.ol,{children:["\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Retry"}),"\n",(0,i.jsx)(n.p,{children:"After a failure, the Script Runner \u201cPause\u201d button changes to \u201cRetry\u201d. Clicking on the Retry button will re-execute the line the failed. For failures due to timing issues, this will often resolve the issue and allow the script to continue. Make note of the failure and be sure to update your script prior to the next run."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Use the Debug Prompt"}),"\n",(0,i.jsx)(n.p,{children:"By selecting Script -> Toggle Debug, you can perform arbitrary actions that may be needed to correct the situation without stopping the running script. You can also inspect variables to help determine why something failed."}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Execute Selection"}),"\n",(0,i.jsx)(n.p,{children:'If only a small section of a script needs to be run, then \u201cExecute Selection" can be used to execute only a small portion of the script. This can also be used when a script is paused or stopped in error.'}),"\n"]}),"\n",(0,i.jsxs)(n.li,{children:["\n",(0,i.jsx)(n.p,{children:"Run from here"}),"\n",(0,i.jsx)(n.p,{children:'By clicking into a script, and right clicking to select "Run from here", users can restart a script at an arbitrary point. This works well if no required variable definitions exist earlier in the script.'}),"\n"]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"advanced-topics",children:"Advanced Topics"}),"\n",(0,i.jsx)(n.h3,{id:"advanced-script-configuration-with-csv-or-excel",children:"Advanced Script Configuration with CSV or Excel"}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.p,{children:"The Ruby CSV class be used to easily read data from CSV files (recommended for cross platform projects)."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"require 'csv'\nvalues = CSV.read('test.csv')\nputs values[0][0]\n"})}),"\n",(0,i.jsx)(n.p,{children:"If you are only using Windows, COSMOS also contains a library for reading Excel files."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"require 'openc3/win32/excel'\nss = ExcelSpreadsheet.new('C:/git/cosmos/test.xlsx')\nputs ss[0][0][0]\n"})}),"\n",(0,i.jsx)(n.h3,{id:"when-to-use-ruby-modules",children:"When to use Ruby Modules"}),"\n",(0,i.jsx)(n.p,{children:"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't typically useful for COSMOS scripting though."}),"\n",(0,i.jsx)(n.p,{children:"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."}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-ruby",children:"module MyModule\n def module_method\n end\nend\nclass MyTest < OpenC3::Group\n include MyModule\n def test_1\n module_method()\n end\nend\n"})})]})}function h(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},1184:(e,n,t)=>{t.d(n,{R:()=>a});var i=t(4041);const s={},r=i.createContext(s);function a(e){const n=i.useContext(r);return i.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[4650],{1167:(e,t,n)=>{"use strict";n.d(t,{A:()=>E});var s=n(4041),o=n(1085);function a(e){const{mdxAdmonitionTitle:t,rest:n}=function(e){const t=s.Children.toArray(e),n=t.find((e=>s.isValidElement(e)&&"mdxAdmonitionTitle"===e.type)),a=t.filter((e=>e!==n)),c=n?.props.children;return{mdxAdmonitionTitle:c,rest:a.length>0?(0,o.jsx)(o.Fragment,{children:a}):null}}(e.children),a=e.title??t;return{...e,...a&&{title:a},children:n}}var c=n(4357),i=n(9082),r=n(7473);const l={admonition:"admonition_IZjC",admonitionHeading:"admonitionHeading_uVvU",admonitionIcon:"admonitionIcon_HiR3",admonitionContent:"admonitionContent_bl22"};function d(e){let{type:t,className:n,children:s}=e;return(0,o.jsx)("div",{className:(0,c.A)(r.G.common.admonition,r.G.common.admonitionType(t),l.admonition,n),children:s})}function u(e){let{icon:t,title:n}=e;return(0,o.jsxs)("div",{className:l.admonitionHeading,children:[(0,o.jsx)("span",{className:l.admonitionIcon,children:t}),n]})}function m(e){let{children:t}=e;return t?(0,o.jsx)("div",{className:l.admonitionContent,children:t}):null}function h(e){const{type:t,icon:n,title:s,children:a,className:c}=e;return(0,o.jsxs)(d,{type:t,className:c,children:[s||n?(0,o.jsx)(u,{title:s,icon:n}):null,(0,o.jsx)(m,{children:a})]})}function f(e){return(0,o.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"})})}const p={icon:(0,o.jsx)(f,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.note",description:"The default label used for the Note admonition (:::note)",children:"note"})};function x(e){return(0,o.jsx)(h,{...p,...e,className:(0,c.A)("alert alert--secondary",e.className),children:e.children})}function g(e){return(0,o.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})})}const v={icon:(0,o.jsx)(g,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.tip",description:"The default label used for the Tip admonition (:::tip)",children:"tip"})};function j(e){return(0,o.jsx)(h,{...v,...e,className:(0,c.A)("alert alert--success",e.className),children:e.children})}function b(e){return(0,o.jsx)("svg",{viewBox:"0 0 14 16",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"})})}const N={icon:(0,o.jsx)(b,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.info",description:"The default label used for the Info admonition (:::info)",children:"info"})};function y(e){return(0,o.jsx)(h,{...N,...e,className:(0,c.A)("alert alert--info",e.className),children:e.children})}function A(e){return(0,o.jsx)("svg",{viewBox:"0 0 16 16",...e,children:(0,o.jsx)("path",{fillRule:"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"})})}const C={icon:(0,o.jsx)(A,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.warning",description:"The default label used for the Warning admonition (:::warning)",children:"warning"})};function k(e){return(0,o.jsx)("svg",{viewBox:"0 0 12 16",...e,children:(0,o.jsx)("path",{fillRule:"evenodd",d:"M5.05.31c.81 2.17.41 3.38-.52 4.31C3.55 5.67 1.98 6.45.9 7.98c-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-.3-6.61-.61 2.03.53 3.33 1.94 2.86 1.39-.47 2.3.53 2.27 1.67-.02.78-.31 1.44-1.13 1.81 3.42-.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52.13-2.03 1.13-1.89 2.75.09 1.08-1.02 1.8-1.86 1.33-.67-.41-.66-1.19-.06-1.78C8.18 5.31 8.68 2.45 5.05.32L5.03.3l.02.01z"})})}const B={icon:(0,o.jsx)(k,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.danger",description:"The default label used for the Danger admonition (:::danger)",children:"danger"})};const w={icon:(0,o.jsx)(A,{}),title:(0,o.jsx)(i.A,{id:"theme.admonition.caution",description:"The default label used for the Caution admonition (:::caution)",children:"caution"})};const L={...{note:x,tip:j,info:y,warning:function(e){return(0,o.jsx)(h,{...C,...e,className:(0,c.A)("alert alert--warning",e.className),children:e.children})},danger:function(e){return(0,o.jsx)(h,{...B,...e,className:(0,c.A)("alert alert--danger",e.className),children:e.children})}},...{secondary:e=>(0,o.jsx)(x,{title:"secondary",...e}),important:e=>(0,o.jsx)(y,{title:"important",...e}),success:e=>(0,o.jsx)(j,{title:"success",...e}),caution:function(e){return(0,o.jsx)(h,{...w,...e,className:(0,c.A)("alert alert--warning",e.className),children:e.children})}}};function E(e){const t=a(e),n=(s=t.type,L[s]||(console.warn(`No admonition component found for admonition type "${s}". Using Info as fallback.`),L.info));var s;return(0,o.jsx)(n,{...t})}},3412:(e,t,n)=>{"use strict";n.d(t,{A:()=>g});n(4041);var s=n(4357),o=n(9082),a=n(7473),c=n(2436);const i={iconEdit:"iconEdit_UohW"};var r=n(1085);function l(e){let{className:t,...n}=e;return(0,r.jsx)("svg",{fill:"currentColor",height:"20",width:"20",viewBox:"0 0 40 40",className:(0,s.A)(i.iconEdit,t),"aria-hidden":"true",...n,children:(0,r.jsx)("g",{children:(0,r.jsx)("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"})})})}function d(e){let{editUrl:t}=e;return(0,r.jsxs)(c.A,{to:t,className:a.G.common.editThisPage,children:[(0,r.jsx)(l,{}),(0,r.jsx)(o.A,{id:"theme.common.editThisPage",description:"The link label to edit the current page",children:"Edit this page"})]})}var u=n(396);function m(e){void 0===e&&(e={});const{i18n:{currentLocale:t}}=(0,u.A)(),n=function(){const{i18n:{currentLocale:e,localeConfigs:t}}=(0,u.A)();return t[e].calendar}();return new Intl.DateTimeFormat(t,{calendar:n,...e})}function h(e){let{lastUpdatedAt:t}=e;const n=new Date(t),s=m({day:"numeric",month:"short",year:"numeric",timeZone:"UTC"}).format(n);return(0,r.jsx)(o.A,{id:"theme.lastUpdated.atDate",description:"The words used to describe on which date a page has been last updated",values:{date:(0,r.jsx)("b",{children:(0,r.jsx)("time",{dateTime:n.toISOString(),itemProp:"dateModified",children:s})})},children:" on {date}"})}function f(e){let{lastUpdatedBy:t}=e;return(0,r.jsx)(o.A,{id:"theme.lastUpdated.byUser",description:"The words used to describe by who the page has been last updated",values:{user:(0,r.jsx)("b",{children:t})},children:" by {user}"})}function p(e){let{lastUpdatedAt:t,lastUpdatedBy:n}=e;return(0,r.jsxs)("span",{className:a.G.common.lastUpdated,children:[(0,r.jsx)(o.A,{id:"theme.lastUpdated.lastUpdatedAtBy",description:"The sentence used to display when a page has been last updated, and by who",values:{atDate:t?(0,r.jsx)(h,{lastUpdatedAt:t}):"",byUser:n?(0,r.jsx)(f,{lastUpdatedBy:n}):""},children:"Last updated{atDate}{byUser}"}),!1]})}const x={lastUpdated:"lastUpdated_g62E"};function g(e){let{className:t,editUrl:n,lastUpdatedAt:o,lastUpdatedBy:a}=e;return(0,r.jsxs)("div",{className:(0,s.A)("row",t),children:[(0,r.jsx)("div",{className:"col",children:n&&(0,r.jsx)(d,{editUrl:n})}),(0,r.jsx)("div",{className:(0,s.A)("col",x.lastUpdated),children:(o||a)&&(0,r.jsx)(p,{lastUpdatedAt:o,lastUpdatedBy:a})})]})}},5604:(e,t,n)=>{"use strict";n.d(t,{A:()=>le});var s=n(4041);const o={},a=s.createContext(o);function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:function(e){const t=s.useContext(a);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}(e.components),s.createElement(a.Provider,{value:t},e.children)}var i=n(9058),r=n(213),l=n(4357),d=n(2727),u=n(2520);function m(){const{prism:e}=(0,u.p)(),{colorMode:t}=(0,d.G)(),n=e.theme,s=e.darkTheme||n;return"dark"===t?s:n}var h=n(7473),f=n(1431),p=n.n(f);const x=/title=(?<quote>["'])(?<title>.*?)\1/,g=/\{(?<range>[\d,-]+)\}/,v={js:{start:"\\/\\/",end:""},jsBlock:{start:"\\/\\*",end:"\\*\\/"},jsx:{start:"\\{\\s*\\/\\*",end:"\\*\\/\\s*\\}"},bash:{start:"#",end:""},html:{start:"\x3c!--",end:"--\x3e"}},j={...v,lua:{start:"--",end:""},wasm:{start:"\\;\\;",end:""},tex:{start:"%",end:""},vb:{start:"['\u2018\u2019]",end:""},vbnet:{start:"(?:_\\s*)?['\u2018\u2019]",end:""},rem:{start:"[Rr][Ee][Mm]\\b",end:""},f90:{start:"!",end:""},ml:{start:"\\(\\*",end:"\\*\\)"},cobol:{start:"\\*>",end:""}},b=Object.keys(v);function N(e,t){const n=e.map((e=>{const{start:n,end:s}=j[e];return`(?:${n}\\s*(${t.flatMap((e=>[e.line,e.block?.start,e.block?.end].filter(Boolean))).join("|")})\\s*${s})`})).join("|");return new RegExp(`^\\s*(?:${n})\\s*$`)}function y(e,t){let n=e.replace(/\n$/,"");const{language:s,magicComments:o,metastring:a}=t;if(a&&g.test(a)){const e=a.match(g).groups.range;if(0===o.length)throw new Error(`A highlight range has been given in code block's metastring (\`\`\` ${a}), but no magic comment config is available. Docusaurus applies the first magic comment entry's className for metastring ranges.`);const t=o[0].className,s=p()(e).filter((e=>e>0)).map((e=>[e-1,[t]]));return{lineClassNames:Object.fromEntries(s),code:n}}if(void 0===s)return{lineClassNames:{},code:n};const c=function(e,t){switch(e){case"js":case"javascript":case"ts":case"typescript":return N(["js","jsBlock"],t);case"jsx":case"tsx":return N(["js","jsBlock","jsx"],t);case"html":return N(["js","jsBlock","html"],t);case"python":case"py":case"bash":return N(["bash"],t);case"markdown":case"md":return N(["html","jsx","bash"],t);case"tex":case"latex":case"matlab":return N(["tex"],t);case"lua":case"haskell":case"sql":return N(["lua"],t);case"wasm":return N(["wasm"],t);case"vb":case"vba":case"visual-basic":return N(["vb","rem"],t);case"vbnet":return N(["vbnet","rem"],t);case"batch":return N(["rem"],t);case"basic":return N(["rem","f90"],t);case"fsharp":return N(["js","ml"],t);case"ocaml":case"sml":return N(["ml"],t);case"fortran":return N(["f90"],t);case"cobol":return N(["cobol"],t);default:return N(b,t)}}(s,o),i=n.split("\n"),r=Object.fromEntries(o.map((e=>[e.className,{start:0,range:""}]))),l=Object.fromEntries(o.filter((e=>e.line)).map((e=>{let{className:t,line:n}=e;return[n,t]}))),d=Object.fromEntries(o.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.start,t]}))),u=Object.fromEntries(o.filter((e=>e.block)).map((e=>{let{className:t,block:n}=e;return[n.end,t]})));for(let h=0;h<i.length;){const e=i[h].match(c);if(!e){h+=1;continue}const t=e.slice(1).find((e=>void 0!==e));l[t]?r[l[t]].range+=`${h},`:d[t]?r[d[t]].start=h:u[t]&&(r[u[t]].range+=`${r[u[t]].start}-${h-1},`),i.splice(h,1)}n=i.join("\n");const m={};return Object.entries(r).forEach((e=>{let[t,{range:n}]=e;p()(n).forEach((e=>{m[e]??=[],m[e].push(t)}))})),{lineClassNames:m,code:n}}const A={codeBlockContainer:"codeBlockContainer_ZGJx"};var C=n(1085);function k(e){let{as:t,...n}=e;const s=function(e){const t={color:"--prism-color",backgroundColor:"--prism-background-color"},n={};return Object.entries(e.plain).forEach((e=>{let[s,o]=e;const a=t[s];a&&"string"==typeof o&&(n[a]=o)})),n}(m());return(0,C.jsx)(t,{...n,style:s,className:(0,l.A)(n.className,A.codeBlockContainer,h.G.common.codeBlock)})}const B={codeBlockContent:"codeBlockContent_qZBB",codeBlockTitle:"codeBlockTitle_zAEH",codeBlock:"codeBlock_TAPP",codeBlockStandalone:"codeBlockStandalone_K9VJ",codeBlockLines:"codeBlockLines_AdAo",codeBlockLinesWithNumbering:"codeBlockLinesWithNumbering_p5De",buttonGroup:"buttonGroup_TNwR"};function w(e){let{children:t,className:n}=e;return(0,C.jsx)(k,{as:"pre",tabIndex:0,className:(0,l.A)(B.codeBlockStandalone,"thin-scrollbar",n),children:(0,C.jsx)("code",{className:B.codeBlockLines,children:t})})}var L=n(1786);const E={attributes:!0,characterData:!0,childList:!0,subtree:!0};function T(e,t){const[n,o]=(0,s.useState)(),a=(0,s.useCallback)((()=>{o(e.current?.closest("[role=tabpanel][hidden]"))}),[e,o]);(0,s.useEffect)((()=>{a()}),[a]),function(e,t,n){void 0===n&&(n=E);const o=(0,L._q)(t),a=(0,L.Be)(n);(0,s.useEffect)((()=>{const t=new MutationObserver(o);return e&&t.observe(e,a),()=>t.disconnect()}),[e,o,a])}(n,(e=>{e.forEach((e=>{"attributes"===e.type&&"hidden"===e.attributeName&&(t(),a())}))}),{attributes:!0,characterData:!1,childList:!1,subtree:!1})}var H=n(4370);const _={codeLine:"codeLine_DPDv",codeLineNumber:"codeLineNumber_YxQB",codeLineContent:"codeLineContent_SOIp"};function S(e){let{line:t,classNames:n,showLineNumbers:s,getLineProps:o,getTokenProps:a}=e;1===t.length&&"\n"===t[0].content&&(t[0].content="");const c=o({line:t,className:(0,l.A)(n,s&&_.codeLine)}),i=t.map(((e,t)=>(0,C.jsx)("span",{...a({token:e})},t)));return(0,C.jsxs)("span",{...c,children:[s?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)("span",{className:_.codeLineNumber}),(0,C.jsx)("span",{className:_.codeLineContent,children:i})]}):i,(0,C.jsx)("br",{})]})}var I=n(9082);function M(e){return(0,C.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,C.jsx)("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"})})}function U(e){return(0,C.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,C.jsx)("path",{fill:"currentColor",d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})}const z={copyButtonCopied:"copyButtonCopied_Mzdr",copyButtonIcons:"copyButtonIcons_MVhB",copyButtonIcon:"copyButtonIcon_yxgH",copyButtonSuccessIcon:"copyButtonSuccessIcon_QJLJ"};function R(e){let{code:t,className:n}=e;const[o,a]=(0,s.useState)(!1),c=(0,s.useRef)(void 0),i=(0,s.useCallback)((()=>{!function(e,t){let{target:n=document.body}=void 0===t?{}:t;if("string"!=typeof e)throw new TypeError(`Expected parameter \`text\` to be a \`string\`, got \`${typeof e}\`.`);const s=document.createElement("textarea"),o=document.activeElement;s.value=e,s.setAttribute("readonly",""),s.style.contain="strict",s.style.position="absolute",s.style.left="-9999px",s.style.fontSize="12pt";const a=document.getSelection(),c=a.rangeCount>0&&a.getRangeAt(0);n.append(s),s.select(),s.selectionStart=0,s.selectionEnd=e.length;let i=!1;try{i=document.execCommand("copy")}catch{}s.remove(),c&&(a.removeAllRanges(),a.addRange(c)),o&&o.focus()}(t),a(!0),c.current=window.setTimeout((()=>{a(!1)}),1e3)}),[t]);return(0,s.useEffect)((()=>()=>window.clearTimeout(c.current)),[]),(0,C.jsx)("button",{type:"button","aria-label":o?(0,I.T)({id:"theme.CodeBlock.copied",message:"Copied",description:"The copied button label on code blocks"}):(0,I.T)({id:"theme.CodeBlock.copyButtonAriaLabel",message:"Copy code to clipboard",description:"The ARIA label for copy code blocks button"}),title:(0,I.T)({id:"theme.CodeBlock.copy",message:"Copy",description:"The copy button label on code blocks"}),className:(0,l.A)("clean-btn",n,z.copyButton,o&&z.copyButtonCopied),onClick:i,children:(0,C.jsxs)("span",{className:z.copyButtonIcons,"aria-hidden":"true",children:[(0,C.jsx)(M,{className:z.copyButtonIcon}),(0,C.jsx)(U,{className:z.copyButtonSuccessIcon})]})})}function O(e){return(0,C.jsx)("svg",{viewBox:"0 0 24 24",...e,children:(0,C.jsx)("path",{fill:"currentColor",d:"M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3l3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"})})}const V={wordWrapButtonIcon:"wordWrapButtonIcon_SMj9",wordWrapButtonEnabled:"wordWrapButtonEnabled_vR9E"};function $(e){let{className:t,onClick:n,isEnabled:s}=e;const o=(0,I.T)({id:"theme.CodeBlock.wordWrapToggle",message:"Toggle word wrap",description:"The title attribute for toggle word wrapping button of code block lines"});return(0,C.jsx)("button",{type:"button",onClick:n,className:(0,l.A)("clean-btn",t,s&&V.wordWrapButtonEnabled),"aria-label":o,title:o,children:(0,C.jsx)(O,{className:V.wordWrapButtonIcon,"aria-hidden":"true"})})}function D(e){let{children:t,className:n="",metastring:o,title:a,showLineNumbers:c,language:i}=e;const{prism:{defaultLanguage:r,magicComments:d}}=(0,u.p)(),h=function(e){return e?.toLowerCase()}(i??function(e){const t=e.split(" ").find((e=>e.startsWith("language-")));return t?.replace(/language-/,"")}(n)??r),f=m(),p=function(){const[e,t]=(0,s.useState)(!1),[n,o]=(0,s.useState)(!1),a=(0,s.useRef)(null),c=(0,s.useCallback)((()=>{const n=a.current.querySelector("code");e?n.removeAttribute("style"):(n.style.whiteSpace="pre-wrap",n.style.overflowWrap="anywhere"),t((e=>!e))}),[a,e]),i=(0,s.useCallback)((()=>{const{scrollWidth:e,clientWidth:t}=a.current,n=e>t||a.current.querySelector("code").hasAttribute("style");o(n)}),[a]);return T(a,i),(0,s.useEffect)((()=>{i()}),[e,i]),(0,s.useEffect)((()=>(window.addEventListener("resize",i,{passive:!0}),()=>{window.removeEventListener("resize",i)})),[i]),{codeBlockRef:a,isEnabled:e,isCodeScrollable:n,toggle:c}}(),g=function(e){return e?.match(x)?.groups.title??""}(o)||a,{lineClassNames:v,code:j}=y(t,{metastring:o,language:h,magicComments:d}),b=c??function(e){return Boolean(e?.includes("showLineNumbers"))}(o);return(0,C.jsxs)(k,{as:"div",className:(0,l.A)(n,h&&!n.includes(`language-${h}`)&&`language-${h}`),children:[g&&(0,C.jsx)("div",{className:B.codeBlockTitle,children:g}),(0,C.jsxs)("div",{className:B.codeBlockContent,children:[(0,C.jsx)(H.f4,{theme:f,code:j,language:h??"text",children:e=>{let{className:t,style:n,tokens:s,getLineProps:o,getTokenProps:a}=e;return(0,C.jsx)("pre",{tabIndex:0,ref:p.codeBlockRef,className:(0,l.A)(t,B.codeBlock,"thin-scrollbar"),style:n,children:(0,C.jsx)("code",{className:(0,l.A)(B.codeBlockLines,b&&B.codeBlockLinesWithNumbering),children:s.map(((e,t)=>(0,C.jsx)(S,{line:e,getLineProps:o,getTokenProps:a,classNames:v[t],showLineNumbers:b},t)))})})}}),(0,C.jsxs)("div",{className:B.buttonGroup,children:[(p.isEnabled||p.isCodeScrollable)&&(0,C.jsx)($,{className:B.codeButton,onClick:()=>p.toggle(),isEnabled:p.isEnabled}),(0,C.jsx)(R,{className:B.codeButton,code:j})]})]})]})}function W(e){let{children:t,...n}=e;const o=(0,r.A)(),a=function(e){return s.Children.toArray(e).some((e=>(0,s.isValidElement)(e)))?e:Array.isArray(e)?e.join(""):e}(t),c="string"==typeof a?D:w;return(0,C.jsx)(c,{...n,children:a},String(o))}function P(e){return(0,C.jsx)("code",{...e})}var G=n(2436);var q=n(6357),F=n(6476);const J={details:"details_B4FW",isBrowser:"isBrowser_Cof9",collapsibleContent:"collapsibleContent_VYua"};function Z(e){return!!e&&("SUMMARY"===e.tagName||Z(e.parentElement))}function Y(e,t){return!!e&&(e===t||Y(e.parentElement,t))}function Q(e){let{summary:t,children:n,...o}=e;(0,q.A)().collectAnchor(o.id);const a=(0,r.A)(),c=(0,s.useRef)(null),{collapsed:i,setCollapsed:d}=(0,F.u)({initialState:!o.open}),[u,m]=(0,s.useState)(o.open),h=s.isValidElement(t)?t:(0,C.jsx)("summary",{children:t??"Details"});return(0,C.jsxs)("details",{...o,ref:c,open:u,"data-collapsed":i,className:(0,l.A)(J.details,a&&J.isBrowser,o.className),onMouseDown:e=>{Z(e.target)&&e.detail>1&&e.preventDefault()},onClick:e=>{e.stopPropagation();const t=e.target;Z(t)&&Y(t,c.current)&&(e.preventDefault(),i?(d(!1),m(!0)):d(!0))},children:[h,(0,C.jsx)(F.N,{lazy:!1,collapsed:i,disableSSRStyle:!0,onCollapseTransitionEnd:e=>{d(e),m(!e)},children:(0,C.jsx)("div",{className:J.collapsibleContent,children:n})})]})}const K={details:"details_SZgV"},X="alert alert--info";function ee(e){let{...t}=e;return(0,C.jsx)(Q,{...t,className:(0,l.A)(X,K.details,t.className)})}function te(e){const t=s.Children.toArray(e.children),n=t.find((e=>s.isValidElement(e)&&"summary"===e.type)),o=(0,C.jsx)(C.Fragment,{children:t.filter((e=>e!==n))});return(0,C.jsx)(ee,{...e,summary:n,children:o})}var ne=n(4775);function se(e){return(0,C.jsx)(ne.A,{...e})}const oe={containsTaskList:"containsTaskList__YnT"};function ae(e){if(void 0!==e)return(0,l.A)(e,e?.includes("contains-task-list")&&oe.containsTaskList)}const ce={img:"img__Ss2"};var ie=n(1167);const re={Head:i.A,details:te,Details:te,code:function(e){return function(e){return void 0!==e.children&&s.Children.toArray(e.children).every((e=>"string"==typeof e&&!e.includes("\n")))}(e)?(0,C.jsx)(P,{...e}):(0,C.jsx)(W,{...e})},a:function(e){return(0,C.jsx)(G.A,{...e})},pre:function(e){return(0,C.jsx)(C.Fragment,{children:e.children})},ul:function(e){return(0,C.jsx)("ul",{...e,className:ae(e.className)})},li:function(e){return(0,q.A)().collectAnchor(e.id),(0,C.jsx)("li",{...e})},img:function(e){return(0,C.jsx)("img",{decoding:"async",loading:"lazy",...e,className:(t=e.className,(0,l.A)(t,ce.img))});var t},h1:e=>(0,C.jsx)(se,{as:"h1",...e}),h2:e=>(0,C.jsx)(se,{as:"h2",...e}),h3:e=>(0,C.jsx)(se,{as:"h3",...e}),h4:e=>(0,C.jsx)(se,{as:"h4",...e}),h5:e=>(0,C.jsx)(se,{as:"h5",...e}),h6:e=>(0,C.jsx)(se,{as:"h6",...e}),admonition:ie.A,mermaid:()=>null};function le(e){let{children:t}=e;return(0,C.jsx)(c,{components:re,children:t})}},7703:(e,t,n)=>{"use strict";n.d(t,{A:()=>l});n(4041);var s=n(4357),o=n(9969);const a={tableOfContents:"tableOfContents_TN1Q",docItemContainer:"docItemContainer_JtJJ"};var c=n(1085);const i="table-of-contents__link toc-highlight",r="table-of-contents__link--active";function l(e){let{className:t,...n}=e;return(0,c.jsx)("div",{className:(0,s.A)(a.tableOfContents,"thin-scrollbar",t),children:(0,c.jsx)(o.A,{...n,linkClassName:i,linkActiveClassName:r})})}},9969:(e,t,n)=>{"use strict";n.d(t,{A:()=>p});var s=n(4041),o=n(2520);function a(e){const t=e.map((e=>({...e,parentIndex:-1,children:[]}))),n=Array(7).fill(-1);t.forEach(((e,t)=>{const s=n.slice(2,e.level);e.parentIndex=Math.max(...s),n[e.level]=t}));const s=[];return t.forEach((e=>{const{parentIndex:n,...o}=e;n>=0?t[n].children.push(o):s.push(o)})),s}function c(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:s}=e;return t.flatMap((e=>{const t=c({toc:e.children,minHeadingLevel:n,maxHeadingLevel:s});return function(e){return e.level>=n&&e.level<=s}(e)?[{...e,children:t}]:t}))}function i(e){const t=e.getBoundingClientRect();return t.top===t.bottom?i(e.parentNode):t}function r(e,t){let{anchorTopOffset:n}=t;const s=e.find((e=>i(e).top>=n));if(s){return function(e){return e.top>0&&e.bottom<window.innerHeight/2}(i(s))?s:e[e.indexOf(s)-1]??null}return e[e.length-1]??null}function l(){const e=(0,s.useRef)(0),{navbar:{hideOnScroll:t}}=(0,o.p)();return(0,s.useEffect)((()=>{e.current=t?0:document.querySelector(".navbar").clientHeight}),[t]),e}function d(e){const t=(0,s.useRef)(void 0),n=l();(0,s.useEffect)((()=>{if(!e)return()=>{};const{linkClassName:s,linkActiveClassName:o,minHeadingLevel:a,maxHeadingLevel:c}=e;function i(){const e=function(e){return Array.from(document.getElementsByClassName(e))}(s),i=function(e){let{minHeadingLevel:t,maxHeadingLevel:n}=e;const s=[];for(let o=t;o<=n;o+=1)s.push(`h${o}.anchor`);return Array.from(document.querySelectorAll(s.join()))}({minHeadingLevel:a,maxHeadingLevel:c}),l=r(i,{anchorTopOffset:n.current}),d=e.find((e=>l&&l.id===function(e){return decodeURIComponent(e.href.substring(e.href.indexOf("#")+1))}(e)));e.forEach((e=>{!function(e,n){n?(t.current&&t.current!==e&&t.current.classList.remove(o),e.classList.add(o),t.current=e):e.classList.remove(o)}(e,e===d)}))}return document.addEventListener("scroll",i),document.addEventListener("resize",i),i(),()=>{document.removeEventListener("scroll",i),document.removeEventListener("resize",i)}}),[e,n])}var u=n(2436),m=n(1085);function h(e){let{toc:t,className:n,linkClassName:s,isChild:o}=e;return t.length?(0,m.jsx)("ul",{className:o?void 0:n,children:t.map((e=>(0,m.jsxs)("li",{children:[(0,m.jsx)(u.A,{to:`#${e.id}`,className:s??void 0,dangerouslySetInnerHTML:{__html:e.value}}),(0,m.jsx)(h,{isChild:!0,toc:e.children,className:n,linkClassName:s})]},e.id)))}):null}const f=s.memo(h);function p(e){let{toc:t,className:n="table-of-contents table-of-contents__left-border",linkClassName:i="table-of-contents__link",linkActiveClassName:r,minHeadingLevel:l,maxHeadingLevel:u,...h}=e;const p=(0,o.p)(),x=l??p.tableOfContents.minHeadingLevel,g=u??p.tableOfContents.maxHeadingLevel,v=function(e){let{toc:t,minHeadingLevel:n,maxHeadingLevel:o}=e;return(0,s.useMemo)((()=>c({toc:a(t),minHeadingLevel:n,maxHeadingLevel:o})),[t,n,o])}({toc:t,minHeadingLevel:x,maxHeadingLevel:g});return d((0,s.useMemo)((()=>{if(i&&r)return{linkClassName:i,linkActiveClassName:r,minHeadingLevel:x,maxHeadingLevel:g}}),[i,r,x,g])),(0,m.jsx)(f,{toc:v,className:n,linkClassName:i,...h})}},7262:(e,t,n)=>{"use strict";n.d(t,{A:()=>h});n(4041);var s=n(4357),o=n(9082),a=n(9058),c=n(1085);function i(){return(0,c.jsx)(o.A,{id:"theme.unlistedContent.title",description:"The unlisted content banner title",children:"Unlisted page"})}function r(){return(0,c.jsx)(o.A,{id:"theme.unlistedContent.message",description:"The unlisted content banner message",children:"This page is unlisted. Search engines will not index it, and only users having a direct link can access it."})}function l(){return(0,c.jsx)(a.A,{children:(0,c.jsx)("meta",{name:"robots",content:"noindex, nofollow"})})}var d=n(7473),u=n(1167);function m(e){let{className:t}=e;return(0,c.jsx)(u.A,{type:"caution",title:(0,c.jsx)(i,{}),className:(0,s.A)(t,d.G.common.unlistedBanner),children:(0,c.jsx)(r,{})})}function h(e){return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(l,{}),(0,c.jsx)(m,{...e})]})}},1431:(e,t)=>{function n(e){let t,n=[];for(let s of e.split(",").map((e=>e.trim())))if(/^-?\d+$/.test(s))n.push(parseInt(s,10));else if(t=s.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){let[e,s,o,a]=t;if(s&&a){s=parseInt(s),a=parseInt(a);const e=s<a?1:-1;"-"!==o&&".."!==o&&"\u2025"!==o||(a+=e);for(let t=s;t!==a;t+=e)n.push(t)}}return n}t.default=n,e.exports=n}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[3135],{3465:(e,a,s)=>{s.r(a),s.d(a,{default:()=>x});s(4041);var t=s(4357),d=s(145),c=s(7473),l=s(2665),i=s(5604),r=s(7703),n=s(7262),o=s(3412);const m={mdxPageWrapper:"mdxPageWrapper_SLvB"};var p=s(1085);function x(e){const{content:a}=e,{metadata:{title:s,editUrl:x,description:g,frontMatter:h,unlisted:_,lastUpdatedBy:j,lastUpdatedAt:v},assets:A}=a,{keywords:u,wrapperClassName:w,hide_table_of_contents:f}=h,N=A.image??h.image,k=!!(x||v||j);return(0,p.jsx)(d.e3,{className:(0,t.A)(w??c.G.wrapper.mdxPages,c.G.page.mdxPage),children:(0,p.jsxs)(l.A,{children:[(0,p.jsx)(d.be,{title:s,description:g,keywords:u,image:N}),(0,p.jsx)("main",{className:"container container--fluid margin-vert--lg",children:(0,p.jsxs)("div",{className:(0,t.A)("row",m.mdxPageWrapper),children:[(0,p.jsxs)("div",{className:(0,t.A)("col",!f&&"col--8"),children:[_&&(0,p.jsx)(n.A,{}),(0,p.jsx)("article",{children:(0,p.jsx)(i.A,{children:(0,p.jsx)(a,{})})}),k&&(0,p.jsx)(o.A,{className:(0,t.A)("margin-top--sm",c.G.pages.pageFooterEditMetaRow),editUrl:x,lastUpdatedAt:v,lastUpdatedBy:j})]}),!f&&a.toc.length>0&&(0,p.jsx)("div",{className:"col col--2",children:(0,p.jsx)(r.A,{toc:a.toc,minHeadingLevel:h.toc_min_heading_level,maxHeadingLevel:h.toc_max_heading_level})})]})})]})})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[1145],{6586:e=>{e.exports=JSON.parse('{"name":"docusaurus-plugin-content-pages","id":"default"}')}}]);
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[2827],{8552:e=>{e.exports=JSON.parse('{"name":"docusaurus-plugin-content-pages","id":"default"}')}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[9280],{5498:e=>{e.exports=JSON.parse('{"version":{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"noIndex":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"defaultSidebar":[{"type":"link","label":"Introduction","href":"/tools/staticdocs/docs/","docId":"introduction","unlisted":false},{"type":"category","label":"Getting Started","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Installation","href":"/tools/staticdocs/docs/getting-started/installation","docId":"getting-started/installation","unlisted":false},{"type":"link","label":"Getting Started","href":"/tools/staticdocs/docs/getting-started/gettingstarted","docId":"getting-started/gettingstarted","unlisted":false},{"type":"link","label":"Code Generators","href":"/tools/staticdocs/docs/getting-started/generators","docId":"getting-started/generators","unlisted":false},{"type":"link","label":"Upgrading","href":"/tools/staticdocs/docs/getting-started/upgrading","docId":"getting-started/upgrading","unlisted":false},{"type":"link","label":"Key Concepts","href":"/tools/staticdocs/docs/getting-started/key_concepts","docId":"getting-started/key_concepts","unlisted":false},{"type":"link","label":"Requirements and Design","href":"/tools/staticdocs/docs/getting-started/requirements","docId":"getting-started/requirements","unlisted":false},{"type":"link","label":"Podman","href":"/tools/staticdocs/docs/getting-started/podman","docId":"getting-started/podman","unlisted":false}],"href":"/tools/staticdocs/docs/getting-started"},{"type":"category","label":"Configuration","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"File Format","href":"/tools/staticdocs/docs/configuration/format","docId":"configuration/format","unlisted":false},{"type":"link","label":"Plugins","href":"/tools/staticdocs/docs/configuration/plugins","docId":"configuration/plugins","unlisted":false},{"type":"link","label":"Targets","href":"/tools/staticdocs/docs/configuration/target","docId":"configuration/target","unlisted":false},{"type":"link","label":"Commands","href":"/tools/staticdocs/docs/configuration/command","docId":"configuration/command","unlisted":false},{"type":"link","label":"Telemetry","href":"/tools/staticdocs/docs/configuration/telemetry","docId":"configuration/telemetry","unlisted":false},{"type":"link","label":"Interfaces","href":"/tools/staticdocs/docs/configuration/interfaces","docId":"configuration/interfaces","unlisted":false},{"type":"link","label":"Protocols","href":"/tools/staticdocs/docs/configuration/protocols","docId":"configuration/protocols","unlisted":false},{"type":"link","label":"Tables","href":"/tools/staticdocs/docs/configuration/table","docId":"configuration/table","unlisted":false},{"type":"link","label":"Screens","href":"/tools/staticdocs/docs/configuration/telemetry-screens","docId":"configuration/telemetry-screens","unlisted":false},{"type":"link","label":"SSL-TLS","href":"/tools/staticdocs/docs/configuration/ssl-tls","docId":"configuration/ssl-tls","unlisted":false}],"href":"/tools/staticdocs/docs/configuration"},{"type":"category","label":"Tools","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Autonomic (Enterprise)","href":"/tools/staticdocs/docs/tools/autonomic","docId":"tools/autonomic","unlisted":false},{"type":"link","label":"Bucket Explorer","href":"/tools/staticdocs/docs/tools/bucket-explorer","docId":"tools/bucket-explorer","unlisted":false},{"type":"link","label":"Calendar (Enterprise)","href":"/tools/staticdocs/docs/tools/calendar","docId":"tools/calendar","unlisted":false},{"type":"link","label":"Command Sender","href":"/tools/staticdocs/docs/tools/cmd-sender","docId":"tools/cmd-sender","unlisted":false},{"type":"link","label":"Command and Telemetry Server","href":"/tools/staticdocs/docs/tools/cmd-tlm-server","docId":"tools/cmd-tlm-server","unlisted":false},{"type":"link","label":"Data Extractor","href":"/tools/staticdocs/docs/tools/data-extractor","docId":"tools/data-extractor","unlisted":false},{"type":"link","label":"Data Viewer","href":"/tools/staticdocs/docs/tools/data-viewer","docId":"tools/data-viewer","unlisted":false},{"type":"link","label":"Handbooks","href":"/tools/staticdocs/docs/tools/handbooks","docId":"tools/handbooks","unlisted":false},{"type":"link","label":"Limits Monitor","href":"/tools/staticdocs/docs/tools/limits-monitor","docId":"tools/limits-monitor","unlisted":false},{"type":"link","label":"Packet Viewer","href":"/tools/staticdocs/docs/tools/packet-viewer","docId":"tools/packet-viewer","unlisted":false},{"type":"link","label":"Script Runner","href":"/tools/staticdocs/docs/tools/script-runner","docId":"tools/script-runner","unlisted":false},{"type":"link","label":"Table Manager","href":"/tools/staticdocs/docs/tools/table-manager","docId":"tools/table-manager","unlisted":false},{"type":"link","label":"Telemetry Grapher","href":"/tools/staticdocs/docs/tools/tlm-grapher","docId":"tools/tlm-grapher","unlisted":false},{"type":"link","label":"Telemetry Viewer","href":"/tools/staticdocs/docs/tools/tlm-viewer","docId":"tools/tlm-viewer","unlisted":false}],"href":"/tools/staticdocs/docs/tools"},{"type":"category","label":"Guides","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Bridges","href":"/tools/staticdocs/docs/guides/bridges","docId":"guides/bridges","unlisted":false},{"type":"link","label":"COSMOS and NASA cFS","href":"/tools/staticdocs/docs/guides/cfs","docId":"guides/cfs","unlisted":false},{"type":"link","label":"Custom Widgets","href":"/tools/staticdocs/docs/guides/custom-widgets","docId":"guides/custom-widgets","unlisted":false},{"type":"link","label":"Little Endian Bitfields","href":"/tools/staticdocs/docs/guides/little-endian-bitfields","docId":"guides/little-endian-bitfields","unlisted":false},{"type":"link","label":"Local Mode","href":"/tools/staticdocs/docs/guides/local-mode","docId":"guides/local-mode","unlisted":false},{"type":"link","label":"Logging","href":"/tools/staticdocs/docs/guides/logging","docId":"guides/logging","unlisted":false},{"type":"link","label":"Monitoring","href":"/tools/staticdocs/docs/guides/monitoring","docId":"guides/monitoring","unlisted":false},{"type":"link","label":"Performance","href":"/tools/staticdocs/docs/guides/performance","docId":"guides/performance","unlisted":false},{"type":"link","label":"Raspberry Pi","href":"/tools/staticdocs/docs/guides/raspberrypi","docId":"guides/raspberrypi","unlisted":false},{"type":"link","label":"Script Writing Guide","href":"/tools/staticdocs/docs/guides/script-writing","docId":"guides/script-writing","unlisted":false},{"type":"link","label":"Scripting API Guide","href":"/tools/staticdocs/docs/guides/scripting-api","docId":"guides/scripting-api","unlisted":false}],"href":"/tools/staticdocs/docs/guides"},{"type":"category","label":"Development","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Testing with Curl","href":"/tools/staticdocs/docs/development/curl","docId":"development/curl","unlisted":false},{"type":"link","label":"Developing COSMOS","href":"/tools/staticdocs/docs/development/developing","docId":"development/developing","unlisted":false},{"type":"link","label":"Host Install","href":"/tools/staticdocs/docs/development/host-install","docId":"development/host-install","unlisted":false},{"type":"link","label":"JSON API","href":"/tools/staticdocs/docs/development/json-api","docId":"development/json-api","unlisted":false},{"type":"link","label":"Log Structure","href":"/tools/staticdocs/docs/development/log-structure","docId":"development/log-structure","unlisted":false},{"type":"link","label":"Roadmap","href":"/tools/staticdocs/docs/development/roadmap","docId":"development/roadmap","unlisted":false},{"type":"link","label":"Streaming API","href":"/tools/staticdocs/docs/development/streaming-api","docId":"development/streaming-api","unlisted":false},{"type":"link","label":"Testing COSMOS","href":"/tools/staticdocs/docs/development/testing","docId":"development/testing","unlisted":false}],"href":"/tools/staticdocs/docs/development"},{"type":"category","label":"Meta","collapsible":true,"collapsed":true,"items":[{"type":"link","label":"Contributing","href":"/tools/staticdocs/docs/meta/contributing","docId":"meta/contributing","unlisted":false},{"type":"link","label":"Understanding Licenses","href":"/tools/staticdocs/docs/meta/licenses","docId":"meta/licenses","unlisted":false},{"type":"link","label":"Philosophy","href":"/tools/staticdocs/docs/meta/philosophy","docId":"meta/philosophy","unlisted":false},{"type":"link","label":"XTCE Support","href":"/tools/staticdocs/docs/meta/xtce","docId":"meta/xtce","unlisted":false}],"href":"/tools/staticdocs/docs/meta"},{"type":"link","label":"OpenC3, Inc. Privacy Policy","href":"/tools/staticdocs/docs/privacy","docId":"privacy","unlisted":false}]},"docs":{"configuration/command":{"id":"configuration/command","title":"Commands","description":"Command Definition Files","sidebar":"defaultSidebar"},"configuration/format":{"id":"configuration/format","title":"File Format","description":"COSMOS configuration files are just text files. They can (and should) be checked into your configuration management system and thus can be easily diffed throughout their history. They support ERB syntax, partials, and various line continuations which make them extremely flexible.","sidebar":"defaultSidebar"},"configuration/interfaces":{"id":"configuration/interfaces","title":"Interfaces","description":"Interfaces are the connection to the external embedded systems called targets. Interfaces are defined by the top level INTERFACE keyword in the plugin.txt file.","sidebar":"defaultSidebar"},"configuration/plugins":{"id":"configuration/plugins","title":"Plugins","description":"Introduction","sidebar":"defaultSidebar"},"configuration/protocols":{"id":"configuration/protocols","title":"Protocols","description":"Protocols process data on behalf of an Interface. They can modify the data being written, data being read, or both. Protocols can also mark a packet as stored instead of real-time which means COSMOS will not update the current value table with the packet data. Protocols can be layered and will be processed in order. For example, if you have a low-level encryption layer that must be first removed before processing a higher level buffer length protocol.","sidebar":"defaultSidebar"},"configuration/ssl-tls":{"id":"configuration/ssl-tls","title":"SSL-TLS","description":"COSMOS 5 is a container based service which does not use SSL/TLS out of the box. This guide will help you configure SSL and TLS. Learn more at the Traefik docs.","sidebar":"defaultSidebar"},"configuration/table":{"id":"configuration/table","title":"Tables","description":"Table Definition Files","sidebar":"defaultSidebar"},"configuration/target":{"id":"configuration/target","title":"Targets","description":"Targets are the external embedded systems that COSMOS connects to. Targets are defined by the top level TARGET keyword in the plugin.txt file. Each target is self contained in a target directory named after the target. In the root of the target directory there is a configuration file named target.txt which configures the individual target.","sidebar":"defaultSidebar"},"configuration/telemetry":{"id":"configuration/telemetry","title":"Telemetry","description":"Telemetry Definition Files","sidebar":"defaultSidebar"},"configuration/telemetry-screens":{"id":"configuration/telemetry-screens","title":"Screens","description":"This document provides the information necessary to generate and use COSMOS Telemetry Screens, which are displayed by the COSMOS Telemetry Viewer application.","sidebar":"defaultSidebar"},"development/curl":{"id":"development/curl","title":"Testing with Curl","description":"This information is just generally used behind the scenes in COSMOS tools","sidebar":"defaultSidebar"},"development/developing":{"id":"development/developing","title":"Developing COSMOS","description":"So you want to help develop COSMOS? All of our open source COSMOS code is on Github so the first thing to do is get an account. Next clone the COSMOS repository. We accept contributions from others as Pull Requests.","sidebar":"defaultSidebar"},"development/host-install":{"id":"development/host-install","title":"Host Install","description":"Installing COSMOS Directly onto a Host (No Containers)","sidebar":"defaultSidebar"},"development/json-api":{"id":"development/json-api","title":"JSON API","description":"If you\'re looking for the methods available to write test procedures using the COSMOS scripting API, refer to the Scripting API Guide page. If you\'re trying to interface to a COSMOS Command and Telemetry Server from an external application using any language then this is the right place.","sidebar":"defaultSidebar"},"development/log-structure":{"id":"development/log-structure","title":"Log Structure","description":"Updated: 8-21-2023 to the format as of OpenC3 COSMOS 5.11.0","sidebar":"defaultSidebar"},"development/roadmap":{"id":"development/roadmap","title":"Roadmap","description":"Key Features Still to Come in OpenC3 COSMOS 5.x:","sidebar":"defaultSidebar"},"development/streaming-api":{"id":"development/streaming-api","title":"Streaming API","description":"This information is just generally used behind the scenes in COSMOS tools","sidebar":"defaultSidebar"},"development/testing":{"id":"development/testing","title":"Testing COSMOS","description":"Playwright","sidebar":"defaultSidebar"},"getting-started/generators":{"id":"getting-started/generators","title":"Code Generators","description":"The COSMOS Code Generators are built into the scripts openc3.sh and openc3.bat that are included in the COSMOS project (more about projects).","sidebar":"defaultSidebar"},"getting-started/gettingstarted":{"id":"getting-started/gettingstarted","title":"Getting Started","description":"Welcome to the OpenC3 COSMOS system... Let\'s get started! This guide is a high level overview that will help with setting up your first COSMOS project.","sidebar":"defaultSidebar"},"getting-started/installation":{"id":"getting-started/installation","title":"Installation","description":"Installing OpenC3 COSMOS","sidebar":"defaultSidebar"},"getting-started/key_concepts":{"id":"getting-started/key_concepts","title":"Key Concepts","description":"Projects","sidebar":"defaultSidebar"},"getting-started/podman":{"id":"getting-started/podman","title":"Podman","description":"OpenC3 COSMOS Using Rootless Podman and Docker-Compose","sidebar":"defaultSidebar"},"getting-started/requirements":{"id":"getting-started/requirements","title":"Requirements and Design","description":"OpenC3 COSMOS is a command and control system providing commanding, scripting, and data visualization capabilities for embedded systems and systems of systems. COSMOS is intended for use during all phases of testing (board, box, integrated system) and during operations.","sidebar":"defaultSidebar"},"getting-started/upgrading":{"id":"getting-started/upgrading","title":"Upgrading","description":"COSMOS Upgrades","sidebar":"defaultSidebar"},"guides/bridges":{"id":"guides/bridges","title":"Bridges","description":"COSMOS Bridges provide an easy solution for getting data from devices that don\'t speak Ethernet into COSMOS.","sidebar":"defaultSidebar"},"guides/cfs":{"id":"guides/cfs","title":"COSMOS and NASA cFS","description":"Working configuration","sidebar":"defaultSidebar"},"guides/custom-widgets":{"id":"guides/custom-widgets","title":"Custom Widgets","description":"COSMOS allows you to build custom widgets which can be deployed with your plugin and used in Telemetry Viewer. Building custom widgets can utilitize any javascript frameworks but since COSMOS is written with Vue.js, we will use that framework in this tutorial. Please see the Widget Generator guide for information about generating the scaffolding for a custom widget.","sidebar":"defaultSidebar"},"guides/little-endian-bitfields":{"id":"guides/little-endian-bitfields","title":"Little Endian Bitfields","description":"Defining little endian bitfields is a little weird but is possible in COSMOS. However, note that APPEND does not work with little endian bitfields.","sidebar":"defaultSidebar"},"guides/local-mode":{"id":"guides/local-mode","title":"Local Mode","description":"Local Mode is a new feature in the 5.0.9 COSMOS release. It is intended to capture the configuration of an edited plugin so it can be configuration managed. It allows you to edit portions of a plugin (scripts and screens) locally in the editor of your choice and instantly have those changes appear in the COSMOS plugin. This avoids the plugin build / install cycle which is required when editing command and telemetry or interface definitions.","sidebar":"defaultSidebar"},"guides/logging":{"id":"guides/logging","title":"Logging","description":"The COSMOS Bucket Explorer tool provides a way to browse the COSMOS bucket storage backend whether you are running locally or in a cloud environment. Browse to http2900/tools/bucketexplorer and you should see the list of buckets at the top:","sidebar":"defaultSidebar"},"guides/monitoring":{"id":"guides/monitoring","title":"Monitoring","description":"Monitoring and observability","sidebar":"defaultSidebar"},"guides/performance":{"id":"guides/performance","title":"Performance","description":"The COSMOS architecture was created with scalability in mind. Our goal is to support an unlimited number of connections and use cloud technologies to scale. Only COSMOS Enterprise Edition supports Kubernetes and the various cloud platforms which allow this level of scalability. While true scalability is only achieved in COSMOS Enterprise, both Open Source and Enterprise have various levels of observability and configuration settings which can affect performance.","sidebar":"defaultSidebar"},"guides/raspberrypi":{"id":"guides/raspberrypi","title":"Raspberry Pi","description":"COSMOS Running on Raspberry Pi 4","sidebar":"defaultSidebar"},"guides/script-writing":{"id":"guides/script-writing","title":"Script Writing Guide","description":"Introduction","sidebar":"defaultSidebar"},"guides/scripting-api":{"id":"guides/scripting-api","title":"Scripting API Guide","description":"This document provides the information necessary to write test procedures using the COSMOS scripting API. Scripting in COSMOS is designed to be simple and intuitive. The code completion ability for command and telemetry mnemonics makes Script Runner the ideal place to write your procedures, however any text editor will do. If there is functionality that you don\'t see here or perhaps an easier syntax for doing something, please submit a ticket.","sidebar":"defaultSidebar"},"introduction":{"id":"introduction","title":"Introduction","description":"This site aims to be a comprehensive guide to OpenC3 COSMOS. We\'ll cover topics such","sidebar":"defaultSidebar"},"meta/contributing":{"id":"meta/contributing","title":"Contributing","description":"So you\'ve got an awesome idea to throw into COSMOS. Great! This is the basic process:","sidebar":"defaultSidebar"},"meta/licenses":{"id":"meta/licenses","title":"Understanding Licenses","description":"OpenC3 COSMOS is offered under a tri-licensing model allowing users to choose between the following three options:","sidebar":"defaultSidebar"},"meta/philosophy":{"id":"meta/philosophy","title":"Philosophy","description":"COSMOS is a C3 (Command, Control and Communication) system with the following primary goals:","sidebar":"defaultSidebar"},"meta/xtce":{"id":"meta/xtce","title":"XTCE Support","description":"COSMOS now has support for the XTCE Command and Telemetry Definition Standard. This is an open standard designed to allow command and telemetry definitions to be transferred between different ground systems. COSMOS can run directly using the .xtce files, or can convert them into the COSMOS configuration file format.","sidebar":"defaultSidebar"},"privacy":{"id":"privacy","title":"OpenC3, Inc. Privacy Policy","description":"OpenC3 Inc. is strongly committed to protecting your privacy and complying with your choices. Both personal and non-personal information collected is safeguarded according to the highest privacy and data protection standards adopted worldwide. We have always had a robust and effective data protection program in place which complies with existing law and abides by the data protection principles. However, we recognise our obligations in updating and expanding this program to meet the demands of the GDPR.","sidebar":"defaultSidebar"},"tools/autonomic":{"id":"tools/autonomic","title":"Autonomic (Enterprise)","description":"Introduction","sidebar":"defaultSidebar"},"tools/bucket-explorer":{"id":"tools/bucket-explorer","title":"Bucket Explorer","description":"Introduction","sidebar":"defaultSidebar"},"tools/calendar":{"id":"tools/calendar","title":"Calendar (Enterprise)","description":"Introduction","sidebar":"defaultSidebar"},"tools/cmd-sender":{"id":"tools/cmd-sender","title":"Command Sender","description":"Introduction","sidebar":"defaultSidebar"},"tools/cmd-tlm-server":{"id":"tools/cmd-tlm-server","title":"Command and Telemetry Server","description":"Introduction","sidebar":"defaultSidebar"},"tools/data-extractor":{"id":"tools/data-extractor","title":"Data Extractor","description":"Introduction","sidebar":"defaultSidebar"},"tools/data-viewer":{"id":"tools/data-viewer","title":"Data Viewer","description":"Introduction","sidebar":"defaultSidebar"},"tools/handbooks":{"id":"tools/handbooks","title":"Handbooks","description":"Introduction","sidebar":"defaultSidebar"},"tools/limits-monitor":{"id":"tools/limits-monitor","title":"Limits Monitor","description":"Introduction","sidebar":"defaultSidebar"},"tools/packet-viewer":{"id":"tools/packet-viewer","title":"Packet Viewer","description":"Introduction","sidebar":"defaultSidebar"},"tools/script-runner":{"id":"tools/script-runner","title":"Script Runner","description":"Introduction","sidebar":"defaultSidebar"},"tools/table-manager":{"id":"tools/table-manager","title":"Table Manager","description":"Introduction","sidebar":"defaultSidebar"},"tools/tlm-grapher":{"id":"tools/tlm-grapher","title":"Telemetry Grapher","description":"Introductions","sidebar":"defaultSidebar"},"tools/tlm-viewer":{"id":"tools/tlm-viewer","title":"Telemetry Viewer","description":"Introduction","sidebar":"defaultSidebar"}}}}')}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[5746],{3426:o=>{o.exports=JSON.parse('{"categoryGeneratedIndex":{"title":"Tools","slug":"/tools","permalink":"/tools/staticdocs/docs/tools","sidebar":"defaultSidebar","navigation":{"previous":{"title":"SSL-TLS","permalink":"/tools/staticdocs/docs/configuration/ssl-tls"},"next":{"title":"Autonomic (Enterprise)","permalink":"/tools/staticdocs/docs/tools/autonomic"}}}}')}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[7362],{1489:c=>{c.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]);
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[2642],{7093:c=>{c.exports=JSON.parse('{"name":"docusaurus-plugin-content-docs","id":"default"}')}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[6586],{5470:t=>{t.exports=JSON.parse('{"categoryGeneratedIndex":{"title":"Getting Started","description":"Get started with OpenC3 COSMOS","slug":"/getting-started","permalink":"/tools/staticdocs/docs/getting-started","sidebar":"defaultSidebar","navigation":{"previous":{"title":"Introduction","permalink":"/tools/staticdocs/docs/"},"next":{"title":"Installation","permalink":"/tools/staticdocs/docs/getting-started/installation"}}}}')}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[3718],{950:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>d,contentTitle:()=>l,default:()=>a,frontMatter:()=>r,metadata:()=>o,toc:()=>c});var n=s(1085),i=s(1184);const r={title:"Performance"},l="COSMOS Hardware Requirements",o={id:"guides/performance",title:"Performance",description:"The COSMOS architecture was created with scalability in mind. Our goal is to support an unlimited number of connections and use cloud technologies to scale. Only COSMOS Enterprise Edition supports Kubernetes and the various cloud platforms which allow this level of scalability. While true scalability is only achieved in COSMOS Enterprise, both Open Source and Enterprise have various levels of observability and configuration settings which can affect performance.",source:"@site/docs/guides/performance.md",sourceDirName:"guides",slug:"/guides/performance",permalink:"/tools/staticdocs/docs/guides/performance",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/performance.md",tags:[],version:"current",frontMatter:{title:"Performance"},sidebar:"defaultSidebar",previous:{title:"Monitoring",permalink:"/tools/staticdocs/docs/guides/monitoring"},next:{title:"Raspberry Pi",permalink:"/tools/staticdocs/docs/guides/raspberrypi"}},d={},c=[{value:"Memory",id:"memory",level:2},{value:"CPU",id:"cpu",level:2},{value:"Performance Comparison",id:"performance-comparison",level:2}];function h(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",section:"section",sup:"sup",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:["The COSMOS architecture was created with scalability in mind. Our goal is to support an unlimited number of connections and use cloud technologies to scale. Only ",(0,n.jsx)(t.a,{href:"https://openc3.com/enterprise",children:"COSMOS Enterprise Edition"})," supports Kubernetes and the various cloud platforms which allow this level of scalability. While true scalability is only achieved in COSMOS Enterprise, both Open Source and Enterprise have various levels of observability and configuration settings which can affect performance."]}),"\n",(0,n.jsx)(t.h1,{id:"cosmos-hardware-requirements",children:"COSMOS Hardware Requirements"}),"\n",(0,n.jsx)(t.h2,{id:"memory",children:"Memory"}),"\n",(0,n.jsx)(t.p,{children:"COSMOS can run on a Raspberry Pi up to a Kubernetes cluster in the cloud. On all platforms the key performance factor is the number and complexity of the targets and their defined packets. Targets can vary from simple targets taking 100 MB of RAM to complex targets taking 400 MB. The base COSMOS containers require about 800 MB of RAM. A good rule of thumb is to average about 300 MB of RAM for targets. As an example data point, the COSMOS Demo has 4 targets, two complex (INST & INST2) and two relatively simple (EXAMPLE & TEMPLATED), and requires 800 MB of RAM (on top of the 800 MB of base container RAM)."}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"Base RAM MB Calculator = 800 + (num targets) * 300"}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["In addition, the Redis streams contain the last 10 min of both raw and decommutated data from all targets. Thus you must wait ~15min to truly see what the high water memory mark will be. In the COSMOS Demo the INST & INST2 targets are fairly simple with four 1Hz packet of ~15 items and one 10Hz packet with 20 items. This only causes 50 MiB of redis RAM usage according to ",(0,n.jsx)(t.code,{children:"docker stats"}),". Installing the COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/openc3-cosmos-load-sim",children:"LoadSim"})," with 10 packets with 1000 items each at 10Hz pushed the redis memory usage to about 350 MiB."]}),"\n",(0,n.jsx)(t.h2,{id:"cpu",children:"CPU"}),"\n",(0,n.jsx)(t.p,{children:"Another consideration is the CPU performance. In the Open Source Edition, by default COSMOS spawns off 2 microservices per target. One combines packet logging and decommutation of the data and the other performs data reduction. In COSMOS Enterprise Edition on Kubernetes, each process becomes an independent container that is deployed on the cluster allowing horizontal scaling."}),"\n",(0,n.jsxs)(t.p,{children:["The COSMOS command and telemetry API and script running API servers should have a dedicated core while targets can generally share cores. It's hard to provide a general rule of thumb with the wide variety of architectures, clock speeds, and core counts. The best practice is to install COSMOS with the expected load and do some monitoring with ",(0,n.jsx)(t.code,{children:"htop"})," to visualize the load on the various cores. Any time a single core gets overloaded (100%) this is a concern and system slowdown can occur."]}),"\n",(0,n.jsx)(t.h2,{id:"performance-comparison",children:"Performance Comparison"}),"\n",(0,n.jsxs)(t.p,{children:["Performance characterization was performed in Azure on a Standard D4s v5 (4 vcpus, 16 GiB memory) chosen to allow virtualization per ",(0,n.jsx)(t.a,{href:"https://docs.docker.com/desktop/vm-vdi/#turn-on-nested-virtualization-on-microsoft-hyper-v",children:"Docker"}),". COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/cosmos-enterprise/releases/tag/v5.9.1",children:"5.9.1"})," Enterprise Edition was installed on both Windows 11 Pro ",(0,n.jsx)(t.sup,{children:(0,n.jsx)(t.a,{href:"#user-content-fn-1",id:"user-content-fnref-1","data-footnote-ref":!0,"aria-describedby":"footnote-label",children:"1"})})," and Ubuntu 22. Note: Enterprise Edition was not utilizing Kubernetes, just Docker. Testing involved starting the COSMOS Demo, connecting all targets (EXAMPLE, INST, INST2, TEMPLATED), opening the following TlmViewer screens (ADCS, ARRAY, BLOCK, COMMANDING, HS, LATEST, LIMITS, OTHER, PARAMS, SIMPLE, TABS) and creating two TlmGrapher graphs consisting of INST HEALTH_STATUS TEMP[1-4] and INST ADCS POS[X,Y,Z] and INST ADCS VEL[X,Y,Z]. This was allowed to run for 1hr and results were collected using ",(0,n.jsx)(t.code,{children:"htop"}),":"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Platform"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Core CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"RAM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Windows 11 Pro"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"12% 12% 10% 10%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.9G / 7.7G"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Headless Ubuntu 22"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"7% 7% 8% 6%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.2G / 15.6G"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:["Windows was only allocated 8 GB of RAM due to the ",(0,n.jsx)(t.a,{href:"https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig",children:".wslconfig"})," settings."]}),"\n",(0,n.jsx)(t.li,{children:"Since Ubuntu was running headless, the screens and graphs were brought up on another machine."}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"docker stats"})," was also run to show individual container cpu and memory usage:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"NAME"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows CPU %"}),(0,n.jsx)(t.th,{children:"Ubuntu CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows MEM"}),(0,n.jsx)(t.th,{children:"Ubuntu MEM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-traefik-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.16%"}),(0,n.jsx)(t.td,{children:"1.32%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"43.54MiB"}),(0,n.jsx)(t.td,{children:"51.38MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-cmd-tlm-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"10.16%"}),(0,n.jsx)(t.td,{children:"6.14%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"401.6MiB"}),(0,n.jsx)(t.td,{children:"392MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-keycloak-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.17%"}),(0,n.jsx)(t.td,{children:"0.13%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"476.8MiB"}),(0,n.jsx)(t.td,{children:"476.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-operator-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"21.27%"}),(0,n.jsx)(t.td,{children:"13.91%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.214GiB"}),(0,n.jsx)(t.td,{children:"1.207GiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-script-runner-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"127.4MiB"}),(0,n.jsx)(t.td,{children:"117.1MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-metrics-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"105.2MiB"}),(0,n.jsx)(t.td,{children:"83.87MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-ephemeral-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.05%"}),(0,n.jsx)(t.td,{children:"1.89%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"46.22MiB"}),(0,n.jsx)(t.td,{children:"69.84MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.56%"}),(0,n.jsx)(t.td,{children:"0.72%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"12.82MiB"}),(0,n.jsx)(t.td,{children:"9.484MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-minio-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"152.9MiB"}),(0,n.jsx)(t.td,{children:"169.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-postgresql-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.00%"}),(0,n.jsx)(t.td,{children:"0.39%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"37.33MiB"}),(0,n.jsx)(t.td,{children:"41.02MiB"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"memory profiles are similar between the two platforms"}),"\n",(0,n.jsx)(t.li,{children:"redis-ephemeral isn't using much memory on the base Demo with its small packets"}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["At this point the COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/openc3-cosmos-load-sim",children:"LoadSim"})," was installed with default settings which creates 10 packets with 1000 items each at 10Hz (110kB/s). After a 1 hr soak, htop now indicated:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Platform"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Core CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"RAM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Windows 11 Pro"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"40% 35% 39% 42%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.64G / 7.7G"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Headless Ubuntu 22"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"17% 20% 16% 18%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.74G / 15.6G"})]})]})]}),"\n",(0,n.jsx)(t.p,{children:"The larger packets and data rate of the LoadSim target caused both platforms to dramatically increase CPU utilization but the Linux machine stays quite performant."}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"docker stats"})," was also run to show individual container cpu and memory usage:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"NAME"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows CPU %"}),(0,n.jsx)(t.th,{children:"Ubuntu CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows MEM"}),(0,n.jsx)(t.th,{children:"Ubuntu MEM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-traefik-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.09%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"44.3MiB"}),(0,n.jsx)(t.td,{children:"0.34MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-cmd-tlm-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"17.78%"}),(0,n.jsx)(t.td,{children:"6.18%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"407.9MiB"}),(0,n.jsx)(t.td,{children:"405.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-keycloak-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.20%"}),(0,n.jsx)(t.td,{children:"0.12%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"480.2MiB"}),(0,n.jsx)(t.td,{children:"481.5MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-operator-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"221.15%"}),(0,n.jsx)(t.td,{children:"66.72%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.6GiB"}),(0,n.jsx)(t.td,{children:"1.512GiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-script-runner-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"136.6MiB"}),(0,n.jsx)(t.td,{children:"127.5MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-metrics-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"106.3MiB"}),(0,n.jsx)(t.td,{children:"84.87MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-ephemeral-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"19.63%"}),(0,n.jsx)(t.td,{children:"3.91%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"333.8MiB"}),(0,n.jsx)(t.td,{children:"370.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"7.42%"}),(0,n.jsx)(t.td,{children:"1.49%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"15.87MiB"}),(0,n.jsx)(t.td,{children:"11.81MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-minio-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.10%"}),(0,n.jsx)(t.td,{children:"0.02%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"167.8MiB"}),(0,n.jsx)(t.td,{children:"179.2MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-postgresql-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.00%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"35.4MiB"}),(0,n.jsx)(t.td,{children:"42.93MiB"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"memory profiles are similar between the two platforms"}),"\n",(0,n.jsx)(t.li,{children:"redis-ephemeral is now using much more RAM as it is storing the large LoadSim packets"}),"\n",(0,n.jsx)(t.li,{children:"Windows is using much more CPU power running the operator, cmd-tlm, and redis"}),"\n"]}),"\n",(0,n.jsx)(t.h1,{id:"conclusions",children:"Conclusions"}),"\n",(0,n.jsxs)(t.p,{children:["While it is easy to run COSMOS on any Docker platform, increasing the number and complexity of the targets requires choosing the correct hardware. Sizing can be approximated but the best solution is to install representative targets and use ",(0,n.jsx)(t.code,{children:"docker stats"})," and ",(0,n.jsx)(t.code,{children:"htop"})," to judge the CPU and memory pressure on the given hardware."]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.a,{href:"https://openc3.com/enterprise",children:"COSMOS Enterprise Edition"})," on Kubernetes helps to eliminate the hardware sizing issue by scaling the cluster to meet the needs of the system. Check out ",(0,n.jsx)(t.a,{href:"https://openc3.com/news/scaling",children:"this recent talk"})," Ryan gave at GSAW showing how we scaled to over 160 satellites on a 4 node kubernetes cluster on EKS."]}),"\n",(0,n.jsx)("hr",{}),"\n",(0,n.jsxs)(t.section,{"data-footnotes":!0,className:"footnotes",children:[(0,n.jsx)(t.h2,{className:"sr-only",id:"footnote-label",children:"Footnotes"}),"\n",(0,n.jsxs)(t.ol,{children:["\n",(0,n.jsxs)(t.li,{id:"user-content-fn-1",children:["\n",(0,n.jsx)(t.p,{children:"Full specs of the Windows Platform:"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{children:"Windows 11 Pro\nDocker Desktop 4.22.0\nWSL version: 1.2.5.0\nKernel version: 5.15.90.1\nWSLg version: 1.0.51\nMSRDC version: 1.2.3770\nDirect3D version: 1.608.2-61064218\nDXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp\nWindows version: 10.0.22621.2134\n"})}),"\n",(0,n.jsx)(t.a,{href:"#user-content-fnref-1","data-footnote-backref":"","aria-label":"Back to reference 1",className:"data-footnote-backref",children:"\u21a9"}),"\n"]}),"\n"]}),"\n"]})]})}function a(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},1184:(e,t,s)=>{s.d(t,{R:()=>l});var n=s(4041);const i={},r=n.createContext(i);function l(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}}}]);
1
+ "use strict";(self.webpackChunkdocs_openc3_com=self.webpackChunkdocs_openc3_com||[]).push([[3718],{950:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>d,contentTitle:()=>l,default:()=>a,frontMatter:()=>r,metadata:()=>o,toc:()=>c});var n=s(1085),i=s(1184);const r={title:"Performance"},l="COSMOS Hardware Requirements",o={id:"guides/performance",title:"Performance",description:"The COSMOS architecture was created with scalability in mind. Our goal is to support an unlimited number of connections and use cloud technologies to scale. Only COSMOS Enterprise Edition supports Kubernetes and the various cloud platforms which allow this level of scalability. While true scalability is only achieved in COSMOS Enterprise, both Open Source and Enterprise have various levels of observability and configuration settings which can affect performance.",source:"@site/docs/guides/performance.md",sourceDirName:"guides",slug:"/guides/performance",permalink:"/tools/staticdocs/docs/guides/performance",draft:!1,unlisted:!1,editUrl:"https://github.com/OpenC3/cosmos/tree/main/docs.openc3.com/docs/guides/performance.md",tags:[],version:"current",frontMatter:{title:"Performance"},sidebar:"defaultSidebar",previous:{title:"Monitoring",permalink:"/tools/staticdocs/docs/guides/monitoring"},next:{title:"Raspberry Pi",permalink:"/tools/staticdocs/docs/guides/raspberrypi"}},d={},c=[{value:"Memory",id:"memory",level:2},{value:"CPU",id:"cpu",level:2},{value:"Performance Comparison",id:"performance-comparison",level:2}];function h(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",ol:"ol",p:"p",pre:"pre",section:"section",sup:"sup",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,i.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:["The COSMOS architecture was created with scalability in mind. Our goal is to support an unlimited number of connections and use cloud technologies to scale. Only ",(0,n.jsx)(t.a,{href:"https://openc3.com/enterprise",children:"COSMOS Enterprise Edition"})," supports Kubernetes and the various cloud platforms which allow this level of scalability. While true scalability is only achieved in COSMOS Enterprise, both Open Source and Enterprise have various levels of observability and configuration settings which can affect performance."]}),"\n",(0,n.jsx)(t.h1,{id:"cosmos-hardware-requirements",children:"COSMOS Hardware Requirements"}),"\n",(0,n.jsx)(t.h2,{id:"memory",children:"Memory"}),"\n",(0,n.jsx)(t.p,{children:"COSMOS can run on a Raspberry Pi up to a Kubernetes cluster in the cloud. On all platforms the key performance factor is the number and complexity of the targets and their defined packets. Targets can vary from simple targets taking 100 MB of RAM to complex targets taking 400 MB. The base COSMOS containers require about 800 MB of RAM. A good rule of thumb is to average about 300 MB of RAM for targets. As an example data point, the COSMOS Demo has 4 targets, two complex (INST & INST2) and two relatively simple (EXAMPLE & TEMPLATED), and requires 800 MB of RAM (on top of the 800 MB of base container RAM)."}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"Base RAM MB Calculator = 800 + (num targets) * 300"}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["In addition, the Redis streams contain the last 10 min of both raw and decommutated data from all targets. Thus you must wait ~15min to truly see what the high water memory mark will be. In the COSMOS Demo the INST & INST2 targets are fairly simple with four 1Hz packet of ~15 items and one 10Hz packet with 20 items. This only causes 50 MiB of redis RAM usage according to ",(0,n.jsx)(t.code,{children:"docker stats"}),". Installing the COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/openc3-cosmos-load-sim",children:"LoadSim"})," with 10 packets with 1000 items each at 10Hz pushed the redis memory usage to about 350 MiB."]}),"\n",(0,n.jsx)(t.h2,{id:"cpu",children:"CPU"}),"\n",(0,n.jsx)(t.p,{children:"Another consideration is the CPU performance. In the Open Source Edition, by default COSMOS spawns off 2 microservices per target. One combines packet logging and decommutation of the data and the other performs data reduction. In COSMOS Enterprise Edition on Kubernetes, each process becomes an independent container that is deployed on the cluster allowing horizontal scaling."}),"\n",(0,n.jsxs)(t.p,{children:["The COSMOS command and telemetry API and script running API servers should have a dedicated core while targets can generally share cores. It's hard to provide a general rule of thumb with the wide variety of architectures, clock speeds, and core counts. The best practice is to install COSMOS with the expected load and do some monitoring with ",(0,n.jsx)(t.code,{children:"htop"})," to visualize the load on the various cores. Any time a single core gets overloaded (100%) this is a concern and system slowdown can occur."]}),"\n",(0,n.jsx)(t.h2,{id:"performance-comparison",children:"Performance Comparison"}),"\n",(0,n.jsxs)(t.p,{children:["Performance characterization was performed in Azure on a Standard D4s v5 (4 vcpus, 16 GiB memory) chosen to allow virtualization per ",(0,n.jsx)(t.a,{href:"https://docs.docker.com/desktop/vm-vdi/#turn-on-nested-virtualization-on-microsoft-hyper-v",children:"Docker"}),". COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/cosmos-enterprise/releases/tag/v5.9.1",children:"5.9.1"})," Enterprise Edition was installed on both Windows 11 Pro ",(0,n.jsx)(t.sup,{children:(0,n.jsx)(t.a,{href:"#user-content-fn-1",id:"user-content-fnref-1","data-footnote-ref":!0,"aria-describedby":"footnote-label",children:"1"})})," and Ubuntu 22. Note: Enterprise Edition was not utilizing Kubernetes, just Docker. Testing involved starting the COSMOS Demo, connecting all targets (EXAMPLE, INST, INST2, TEMPLATED), opening the following TlmViewer screens (ADCS, ARRAY, BLOCK, COMMANDING, HS, LATEST, LIMITS, OTHER, PARAMS, SIMPLE, TABS) and creating two TlmGrapher graphs consisting of INST HEALTH_STATUS TEMP[1-4] and INST ADCS POS[X,Y,Z] and INST ADCS VEL[X,Y,Z]. This was allowed to run for 1hr and results were collected using ",(0,n.jsx)(t.code,{children:"htop"}),":"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Platform"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Core CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"RAM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Windows 11 Pro"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"12% 12% 10% 10%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.9G / 7.7G"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Headless Ubuntu 22"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"7% 7% 8% 6%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.2G / 15.6G"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:["Windows was only allocated 8 GB of RAM due to the ",(0,n.jsx)(t.a,{href:"https://learn.microsoft.com/en-us/windows/wsl/wsl-config#configuration-setting-for-wslconfig",children:".wslconfig"})," settings."]}),"\n",(0,n.jsx)(t.li,{children:"Since Ubuntu was running headless, the screens and graphs were brought up on another machine."}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"docker stats"})," was also run to show individual container cpu and memory usage:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"NAME"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows CPU %"}),(0,n.jsx)(t.th,{children:"Ubuntu CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows MEM"}),(0,n.jsx)(t.th,{children:"Ubuntu MEM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-traefik-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.16%"}),(0,n.jsx)(t.td,{children:"1.32%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"43.54MiB"}),(0,n.jsx)(t.td,{children:"51.38MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-cmd-tlm-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"10.16%"}),(0,n.jsx)(t.td,{children:"6.14%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"401.6MiB"}),(0,n.jsx)(t.td,{children:"392MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-keycloak-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.17%"}),(0,n.jsx)(t.td,{children:"0.13%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"476.8MiB"}),(0,n.jsx)(t.td,{children:"476.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-operator-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"21.27%"}),(0,n.jsx)(t.td,{children:"13.91%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.214GiB"}),(0,n.jsx)(t.td,{children:"1.207GiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-script-runner-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"127.4MiB"}),(0,n.jsx)(t.td,{children:"117.1MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-metrics-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"105.2MiB"}),(0,n.jsx)(t.td,{children:"83.87MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-ephemeral-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.05%"}),(0,n.jsx)(t.td,{children:"1.89%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"46.22MiB"}),(0,n.jsx)(t.td,{children:"69.84MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.56%"}),(0,n.jsx)(t.td,{children:"0.72%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"12.82MiB"}),(0,n.jsx)(t.td,{children:"9.484MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-minio-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"152.9MiB"}),(0,n.jsx)(t.td,{children:"169.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-postgresql-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.00%"}),(0,n.jsx)(t.td,{children:"0.39%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"37.33MiB"}),(0,n.jsx)(t.td,{children:"41.02MiB"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"memory profiles are similar between the two platforms"}),"\n",(0,n.jsx)(t.li,{children:"redis-ephemeral isn't using much memory on the base Demo with its small packets"}),"\n"]}),"\n",(0,n.jsxs)(t.p,{children:["At this point the COSMOS ",(0,n.jsx)(t.a,{href:"https://github.com/OpenC3/openc3-cosmos-load-sim",children:"LoadSim"})," was installed with default settings which creates 10 packets with 1000 items each at 10Hz (110kB/s). After a 1 hr soak, htop now indicated:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Platform"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Core CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"RAM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Windows 11 Pro"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"40% 35% 39% 42%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.64G / 7.7G"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"Headless Ubuntu 22"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"17% 20% 16% 18%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"3.74G / 15.6G"})]})]})]}),"\n",(0,n.jsx)(t.p,{children:"The larger packets and data rate of the LoadSim target caused both platforms to dramatically increase CPU utilization but the Linux machine stays quite performant."}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"docker stats"})," was also run to show individual container cpu and memory usage:"]}),"\n",(0,n.jsxs)(t.table,{children:[(0,n.jsx)(t.thead,{children:(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"NAME"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows CPU %"}),(0,n.jsx)(t.th,{children:"Ubuntu CPU %"}),(0,n.jsx)(t.th,{style:{textAlign:"left"},children:"Windows MEM"}),(0,n.jsx)(t.th,{children:"Ubuntu MEM"})]})}),(0,n.jsxs)(t.tbody,{children:[(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-traefik-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"4.09%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"44.3MiB"}),(0,n.jsx)(t.td,{children:"0.34MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-cmd-tlm-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"17.78%"}),(0,n.jsx)(t.td,{children:"6.18%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"407.9MiB"}),(0,n.jsx)(t.td,{children:"405.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-keycloak-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.20%"}),(0,n.jsx)(t.td,{children:"0.12%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"480.2MiB"}),(0,n.jsx)(t.td,{children:"481.5MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-operator-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"221.15%"}),(0,n.jsx)(t.td,{children:"66.72%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"1.6GiB"}),(0,n.jsx)(t.td,{children:"1.512GiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-cosmos-script-runner-api-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"136.6MiB"}),(0,n.jsx)(t.td,{children:"127.5MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-metrics-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.01%"}),(0,n.jsx)(t.td,{children:"0.01%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"106.3MiB"}),(0,n.jsx)(t.td,{children:"84.87MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-ephemeral-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"19.63%"}),(0,n.jsx)(t.td,{children:"3.91%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"333.8MiB"}),(0,n.jsx)(t.td,{children:"370.8MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-redis-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"7.42%"}),(0,n.jsx)(t.td,{children:"1.49%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"15.87MiB"}),(0,n.jsx)(t.td,{children:"11.81MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-minio-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.10%"}),(0,n.jsx)(t.td,{children:"0.02%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"167.8MiB"}),(0,n.jsx)(t.td,{children:"179.2MiB"})]}),(0,n.jsxs)(t.tr,{children:[(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"cosmos-enterprise-project-openc3-postgresql-1"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"0.00%"}),(0,n.jsx)(t.td,{children:"0.00%"}),(0,n.jsx)(t.td,{style:{textAlign:"left"},children:"35.4MiB"}),(0,n.jsx)(t.td,{children:"42.93MiB"})]})]})]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsx)(t.li,{children:"memory profiles are similar between the two platforms"}),"\n",(0,n.jsx)(t.li,{children:"redis-ephemeral is now using much more RAM as it is storing the large LoadSim packets"}),"\n",(0,n.jsx)(t.li,{children:"Windows is using much more CPU power running the operator, cmd-tlm, and redis"}),"\n"]}),"\n",(0,n.jsx)(t.h1,{id:"conclusions",children:"Conclusions"}),"\n",(0,n.jsxs)(t.p,{children:["While it is easy to run COSMOS on any Docker platform, increasing the number and complexity of the targets requires choosing the correct hardware. Sizing can be approximated but the best solution is to install representative targets and use ",(0,n.jsx)(t.code,{children:"docker stats"})," and ",(0,n.jsx)(t.code,{children:"htop"})," to judge the CPU and memory pressure on the given hardware."]}),"\n",(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.a,{href:"https://openc3.com/enterprise",children:"COSMOS Enterprise Edition"})," on Kubernetes helps to eliminate the hardware sizing issue by scaling the cluster to meet the needs of the system. Check out ",(0,n.jsx)(t.a,{href:"https://openc3.com/news/scaling",children:"this recent talk"})," Ryan gave at GSAW showing how we scaled to over 160 satellites on a 4 node kubernetes cluster on EKS."]}),"\n",(0,n.jsx)("hr",{}),"\n","\n",(0,n.jsxs)(t.section,{"data-footnotes":!0,className:"footnotes",children:[(0,n.jsx)(t.h2,{className:"sr-only",id:"footnote-label",children:"Footnotes"}),"\n",(0,n.jsxs)(t.ol,{children:["\n",(0,n.jsxs)(t.li,{id:"user-content-fn-1",children:["\n",(0,n.jsx)(t.p,{children:"Full specs of the Windows Platform:"}),"\n",(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{children:"Windows 11 Pro\nDocker Desktop 4.22.0\nWSL version: 1.2.5.0\nKernel version: 5.15.90.1\nWSLg version: 1.0.51\nMSRDC version: 1.2.3770\nDirect3D version: 1.608.2-61064218\nDXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp\nWindows version: 10.0.22621.2134\n"})}),"\n",(0,n.jsx)(t.a,{href:"#user-content-fnref-1","data-footnote-backref":"","aria-label":"Back to reference 1",className:"data-footnote-backref",children:"\u21a9"}),"\n"]}),"\n"]}),"\n"]})]})}function a(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(h,{...e})}):h(e)}},1184:(e,t,s)=>{s.d(t,{R:()=>l});var n=s(4041);const i={},r=n.createContext(i);function l(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}}}]);