Class: OpenC3::DiscoveryTopic
- Defined in:
- lib/openc3/topics/discovery_topic.rb
Overview
Discovery requests are published to a bridge hub (bridge_microservice) which hands them to openc3-cosmos-app. openc3-cosmos-app runs the Python Discovery class on the host and the hub publishes the result back on the result topic. See openc3/python/openc3/topics/discovery_topic.py
Constant Summary collapse
- DISCOVERY_TIMEOUT_S =
30
Constants inherited from Topic
Topic::DEFAULT_LOG_CYCLE_TIME_SECONDS, Topic::LOG_CLEANUP_DELAY_SECONDS, Topic::LOG_CYCLE_LOOKUP_RETRY_SECONDS, Topic::STREAM_MAX_AGE_DEFAULT_SECONDS, Topic::STREAM_MAX_AGE_MIN_SECONDS
Class Method Summary collapse
-
.discover(bridge_name, discovery, timeout: nil, scope:) ⇒ Array<Hash>
Run a discovery on the host connected to the given bridge.
- .request_topic(bridge_name, scope:) ⇒ Object
- .result_topic(bridge_name, scope:) ⇒ Object
-
.scan(bridge_name, scan, timeout: nil, scope:) ⇒ Hash
Scan the host connected to the given bridge for hardware and check it against discovery matchers (see openc3/python/openc3/discovery/discovery_scan.py).
Methods inherited from Topic
all_same_db_shard?, clear_stream_max_age_cache, clear_topics, del, get_cnt, get_last_offset, get_newest_message, get_oldest_message, group_topics_by_db_shard, log_stream_max_age_ms, log_stream_min_age_seconds, log_stream_safety_minid, method_missing, read_topics, stream_max_age_ms, stream_max_age_seconds, stream_safety_minid, target_name_from_topic, trim_topic, update_topic_offsets, write_ack, write_topic
Class Method Details
.discover(bridge_name, discovery, timeout: nil, scope:) ⇒ Array<Hash>
Run a discovery on the host connected to the given bridge
39 40 41 42 |
# File 'lib/openc3/topics/discovery_topic.rb', line 39 def self.discover(bridge_name, discovery, timeout: nil, scope:) result = request(bridge_name, { 'discovery' => JSON.generate(discovery) }, timeout: timeout, scope: scope) result['results'] || [] end |
.request_topic(bridge_name, scope:) ⇒ Object
25 26 27 |
# File 'lib/openc3/topics/discovery_topic.rb', line 25 def self.request_topic(bridge_name, scope:) "#{scope}__DISCOVERY__#{bridge_name}" end |
.result_topic(bridge_name, scope:) ⇒ Object
29 30 31 |
# File 'lib/openc3/topics/discovery_topic.rb', line 29 def self.result_topic(bridge_name, scope:) "#{scope}__DISCOVERY_RESULT__#{bridge_name}" end |
.scan(bridge_name, scan, timeout: nil, scope:) ⇒ Hash
Scan the host connected to the given bridge for hardware and check it against discovery matchers (see openc3/python/openc3/discovery/discovery_scan.py)
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/openc3/topics/discovery_topic.rb', line 51 def self.scan(bridge_name, scan, timeout: nil, scope:) # An empty discovery makes an openc3-cosmos-app without scan support answer with an error fields = { 'discovery' => '[]', 'scan' => JSON.generate(scan) } result = request(bridge_name, fields, timeout: timeout, scope: scope) return result['scan'] if result['scan'] raise "openc3-cosmos-app on the host for bridge '#{bridge_name}' does not support hardware discovery. Update openc3-cosmos-app." rescue RuntimeError => error raise "openc3-cosmos-app on the host for bridge '#{bridge_name}' does not support hardware discovery. Update openc3-cosmos-app." if error. == 'no discovery class given' raise end |