lib/openc3/models/cvt_model.rb in openc3-5.14.2 vs lib/openc3/models/cvt_model.rb in openc3-5.15.0
- old
+ new
@@ -19,10 +19,11 @@
#
# This file may also be used under the terms of a commercial license
# if purchased from OpenC3, Inc.
require 'openc3/utilities/store'
+require 'openc3/utilities/store_queued'
require 'openc3/models/target_model'
module OpenC3
class CvtModel
@@packet_cache = {}
@@ -40,16 +41,20 @@
@@packet_cache[tgt_pkt_key] = nil
Store.hdel(key, packet_name)
end
# Set the current value table for a target, packet
- def self.set(hash, target_name:, packet_name:, scope: $openc3_scope)
+ def self.set(hash, target_name:, packet_name:, queued: false, scope: $openc3_scope)
packet_json = JSON.generate(hash.as_json(:allow_nan => true))
key = "#{scope}__tlm__#{target_name}"
tgt_pkt_key = key + "__#{packet_name}"
@@packet_cache[tgt_pkt_key] = [Time.now, hash]
- Store.hset(key, packet_name, packet_json)
+ if queued
+ StoreQueued.hset(key, packet_name, packet_json)
+ else
+ Store.hset(key, packet_name, packet_json)
+ end
end
# Get the hash for packet in the CVT
# Note: Does not apply overrides
def self.get(target_name:, packet_name:, cache_timeout: nil, scope: $openc3_scope)
@@ -66,11 +71,11 @@
@@packet_cache[tgt_pkt_key] = [now, hash]
hash
end
# Set an item in the current value table
- def self.set_item(target_name, packet_name, item_name, value, type:, scope: $openc3_scope)
+ def self.set_item(target_name, packet_name, item_name, value, type:, queued: false, scope: $openc3_scope)
hash = get(target_name: target_name, packet_name: packet_name, cache_timeout: nil, scope: scope)
case type
when :WITH_UNITS
hash["#{item_name}__U"] = value.to_s # WITH_UNITS should always be a string
when :FORMATTED
@@ -85,10 +90,10 @@
hash["#{item_name}__C"] = value
hash[item_name] = value
else
raise "Unknown type '#{type}' for #{target_name} #{packet_name} #{item_name}"
end
- set(hash, target_name: target_name, packet_name: packet_name, scope: scope)
+ set(hash, target_name: target_name, packet_name: packet_name, queued: queued, scope: scope)
end
# Get an item from the current value table
def self.get_item(target_name, packet_name, item_name, type:, cache_timeout: nil, scope: $openc3_scope)
result, types = self._handle_item_override(target_name, packet_name, item_name, type: type, cache_timeout: cache_timeout, scope: scope)