openc3 5.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +18 -0
  3. data/Guardfile +35 -0
  4. data/LICENSE.txt +727 -0
  5. data/README.md +37 -0
  6. data/Rakefile +131 -0
  7. data/bin/cstol_converter +1178 -0
  8. data/bin/openc3cli +531 -0
  9. data/bin/rubysloc +139 -0
  10. data/data/config/_array_params.yaml +23 -0
  11. data/data/config/_id_items.yaml +24 -0
  12. data/data/config/_id_params.yaml +58 -0
  13. data/data/config/_interfaces.yaml +214 -0
  14. data/data/config/_interfaces.yaml.err +1017 -0
  15. data/data/config/_items.yaml +20 -0
  16. data/data/config/_params.yaml +60 -0
  17. data/data/config/cmd_tlm_server.yaml +136 -0
  18. data/data/config/command.yaml +44 -0
  19. data/data/config/command_modifiers.yaml +160 -0
  20. data/data/config/command_telemetry.yaml +3 -0
  21. data/data/config/interface_modifiers.yaml +104 -0
  22. data/data/config/item_modifiers.yaml +221 -0
  23. data/data/config/microservice.yaml +78 -0
  24. data/data/config/param_item_modifiers.yaml +52 -0
  25. data/data/config/parameter_modifiers.yaml +200 -0
  26. data/data/config/plugins.yaml +80 -0
  27. data/data/config/protocols.yaml +290 -0
  28. data/data/config/screen.yaml +147 -0
  29. data/data/config/table_manager.yaml +89 -0
  30. data/data/config/table_parameter_modifiers.yaml +9 -0
  31. data/data/config/target.yaml +142 -0
  32. data/data/config/target_config.yaml +94 -0
  33. data/data/config/telemetry.yaml +87 -0
  34. data/data/config/telemetry_modifiers.yaml +159 -0
  35. data/data/config/tool.yaml +63 -0
  36. data/data/config/unknown.yaml +3 -0
  37. data/data/config/widgets.yaml +1505 -0
  38. data/ext/mkrf_conf.rb +49 -0
  39. data/ext/openc3/ext/array/array.c +122 -0
  40. data/ext/openc3/ext/array/extconf.rb +13 -0
  41. data/ext/openc3/ext/buffered_file/buffered_file.c +198 -0
  42. data/ext/openc3/ext/buffered_file/extconf.rb +13 -0
  43. data/ext/openc3/ext/config_parser/config_parser.c +280 -0
  44. data/ext/openc3/ext/config_parser/extconf.rb +13 -0
  45. data/ext/openc3/ext/crc/crc.c +351 -0
  46. data/ext/openc3/ext/crc/extconf.rb +13 -0
  47. data/ext/openc3/ext/openc3_io/extconf.rb +13 -0
  48. data/ext/openc3/ext/openc3_io/openc3_io.c +158 -0
  49. data/ext/openc3/ext/packet/extconf.rb +13 -0
  50. data/ext/openc3/ext/packet/packet.c +318 -0
  51. data/ext/openc3/ext/platform/extconf.rb +13 -0
  52. data/ext/openc3/ext/platform/platform.c +134 -0
  53. data/ext/openc3/ext/polynomial_conversion/extconf.rb +13 -0
  54. data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +79 -0
  55. data/ext/openc3/ext/string/extconf.rb +13 -0
  56. data/ext/openc3/ext/string/string.c +63 -0
  57. data/ext/openc3/ext/structure/structure.c +1719 -0
  58. data/ext/openc3/ext/tabbed_plots_config/extconf.rb +13 -0
  59. data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +62 -0
  60. data/ext/openc3/ext/telemetry/extconf.rb +13 -0
  61. data/ext/openc3/ext/telemetry/telemetry.c +336 -0
  62. data/lib/cosmos.rb +20 -0
  63. data/lib/cosmosc2.rb +20 -0
  64. data/lib/openc3/api/api.rb +39 -0
  65. data/lib/openc3/api/authorized_api.rb +30 -0
  66. data/lib/openc3/api/cmd_api.rb +451 -0
  67. data/lib/openc3/api/config_api.rb +58 -0
  68. data/lib/openc3/api/interface_api.rb +117 -0
  69. data/lib/openc3/api/limits_api.rb +375 -0
  70. data/lib/openc3/api/router_api.rb +117 -0
  71. data/lib/openc3/api/settings_api.rb +70 -0
  72. data/lib/openc3/api/target_api.rb +78 -0
  73. data/lib/openc3/api/tlm_api.rb +455 -0
  74. data/lib/openc3/bridge/bridge.rb +54 -0
  75. data/lib/openc3/bridge/bridge_config.rb +167 -0
  76. data/lib/openc3/bridge/bridge_interface_thread.rb +42 -0
  77. data/lib/openc3/bridge/bridge_router_thread.rb +42 -0
  78. data/lib/openc3/ccsds/ccsds_packet.rb +68 -0
  79. data/lib/openc3/ccsds/ccsds_parser.rb +148 -0
  80. data/lib/openc3/config/config_parser.rb +549 -0
  81. data/lib/openc3/config/meta_config_parser.rb +74 -0
  82. data/lib/openc3/conversions/conversion.rb +70 -0
  83. data/lib/openc3/conversions/generic_conversion.rb +83 -0
  84. data/lib/openc3/conversions/packet_time_formatted_conversion.rb +43 -0
  85. data/lib/openc3/conversions/packet_time_seconds_conversion.rb +43 -0
  86. data/lib/openc3/conversions/polynomial_conversion.rb +87 -0
  87. data/lib/openc3/conversions/processor_conversion.rb +70 -0
  88. data/lib/openc3/conversions/received_count_conversion.rb +38 -0
  89. data/lib/openc3/conversions/received_time_formatted_conversion.rb +42 -0
  90. data/lib/openc3/conversions/received_time_seconds_conversion.rb +42 -0
  91. data/lib/openc3/conversions/segmented_polynomial_conversion.rb +171 -0
  92. data/lib/openc3/conversions/unix_time_conversion.rb +68 -0
  93. data/lib/openc3/conversions/unix_time_formatted_conversion.rb +49 -0
  94. data/lib/openc3/conversions/unix_time_seconds_conversion.rb +49 -0
  95. data/lib/openc3/conversions.rb +34 -0
  96. data/lib/openc3/core_ext/array.rb +416 -0
  97. data/lib/openc3/core_ext/binding.rb +29 -0
  98. data/lib/openc3/core_ext/class.rb +72 -0
  99. data/lib/openc3/core_ext/exception.rb +61 -0
  100. data/lib/openc3/core_ext/file.rb +83 -0
  101. data/lib/openc3/core_ext/hash.rb +37 -0
  102. data/lib/openc3/core_ext/io.rb +134 -0
  103. data/lib/openc3/core_ext/kernel.rb +42 -0
  104. data/lib/openc3/core_ext/math.rb +128 -0
  105. data/lib/openc3/core_ext/matrix.rb +156 -0
  106. data/lib/openc3/core_ext/objectspace.rb +36 -0
  107. data/lib/openc3/core_ext/openc3_io.rb +57 -0
  108. data/lib/openc3/core_ext/range.rb +27 -0
  109. data/lib/openc3/core_ext/socket.rb +38 -0
  110. data/lib/openc3/core_ext/string.rb +389 -0
  111. data/lib/openc3/core_ext/stringio.rb +33 -0
  112. data/lib/openc3/core_ext/time.rb +508 -0
  113. data/lib/openc3/core_ext.rb +36 -0
  114. data/lib/openc3/interfaces/interface.rb +498 -0
  115. data/lib/openc3/interfaces/linc_interface.rb +475 -0
  116. data/lib/openc3/interfaces/protocols/burst_protocol.rb +192 -0
  117. data/lib/openc3/interfaces/protocols/crc_protocol.rb +193 -0
  118. data/lib/openc3/interfaces/protocols/fixed_protocol.rb +155 -0
  119. data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +56 -0
  120. data/lib/openc3/interfaces/protocols/length_protocol.rb +165 -0
  121. data/lib/openc3/interfaces/protocols/override_protocol.rb +60 -0
  122. data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +206 -0
  123. data/lib/openc3/interfaces/protocols/protocol.rb +82 -0
  124. data/lib/openc3/interfaces/protocols/template_protocol.rb +261 -0
  125. data/lib/openc3/interfaces/protocols/terminated_protocol.rb +93 -0
  126. data/lib/openc3/interfaces/serial_interface.rb +94 -0
  127. data/lib/openc3/interfaces/simulated_target_interface.rb +168 -0
  128. data/lib/openc3/interfaces/stream_interface.rb +81 -0
  129. data/lib/openc3/interfaces/tcpip_client_interface.rb +69 -0
  130. data/lib/openc3/interfaces/tcpip_server_interface.rb +629 -0
  131. data/lib/openc3/interfaces/udp_interface.rb +169 -0
  132. data/lib/openc3/interfaces.rb +44 -0
  133. data/lib/openc3/io/buffered_file.rb +109 -0
  134. data/lib/openc3/io/io_multiplexer.rb +80 -0
  135. data/lib/openc3/io/json_api_object.rb +208 -0
  136. data/lib/openc3/io/json_drb.rb +335 -0
  137. data/lib/openc3/io/json_drb_object.rb +114 -0
  138. data/lib/openc3/io/json_drb_rack.rb +84 -0
  139. data/lib/openc3/io/json_rpc.rb +420 -0
  140. data/lib/openc3/io/openc3_snmp.rb +58 -0
  141. data/lib/openc3/io/posix_serial_driver.rb +156 -0
  142. data/lib/openc3/io/raw_logger.rb +167 -0
  143. data/lib/openc3/io/raw_logger_pair.rb +77 -0
  144. data/lib/openc3/io/serial_driver.rb +105 -0
  145. data/lib/openc3/io/stderr.rb +43 -0
  146. data/lib/openc3/io/stdout.rb +43 -0
  147. data/lib/openc3/io/udp_sockets.rb +194 -0
  148. data/lib/openc3/io/win32_serial_driver.rb +196 -0
  149. data/lib/openc3/logs/log_writer.rb +302 -0
  150. data/lib/openc3/logs/packet_log_constants.rb +62 -0
  151. data/lib/openc3/logs/packet_log_reader.rb +345 -0
  152. data/lib/openc3/logs/packet_log_writer.rb +299 -0
  153. data/lib/openc3/logs/text_log_writer.rb +68 -0
  154. data/lib/openc3/logs.rb +25 -0
  155. data/lib/openc3/microservices/cleanup_microservice.rb +68 -0
  156. data/lib/openc3/microservices/decom_microservice.rb +136 -0
  157. data/lib/openc3/microservices/interface_microservice.rb +532 -0
  158. data/lib/openc3/microservices/log_microservice.rb +108 -0
  159. data/lib/openc3/microservices/microservice.rb +204 -0
  160. data/lib/openc3/microservices/plugin_microservice.rb +43 -0
  161. data/lib/openc3/microservices/reaction_microservice.rb +541 -0
  162. data/lib/openc3/microservices/reducer_microservice.rb +313 -0
  163. data/lib/openc3/microservices/router_microservice.rb +44 -0
  164. data/lib/openc3/microservices/text_log_microservice.rb +84 -0
  165. data/lib/openc3/microservices/timeline_microservice.rb +363 -0
  166. data/lib/openc3/microservices/trigger_group_microservice.rb +638 -0
  167. data/lib/openc3/models/activity_model.rb +319 -0
  168. data/lib/openc3/models/auth_model.rb +65 -0
  169. data/lib/openc3/models/cvt_model.rb +185 -0
  170. data/lib/openc3/models/environment_model.rb +58 -0
  171. data/lib/openc3/models/gem_model.rb +137 -0
  172. data/lib/openc3/models/info_model.rb +31 -0
  173. data/lib/openc3/models/interface_model.rb +281 -0
  174. data/lib/openc3/models/interface_status_model.rb +117 -0
  175. data/lib/openc3/models/metadata_model.rb +139 -0
  176. data/lib/openc3/models/metric_model.rb +59 -0
  177. data/lib/openc3/models/microservice_model.rb +206 -0
  178. data/lib/openc3/models/microservice_status_model.rb +74 -0
  179. data/lib/openc3/models/model.rb +204 -0
  180. data/lib/openc3/models/note_model.rb +122 -0
  181. data/lib/openc3/models/notification_model.rb +40 -0
  182. data/lib/openc3/models/ping_model.rb +35 -0
  183. data/lib/openc3/models/plugin_model.rb +292 -0
  184. data/lib/openc3/models/process_status_model.rb +76 -0
  185. data/lib/openc3/models/reaction_model.rb +322 -0
  186. data/lib/openc3/models/reducer_model.rb +65 -0
  187. data/lib/openc3/models/router_model.rb +35 -0
  188. data/lib/openc3/models/router_status_model.rb +27 -0
  189. data/lib/openc3/models/scope_model.rb +153 -0
  190. data/lib/openc3/models/settings_model.rb +55 -0
  191. data/lib/openc3/models/sorted_model.rb +167 -0
  192. data/lib/openc3/models/target_model.rb +759 -0
  193. data/lib/openc3/models/timeline_model.rb +154 -0
  194. data/lib/openc3/models/tool_config_model.rb +38 -0
  195. data/lib/openc3/models/tool_model.rb +262 -0
  196. data/lib/openc3/models/trigger_group_model.rb +186 -0
  197. data/lib/openc3/models/trigger_model.rb +330 -0
  198. data/lib/openc3/models/widget_model.rb +138 -0
  199. data/lib/openc3/operators/microservice_operator.rb +128 -0
  200. data/lib/openc3/operators/operator.rb +277 -0
  201. data/lib/openc3/packets/binary_accessor.rb +1207 -0
  202. data/lib/openc3/packets/commands.rb +373 -0
  203. data/lib/openc3/packets/json_packet.rb +134 -0
  204. data/lib/openc3/packets/limits.rb +271 -0
  205. data/lib/openc3/packets/limits_response.rb +53 -0
  206. data/lib/openc3/packets/packet.rb +1168 -0
  207. data/lib/openc3/packets/packet_config.rb +625 -0
  208. data/lib/openc3/packets/packet_item.rb +586 -0
  209. data/lib/openc3/packets/packet_item_limits.rb +162 -0
  210. data/lib/openc3/packets/parsers/format_string_parser.rb +65 -0
  211. data/lib/openc3/packets/parsers/limits_parser.rb +159 -0
  212. data/lib/openc3/packets/parsers/limits_response_parser.rb +61 -0
  213. data/lib/openc3/packets/parsers/packet_item_parser.rb +272 -0
  214. data/lib/openc3/packets/parsers/packet_parser.rb +134 -0
  215. data/lib/openc3/packets/parsers/processor_parser.rb +73 -0
  216. data/lib/openc3/packets/parsers/state_parser.rb +127 -0
  217. data/lib/openc3/packets/parsers/xtce_converter.rb +442 -0
  218. data/lib/openc3/packets/parsers/xtce_parser.rb +722 -0
  219. data/lib/openc3/packets/structure.rb +553 -0
  220. data/lib/openc3/packets/structure_item.rb +365 -0
  221. data/lib/openc3/packets/telemetry.rb +487 -0
  222. data/lib/openc3/processors/processor.rb +86 -0
  223. data/lib/openc3/processors/statistics_processor.rb +82 -0
  224. data/lib/openc3/processors/watermark_processor.rb +58 -0
  225. data/lib/openc3/processors.rb +24 -0
  226. data/lib/openc3/script/api_shared.rb +828 -0
  227. data/lib/openc3/script/calendar.rb +89 -0
  228. data/lib/openc3/script/commands.rb +227 -0
  229. data/lib/openc3/script/exceptions.rb +29 -0
  230. data/lib/openc3/script/extract.rb +161 -0
  231. data/lib/openc3/script/limits.rb +60 -0
  232. data/lib/openc3/script/script.rb +299 -0
  233. data/lib/openc3/script/script_runner.rb +238 -0
  234. data/lib/openc3/script/storage.rb +146 -0
  235. data/lib/openc3/script/suite.rb +542 -0
  236. data/lib/openc3/script/suite_results.rb +196 -0
  237. data/lib/openc3/script/suite_runner.rb +217 -0
  238. data/lib/openc3/script.rb +21 -0
  239. data/lib/openc3/streams/serial_stream.rb +167 -0
  240. data/lib/openc3/streams/stream.rb +63 -0
  241. data/lib/openc3/streams/tcpip_client_stream.rb +116 -0
  242. data/lib/openc3/streams/tcpip_socket_stream.rb +195 -0
  243. data/lib/openc3/system/system.rb +127 -0
  244. data/lib/openc3/system/system_config.rb +411 -0
  245. data/lib/openc3/system/target.rb +269 -0
  246. data/lib/openc3/system.rb +24 -0
  247. data/lib/openc3/tools/cmd_tlm_server/api.rb +20 -0
  248. data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +320 -0
  249. data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +294 -0
  250. data/lib/openc3/tools/table_manager/table.rb +77 -0
  251. data/lib/openc3/tools/table_manager/table_config.rb +273 -0
  252. data/lib/openc3/tools/table_manager/table_item.rb +90 -0
  253. data/lib/openc3/tools/table_manager/table_item_parser.rb +66 -0
  254. data/lib/openc3/tools/table_manager/table_manager_core.rb +333 -0
  255. data/lib/openc3/tools/table_manager/table_parser.rb +93 -0
  256. data/lib/openc3/tools/test_runner/test.rb +67 -0
  257. data/lib/openc3/top_level.rb +595 -0
  258. data/lib/openc3/topics/autonomic_topic.rb +52 -0
  259. data/lib/openc3/topics/calendar_topic.rb +44 -0
  260. data/lib/openc3/topics/command_decom_topic.rb +76 -0
  261. data/lib/openc3/topics/command_topic.rb +83 -0
  262. data/lib/openc3/topics/config_topic.rb +68 -0
  263. data/lib/openc3/topics/interface_topic.rb +73 -0
  264. data/lib/openc3/topics/limits_event_topic.rb +109 -0
  265. data/lib/openc3/topics/notifications_topic.rb +28 -0
  266. data/lib/openc3/topics/router_topic.rb +85 -0
  267. data/lib/openc3/topics/telemetry_decom_topic.rb +54 -0
  268. data/lib/openc3/topics/telemetry_topic.rb +36 -0
  269. data/lib/openc3/topics/timeline_topic.rb +45 -0
  270. data/lib/openc3/topics/topic.rb +53 -0
  271. data/lib/openc3/utilities/authentication.rb +141 -0
  272. data/lib/openc3/utilities/authorization.rb +51 -0
  273. data/lib/openc3/utilities/crc.rb +278 -0
  274. data/lib/openc3/utilities/csv.rb +153 -0
  275. data/lib/openc3/utilities/logger.rb +187 -0
  276. data/lib/openc3/utilities/message_log.rb +91 -0
  277. data/lib/openc3/utilities/metric.rb +141 -0
  278. data/lib/openc3/utilities/process_manager.rb +139 -0
  279. data/lib/openc3/utilities/quaternion.rb +257 -0
  280. data/lib/openc3/utilities/ruby_lex_utils.rb +568 -0
  281. data/lib/openc3/utilities/s3.rb +202 -0
  282. data/lib/openc3/utilities/s3_autoload.rb +9 -0
  283. data/lib/openc3/utilities/s3_file_cache.rb +274 -0
  284. data/lib/openc3/utilities/simulated_target.rb +117 -0
  285. data/lib/openc3/utilities/sleeper.rb +51 -0
  286. data/lib/openc3/utilities/store.rb +23 -0
  287. data/lib/openc3/utilities/store_autoload.rb +237 -0
  288. data/lib/openc3/utilities/zip.rb +21 -0
  289. data/lib/openc3/utilities.rb +35 -0
  290. data/lib/openc3/version.rb +14 -0
  291. data/lib/openc3/win32/excel.rb +132 -0
  292. data/lib/openc3/win32/win32.rb +402 -0
  293. data/lib/openc3/win32/win32_main.rb +333 -0
  294. data/lib/openc3.rb +49 -0
  295. data/tasks/gemfile_stats.rake +113 -0
  296. data/tasks/spec.rake +30 -0
  297. data/templates/plugin-template/README.md +15 -0
  298. data/templates/plugin-template/Rakefile +12 -0
  299. data/templates/plugin-template/plugin.gemspec +23 -0
  300. data/templates/plugin-template/plugin.txt +9 -0
  301. data/templates/plugin-template/targets/TARGET/cmd_tlm/cmd.txt +8 -0
  302. data/templates/plugin-template/targets/TARGET/cmd_tlm/tlm.txt +8 -0
  303. data/templates/plugin-template/targets/TARGET/lib/target.rb +10 -0
  304. data/templates/plugin-template/targets/TARGET/procedures/procedure.rb +3 -0
  305. data/templates/plugin-template/targets/TARGET/screens/status.txt +9 -0
  306. data/templates/plugin-template/targets/TARGET/target.txt +5 -0
  307. metadata +849 -0
