Skip to content

Commit

Permalink
Add READ_ONLY to meta_tlm
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Aug 18, 2017
2 parents 58c2583 + 6e44835 commit 8f4f0fa
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,4 @@ TELEMETRY SYSTEM META BIG_ENDIAN "System Meta Data Telemetry Packet"
META READ_ONLY
APPEND_ITEM RUBY_VERSION 240 STRING "Ruby Version"
META READ_ONLY

COMMAND SYSTEM META BIG_ENDIAN "System Meta Data Command Packet"
DISABLED
APPEND_ID_PARAMETER PKTID 8 UINT 1 1 1 "Packet Id"
APPEND_PARAMETER CONFIG 256 STRING "" "Configuration Name"
APPEND_PARAMETER COSMOS_VERSION 240 STRING "" "COSMOS Version"
APPEND_PARAMETER USER_VERSION 240 STRING "" "User Project Version"
APPEND_PARAMETER RUBY_VERSION 240 STRING "" "Ruby Version"
APPEND_ITEM OPERATOR_NAME 512 STRING "Operator Name"
9 changes: 9 additions & 0 deletions install/config/targets/SYSTEM/cmd_tlm/meta_tlm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
TELEMETRY SYSTEM META BIG_ENDIAN "System Meta Data Telemetry Packet"
APPEND_ID_ITEM PKTID 8 UINT 1 "Packet Id"
APPEND_ITEM CONFIG 256 STRING "Configuration Name"
APPEND_ITEM COSMOS_VERSION 240 STRING "COSMOS Version"
META READ_ONLY
APPEND_ITEM USER_VERSION 240 STRING "User Project Version"
META READ_ONLY
APPEND_ITEM RUBY_VERSION 240 STRING "Ruby Version"
META READ_ONLY
9 changes: 9 additions & 0 deletions lib/cosmos/packets/packet_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ def meta
@meta ||= {}
end

def meta=(meta)
if meta
raise ArgumentError, "#{@name}: meta must be a Hash but is a #{meta.class}" unless Hash === meta
@meta = meta.clone
else
@meta = nil
end
end

# Make a light weight clone of this item
def clone
item = super()
Expand Down
104 changes: 51 additions & 53 deletions lib/cosmos/system/system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def initialize(filename = nil)
@limits_set = :DEFAULT
@use_utc = false
@additional_md5_files = []
@meta_init_filename = nil

@ports = {}
@ports['CTS_API'] = 7777
Expand Down Expand Up @@ -150,7 +151,6 @@ def initialize(filename = nil)

@initial_filename = filename
@initial_config = nil
@meta_init_filename = nil
@@instance = self
end

