Open Jesse-Millwood opened 10 months ago
Not well documented yet, but you are looking to use the Stream Api through our script/websocket_api_code code: https://github.com/OpenC3/cosmos/blob/main/openc3/lib/openc3/script/web_socket_api.rb
Something like this commented out example code from the bottom of the file:
OpenC3::StreamingWebSocketApi.new do |api|
api.add(items: ['DECOM__TLM__INST__HEALTH_STATUS__TEMP1__CONVERTED', 'DECOM__TLM__INST__HEALTH_STATUS__TEMP2__CONVERTED'])
5.times do
puts api.read
end
api.remove(items: ['DECOM__TLM__INST__HEALTH_STATUS__TEMP1__CONVERTED'])
5.times do
puts api.read
end
end
# Warning this saves all data to RAM. Do not use for large queries
data = OpenC3::StreamingWebSocketApi.read_all(items: ['DECOM__TLM__INST__HEALTH_STATUS__TEMP1__CONVERTED', 'DECOM__TLM__INST__HEALTH_STATUS__TEMP2__CONVERTED'], start_time: Time.now - 30, end_time: Time.now + 30)
I would like to access logged telemetry from a script for a couple of reasons:
Currently, I am printing out the start and end time of my script and using that in the Data Extractor so that I can archive the chunk of packets for a time frame.
I tried digging into how the Data Extractor does this and it seems like it uses ActionCable to get a subscription? I'm fairly unfamiliar with web programming and this type of architecture so I'm having some trouble connecting the dots here. I do see the streaming api, is that available to scripts in the script runner? It seems like with the container architecture, the data I want would be available, I'm just having trouble getting to it.
It seems like ActionCable is bundled with rails? If that is true, is it already available to scripts running from the script runner? If it is, how would a ruby script use the ActionCable library? I tried looking for actioncable in ruby files in openc3 and tried copying some of the lines into a script to see if I could just access ActionCable and it seems