openc3 5.0.11 → 5.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of openc3 might be problematic. Click here for more details.

Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +3 -0
  3. data/LICENSE.txt +7 -5
  4. data/README.md +11 -9
  5. data/Rakefile +3 -0
  6. data/bin/cstol_converter +3 -0
  7. data/bin/openc3cli +29 -18
  8. data/bin/rubysloc +3 -0
  9. data/data/config/screen.yaml +10 -2
  10. data/data/config/target.yaml +1 -1
  11. data/data/config/widgets.yaml +6 -6
  12. data/ext/mkrf_conf.rb +3 -0
  13. data/ext/openc3/ext/array/array.c +3 -0
  14. data/ext/openc3/ext/buffered_file/buffered_file.c +3 -0
  15. data/ext/openc3/ext/config_parser/config_parser.c +3 -0
  16. data/ext/openc3/ext/crc/crc.c +3 -0
  17. data/ext/openc3/ext/openc3_io/openc3_io.c +3 -0
  18. data/ext/openc3/ext/packet/packet.c +3 -0
  19. data/ext/openc3/ext/platform/platform.c +3 -0
  20. data/ext/openc3/ext/polynomial_conversion/polynomial_conversion.c +3 -0
  21. data/ext/openc3/ext/string/string.c +3 -0
  22. data/ext/openc3/ext/structure/structure.c +3 -0
  23. data/ext/openc3/ext/tabbed_plots_config/tabbed_plots_config.c +3 -0
  24. data/ext/openc3/ext/telemetry/telemetry.c +3 -0
  25. data/lib/cosmos.rb +3 -0
  26. data/lib/cosmosc2.rb +3 -0
  27. data/lib/openc3/accessors/accessor.rb +3 -0
  28. data/lib/openc3/accessors/binary_accessor.rb +3 -0
  29. data/lib/openc3/accessors/cbor_accessor.rb +3 -0
  30. data/lib/openc3/accessors/html_accessor.rb +3 -0
  31. data/lib/openc3/accessors/json_accessor.rb +4 -1
  32. data/lib/openc3/accessors/xml_accessor.rb +3 -0
  33. data/lib/openc3/accessors.rb +3 -0
  34. data/lib/openc3/api/api.rb +3 -0
  35. data/lib/openc3/api/authorized_api.rb +3 -0
  36. data/lib/openc3/api/cmd_api.rb +6 -3
  37. data/lib/openc3/api/config_api.rb +3 -0
  38. data/lib/openc3/api/interface_api.rb +6 -2
  39. data/lib/openc3/api/limits_api.rb +54 -61
  40. data/lib/openc3/api/router_api.rb +6 -3
  41. data/lib/openc3/api/settings_api.rb +3 -0
  42. data/lib/openc3/api/target_api.rb +3 -0
  43. data/lib/openc3/api/tlm_api.rb +27 -32
  44. data/lib/openc3/bridge/bridge.rb +3 -0
  45. data/lib/openc3/bridge/bridge_config.rb +3 -0
  46. data/lib/openc3/bridge/bridge_interface_thread.rb +3 -0
  47. data/lib/openc3/bridge/bridge_router_thread.rb +3 -0
  48. data/lib/openc3/ccsds/ccsds_packet.rb +3 -0
  49. data/lib/openc3/ccsds/ccsds_parser.rb +3 -0
  50. data/lib/openc3/config/config_parser.rb +3 -0
  51. data/lib/openc3/config/meta_config_parser.rb +3 -0
  52. data/lib/openc3/conversions/conversion.rb +3 -0
  53. data/lib/openc3/conversions/generic_conversion.rb +3 -0
  54. data/lib/openc3/conversions/packet_time_formatted_conversion.rb +3 -0
  55. data/lib/openc3/conversions/packet_time_seconds_conversion.rb +3 -0
  56. data/lib/openc3/conversions/polynomial_conversion.rb +3 -0
  57. data/lib/openc3/conversions/processor_conversion.rb +3 -0
  58. data/lib/openc3/conversions/received_count_conversion.rb +3 -0
  59. data/lib/openc3/conversions/received_time_formatted_conversion.rb +3 -0
  60. data/lib/openc3/conversions/received_time_seconds_conversion.rb +3 -0
  61. data/lib/openc3/conversions/segmented_polynomial_conversion.rb +3 -0
  62. data/lib/openc3/conversions/unix_time_conversion.rb +3 -0
  63. data/lib/openc3/conversions/unix_time_formatted_conversion.rb +3 -0
  64. data/lib/openc3/conversions/unix_time_seconds_conversion.rb +3 -0
  65. data/lib/openc3/conversions.rb +3 -0
  66. data/lib/openc3/core_ext/array.rb +3 -0
  67. data/lib/openc3/core_ext/binding.rb +3 -0
  68. data/lib/openc3/core_ext/class.rb +3 -0
  69. data/lib/openc3/core_ext/exception.rb +3 -0
  70. data/lib/openc3/core_ext/file.rb +3 -0
  71. data/lib/openc3/core_ext/hash.rb +3 -0
  72. data/lib/openc3/core_ext/io.rb +3 -0
  73. data/lib/openc3/core_ext/kernel.rb +3 -0
  74. data/lib/openc3/core_ext/math.rb +3 -0
  75. data/lib/openc3/core_ext/matrix.rb +3 -0
  76. data/lib/openc3/core_ext/objectspace.rb +3 -0
  77. data/lib/openc3/core_ext/openc3_io.rb +3 -0
  78. data/lib/openc3/core_ext/range.rb +3 -0
  79. data/lib/openc3/core_ext/socket.rb +3 -0
  80. data/lib/openc3/core_ext/string.rb +3 -0
  81. data/lib/openc3/core_ext/stringio.rb +3 -0
  82. data/lib/openc3/core_ext/tempfile.rb +3 -0
  83. data/lib/openc3/core_ext/time.rb +3 -0
  84. data/lib/openc3/core_ext.rb +3 -0
  85. data/lib/openc3/interfaces/interface.rb +3 -0
  86. data/lib/openc3/interfaces/linc_interface.rb +3 -0
  87. data/lib/openc3/interfaces/protocols/burst_protocol.rb +3 -0
  88. data/lib/openc3/interfaces/protocols/crc_protocol.rb +3 -0
  89. data/lib/openc3/interfaces/protocols/fixed_protocol.rb +3 -0
  90. data/lib/openc3/interfaces/protocols/ignore_packet_protocol.rb +3 -0
  91. data/lib/openc3/interfaces/protocols/length_protocol.rb +3 -0
  92. data/lib/openc3/interfaces/protocols/override_protocol.rb +3 -0
  93. data/lib/openc3/interfaces/protocols/preidentified_protocol.rb +3 -0
  94. data/lib/openc3/interfaces/protocols/protocol.rb +3 -0
  95. data/lib/openc3/interfaces/protocols/template_protocol.rb +3 -0
  96. data/lib/openc3/interfaces/protocols/terminated_protocol.rb +3 -0
  97. data/lib/openc3/interfaces/serial_interface.rb +3 -0
  98. data/lib/openc3/interfaces/simulated_target_interface.rb +3 -0
  99. data/lib/openc3/interfaces/stream_interface.rb +3 -0
  100. data/lib/openc3/interfaces/tcpip_client_interface.rb +3 -0
  101. data/lib/openc3/interfaces/tcpip_server_interface.rb +3 -0
  102. data/lib/openc3/interfaces/udp_interface.rb +3 -0
  103. data/lib/openc3/interfaces.rb +3 -0
  104. data/lib/openc3/io/buffered_file.rb +3 -0
  105. data/lib/openc3/io/io_multiplexer.rb +8 -0
  106. data/lib/openc3/io/json_api_object.rb +5 -2
  107. data/lib/openc3/io/json_drb.rb +3 -0
  108. data/lib/openc3/io/json_drb_object.rb +5 -2
  109. data/lib/openc3/io/json_drb_rack.rb +3 -0
  110. data/lib/openc3/io/json_rpc.rb +8 -3
  111. data/lib/openc3/io/openc3_snmp.rb +3 -0
  112. data/lib/openc3/io/posix_serial_driver.rb +3 -0
  113. data/lib/openc3/io/raw_logger.rb +3 -0
  114. data/lib/openc3/io/raw_logger_pair.rb +3 -0
  115. data/lib/openc3/io/serial_driver.rb +3 -0
  116. data/lib/openc3/io/stderr.rb +3 -0
  117. data/lib/openc3/io/stdout.rb +3 -0
  118. data/lib/openc3/io/udp_sockets.rb +3 -0
  119. data/lib/openc3/io/win32_serial_driver.rb +3 -0
  120. data/lib/openc3/logs/buffered_packet_log_reader.rb +65 -0
  121. data/lib/openc3/logs/buffered_packet_log_writer.rb +120 -0
  122. data/lib/openc3/logs/log_writer.rb +95 -40
  123. data/lib/openc3/logs/packet_log_constants.rb +9 -0
  124. data/lib/openc3/logs/packet_log_reader.rb +34 -3
  125. data/lib/openc3/logs/packet_log_writer.rb +85 -18
  126. data/lib/openc3/logs/text_log_writer.rb +9 -5
  127. data/lib/openc3/logs.rb +8 -2
  128. data/lib/openc3/microservices/cleanup_microservice.rb +18 -18
  129. data/lib/openc3/microservices/decom_microservice.rb +30 -24
  130. data/lib/openc3/microservices/interface_microservice.rb +136 -91
  131. data/lib/openc3/microservices/log_microservice.rb +35 -13
  132. data/lib/openc3/microservices/microservice.rb +16 -14
  133. data/lib/openc3/microservices/plugin_microservice.rb +3 -1
  134. data/lib/openc3/microservices/reaction_microservice.rb +4 -1
  135. data/lib/openc3/microservices/reducer_microservice.rb +332 -149
  136. data/lib/openc3/microservices/router_microservice.rb +3 -0
  137. data/lib/openc3/microservices/text_log_microservice.rb +22 -7
  138. data/lib/openc3/microservices/timeline_microservice.rb +4 -1
  139. data/lib/openc3/microservices/trigger_group_microservice.rb +3 -0
  140. data/lib/openc3/models/activity_model.rb +3 -0
  141. data/lib/openc3/models/auth_model.rb +3 -0
  142. data/lib/openc3/models/cvt_model.rb +14 -5
  143. data/lib/openc3/models/environment_model.rb +3 -0
  144. data/lib/openc3/models/gem_model.rb +30 -51
  145. data/lib/openc3/models/info_model.rb +3 -0
  146. data/lib/openc3/models/interface_model.rb +3 -0
  147. data/lib/openc3/models/interface_status_model.rb +4 -1
  148. data/lib/openc3/models/metadata_model.rb +3 -0
  149. data/lib/openc3/models/metric_model.rb +3 -0
  150. data/lib/openc3/models/microservice_model.rb +9 -6
  151. data/lib/openc3/models/microservice_status_model.rb +4 -1
  152. data/lib/openc3/models/model.rb +3 -0
  153. data/lib/openc3/models/note_model.rb +3 -0
  154. data/lib/openc3/models/notification_model.rb +3 -0
  155. data/lib/openc3/models/ping_model.rb +3 -0
  156. data/lib/openc3/models/plugin_model.rb +20 -14
  157. data/lib/openc3/models/process_status_model.rb +4 -1
  158. data/lib/openc3/models/reaction_model.rb +3 -0
  159. data/lib/openc3/models/reducer_model.rb +31 -24
  160. data/lib/openc3/models/router_model.rb +3 -0
  161. data/lib/openc3/models/router_status_model.rb +3 -0
  162. data/lib/openc3/models/scope_model.rb +3 -4
  163. data/lib/openc3/models/settings_model.rb +3 -0
  164. data/lib/openc3/models/sorted_model.rb +3 -0
  165. data/lib/openc3/models/target_model.rb +61 -94
  166. data/lib/openc3/models/timeline_model.rb +4 -1
  167. data/lib/openc3/models/tool_config_model.rb +3 -0
  168. data/lib/openc3/models/tool_model.rb +11 -9
  169. data/lib/openc3/models/trigger_group_model.rb +3 -0
  170. data/lib/openc3/models/trigger_model.rb +3 -0
  171. data/lib/openc3/models/widget_model.rb +18 -11
  172. data/lib/openc3/operators/microservice_operator.rb +3 -0
  173. data/lib/openc3/operators/operator.rb +105 -34
  174. data/lib/openc3/packets/commands.rb +3 -0
  175. data/lib/openc3/packets/json_packet.rb +87 -14
  176. data/lib/openc3/packets/limits.rb +4 -1
  177. data/lib/openc3/packets/limits_response.rb +3 -0
  178. data/lib/openc3/packets/packet.rb +5 -1
  179. data/lib/openc3/packets/packet_config.rb +3 -0
  180. data/lib/openc3/packets/packet_item.rb +9 -3
  181. data/lib/openc3/packets/packet_item_limits.rb +3 -0
  182. data/lib/openc3/packets/parsers/format_string_parser.rb +3 -0
  183. data/lib/openc3/packets/parsers/limits_parser.rb +3 -0
  184. data/lib/openc3/packets/parsers/limits_response_parser.rb +3 -0
  185. data/lib/openc3/packets/parsers/packet_item_parser.rb +3 -0
  186. data/lib/openc3/packets/parsers/packet_parser.rb +3 -0
  187. data/lib/openc3/packets/parsers/processor_parser.rb +3 -0
  188. data/lib/openc3/packets/parsers/state_parser.rb +3 -0
  189. data/lib/openc3/packets/parsers/xtce_converter.rb +3 -0
  190. data/lib/openc3/packets/parsers/xtce_parser.rb +3 -0
  191. data/lib/openc3/packets/structure.rb +3 -0
  192. data/lib/openc3/packets/structure_item.rb +3 -0
  193. data/lib/openc3/packets/telemetry.rb +3 -0
  194. data/lib/openc3/processors/processor.rb +3 -0
  195. data/lib/openc3/processors/statistics_processor.rb +3 -0
  196. data/lib/openc3/processors/watermark_processor.rb +3 -0
  197. data/lib/openc3/processors.rb +3 -0
  198. data/lib/openc3/script/api_shared.rb +35 -6
  199. data/lib/openc3/script/calendar.rb +3 -0
  200. data/lib/openc3/script/commands.rb +3 -0
  201. data/lib/openc3/script/exceptions.rb +3 -0
  202. data/lib/openc3/script/extract.rb +3 -0
  203. data/lib/openc3/script/limits.rb +3 -24
  204. data/lib/openc3/script/script.rb +11 -7
  205. data/lib/openc3/script/script_runner.rb +3 -0
  206. data/lib/openc3/script/storage.rb +33 -16
  207. data/lib/openc3/script/suite.rb +3 -0
  208. data/lib/openc3/script/suite_results.rb +3 -0
  209. data/lib/openc3/script/suite_runner.rb +3 -0
  210. data/lib/openc3/script/telemetry.rb +43 -0
  211. data/lib/openc3/script.rb +3 -0
  212. data/lib/openc3/streams/serial_stream.rb +3 -0
  213. data/lib/openc3/streams/stream.rb +3 -0
  214. data/lib/openc3/streams/tcpip_client_stream.rb +3 -0
  215. data/lib/openc3/streams/tcpip_socket_stream.rb +3 -0
  216. data/lib/openc3/system/system.rb +23 -10
  217. data/lib/openc3/system/system_config.rb +3 -0
  218. data/lib/openc3/system/target.rb +3 -0
  219. data/lib/openc3/system.rb +3 -0
  220. data/lib/openc3/tools/cmd_tlm_server/api.rb +3 -0
  221. data/lib/openc3/tools/cmd_tlm_server/cmd_tlm_server_config.rb +3 -0
  222. data/lib/openc3/tools/cmd_tlm_server/interface_thread.rb +3 -0
  223. data/lib/openc3/tools/table_manager/table.rb +3 -0
  224. data/lib/openc3/tools/table_manager/table_config.rb +3 -0
  225. data/lib/openc3/tools/table_manager/table_item.rb +3 -0
  226. data/lib/openc3/tools/table_manager/table_item_parser.rb +3 -0
  227. data/lib/openc3/tools/table_manager/table_manager_core.rb +3 -0
  228. data/lib/openc3/tools/table_manager/table_parser.rb +3 -0
  229. data/lib/openc3/tools/test_runner/test.rb +3 -0
  230. data/lib/openc3/top_level.rb +3 -0
  231. data/lib/openc3/topics/autonomic_topic.rb +3 -0
  232. data/lib/openc3/topics/calendar_topic.rb +3 -0
  233. data/lib/openc3/topics/command_decom_topic.rb +4 -1
  234. data/lib/openc3/topics/command_topic.rb +6 -1
  235. data/lib/openc3/topics/config_topic.rb +3 -0
  236. data/lib/openc3/topics/interface_topic.rb +9 -2
  237. data/lib/openc3/topics/limits_event_topic.rb +144 -10
  238. data/lib/openc3/topics/notifications_topic.rb +3 -0
  239. data/lib/openc3/topics/router_topic.rb +10 -3
  240. data/lib/openc3/topics/telemetry_decom_topic.rb +26 -20
  241. data/lib/openc3/topics/telemetry_reduced_topics.rb +92 -0
  242. data/lib/openc3/topics/telemetry_topic.rb +5 -2
  243. data/lib/openc3/topics/timeline_topic.rb +3 -0
  244. data/lib/openc3/topics/topic.rb +3 -0
  245. data/lib/openc3/utilities/authentication.rb +3 -0
  246. data/lib/openc3/utilities/authorization.rb +3 -0
  247. data/lib/openc3/utilities/aws_bucket.rb +199 -0
  248. data/lib/openc3/utilities/bucket.rb +82 -0
  249. data/lib/openc3/utilities/bucket_file_cache.rb +264 -0
  250. data/lib/openc3/utilities/bucket_utilities.rb +109 -0
  251. data/lib/openc3/utilities/crc.rb +3 -0
  252. data/lib/openc3/utilities/csv.rb +3 -0
  253. data/lib/openc3/utilities/local_bucket.rb +28 -0
  254. data/lib/openc3/utilities/local_mode.rb +47 -61
  255. data/lib/openc3/utilities/logger.rb +7 -1
  256. data/lib/openc3/utilities/message_log.rb +7 -4
  257. data/lib/openc3/utilities/metric.rb +4 -1
  258. data/lib/openc3/utilities/open_telemetry.rb +96 -0
  259. data/lib/openc3/utilities/process_manager.rb +3 -0
  260. data/lib/openc3/utilities/quaternion.rb +3 -0
  261. data/lib/openc3/utilities/ruby_lex_utils.rb +3 -0
  262. data/lib/openc3/utilities/s3_autoload.rb +3 -3
  263. data/lib/openc3/utilities/simulated_target.rb +3 -0
  264. data/lib/openc3/utilities/sleeper.rb +3 -0
  265. data/lib/openc3/utilities/store.rb +3 -0
  266. data/lib/openc3/utilities/store_autoload.rb +30 -23
  267. data/lib/openc3/utilities/target_file.rb +70 -83
  268. data/lib/openc3/utilities/zip.rb +3 -0
  269. data/lib/openc3/utilities.rb +3 -0
  270. data/lib/openc3/version.rb +6 -6
  271. data/lib/openc3/win32/excel.rb +3 -0
  272. data/lib/openc3/win32/win32.rb +3 -0
  273. data/lib/openc3/win32/win32_main.rb +3 -0
  274. data/lib/openc3.rb +3 -0
  275. data/tasks/gemfile_stats.rake +3 -0
  276. data/tasks/spec.rake +3 -0
  277. data/templates/plugin-template/plugin.gemspec +1 -1
  278. metadata +112 -6
  279. data/lib/openc3/utilities/s3.rb +0 -220
  280. data/lib/openc3/utilities/s3_file_cache.rb +0 -274
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  autoload(:Processor, 'openc3/processors/processor.rb')
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/script/extract'
21
24
 
