openc3 5.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,49 @@
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/conversions/unix_time_conversion'
21
+
22
+ module OpenC3
23
+ # Converts a unix format time: Epoch Jan 1 1970, seconds and microseconds,
24
+ # into a formatted string.
25
+ class UnixTimeFormattedConversion < UnixTimeConversion
26
+ # Initializes converted_type to :STRING and converted_bit_size to 0
27
+ #
28
+ # @param seconds_item_name [String] The telemetry item in the packet which
29
+ # represents the number of seconds since the UNIX time epoch
30
+ # @param microseconds_item_name [String] The telemetry item in the packet
31
+ # which represents microseconds
32
+ def initialize(seconds_item_name, microseconds_item_name = nil)
33
+ super(seconds_item_name, microseconds_item_name)
34
+ @converted_type = :STRING
35
+ @converted_bit_size = 0
36
+ end
37
+
38
+ # @param (see Conversion#call)
39
+ # @return [String] Formatted packet time
40
+ def call(value, packet, buffer)
41
+ super.formatted
42
+ end
43
+
44
+ # @return [String] The name of the class followed by the time conversion
45
+ def to_s
46
+ super << ".formatted"
47
+ end
48
+ end # class UnixTimeFormattedConversion
49
+ end
@@ -0,0 +1,49 @@
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/conversions/unix_time_conversion'
21
+
22
+ module OpenC3
23
+ # Converts a unix format time: Epoch Jan 1 1970, seconds and microseconds,
24
+ # into a floating point number.
25
+ class UnixTimeSecondsConversion < UnixTimeConversion
26
+ # Initializes converted_type to :FLOAT and converted_bit_size to 64
27
+ #
28
+ # @param seconds_item_name [String] The telemetry item in the packet which
29
+ # represents the number of seconds since the UNIX time epoch
30
+ # @param microseconds_item_name [String] The telemetry item in the packet
31
+ # which represents microseconds
32
+ def initialize(seconds_item_name, microseconds_item_name = nil)
33
+ super(seconds_item_name, microseconds_item_name)
34
+ @converted_type = :FLOAT
35
+ @converted_bit_size = 64
36
+ end
37
+
38
+ # @param (see Conversion#call)
39
+ # @return [Float] Packet time in seconds since UNIX epoch
40
+ def call(value, packet, buffer)
41
+ super.to_f
42
+ end
43
+
44
+ # @return [String] The name of the class followed by the time conversion
45
+ def to_s
46
+ super << ".to_f"
47
+ end
48
+ end # class UnixTimeSecondsConversion
49
+ end
@@ -0,0 +1,34 @@
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
+ autoload(:Conversion, 'openc3/conversions/conversion.rb')
22
+ autoload(:GenericConversion, 'openc3/conversions/generic_conversion.rb')
23
+ autoload(:PacketTimeFormattedConversion, 'openc3/conversions/packet_time_formatted_conversion.rb')
24
+ autoload(:PacketTimeSecondsConversion, 'openc3/conversions/packet_time_seconds_conversion.rb')
25
+ autoload(:PolynomialConversion, 'openc3/conversions/polynomial_conversion.rb')
26
+ autoload(:ProcessorConversion, 'openc3/conversions/processor_conversion.rb')
27
+ autoload(:ReceivedCountConversion, 'openc3/conversions/received_count_conversion.rb')
28
+ autoload(:ReceivedTimeFormattedConversion, 'openc3/conversions/received_time_formatted_conversion.rb')
29
+ autoload(:ReceivedTimeSecondsConversion, 'openc3/conversions/received_time_seconds_conversion.rb')
30
+ autoload(:SegmentedPolynomialConversion, 'openc3/conversions/segmented_polynomial_conversion.rb')
31
+ autoload(:UnixTimeConversion, 'openc3/conversions/unix_time_conversion.rb')
32
+ autoload(:UnixTimeFormattedConversion, 'openc3/conversions/unix_time_formatted_conversion.rb')
33
+ autoload(:UnixTimeSecondsConversion, 'openc3/conversions/unix_time_seconds_conversion.rb')
34
+ end
@@ -0,0 +1,416 @@
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/ext/array' if RUBY_ENGINE == 'ruby' and !ENV['OPENC3_NO_EXT']
21
+
22
+ # OpenC3 specific additions to the Ruby Array class
23
+ class Array
24
+ # Redefine inspect to only print for small numbers of
25
+ # items. Prevents exceptions taking forever to be raise with
26
+ # large objects. See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/105145
27
+ alias old_inspect inspect
28
+
29
+ # @param max_elements [Integer] The maximum number of elements in the array to
30
+ # print out before simply displaying the array class and object id
31
+ # @return [String] String representation of the array
32
+ def inspect(max_elements = 10)
33
+ if self.length <= max_elements
34
+ old_inspect()
35
+ else
36
+ '#<' + self.class.to_s + ':' + self.object_id.to_s + '>'
37
+ end
38
+ end
39
+
40
+ # @return [Array] Cloned array after all elements called to_f
41
+ def clone_to_f
42
+ new_array = self.class.new(0)
43
+ self.each do |value|
44
+ new_array << value.to_f
45
+ end
46
+ new_array
47
+ end
48
+
49
+ # Returns the array index nearest to the passed in value. This only makes sense
50
+ # for numerical arrays containing integers or floats. It has an optimized
51
+ # algorithm if the array is sorted but will fail if passed unsorted data with
52
+ # the sorted option.
53
+ #
54
+ # @param value [Numeric] A value to search for in the array
55
+ # @param ordered_data [Boolean] Whether or not the data is sorted
56
+ # @return [Integer] The index of the element closest to value
57
+ def nearest_index(value, ordered_data = true)
58
+ raise "Cannot search on empty array" if self.empty?
59
+
60
+ if ordered_data
61
+ last_index = self.length - 1
62
+ first_value = self[0].to_f
63
+ last_value = self[-1].to_f
64
+ return 0 if first_value == last_value
65
+
66
+ slope = last_index.to_f / (last_value - first_value)
67
+ offset = -(slope * first_value)
68
+ guess_index = ((slope * value.to_f) + offset).to_i
69
+
70
+ # Return immediately for boundary conditions
71
+ return 0 if guess_index < 0
72
+ return last_index if guess_index > last_index
73
+
74
+ # Verify guess index
75
+ previous_guess_index = nil
76
+ previous_guess_value = nil
77
+
78
+ # While in the valid range of indexes
79
+ while guess_index >= 0 and guess_index <= last_index
80
+
81
+ # Retrieve the value at our current guess index
82
+ guess_value = self[guess_index]
83
+
84
+ # We're done if we found the exact value
85
+ return guess_index if guess_value == value
86
+
87
+ if previous_guess_value # Determine if we did better or worse
88
+ # Was previous guess better or worse?
89
+ if (guess_value - value).abs <= (previous_guess_value - value).abs
90
+ # Previous Guess Worse or the same
91
+ if guess_value > value # Moving with decreasing indexes
92
+ if previous_guess_value > value # Still moving in right direction
93
+ previous_guess_index = guess_index
94
+ guess_index -= 1
95
+ else # We passed the value
96
+ return guess_index
97
+ end
98
+ else # guess_value < value and moving with increasing indexes
99
+ if previous_guess_value < value # Still moving in right direction
100
+ previous_guess_index = guess_index
101
+ guess_index += 1
102
+ else # We passed the value
103
+ return guess_index
104
+ end
105
+ end
106
+ else
107
+ # Previous Guess Better
108
+ return previous_guess_index
109
+ end
110
+ else # Move to the next point
111
+ previous_guess_index = guess_index
112
+ if guess_value > value
113
+ guess_index -= 1
114
+ else # guess_value < value
115
+ guess_index += 1
116
+ end
117
+ end
118
+ previous_guess_value = guess_value
119
+ end
120
+
121
+ # Return our best guess
122
+ return 0 if guess_index < 0
123
+
124
+ return last_index
125
+ else # Brute force search
126
+ # Calculate the initial delta
127
+ min_delta = (self[0] - value).abs
128
+ closest_index = 0
129
+ self.each_with_index do |self_value, index|
130
+ # Calculate the delta between the current value and value we are
131
+ # searching for
132
+ delta = (value - self_value).abs
133
+ # If the newly calculate delta is less than or equal to are previous
134
+ # minimum delta then we proceed
135
+ if delta <= min_delta
136
+ # There is a special case if the delta is equal to the previously
137
+ # calculated delta. We want to round up in this case so we check if
138
+ # the value we are searching for is greater than the current value.
139
+ # If so we skip this value since we don't want to round down.
140
+ next if (delta == min_delta) and (value > self_value)
141
+
142
+ min_delta = delta
143
+ closest_index = index
144
+ end
145
+ end
146
+ return closest_index
147
+ end
148
+ end
149
+
150
+ # Returns the index of the first element which is less than or equal to the
151
+ # passed in value.
152
+ #
153
+ # NOTE: This routine only works on sorted data!
154
+ #
155
+ # @param value [Numeric] The value to search for in the array
156
+ # @return [Fixnum] The index of the element which is less than or equal to
157
+ # the value
158
+ def index_lt_eq(value)
159
+ index = nearest_index(value)
160
+
161
+ # Keep backing up if self[index - 1] == value to move past duplicates
162
+ while index > 0 and self[index - 1] == value
163
+ index -= 1
164
+ end
165
+
166
+ return index if self[index] <= value
167
+
168
+ index -= 1 if index > 0
169
+ return index
170
+ end
171
+
172
+ # Returns the index of the last element which is greater than or equal to the
173
+ # passed in value.
174
+ #
175
+ # NOTE: This routine only works on sorted data!
176
+ #
177
+ # @param value [Numeric] The value to search for in the array
178
+ # @return [Fixnum] The index of the element which is greater than or equal to
179
+ # the value
180
+ def index_gt_eq(value)
181
+ index = nearest_index(value)
182
+ last_index = self.length - 1
183
+
184
+ # Keep moving forward if self[index - 1] == value to move past duplicates
185
+ while index < last_index and self[index + 1] == value
186
+ index += 1
187
+ end
188
+
189
+ return index if self[index] >= value
190
+
191
+ index += 1 if (self.length - 1) > index
192
+ return index
193
+ end
194
+
195
+ # Returns the range of array elements which contain both the start value and
196
+ # end value.
197
+ #
198
+ # NOTE: This routine only works on sorted data!
199
+ #
200
+ # @param start_value [Numeric] The start value to search for (must be less
201
+ # than end_value)
202
+ # @param end_value [Numeric] The end value to search for
203
+ # @return [Range] The range of array elements which contain both the
204
+ # start_value and end_value
205
+ def range_containing(start_value, end_value)
206
+ raise "end_value: #{end_value} must be greater than start_value: #{start_value}" if end_value < start_value
207
+
208
+ Range.new(index_lt_eq(start_value), index_gt_eq(end_value))
209
+ end
210
+
211
+ # Returns the range of array elements which within both the start value and
212
+ # end value.
213
+ #
214
+ # NOTE: This routine only works on sorted data!
215
+ #
216
+ # @param start_value [Numeric] The start value to search for (must be less
217
+ # than end_value)
218
+ # @param end_value [Numeric] The end value to search for
219
+ # @return [Range] The range of array elements which contain both the
220
+ # start_value and end_value
221
+ def range_within(start_value, end_value)
222
+ raise "end_value: #{end_value} must be greater than start_value: #{start_value}" if end_value < start_value
223
+
224
+ range = Range.new(index_gt_eq(start_value), index_lt_eq(end_value))
225
+ # Sometimes we get a backwards range so check for that and reverse it
226
+ range = Range.new(range.last, range.first) if range.last < range.first
227
+ range
228
+ end
229
+
230
+ if !(self.method_defined?(:sum))
231
+ # @return [Numeric] The sum of all the elements in the array
232
+ def sum
233
+ self.inject(0, :+)
234
+ end
235
+ end
236
+
237
+ # return [Float] The mean of all the elements in the array
238
+ def mean
239
+ return 0.0 if self.empty?
240
+
241
+ return self.sum / self.length.to_f
242
+ end
243
+
244
+ # return [Array] A new array with each value of the original squared
245
+ def squared
246
+ self.map { |value| value * value }
247
+ end
248
+
249
+ if RUBY_ENGINE != 'ruby' or ENV['OPENC3_NO_EXT']
250
+ # return [Numeric, Fixnum] The first maximum value and its index
251
+ def max_with_index
252
+ maximum = nil
253
+ maximum_index = nil
254
+
255
+ if self.length > 0
256
+ maximum = self[0]
257
+ maximum_index = 0
258
+
259
+ (1..(self.length - 1)).each do |index|
260
+ value = self[index]
261
+
262
+ if value > maximum
263
+ maximum = value
264
+ maximum_index = index
265
+ end
266
+ end
267
+ end
268
+
269
+ return [maximum, maximum_index]
270
+ end
271
+
272
+ # return [Numeric, Fixnum] The first minimum value and its index
273
+ def min_with_index
274
+ minimum = nil
275
+ minimum_index = nil
276
+
277
+ if self.length > 0
278
+ minimum = self[0]
279
+ minimum_index = 0
280
+
281
+ (1..(self.length - 1)).each do |index|
282
+ value = self[index]
283
+
284
+ if value < minimum
285
+ minimum = value
286
+ minimum_index = index
287
+ end
288
+ end
289
+ end
290
+
291
+ return [minimum, minimum_index]
292
+ end
293
+ end
294
+
295
+ # @param num_buckets [Integer] The number of buckets (groups of numbers) that
296
+ # will be used when histogramming. nil indicates to use as many buckets as
297
+ # necessary to cause each bucket to have a unique element.
298
+ # @param numeric [Boolean] Whether the array data is numeric
299
+ # @param block [Proc] If a block is given it will be called to sort buckets
300
+ # with the same object. This might be necessary if your data is not numeric
301
+ # and you want to override the way your objects compare.
302
+ # @return [Array<Array(first_value, last_value, num_values)>] Array of buckets
303
+ # which are arrays containing the first value that is found in the bucket,
304
+ # the last value found in the bucket, and the total number of values in the
305
+ # bucket.
306
+ def histogram(num_buckets = nil, numeric = false, &block)
307
+ buckets = {}
308
+
309
+ # Count the occurance of each value
310
+ self.each do |value|
311
+ buckets[value] ||= 0
312
+ buckets[value] += 1
313
+ end
314
+
315
+ # Sort buckets by value, use block for sorting if given
316
+ if block_given?
317
+ sorted_buckets = buckets.sort { |x, y| yield(x, y) }
318
+ else
319
+ sorted_buckets = buckets.sort
320
+ end
321
+
322
+ reduced_buckets = []
323
+ if num_buckets
324
+ # Validate num_buckets
325
+ raise "Invalid num_buckets #{num_buckets}" if num_buckets.to_i <= 0
326
+
327
+ # Handle histogram types
328
+ if numeric
329
+ # Numeric histograms use the same sized range for each bucket
330
+ first_value = sorted_buckets[0][0]
331
+ last_value = sorted_buckets[-1][0]
332
+ delta = last_value - first_value
333
+ bucket_size = delta.to_f / num_buckets.to_f
334
+ integers = false
335
+ integers = true if first_value.kind_of?(Integer) and last_value.kind_of?(Integer)
336
+ if integers
337
+ bucket_size = bucket_size.ceil
338
+ last_value = first_value + bucket_size * num_buckets - 1
339
+ delta = last_value - first_value
340
+ (delta + 1).times do |index|
341
+ buckets[first_value + index] ||= 0
342
+ end
343
+ if block_given?
344
+ sorted_buckets = buckets.sort { |val1, val2| yield(val1, val2) }
345
+ else
346
+ sorted_buckets = buckets.sort
347
+ end
348
+ end
349
+ bucket_ranges = []
350
+ current_value = first_value
351
+ num_buckets.times do |bucket_index|
352
+ if bucket_index == (num_buckets - 1)
353
+ bucket_ranges[bucket_index] = (current_value)..(last_value)
354
+ else
355
+ if integers
356
+ bucket_ranges[bucket_index] = (current_value)..(current_value + bucket_size - 1)
357
+ else
358
+ bucket_ranges[bucket_index] = (current_value)..(current_value + bucket_size)
359
+ end
360
+ end
361
+ current_value += bucket_size
362
+ end
363
+
364
+ # Build the final buckets
365
+ first_index = 0
366
+ sorted_index = 0
367
+ num_buckets.times do |bucket_index|
368
+ break if sorted_index > (sorted_buckets.length - 1)
369
+
370
+ sum = 0
371
+ bucket_range = bucket_ranges[bucket_index]
372
+ while bucket_range.include?(sorted_buckets[sorted_index][0])
373
+ sum += sorted_buckets[sorted_index][1]
374
+ sorted_index += 1
375
+ break if sorted_index > (sorted_buckets.length - 1)
376
+ end
377
+ reduced_buckets[bucket_index] = [bucket_range.first, bucket_range.last, sum]
378
+ end
379
+ else
380
+ # Non-numeric histograms use the same number of items per bucket
381
+ items_per_bucket = sorted_buckets.length / num_buckets.to_i
382
+ items_per_bucket = 1 if items_per_bucket < 1
383
+ bucket_sizes = [items_per_bucket] * num_buckets
384
+ excess_items = sorted_buckets.length - (items_per_bucket * num_buckets)
385
+ if excess_items > 0
386
+ bucket_sizes.length.times do |bucket_size_index|
387
+ break if excess_items <= 0
388
+
389
+ bucket_sizes[bucket_size_index] += 1
390
+ excess_items -= 1
391
+ end
392
+ end
393
+
394
+ # Build the final buckets
395
+ first_index = 0
396
+ num_buckets.times do |bucket_index|
397
+ break if first_index > (sorted_buckets.length - 1)
398
+
399
+ if bucket_index == (num_buckets - 1)
400
+ last_index = sorted_buckets.length - 1
401
+ else
402
+ last_index = first_index + bucket_sizes[bucket_index] - 1
403
+ last_index = sorted_buckets.length - 1 if last_index > (sorted_buckets.length - 1)
404
+ end
405
+ sum = 0
406
+ sorted_buckets[first_index..last_index].each { |key, value| sum += value }
407
+ reduced_buckets[bucket_index] = [sorted_buckets[first_index][0], sorted_buckets[last_index][0], sum]
408
+ first_index = first_index + bucket_sizes[bucket_index]
409
+ end
410
+ end
411
+ else
412
+ sorted_buckets.each { |key, value| reduced_buckets << [key, key, value] }
413
+ end
414
+ reduced_buckets
415
+ end
416
+ end # class Array
@@ -0,0 +1,29 @@
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
+ # OpenC3 specific additions to the Ruby Binding class
21
+ class Binding
22
+ def set_variables(variables)
23
+ variables ||= {}
24
+ variables.each do |variables_key, variables_value|
25
+ local_variable_set(variables_key.intern, variables_value)
26
+ end
27
+ self
28
+ end
29
+ end
@@ -0,0 +1,72 @@
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
+ # OpenC3 specific additions to the Ruby Class class
21
+ class Class
22
+ # Creates instance variables in the class which have corresponding class
23
+ # method accessors. NOTE: You must define self.instance for this to work.
24
+ #
25
+ # For example:
26
+ # class MyClass
27
+ # instance_attr_reader :test
28
+ # @@instance = nil
29
+ # def self.instance
30
+ # @@instance ||= self.new
31
+ # return @@instance
32
+ # end
33
+ # def initialize
34
+ # @test = "Test"
35
+ # @@instance = self
36
+ # end
37
+ #
38
+ # Will allow the following:
39
+ # my = MyClass.new
40
+ # my.test # returns "Test"
41
+ # MyClass.test # returns "Test"
42
+ #
43
+ # @param args [Array<Symbol>] Array of symbols which should be turned into
44
+ # instance variables with class method readers
45
+ def instance_attr_reader(*args)
46
+ args.each do |arg|
47
+ # Non-word characters (letter, number, underscore) are disallowed
48
+ raise ArgumentError, "Non-word characters characters parsed" if arg =~ /\W/
49
+
50
+ # Fortify: Dynamic Code Evaluation: Code Injection
51
+ # This is true but we're whitelisting the input above
52
+ self.class_eval("def #{arg};@#{arg};end")
53
+ self.instance_eval("def #{arg};self.instance.#{arg};end")
54
+ end
55
+ end
56
+
57
+ # @param args [Array<Symbol>] Array of symbols which should be turned into
58
+ # instance variables with class method accessors (read and write)
59
+ def instance_attr_accessor(*args)
60
+ args.each do |arg|
61
+ # Non-word characters (letter, number, underscore) are disallowed
62
+ raise ArgumentError, "Non-word characters characters parsed" if arg =~ /\W/
63
+
64
+ # Fortify: Dynamic Code Evaluation: Code Injection
65
+ # This is true but we're whitelisting the input above
66
+ self.class_eval("def #{arg};@#{arg};end")
67
+ self.instance_eval("def #{arg};self.instance.#{arg};end")
68
+ self.class_eval("def #{arg}=(arg);@#{arg} = arg;end")
69
+ self.instance_eval("def #{arg}=(arg);self.instance.#{arg} = arg;end")
70
+ end
71
+ end
72
+ end