Top Level Namespace

Includes:
Math, OpenC3::Script

Defined Under Namespace

Modules: Aws, CosmosCompatibility, Enumerable, Faraday, Kernel, MQTT, Math, ObjectSpace, OpenC3, OpenC3IO, Puma, QDA Classes: Array, Binding, BucketFile, BucketFileCache, Class, CriticalCmdError, Date, DateTime, DisabledError, EnvHelper, Exception, FalseClass, File, Float, Hash, HazardousError, IO, Matrix, NilClass, Numeric, Object, Range, Redis, Regexp, RubyLexUtils, RunningScript, Script, Socket, String, StringIO, Struct, Subpacketizer, Symbol, Tempfile, Time, TrueClass

Constant Summary collapse

OPENC3_VERSION =
'7.2.0'
Cosmos =
OpenC3
RAILS_ROOT =
File.expand_path(File.join(__dir__, '..', '..'))
SCRIPT_API =
'script-api'
RUNNING_SCRIPT_CHANNEL_PREFIX =

process.

'running-script-channel:'
RUNNING_SCRIPT_REPLAY_MAXLEN =
1000
RUNNING_SCRIPT_REPLAY_TTL =

seconds

86400
RUNNING_SCRIPT_REPLAY_FLUSH_INTERVAL =

Flush the replay queue quickly so live output/state stays near real-time while remaining non-blocking. Applied via set_update_interval in RunningScript’s initialize so it only affects this (running script) process.

0.1
DYNAMIC_STRING_LEN =
2048
INVALID_CHARS =
'[]./'
REPLACEMENT_CHAR =
'_'
ALIAS_NAMESPACE =
'COSMOS'
COMBINED_NAME =
"COMBINED"
MAX_64_BIT_INT =
18446744073709551614
COSMOS_NATIVE_DERIVED_ITEMS =
['PACKET_TIMESECONDS', 'PACKET_TIMEFORMATTED', 'RECEIVED_TIMESECONDS', 'RECEIVED_TIMEFORMATTED', 'RECEIVED_COUNT']
PACKET_TIME_STRING =
"PACKET_TIME"

Constants included from OpenC3::ApiShared

OpenC3::ApiShared::DEFAULT_TLM_POLLING_RATE

Constants included from OpenC3::Extract

OpenC3::Extract::SCANNING_REGULAR_EXPRESSION

Instance Method Summary collapse

Methods included from Math

#cos_squared, #luma_from_rgb_max_255, #sin_squared, #stddev_population, #stddev_sample, #variance_population, #variance_sample

Methods included from OpenC3::Script

included

Instance Method Details

#running_script_anycable_publish(channel_name, data) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/openc3/utilities/running_script.rb', line 69

def running_script_anycable_publish(channel_name, data)
  json = JSON.generate(data, allow_nan: true)
  if channel_name.start_with?(RUNNING_SCRIPT_CHANNEL_PREFIX)
    # Per-script events are delivered to the frontend by RunningScriptChannel
    # tailing this replay stream (backlog + live from a single ordered source),
    # so they are NOT broadcast over anycable pub/sub -- doing both would deliver
    # every message twice. Queued (EphemeralStoreQueued) so the script never
    # blocks on Redis; best-effort so a replay failure can never affect script
    # execution. Topic (read by the channel) uses the EphemeralStore.
    begin
      replay_key = "#{channel_name}:replay"
      OpenC3::EphemeralStoreQueued.instance.write_topic(replay_key, { 'data' => json }, '*', RUNNING_SCRIPT_REPLAY_MAXLEN, '~')
      OpenC3::EphemeralStoreQueued.instance.expire(replay_key, RUNNING_SCRIPT_REPLAY_TTL)
    rescue StandardError => e
      OpenC3::Logger.warn("running_script replay write failed: #{e.message}") rescue nil
    end
  else
    # Other channels (all-scripts, etc.) are still delivered live over pub/sub.
    stream_name = [SCRIPT_API, channel_name].compact.join(":")
    stream_data = {"stream" => stream_name, "data" => json}
    OpenC3::Store.publish("__anycable__", JSON.generate(stream_data, allow_nan: true))
  end
end

#running_script_publish(channel_name, data) ⇒ Object

seconds



64
65
66
67
# File 'lib/openc3/utilities/running_script.rb', line 64

def running_script_publish(channel_name, data)
  stream_name = [SCRIPT_API, channel_name].compact.join(":")
  OpenC3::Store.publish(stream_name, JSON.generate(data, allow_nan: true))
end