@@ -238,7 +241,7 @@ module OpenC3
238
241
  if value.is_a?(Array)
239
242
  expected_value, tolerance = array_tolerance_process_args(value.size, expected_value, tolerance, 'wait_tolerance', scope: scope, token: token)
240
243
 
241
- success, value = openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scop, token: token)
244
+ success, value = openc3_script_wait_implementation_array_tolerance(value.size, target_name, packet_name, item_name, type, expected_value, tolerance, timeout, polling_rate, scope: scope, token: token)
242
245
  time = Time.now.sys - start_time
243
246
 
244
247
  message = ""
@@ -463,6 +466,18 @@ module OpenC3
463
466
  end
464
467
  end
465
468
 
469
+ def set_max_output(characters)
470
+ if defined? RunningScript
471
+ RunningScript.max_output_characters = Integer(characters)
472
+ end
473
+ end
474
+
475
+ def get_max_output
476
+ if defined? RunningScript
477
+ RunningScript.max_output_characters
478
+ end
479
+ end
480
+
466
481
  ###########################################################################
467
482
  # Scripts Outside of ScriptRunner Support
468
483
  # ScriptRunner overrides these methods to work in the OpenC3 cluster
@@ -563,6 +578,8 @@ module OpenC3
563
578
  scope: $openc3_scope, token: $openc3_token)
