Method: OpenC3::TargetModel.get_telemetry_counts

Defined in:
lib/openc3/models/target_model.rb

.get_telemetry_counts(target_packets, scope:) ⇒ Object



1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
# File 'lib/openc3/models/target_model.rb', line 1302

def self.get_telemetry_counts(target_packets, scope:)
  result = []
  if $openc3_redis_cluster
    # No pipelining for cluster mode
    # because it requires using the same shard for all keys
    target_packets.each do |target_name, packet_name|
      target_name = target_name.upcase
      packet_name = packet_name.upcase
      result << Store.hget("#{scope}__TELEMETRYCNTS__{#{target_name}}", packet_name)
    end
  else
    result = Store.redis_pool.pipelined do
      target_packets.each do |target_name, packet_name|
        target_name = target_name.upcase
        packet_name = packet_name.upcase
        Store.hget("#{scope}__TELEMETRYCNTS__{#{target_name}}", packet_name)
      end
    end
  end
  counts = []
  result.each do |count|
    if count
      counts << count.to_i
    else
      counts << 0
    end
  end
  return counts
end