@@ -0,0 +1,375 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+
16
+ # Modified by OpenC3, Inc.
17
+ # All changes Copyright 2022, OpenC3, Inc.
18
+ # All Rights Reserved
19
+
20
+ require 'openc3/api/target_api'
21
+
22
+ module OpenC3
23
+ module Api
24
+ WHITELIST ||= []
25
+ WHITELIST.concat([
26
+ 'get_stale',
27
+ 'get_out_of_limits',
28
+ 'get_overall_limits_state',
29
+ 'limits_enabled?',
30
+ 'enable_limits',
31
+ 'disable_limits',
32
+ 'get_limits',
33
+ 'set_limits',
34
+ 'get_limits_groups',
35
+ 'enable_limits_group',
36
+ 'disable_limits_group',
37
+ 'get_limits_sets',
38
+ 'set_limits_set',
39
+ 'get_limits_set',
40
+ 'get_limits_events',
41
+ ])
42
+
43
+ # Get the list of stale packets for a specific target or pass nil to list
44
+ # all stale packets
45
+ #
46
+ # @param with_limits_only [Boolean] Return only the stale packets
47
+ # that have limits items and thus affect the overall limits
48
+ # state of the system
49
+ # @param target_name [String] The target to find stale packets for or nil to list
50
+ # all stale packets in the system
51
+ # @param staleness_sec [Integer] The amount of time to pass before a packet is marked stale
52
+ # @return [Array<Array<String, String>>] Array of arrays listing the target
53
+ # name and packet name
54
+ def get_stale(with_limits_only: false, target_name: nil, staleness_sec: 30, scope: $openc3_scope, token: $openc3_token)
55
+ authorize(permission: 'tlm', target_name: target_name, scope: scope, token: token)
56
+ stale_time = Time.now.sys.to_nsec_from_epoch - (staleness_sec * Time::NSEC_PER_SECOND)
57
+ stale = []
58
+ targets = []
59
+ if target_name
60
+ targets = [target_name]
61
+ else
62
+ targets = get_target_list()
63
+ end
64
+ targets.each do |target_name|
65
+ get_all_telemetry(target_name, scope: scope).each do |packet|
66
+ topic = "#{scope}__TELEMETRY__{#{target_name}}__#{packet['packet_name']}"
67
+ _, msg_hash = Topic.get_newest_message(topic)
68
+ unless msg_hash && msg_hash['time'].to_i > stale_time
69
+ next if with_limits_only && packet['items'].find { |item| item['limits'] }.nil?
70
+
71
+ stale << [packet['target_name'], packet['packet_name']]
72
+ end
73
+ end
74
+ end
75
+ stale
76
+ end
77
+
78
+ # Return an array of arrays indicating all items in the packet that are out of limits
79
+ # [[target name, packet name, item name, item limits state], ...]
80
+ #
81
+ # @return [Array<Array<String, String, String, String>>]
82
+ def get_out_of_limits(scope: $openc3_scope, token: $openc3_token)
83
+ authorize(permission: 'tlm', scope: scope, token: token)
84
+ LimitsEventTopic.out_of_limits(scope: scope)
85
+ end
86
+
87
+ # Get the overall limits state which is the worse case of all limits items.
88
+ # For example if any limits are YELLOW_LOW or YELLOW_HIGH then the overall limits state is YELLOW.
89
+ # If a single limit item then turns RED_HIGH the overall limits state is RED.
90
+ #
91
+ # @param ignored_items [Array<Array<String, String, String|nil>>] Array of [TGT, PKT, ITEM] strings
92
+ # to ignore when determining overall state. Note, ITEM can be nil to indicate to ignore entire packet.
93
+ # @return [String] The overall limits state for the system, one of 'GREEN', 'YELLOW', 'RED'
94
+ def get_overall_limits_state(ignored_items = nil, scope: $openc3_scope, token: $openc3_token)
95
+ # We only need to check out of limits items so call get_out_of_limits() which authorizes
96
+ out_of_limits = get_out_of_limits(scope: scope, token: token)
97
+ overall = 'GREEN'
98
+ limits_packet_stale = false # TODO: Calculate stale
99
+
100
+ # Build easily matchable ignore list
101
+ if ignored_items
102
+ ignored_items.map! do |item|
103
+ raise "Invalid ignored item: #{item}. Must be [TGT, PKT, ITEM] where ITEM can be nil." if item.length != 3
104
+
105
+ item.join('__')
106
+ end
107
+ else
108
+ ignored_items = []
109
+ end
110
+
111
+ out_of_limits.each do |target_name, packet_name, item_name, limits_state|
112
+ # Ignore this item if we match one of the ignored items. Checking against /^#{item}/
113
+ # allows us to detect matches against a TGT__PKT__ with no item defined.
114
+ next if ignored_items.detect { |item| "#{target_name}__#{packet_name}__#{item_name}" =~ /^#{item}/ }
115
+
116
+ case overall
117
+ # If our overall state is currently blue or green we can go to any state
118
+ when 'BLUE', 'GREEN', 'GREEN_HIGH', 'GREEN_LOW'
119
+ overall = limits_state
120
+ # If our overal state is yellow we can only go higher to red
121
+ when 'YELLOW', 'YELLOW_HIGH', 'YELLOW_LOW'
122
+ if limits_state == 'RED' || limits_state == 'RED_HIGH' || limits_state == 'RED_LOW'
123
+ overall = limits_state
124
+ break # Red is as high as we go so no need to look for more
125
+ end
126
+ end
127
+ end
128
+ overall = 'GREEN' if overall == 'GREEN_HIGH' || overall == 'GREEN_LOW' || overall == 'BLUE'
129
+ overall = 'YELLOW' if overall == 'YELLOW_HIGH' || overall == 'YELLOW_LOW'
130
+ overall = 'RED' if overall == 'RED_HIGH' || overall == 'RED_LOW'
131
+ overall = 'STALE' if (overall == 'GREEN' || overall == 'BLUE') && limits_packet_stale
132
+ return overall
133
+ end
134
+
135
+ # Whether the limits are enabled for the given item
136
+ #
137
+ # Accepts two different calling styles:
138
+ # limits_enabled?("TGT PKT ITEM")
139
+ # limits_enabled?('TGT','PKT','ITEM')
140
+ #
141
+ # Favor the first syntax where possible as it is more succinct.
142
+ #
143
+ # @param args [String|Array<String>] See the description for calling style
144
+ # @return [Boolean] Whether limits are enable for the itme
145
+ def limits_enabled?(*args, scope: $openc3_scope, token: $openc3_token)
146
+ target_name, packet_name, item_name = tlm_process_args(args, 'limits_enabled?', scope: scope)
147
+ authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
148
+ return TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)['limits']['enabled'] ? true : false
149
+ end
150
+
151
+ # Enable limits checking for a telemetry item
152
+ #
153
+ # Accepts two different calling styles:
154
+ # enable_limits("TGT PKT ITEM")
155
+ # enable_limits('TGT','PKT','ITEM')
156
+ #
157
+ # Favor the first syntax where possible as it is more succinct.
158
+ #
159
+ # @param args [String|Array<String>] See the description for calling style
160
+ def enable_limits(*args, scope: $openc3_scope, token: $openc3_token)
161
+ target_name, packet_name, item_name = tlm_process_args(args, 'enable_limits', scope: scope)
162
+ authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
163
+ packet = TargetModel.packet(target_name, packet_name, scope: scope)
164
+ found_item = nil
165
+ packet['items'].each do |item|
166
+ if item['name'] == item_name
167
+ item['limits']['enabled'] = true
168
+ found_item = item
169
+ break
170
+ end
171
+ end
172
+ raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist" unless found_item
173
+
174
+ TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
175
+ end
176
+
177
+ # Disable limit checking for a telemetry item
178
+ #
179
+ # Accepts two different calling styles:
180
+ # disable_limits("TGT PKT ITEM")
181
+ # disable_limits('TGT','PKT','ITEM')
182
+ #
183
+ # Favor the first syntax where possible as it is more succinct.
184
+ #
185
+ # @param args [String|Array<String>] See the description for calling style
186
+ def disable_limits(*args, scope: $openc3_scope, token: $openc3_token)
187
+ target_name, packet_name, item_name = tlm_process_args(args, 'disable_limits', scope: scope)
188
+ authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
189
+ packet = TargetModel.packet(target_name, packet_name, scope: scope)
190
+ found_item = nil
191
+ packet['items'].each do |item|
192
+ if item['name'] == item_name
193
+ item['limits'].delete('enabled')
194
+ found_item = item
195
+ break
196
+ end
197
+ end
198
+ raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist" unless found_item
199
+
200
+ TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
201
+ end
202
+
203
+ # Get a Hash of all the limits sets defined for an item. Hash keys are the limit
204
+ # set name in uppercase (note there is always a DEFAULT) and the value is an array
205
+ # of limit values: red low, yellow low, yellow high, red high, <green low, green high>.
206
+ # Green low and green high are optional.
207
+ #
208
+ # For example: {'DEFAULT' => [-80, -70, 60, 80, -20, 20],
209
+ # 'TVAC' => [-25, -10, 50, 55] }
210
+ #
211
+ # @return [Hash{String => Array<Number, Number, Number, Number, Number, Number>}]
212
+ def get_limits(target_name, packet_name, item_name, scope: $openc3_scope, token: $openc3_token)
213
+ authorize(permission: 'tlm', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
214
+ limits = {}
215
+ item = TargetModel.packet_item(target_name, packet_name, item_name, scope: scope)
216
+ item['limits'].each do |key, vals|
217
+ next unless vals.is_a?(Hash)
218
+
219
+ limits[key] = [vals['red_low'], vals['yellow_low'], vals['yellow_high'], vals['red_high']]
220
+ limits[key].concat([vals['green_low'], vals['green_high']]) if vals['green_low']
221
+ end
222
+ return limits
223
+ end
224
+
225
+ # Change the limits settings for a given item. By default, a new limits set called 'CUSTOM'
226
+ # is created to avoid overriding existing limits.
227
+ def set_limits(target_name, packet_name, item_name, red_low, yellow_low, yellow_high, red_high,
228
+ green_low = nil, green_high = nil, limits_set = :CUSTOM, persistence = nil, enabled = true,
229
+ scope: $openc3_scope, token: $openc3_token)
230
+ authorize(permission: 'tlm_set', target_name: target_name, packet_name: packet_name, scope: scope, token: token)
231
+ if (red_low > yellow_low) || (yellow_low >= yellow_high) || (yellow_high > red_high)
232
+ raise "Invalid limits specified. Ensure yellow limits are within red limits."
233
+ end
234
+ if (green_low && green_high) && ((yellow_low > green_low) || (green_low >= green_high) || (green_high > yellow_high))
235
+ raise "Invalid limits specified. Ensure green limits are within yellow limits."
236
+ end
237
+ packet = TargetModel.packet(target_name, packet_name, scope: scope)
238
+ found_item = nil
239
+ packet['items'].each do |item|
240
+ if item['name'] == item_name
241
+ item['limits']['persistence_setting'] = persistence
242
+ if enabled
243
+ item['limits']['enabled'] = true
244
+ else
245
+ item['limits'].delete('enabled')
246
+ end
247
+ limits = {}
248
+ limits['red_low'] = red_low
249
+ limits['yellow_low'] = yellow_low
250
+ limits['yellow_high'] = yellow_high
251
+ limits['red_high'] = red_high
252
+ limits['green_low'] = green_low if green_low && green_high
253
+ limits['green_high'] = green_high if green_low && green_high
254
+ item['limits'][limits_set] = limits
255
+ found_item = item
256
+ break
257
+ end
258
+ end
259
+ raise "Item '#{target_name} #{packet_name} #{item_name}' does not exist" unless found_item
260
+ message = "Setting '#{target_name} #{packet_name} #{item_name}' limits to #{red_low} #{yellow_low} #{yellow_high} #{red_high}"
261
+ message << " #{green_low} #{green_high}" if green_low && green_high
262
+ message << " in set #{limits_set} with persistence #{persistence} as enabled #{enabled}"
263
+ Logger.info(message)
264
+
265
+ TargetModel.set_packet(target_name, packet_name, packet, scope: scope)
266
+
267
+ event = { type: :LIMITS_SETTINGS, target_name: target_name, packet_name: packet_name,
268
+ item_name: item_name, red_low: red_low, yellow_low: yellow_low, yellow_high: yellow_high, red_high: red_high,
269
+ green_low: green_low, green_high: green_high, limits_set: limits_set, persistence: persistence, enabled: enabled,
270
+ time_nsec: Time.now.to_nsec_from_epoch, message: message }
271
+ LimitsEventTopic.write(event, scope: scope)
272
+ end
273
+
274
+ # Returns all limits_groups and their members
275
+ # @since 5.0.0 Returns hash with values
276
+ # @return [Hash{String => Array<Array<String, String, String>>]
277
+ def get_limits_groups(scope: $openc3_scope, token: $openc3_token)
278
+ authorize(permission: 'tlm', scope: scope, token: token)
279
+ TargetModel.limits_groups(scope: scope)
280
+ end
281
+
282
+ # Enables limits for all the items in the group
283
+ #
284
+ # @param group_name [String] Name of the group to enable
285
+ def enable_limits_group(group_name, scope: $openc3_scope, token: $openc3_token)
286
+ _limits_group(group_name, action: :enable, scope: scope, token: token)
287
+ end
288
+
289
+ # Disables limits for all the items in the group
290
+ #
291
+ # @param group_name [String] Name of the group to disable
292
+ def disable_limits_group(group_name, scope: $openc3_scope, token: $openc3_token)
293
+ _limits_group(group_name, action: :disable, scope: scope, token: token)
294
+ end
295
+
296
+ # Returns all defined limits sets
297
+ #
298
+ # @return [Array<String>] All defined limits sets
299
+ def get_limits_sets(scope: $openc3_scope, token: $openc3_token)
300
+ authorize(permission: 'tlm', scope: scope, token: token)
301
+ LimitsEventTopic.sets(scope: scope).keys
302
+ end
303
+
304
+ # Changes the active limits set that applies to all telemetry
305
+ #
306
+ # @param limits_set [String] The name of the limits set
307
+ def set_limits_set(limits_set, scope: $openc3_scope, token: $openc3_token)
308
+ authorize(permission: 'tlm_set', scope: scope, token: token)
309
+ message = "Setting Limits Set: #{limits_set}"
310
+ Logger.info(message)
311
+ LimitsEventTopic.write({ type: :LIMITS_SET, set: limits_set.to_s,
312
+ time_nsec: Time.now.to_nsec_from_epoch, message: message }, scope: scope)
313
+ end
314
+
315
+ # Returns the active limits set that applies to all telemetry
316
+ #
317
+ # @return [String] The current limits set
318
+ def get_limits_set(scope: $openc3_scope, token: $openc3_token)
319
+ authorize(permission: 'tlm', scope: scope, token: token)
320
+ LimitsEventTopic.current_set(scope: scope)
321
+ end
322
+
323
+ # Returns limits events starting at the provided offset. Passing nil for an
324
+ # offset will return the last received limits event and associated offset.
325
+ #
326
+ # @param offset [Integer] Offset to start reading limits events. Nil to return
327
+ # the last received limits event (if any).
328
+ # @param count [Integer] The total number of events returned. Default is 100.
329
+ # @return [Hash, Integer] Event hash followed by the offset. The offset can
330
+ # be used in subsequent calls to return events from where the last call left off.
331
+ def get_limits_events(offset = nil, count: 100, scope: $openc3_scope, token: $openc3_token)
332
+ authorize(permission: 'tlm', scope: scope, token: token)
333
+ LimitsEventTopic.read(offset, count: count, scope: scope)
334
+ end
335
+
336
+ ###########################################################################
337
+ # PRIVATE implementation details
338
+ ###########################################################################
339
+
340
+ def _limits_group(group_name, action:, scope:, token:)
341
+ authorize(permission: 'tlm_set', scope: scope, token: token)
342
+ group_name.upcase!
343
+ group = get_limits_groups()[group_name]
344
+ raise "LIMITS_GROUP #{group_name} undefined. Ensure your telemetry definition contains the line: LIMITS_GROUP #{group_name}" unless group
345
+
346
+ Logger.info("Disabling Limits Group: #{group_name}")
347
+ last_target_name = nil
348
+ last_packet_name = nil
349
+ packet = nil
350
+ group.sort.each do |target_name, packet_name, item_name|
351
+ if last_target_name != target_name || last_packet_name != packet_name
352
+ if last_target_name && last_packet_name
353
+ TargetModel.set_packet(last_target_name, last_packet_name, packet, scope: scope)
354
+ end
355
+ packet = TargetModel.packet(target_name, packet_name, scope: scope)
356
+ end
357
+ packet['items'].each do |item|
358
+ if item['name'] == item_name
359
+ if action == :enable
360
+ item['limits']['enabled'] = true
361
+ elsif action == :disable
362
+ item['limits'].delete('enabled')
363
+ end
364
+ break
365
+ end
366
+ end
367
+ last_target_name = target_name
368
+ last_packet_name = packet_name
369
+ end
370
+ if last_target_name && last_packet_name
371
+ TargetModel.set_packet(last_target_name, last_packet_name, packet, scope: scope)
372
+ end
373
+ end
374
+ end
375
+ end
@@ -0,0 +1,117 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+
16
+ # Modified by OpenC3, Inc.
17
+ # All changes Copyright 2022, OpenC3, Inc.
18
+ # All Rights Reserved
19
+
20
+ require 'openc3/models/router_model'
21
+ require 'openc3/models/router_status_model'
22
+ require 'openc3/topics/router_topic'
23
+
24
+ module OpenC3
25
+ module Api
26
+ WHITELIST ||= []
27
+ WHITELIST.concat([
28
+ 'get_router',
29
+ 'get_router_names',
30
+ 'connect_router',
31
+ 'disconnect_router',
32
+ 'start_raw_logging_router',
33
+ 'stop_raw_logging_router',
34
+ 'get_all_router_info',
35
+ ])
36
+
37
+ # Get information about a router
38
+ #
39
+ # @param router_name [String] Router name
40
+ # @return [Hash] Hash of all the router information
41
+ def get_router(router_name, scope: $openc3_scope, token: $openc3_token)
42
+ authorize(permission: 'system', router_name: router_name, scope: scope, token: token)
43
+ router = RouterModel.get(name: router_name, scope: scope)
44
+ raise "Router '#{router_name}' does not exist" unless router
45
+
46
+ router.merge(RouterStatusModel.get(name: router_name, scope: scope))
47
+ end
48
+
49
+ # @return [Array<String>] All the router names
50
+ def get_router_names(scope: $openc3_scope, token: $openc3_token)
51
+ authorize(permission: 'system', scope: scope, token: token)
52
+ RouterModel.names(scope: scope)
53
+ end
54
+
55
+ # Connects a router and starts its command gathering thread
56
+ #
57
+ # @param router_name [String] Name of router
58
+ # @param params [Array] Parameters to pass to the router.
59
+ def connect_router(router_name, *params, scope: $openc3_scope, token: $openc3_token)
60
+ authorize(permission: 'system_set', router_name: router_name, scope: scope, token: token)
61
+ RouterTopic.connect_router(router_name, scope: scope)
62
+ end
63
+
64
+ # Disconnects a router and kills its command gathering thread
65
+ #
66
+ # @param router_name [String] Name of router
67
+ def disconnect_router(router_name, scope: $openc3_scope, token: $openc3_token)
68
+ authorize(permission: 'system_set', router_name: router_name, scope: scope, token: token)
69
+ RouterTopic.disconnect_router(router_name, scope: scope)
70
+ end
71
+
72
+ # Starts raw logging for a router
73
+ #
74
+ # @param router_name [String] The name of the interface
75
+ def start_raw_logging_router(router_name = 'ALL', scope: $openc3_scope, token: $openc3_token)
76
+ authorize(permission: 'system_set', router_name: router_name, scope: scope, token: token)
77
+ if router_name == 'ALL'
78
+ get_router_names().each do |router_name|
79
+ RouterTopic.start_raw_logging(router_name, scope: scope)
80
+ end
81
+ else
82
+ RouterTopic.start_raw_logging(router_name, scope: scope)
83
+ end
84
+ end
85
+
86
+ # Stop raw logging for a router
87
+ #
88
+ # @param router_name [String] The name of the interface
89
+ def stop_raw_logging_router(router_name = 'ALL', scope: $openc3_scope, token: $openc3_token)
90
+ authorize(permission: 'system_set', router_name: router_name, scope: scope, token: token)
91
+ if router_name == 'ALL'
92
+ get_router_names().each do |router_name|
93
+ RouterTopic.stop_raw_logging(router_name, scope: scope)
94
+ end
95
+ else
96
+ RouterTopic.stop_raw_logging(router_name, scope: scope)
97
+ end
98
+ end
99
+
100
+ # Consolidate all router info into a single API call
101
+ #
102
+ # @return [Array<Array<String, Numeric, Numeric, Numeric, Numeric, Numeric,
103
+ # Numeric, Numeric>>] Array of Arrays containing \[name, state, num clients,
104
+ # TX queue size, RX queue size, TX bytes, RX bytes, Command count,
105
+ # Telemetry count] for all routers
106
+ def get_all_router_info(scope: $openc3_scope, token: $openc3_token)
107
+ authorize(permission: 'system', scope: scope, token: token)
108
+ info = []
109
+ RouterStatusModel.all(scope: scope).each do |router_name, router|
110
+ info << [router['name'], router['state'], router['clients'], router['txsize'], router['rxsize'],\
111
+ router['txbytes'], router['rxbytes'], router['rxcnt'], router['txcnt']]
112
+ end
113
+ info.sort! { |a, b| a[0] <=> b[0] }
114
+ info
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,70 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+
16
+ # Modified by OpenC3, Inc.
17
+ # All changes Copyright 2022, OpenC3, Inc.
18
+ # All Rights Reserved
19
+
20
+ module OpenC3
21
+ module Api
22
+ WHITELIST ||= []
23
+ WHITELIST.concat([
24
+ 'list_settings',
25
+ 'get_all_settings',
26
+ 'get_setting',
27
+ 'get_settings',
28
+ 'save_setting'
29
+ ])
30
+
31
+ def list_settings(scope: $openc3_scope, token: $openc3_token)
32
+ authorize(permission: 'system', scope: scope, token: token)
33
+ SettingsModel.names(scope: scope)
34
+ end
35
+
36
+ def get_all_settings(scope: $openc3_scope, token: $openc3_token)
37
+ authorize(permission: 'system', scope: scope, token: token)
38
+ SettingsModel.all(scope: scope)
39
+ end
40
+
41
+ def get_setting(name, scope: $openc3_scope, token: $openc3_token)
42
+ authorize(permission: 'system', scope: scope, token: token)
43
+ setting = SettingsModel.get(name: name, scope: scope)
44
+ if setting
45
+ return setting["data"]
46
+ else
47
+ return nil
48
+ end
49
+ end
50
+
51
+ def get_settings(*args, scope: $openc3_scope, token: $openc3_token)
52
+ authorize(permission: 'system', scope: scope, token: token)
53
+ ret = []
54
+ args.each do |name|
55
+ setting = SettingsModel.get(name: name, scope: scope)
56
+ if setting
57
+ ret << setting["data"]
58
+ else
59
+ ret << nil
60
+ end
61
+ end
62
+ return ret
63
+ end
64
+
65
+ def save_setting(name, data, scope: $openc3_scope, token: $openc3_token)
66
+ authorize(permission: 'admin', scope: scope, token: token)
67
+ SettingsModel.set({ name: name, data: data }, scope: scope)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,78 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 Ball Aerospace & Technologies Corp.
4
+ # All Rights Reserved.
5
+ #
6
+ # This program is free software; you can modify and/or redistribute it
7
+ # under the terms of the GNU Affero General Public License
8
+ # as published by the Free Software Foundation; version 3 with
9
+ # attribution addendums as found in the LICENSE.txt
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU Affero General Public License for more details.
15
+
16
+ # Modified by OpenC3, Inc.
17
+ # All changes Copyright 2022, OpenC3, Inc.
18
+ # All Rights Reserved
19
+
20
+ require 'openc3/models/target_model'
21
+
22
+ module OpenC3
23
+ module Api
24
+ WHITELIST ||= []
25
+ WHITELIST.concat([
26
+ 'get_target_list',
27
+ 'get_target',
28
+ 'get_all_target_info',
29
+ ])
30
+
31
+ # Returns the list of all target names
32
+ #
33
+ # @return [Array<String>] All target names
34
+ def get_target_list(scope: $openc3_scope, token: $openc3_token)
35
+ authorize(permission: 'tlm', scope: scope, token: token)
36
+ TargetModel.names(scope: scope)
37
+ end
38
+
39
+ # Gets the full target hash
40
+ #
41
+ # @since 5.0.0
42
+ # @param target_name [String] Target name
43
+ # @return [Hash] Hash of all the target properties
44
+ def get_target(target_name, scope: $openc3_scope, token: $openc3_token)
45
+ authorize(permission: 'system', target_name: target_name, scope: scope, token: token)
46
+ TargetModel.get(name: target_name, scope: scope)
47
+ end
48
+
49
+ # Get information about all targets
50
+ #
51
+ # @return [Array<Array<String, Numeric, Numeric>] Array of Arrays \[name, interface, cmd_cnt, tlm_cnt]
52
+ def get_all_target_info(scope: $openc3_scope, token: $openc3_token)
53
+ authorize(permission: 'system', scope: scope, token: token)
54
+ info = []
55
+ get_target_list(scope: scope, token: token).each do |target_name|
56
+ cmd_cnt = 0
57
+ packets = TargetModel.packets(target_name, type: :CMD, scope: scope)
58
+ packets.each do |packet|
59
+ cmd_cnt += Topic.get_cnt("#{scope}__COMMAND__{#{target_name}}__#{packet['packet_name']}")
60
+ end
61
+ tlm_cnt = 0
62
+ packets = TargetModel.packets(target_name, type: :TLM, scope: scope)
63
+ packets.each do |packet|
64
+ tlm_cnt += Topic.get_cnt("#{scope}__TELEMETRY__{#{target_name}}__#{packet['packet_name']}")
65
+ end
66
+ interface_name = ''
67
+ InterfaceModel.all(scope: scope).each do |name, interface|
68
+ if interface['target_names'].include? target_name
69
+ interface_name = interface['name']
70
+ break
71
+ end
72
+ end
73
+ info << [target_name, interface_name, cmd_cnt, tlm_cnt]
74
+ end
75
+ info
76
+ end
77
+ end
78
+ end