564
579
  type = (check ? 'CHECK' : 'WAIT')
565
580
  initial_count = tlm(target_name, packet_name, 'RECEIVED_COUNT', scope: scope, token: token)
581
+ # If the packet has not been received the initial_count could be nil
582
+ initial_count = 0 unless initial_count
566
583
  start_time = Time.now.sys
567
584
  success, value = openc3_script_wait_implementation(target_name,
568
585
  packet_name,
@@ -573,6 +590,8 @@ module OpenC3
573
590
  polling_rate,
574
591
  scope: scope,
575
592
  token: token)
593
+ # If the packet has not been received the value could be nil
594
+ value = 0 unless value
576
595
  time = Time.now.sys - start_time
577
596
  if success
578
597
  Logger.info "#{type}: #{target_name.upcase} #{packet_name.upcase} received #{value - initial_count} times after waiting #{time} seconds"
@@ -704,8 +723,13 @@ module OpenC3
704
723
  return true, value
705
724
  end
706
725
  else
707
- if eval(exp_to_eval)
708
- return true, value
726
+ begin
727
+ if eval(exp_to_eval)
728
+ return true, value
729
+ end
730
+ # NoMethodError is raised when the tlm() returns nil and we try to eval the expression
731
+ # In this case we just continue and see if eventually we get a good value from tlm()
732
+ rescue NoMethodError
709
733
  end
