Class: OpenC3::DecomInterfaceTopic
- Inherits:
-
Topic
show all
- Defined in:
- lib/openc3/topics/decom_interface_topic.rb
Class Method Summary
collapse
-
.build_cmd(target_name, cmd_name, cmd_params, range_check, raw, timeout: 5, scope:) ⇒ Object
-
.get_tlm_buffer(target_name, packet_name, timeout: 5, scope:) ⇒ Object
-
.inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, stored: false, timeout: 5, scope:) ⇒ Object
Methods inherited from Topic
all_same_db_shard?, clear_topics, del, get_cnt, get_last_offset, get_newest_message, get_oldest_message, group_topics_by_db_shard, method_missing, read_topics, trim_topic, update_topic_offsets, write_ack, write_topic
Class Method Details
.build_cmd(target_name, cmd_name, cmd_params, range_check, raw, timeout: 5, scope:) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/openc3/topics/decom_interface_topic.rb', line 19
def self.build_cmd(target_name, cmd_name, cmd_params, range_check, raw, timeout: 5, scope:)
data = {}
data['target_name'] = target_name.to_s.upcase
data['cmd_name'] = cmd_name.to_s.upcase
data['cmd_params'] = cmd_params
data['range_check'] = range_check
data['raw'] = raw
db_shard = Store.db_shard_for_target(target_name, scope: scope)
ack_topic = "{#{scope}__ACKCMD}TARGET__#{target_name}"
Topic.update_topic_offsets([ack_topic], db_shard: db_shard)
decom_id = Topic.write_topic("#{scope}__DECOMINTERFACE__{#{target_name}}",
{ 'build_cmd' => JSON.generate(data, allow_nan: true) }, '*', 100, db_shard: db_shard)
time = Time.now
while (Time.now - time) < timeout
Topic.read_topics([ack_topic], db_shard: db_shard) do |_topic, _msg_id, msg_hash, _redis|
if msg_hash["id"] == decom_id
if msg_hash["result"] == "SUCCESS"
return msg_hash
else
raise msg_hash["result"]
end
end
end
end
raise "Timeout of #{timeout}s waiting for cmd ack. Does target '#{target_name}' exist?"
end
|
.get_tlm_buffer(target_name, packet_name, timeout: 5, scope:) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/openc3/topics/decom_interface_topic.rb', line 77
def self.get_tlm_buffer(target_name, packet_name, timeout: 5, scope:)
data = {}
data['target_name'] = target_name.to_s.upcase
data['packet_name'] = packet_name.to_s.upcase
db_shard = Store.db_shard_for_target(target_name, scope: scope)
ack_topic = "{#{scope}__ACKCMD}TARGET__#{target_name}"
Topic.update_topic_offsets([ack_topic], db_shard: db_shard)
decom_id = Topic.write_topic("#{scope}__DECOMINTERFACE__{#{target_name}}",
{ 'get_tlm_buffer' => JSON.generate(data, allow_nan: true) }, '*', 100, db_shard: db_shard)
time = Time.now
while (Time.now - time) < timeout
Topic.read_topics([ack_topic], db_shard: db_shard) do |_topic, _msg_id, msg_hash, _redis|
if msg_hash["id"] == decom_id
if msg_hash["result"] == "SUCCESS"
msg_hash["stored"] = ConfigParser.handle_true_false(msg_hash["stored"])
= msg_hash["extra"]
if and .length > 0
msg_hash["extra"] = JSON.parse(, allow_nan: true, create_additions: true)
end
return msg_hash
else
raise msg_hash["result"]
end
end
end
end
raise "Timeout of #{timeout}s waiting for ack. Does target '#{target_name}' exist?"
end
|
.inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, stored: false, timeout: 5, scope:) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/openc3/topics/decom_interface_topic.rb', line 49
def self.inject_tlm(target_name, packet_name, item_hash = nil, type: :CONVERTED, stored: false, timeout: 5, scope:)
data = {}
data['target_name'] = target_name.to_s.upcase
data['packet_name'] = packet_name.to_s.upcase
data['item_hash'] = item_hash
data['type'] = type
db_shard = Store.db_shard_for_target(target_name, scope: scope)
data['stored'] = stored
ack_topic = "{#{scope}__ACKCMD}TARGET__#{target_name}"
Topic.update_topic_offsets([ack_topic], db_shard: db_shard)
decom_id = Topic.write_topic("#{scope}__DECOMINTERFACE__{#{target_name}}",
{ 'inject_tlm' => JSON.generate(data, allow_nan: true) }, '*', 100, db_shard: db_shard)
time = Time.now
while (Time.now - time) < timeout
Topic.read_topics([ack_topic], db_shard: db_shard) do |_topic, _msg_id, msg_hash, _redis|
if msg_hash["id"] == decom_id
if msg_hash["result"] == "SUCCESS"
return
else
raise msg_hash["result"]
end
end
end
end
raise "Timeout of #{timeout}s waiting for cmd ack. Does target '#{target_name}' exist?"
end
|