Expand Down Expand Up @@ -687,64 +687,27 @@ def load_packets(configuration_name = nil)
def setup_system_meta
# Ensure SYSTEM META is defined and defined correctly
begin
if @commands.target_names.include?("SYSTEM")
pkts = @commands.packets('SYSTEM')
# User should not define COMMAND SYSTEM META as we build it to match TELEMETRY
raise "COMMAND SYSTEM META defined" if pkts.keys.include?('META')
end
tlm_meta = @telemetry.packet('SYSTEM', 'META')
cmd_meta = @commands.packet('SYSTEM', 'META')
item = tlm_meta.get_item('PKTID')
raise "PKTID Incorrect" unless (item.bit_size == 8) && (item.bit_offset == 0)
item = cmd_meta.get_item('PKTID')
raise "PKTID Incorrect" unless (item.bit_size == 8) && (item.bit_offset == 0)
raise "PKTID incorrect" unless (item.bit_size == 8) && (item.bit_offset == 0)
item = tlm_meta.get_item('CONFIG')
raise "CONFIG Incorrect" unless (item.bit_size == 256) && (item.bit_offset == 8)
item = cmd_meta.get_item('CONFIG')
raise "CONFIG Incorrect" unless (item.bit_size == 256) && (item.bit_offset == 8)
raise "CONFIG incorrect" unless (item.bit_size == 256) && (item.bit_offset == 8)
item = tlm_meta.get_item('COSMOS_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 264)
item = cmd_meta.get_item('COSMOS_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 264)
raise "COSMOS_VERSION incorrect" unless (item.bit_size == 240) && (item.bit_offset == 264)
item = tlm_meta.get_item('USER_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 504)
item = cmd_meta.get_item('USER_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 504)
raise "USER_VERSION incorrect" unless (item.bit_size == 240) && (item.bit_offset == 504)
item = tlm_meta.get_item('RUBY_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 744)
item = cmd_meta.get_item('RUBY_VERSION')
raise "CONFIG Incorrect" unless (item.bit_size == 240) && (item.bit_offset == 744)
rescue
Logger.error "SYSTEM META not defined or defined incorrectly - defaulting"

cmd_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
item = cmd_meta.append_item('PKTID', 8, :UINT, nil, :BIG_ENDIAN, :ERROR, nil, nil, nil, 1)
item.range = 1..1
item.default = 1
item.description = 'Packet Id'
item = cmd_meta.append_item('CONFIG', 32 * 8, :STRING)
item.default = ''
item.description = 'Configuration Name'
item = cmd_meta.append_item('COSMOS_VERSION', 30 * 8, :STRING)
item.default = ''
item.description = 'COSMOS Version'
item = cmd_meta.append_item('USER_VERSION', 30 * 8, :STRING)
item.default = ''
item.description = 'User Project Version'
item = cmd_meta.append_item('RUBY_VERSION', 30 * 8, :STRING)
item.default = ''
item.description = 'Ruby Version'
@config.commands['SYSTEM'] ||= {}
@config.commands['SYSTEM']['META'] = cmd_meta

tlm_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
item = tlm_meta.append_item('PKTID', 8, :UINT, nil, :BIG_ENDIAN, :ERROR, nil, nil, nil, 1)
item.description = 'Packet Id'
item = tlm_meta.append_item('CONFIG', 32 * 8, :STRING)
item.description = 'Configuration Name'
item = tlm_meta.append_item('COSMOS_VERSION', 30 * 8, :STRING)
item.description = 'COSMOS Version'
item = tlm_meta.append_item('USER_VERSION', 30 * 8, :STRING)
item.description = 'User Project Version'
item = tlm_meta.append_item('RUBY_VERSION', 30 * 8, :STRING)
item.description = 'Ruby Version'
@config.telemetry['SYSTEM'] ||= {}
@config.telemetry['SYSTEM']['META'] = tlm_meta
raise "RUBY_VERSION incorrect" unless (item.bit_size == 240) && (item.bit_offset == 744)
cmd_meta = build_cmd_system_meta()
rescue => err
Logger.error "SYSTEM META not defined correctly due to #{err.message} - defaulting"
tlm_meta = build_tlm_system_meta()
cmd_meta = build_cmd_system_meta()
end

# Initialize the meta packet (if given init filename)
Expand Down Expand Up @@ -776,5 +739,40 @@ def setup_system_meta

cmd_meta.buffer = tlm_meta.buffer
end

def build_cmd_system_meta
cmd_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
cmd_meta.disabled = true
tlm_meta = @telemetry.packet('SYSTEM', 'META')
tlm_meta.sorted_items.each do |item|
next if item.name.include?("RECEIVED") # Tlm only items
cmd_meta.define(item.clone)
end
@config.commands['SYSTEM'] ||= {}
@config.commands['SYSTEM']['META'] = cmd_meta
cmd_meta
end

def build_tlm_system_meta
tlm_meta = Packet.new('SYSTEM', 'META', :BIG_ENDIAN)
item = tlm_meta.append_item('PKTID', 8, :UINT, nil, :BIG_ENDIAN, :ERROR, nil, nil, nil, 1)
item.description = 'Packet Id'
item.meta["READ_ONLY"] = []
item = tlm_meta.append_item('CONFIG', 32 * 8, :STRING)
item.description = 'Configuration Name'
item.meta["READ_ONLY"] = []
item = tlm_meta.append_item('COSMOS_VERSION', 30 * 8, :STRING)
item.description = 'COSMOS Version'
item.meta["READ_ONLY"] = []
item = tlm_meta.append_item('USER_VERSION', 30 * 8, :STRING)
item.description = 'User Project Version'
item.meta["READ_ONLY"] = []
item = tlm_meta.append_item('RUBY_VERSION', 30 * 8, :STRING)
item.description = 'Ruby Version'
item.meta["READ_ONLY"] = []
@config.telemetry['SYSTEM'] ||= {}
@config.telemetry['SYSTEM']['META'] = tlm_meta
tlm_meta
end
end
end
6 changes: 3 additions & 3 deletions spec/install/config/targets/INST/cmd_tlm/inst_tlm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ TELEMETRY INST PARAMS BIG_ENDIAN "Params set by SETPARAMS command"
ITEM TIMESEC 48 32 UINT "Seconds since epoch (January 1st, 1970, midnight)"
ITEM TIMEUS 80 32 UINT "Microseconds of second"
ID_ITEM PKTID 112 16 UINT 1 "Packet id (The combination of CCSDS_APID and PACKET_ID identify the packet)"
MACRO_APPEND_START 5 1
APPEND_ITEM Value 16 UINT "Value setting"
<% 5.times do |i| %>
APPEND_ITEM VALUE<%= i %> 16 UINT "Value setting"
STATE GOOD 0 GREEN
STATE BAD 1 RED
MACRO_APPEND_END
<% end %>
ITEM TIMESECONDS 0 0 DERIVED "Derived floating-point time since epoch in seconds"
READ_CONVERSION unix_time_seconds_conversion.rb TIMESEC TIMEUS
FORMAT_STRING '%0.6f'
Expand Down
16 changes: 0 additions & 16 deletions spec/install/config/targets/SYSTEM/cmd_tlm/meta_cmd_tlm.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,3 @@ TELEMETRY SYSTEM META BIG_ENDIAN "System Meta Data Telemetry Packet"
APPEND_ITEM RUBY_VERSION 240 STRING "Ruby Version"
META READ_ONLY
APPEND_ITEM OPERATOR_NAME 512 STRING "Operator Name"

COMMAND SYSTEM META BIG_ENDIAN "System Meta Data Command Packet"
DISABLED
APPEND_ID_PARAMETER PKTID 8 UINT 1 1 1 "Packet Id"
APPEND_PARAMETER CONFIG 256 STRING "" "Configuration Name"
APPEND_PARAMETER COSMOS_VERSION 240 STRING "" "COSMOS Version"
APPEND_PARAMETER USER_VERSION 240 STRING "" "User Project Version"
APPEND_PARAMETER RUBY_VERSION 240 STRING "" "Ruby Version"
APPEND_PARAMETER OPERATOR_NAME 512 STRING "" "Operator Name"

0 comments on commit 8f4f0fa

Please sign in to comment.