710
734
  end
711
735
  break if Time.now.sys >= end_time
@@ -719,9 +743,14 @@ module OpenC3
719
743
 
720
744
  if canceled
721
745
  value = tlm(target_name, packet_name, item_name, type: value_type, scope: scope, token: token)
722
- if eval(exp_to_eval)
723
- return true, value
724
- else
746
+ begin
747
+ if eval(exp_to_eval)
748
+ return true, value
749
+ else
750
+ return false, value
751
+ end
752
+ # NoMethodError is raised when the tlm() returns nil and we try to eval the expression
753
+ rescue NoMethodError
725
754
  return false, value
726
755
  end
727
756
  end
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/script/extract'
21
24
  require 'time'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/packets/packet'
21
24
  require 'openc3/script/extract'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  # Error raised by the API when a check fails
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/utilities/store'
21
24
 
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  module Script
@@ -32,29 +35,5 @@ module OpenC3
32
35
  end
33
36
  end
34
37
  end
35
-
36
- def get_limits_events(offset = nil, count: 100, scope: $openc3_scope)
37
- result = $api_server.get_limits_events(offset, count: count, scope: scope)
38
- if result
39
- result[0] = result[0].to_s.intern
40
- if result[0] == :LIMITS_CHANGE
41
- result[1][3] = result[1][3].to_s.intern if result[1][3]
42
- result[1][4] = result[1][4].to_s.intern if result[1][4]
43
- if result[1][5] and result[1][6]
44
- result[1][5] = Time.at(result[1][5], result[1][6]).sys
45
- result[1].delete_at(6)
46
- end
47
- elsif result[0] == :LIMITS_SETTINGS
48
- result[1][3] = result[1][3].to_s.intern if result[1][3]
49
- elsif result[0] == :STALE_PACKET
50
- # Nothing extra to do
51
- elsif result[0] == :STALE_PACKET_RCVD
52
- # Nothing extra to do
53
- else
54
- result[1] = result[1].to_s.intern
55
- end
56
- end
57
- result
58
- end
59
38
  end
60
39
  end
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3'
21
24
  require 'openc3/api/api'
@@ -23,6 +26,7 @@ require 'openc3/io/json_drb_object'
23
26
  require 'openc3/script/api_shared'
24
27
  require 'openc3/script/calendar'
25
28
  require 'openc3/script/commands'
29
+ require 'openc3/script/telemetry'
26
30
  require 'openc3/script/limits'
27
31
  require 'openc3/script/exceptions'
28
32
  require 'openc3/script/script_runner'
@@ -68,7 +72,7 @@ module OpenC3
68
72
  shutdown_script()
69
73
  $disconnect = false
70
74
  $api_server = ServerProxy.new
71
- if $api_server.generate_url =~ /openc3-cmd-tlm-api/
75
+ if $api_server.generate_url =~ /openc3-cosmos-cmd-tlm-api/
72
76
  $openc3_in_cluster = true
73
77
  else
74
78
  $openc3_in_cluster = false
@@ -178,16 +182,16 @@ module OpenC3
178
182
 
179
183
  # Provides a proxy to the JsonDRbObject which communicates with the API server
180
184
  class ServerProxy
181
- # pull openc3-cmd-tlm-api url from environment variables
185
+ # pull openc3-cosmos-cmd-tlm-api url from environment variables
182
186
  def generate_url
183
187
  schema = ENV['OPENC3_API_SCHEMA'] || 'http'
184
- hostname = ENV['OPENC3_API_HOSTNAME'] || (ENV['OPENC3_DEVEL'] ? '127.0.0.1' : 'openc3-cmd-tlm-api')
188
+ hostname = ENV['OPENC3_API_HOSTNAME'] || (ENV['OPENC3_DEVEL'] ? '127.0.0.1' : 'openc3-cosmos-cmd-tlm-api')
185
189
  port = ENV['OPENC3_API_PORT'] || '2901'
186
190
  port = port.to_i
187
191
  return "#{schema}://#{hostname}:#{port}"
188
192
  end
189
193
 
190
- # pull openc3-cmd-tlm-api timeout from environment variables
194
+ # pull openc3-cosmos-cmd-tlm-api timeout from environment variables
191
195
  def generate_timeout
192
196
  timeout = ENV['OPENC3_API_TIMEOUT'] || '1.0'
193
197
  return timeout.to_f
@@ -244,16 +248,16 @@ module OpenC3
244
248
 
245
249
  # Provides a proxy to the Script Runner Api which communicates with the API server
246
250
  class ScriptServerProxy
247
- # pull openc3-script-runner-api url from environment variables
251
+ # pull openc3-cosmos-script-runner-api url from environment variables
248
252
  def generate_url
249
253
  schema = ENV['OPENC3_SCRIPT_API_SCHEMA'] || 'http'
250
- hostname = ENV['OPENC3_SCRIPT_API_HOSTNAME'] || (ENV['OPENC3_DEVEL'] ? '127.0.0.1' : 'openc3-script-runner-api')
254
+ hostname = ENV['OPENC3_SCRIPT_API_HOSTNAME'] || (ENV['OPENC3_DEVEL'] ? '127.0.0.1' : 'openc3-cosmos-script-runner-api')
251
255
  port = ENV['OPENC3_SCRIPT_API_PORT'] || '2902'
252
256
  port = port.to_i
253
257
  return "#{schema}://#{hostname}:#{port}"
254
258
  end
255
259
 
256
- # pull openc3-cmd-tlm-api timeout from environment variables
260
+ # pull openc3-cosmos-script-runner-api timeout from environment variables
257
261
  def generate_timeout
258
262
  timeout = ENV['OPENC3_SCRIPT_API_TIMEOUT'] || '5.0'
259
263
  return timeout.to_f
@@ -12,6 +12,9 @@
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
14
  # GNU Affero General Public License for more details.
15
+ #
16
+ # This file may also be used under the terms of a commercial license
17
+ # if purchased from OpenC3, Inc.
15
18
 
16
19
  module OpenC3
17
20
  module Script
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'tempfile'
21
24
  require 'net/http'
@@ -33,7 +36,8 @@ module OpenC3
33
36
  delete_path = "#{scope}/targets_modified/#{path}"
34
37
  endpoint = "/openc3-api/storage/delete/#{delete_path}"
35
38
  OpenC3::Logger.info "Deleting #{delete_path}"
36
- response = $api_server.request('delete', endpoint, query: {bucket: 'config'}, scope: scope)
39
+ # Pass the name of the ENV variable name where we pull the actual bucket name
40
+ response = $api_server.request('delete', endpoint, query: { bucket: 'OPENC3_CONFIG_BUCKET' }, scope: scope)
37
41
  if response.nil? || response.code != 200
38
42
  raise "Failed to delete #{delete_path}"
39
43
  end
@@ -58,27 +62,28 @@ module OpenC3
58
62
  end
59
63
 
60
64
  endpoint = "/openc3-api/storage/upload/#{upload_path}"
61
- OpenC3::Logger.info "Writing #{upload_path}"
62
65
  result = _get_presigned_request(endpoint, scope: scope)
66
+ OpenC3::Logger.info "Writing #{upload_path} at #{result['url']}"
63
67
 
64
68
  # Try to put the file
65
- success = false
66
69
  begin
67
70
  uri = _get_uri(result['url'])
68
- Net::HTTP.start(uri.host, uri.port) do |http|
71
+ Net::HTTP.start(uri.host, uri.port) do
69
72
  request = Net::HTTP::Put.new(uri, {'Content-Length' => io_or_string.length.to_s})
70
73
  if String === io_or_string
71
74
  request.body = io_or_string
72
75
  else
73
76
  request.body_stream = io_or_string
74
77
  end
75
- result = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
76
- http.request(request)
78
+ response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
79
+ http.request(request) do |response|
80
+ response.value() # Raises an HTTP error if the response is not 2xx (success)
81
+ return response
82
+ end
77
83
  end
78
- return result
79
84
  end
80
85
  rescue => error
81
- raise "Failed to write #{upload_path}"
86
+ raise "Failed to write #{upload_path} due to #{error.message}"
82
87
  end
83
88
  nil
84
89
  end
@@ -125,16 +130,19 @@ module OpenC3
125
130
  file = Tempfile.new('target', binmode: true)
126
131
 
127
132
  endpoint = "/openc3-api/storage/download/#{scope}/#{path}"
128
- OpenC3::Logger.info "Reading #{scope}/#{path}"
129
133
  result = _get_presigned_request(endpoint, scope: scope)
134
+ OpenC3::Logger.info "Reading #{scope}/#{path} at #{result['url']}"
130
135
 
131
136
  # Try to get the file
132
137
  uri = _get_uri(result['url'])
133
- Net::HTTP.start(uri.host, uri.port) do |http|
138
+ Net::HTTP.start(uri.host, uri.port) do
134
139
  request = Net::HTTP::Get.new uri
135
- http.request request do |response|
136
- response.read_body do |chunk|
137
- file.write chunk
140
+ Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
141
+ http.request(request) do |response|
142
+ response.value() # Raises an HTTP error if the response is not 2xx (success)
143
+ response.read_body do |chunk|
144
+ file.write chunk
145
+ end
138
146
  end
139
147
  end
140
148
  file.rewind
@@ -144,7 +152,16 @@ module OpenC3
144
152
 
145
153
  def _get_uri(url)
146
154
  if $openc3_in_cluster
147
- uri = URI.parse("http://openc3-minio:9000" + url)
155
+ case ENV['OPENC3_CLOUD']
156
+ when 'local'
157
+ uri = URI.parse("http://openc3-minio:9000" + url)
158
+ # when 'aws'
159
+ when 'gcp'
160
+ uri = URI.parse("https://storage.googleapis.com" + url)
161
+ # when 'azure'
162
+ else
163
+ raise "Unknown cloud #{ENV['OPENC3_CLOUD']}"
164
+ end
148
165
  else
149
166
  uri = URI.parse($api_server.generate_url + url)
150
167
  end
@@ -152,9 +169,9 @@ module OpenC3
152
169
 
153
170
  def _get_presigned_request(endpoint, scope: $openc3_scope)
154
171
  if $openc3_in_cluster
155
- response = $api_server.request('get', endpoint, query: { bucket: 'config', internal: true }, scope: scope)
172
+ response = $api_server.request('get', endpoint, query: { bucket: 'OPENC3_CONFIG_BUCKET', internal: true }, scope: scope)
156
173
  else
157
- response = $api_server.request('get', endpoint, query: { bucket: 'config' }, scope: scope)
174
+ response = $api_server.request('get', endpoint, query: { bucket: 'OPENC3_CONFIG_BUCKET' }, scope: scope)
158
175
  end
159
176
  if response.nil? || response.code != 201
160
177
  raise "Failed to get presigned URL for #{endpoint}"
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/script/exceptions'
21
24
  require 'openc3/core_ext/stringio'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  class SuiteResults
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/script/suite'
21
24
  require 'openc3/script/suite_results'
@@ -0,0 +1,43 @@
1
+ # encoding: ascii-8bit
2
+
3
+ # Copyright 2022 OpenC3, Inc.
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
+ # This file may also be used under the terms of a commercial license
17
+ # if purchased from OpenC3, Inc.
18
+
19
+ module OpenC3
20
+ module Script
21
+ private
22
+
23
+ # Get packets based on ID returned from subscribe_packet.
24
+ # @param id [String] ID returned from subscribe_packets or last call to get_packets
25
+ # @param block [Float] Time in seconds to wait for packets to be received
26
+ # @param block_delay [Float] Time in seconds to sleep between polls
27
+ # @param count [Integer] Maximum number of packets to return from EACH packet stream
28
+ # @return [Array<String, Array<Hash>] Array of the ID and array of all packets found
29
+ def get_packets(id, block: nil, block_delay: 0.1, count: 1000, scope: $openc3_scope, token: $openc3_token)
30
+ start_time = Time.now
31
+ end_time = start_time + block if block
32
+ while true
33
+ id, packets = $api_server.public_send(:get_packets, id, count: count, scope: scope, token: token)
34
+ if block and Time.now < end_time and packets.empty?
35
+ openc3_script_sleep(block_delay)
36
+ else
37
+ break
38
+ end
39
+ end
40
+ return id, packets
41
+ end
42
+ end
43
+ end
data/lib/openc3/script.rb CHANGED
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/script/script'
21
24
  include OpenC3::Script
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'thread' # For Mutex
21
24
  require 'openc3/streams/stream'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  # Class that implments the following methods: read, write(data),
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'socket'
21
24
  require 'thread' # For Mutex
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'socket'
21
24
  require 'thread' # For Mutex
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/config/config_parser'
21
24
  require 'openc3/packets/packet_config'
@@ -24,9 +27,9 @@ require 'openc3/packets/commands'
24
27
  require 'openc3/packets/telemetry'
25
28
  require 'openc3/packets/limits'
26
29
  require 'openc3/system/target'
27
- require 'openc3/utilities/s3'
30
+ require 'openc3/utilities/bucket'
28
31
  require 'openc3/utilities/zip'
29
- require 'openc3/models/scope_model'
32
+ require 'openc3/topics/limits_event_topic'
30
33
  require 'thread'
31
34
  require 'fileutils'
32
35
 
@@ -53,22 +56,32 @@ module OpenC3
53
56
  # Mutex used to ensure that only one instance of System is created
54
57
  @@instance_mutex = Mutex.new
55
58
 
59
+ # The current limits set
60
+ @@limits_set = nil
61
+
56
62
  # @return [Symbol] The current limits_set of the system returned from Redis
57
63
  def self.limits_set
58
- ScopeModel.limits_set(scope: $openc3_scope)
64
+ unless @@limits_set
65
+ @@limits_set = LimitsEventTopic.current_set(scope: $openc3_scope).to_s.intern
66
+ end
67
+ @@limits_set
68
+ end
69
+
70
+ def self.limits_set=(value)
71
+ @@limits_set = value.to_s.intern
59
72
  end
60
73
 
61
74
  def self.setup_targets(target_names, base_dir, scope:)
62
75
  FileUtils.mkdir_p("#{base_dir}/targets")
63
- rubys3_client = Aws::S3::Client.new
76
+ bucket = Bucket.getClient()
64
77
  target_names.each do |target_name|
65
78
  # Retrieve bucket/targets/target_name/target_id.zip
66
- response_target = "#{base_dir}/targets/#{target_name}_current.zip"
67
- FileUtils.mkdir_p(File.dirname(response_target))
68
- s3_key = "#{scope}/target_archives/#{target_name}/#{target_name}_current.zip"
69
- Logger.info("Retrieving #{s3_key} from targets bucket")
70
- rubys3_client.get_object(bucket: "config", key: s3_key, response_target: response_target)
71
- Zip::File.open(response_target) do |zip_file|
79
+ zip_path = "#{base_dir}/targets/#{target_name}_current.zip"
80
+ FileUtils.mkdir_p(File.dirname(zip_path))
81
+ bucket_key = "#{scope}/target_archives/#{target_name}/#{target_name}_current.zip"
82
+ Logger.info("Retrieving #{bucket_key} from targets bucket")
83
+ bucket.get_object(bucket: ENV['OPENC3_CONFIG_BUCKET'], key: bucket_key, path: zip_path)
84
+ Zip::File.open(zip_path) do |zip_file|
72
85
  zip_file.each do |entry|
73
86
  path = File.join("#{base_dir}/targets", entry.name)
74
87
  FileUtils.mkdir_p(File.dirname(path))
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/config/config_parser'
21
24
  require 'openc3/packets/packet_config'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/config/config_parser'
21
24
  require 'pathname'
data/lib/openc3/system.rb CHANGED
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  autoload(:Target, "openc3/system/target.rb")
@@ -16,5 +16,8 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/api/api'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/config/config_parser'
21
24
 
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  module OpenC3
21
24
  # Encapsulates an {Interface} in a Ruby thread. When the thread is started by
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/packets/packet'
21
24
  require 'openc3/tools/table_manager/table_item'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/config/config_parser'
21
24
  require 'openc3/packets/packet_config'
@@ -16,6 +16,9 @@
16
16
  # Modified by OpenC3, Inc.
17
17
  # All changes Copyright 2022, OpenC3, Inc.
18
18
  # All Rights Reserved
19
+ #
20
+ # This file may also be used under the terms of a commercial license
21
+ # if purchased from OpenC3, Inc.
19
22
 
20
23
  require 'openc3/packets/packet_item'
21
24