Class: F4R::Definition::RecordHeader
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- F4R::Definition::RecordHeader
- Defined in:
- lib/f4r.rb
Overview
Record header
| Bit | Value | Description |
|-----+-------------+-----------------------|
| 7 | 0 | Normal Header |
| 6 | 0 or 1 | Message Type: |
| | | 1: Definition |
| | | 2: Data |
| 5 | 0 (default) | Message Type Specific |
| 4 | 0 | Reserved |
| 0-3 | 0-15 | Local Message Type |
Instance Method Summary collapse
- #compressed? ⇒ Boolean
- #for_new_definition? ⇒ Boolean
-
#read(io) ⇒ Object
Serves as first place for validating data.
-
#to_log_s ⇒ String
Header format for log output.
- #write(io) ⇒ Object
-
#write_data_header(io, record) ⇒ Object
Helper method for writing data headers.
Instance Method Details
#compressed? ⇒ Boolean
879 880 881 |
# File 'lib/f4r.rb', line 879 def compressed? normal.snapshot == 1 end |
#for_new_definition? ⇒ Boolean
886 887 888 |
# File 'lib/f4r.rb', line 886 def for_new_definition? normal.snapshot.zero? && .snapshot == 1 end |
#read(io) ⇒ Object
Serves as first place for validating data.
857 858 859 860 861 862 863 864 865 |
# File 'lib/f4r.rb', line 857 def read(io) super if compressed? Log.error "Compressed Timestamp Headers are not supported. #{inspect}" end Log.decode [self.class, __method__], to_log_s end |
#to_log_s ⇒ String
Header format for log output
@example:
record_{data}_header: N: 0 MT: 1 DDF: 0 R: 0 LMT: 6
898 899 900 901 902 903 904 905 906 907 908 |
# File 'lib/f4r.rb', line 898 def to_log_s { "#{.snapshot.zero? ? 'record_data' : 'record'}_header" => [ ('%-8s' % "N: #{normal.snapshot}"), ('%-8s' % "MT: #{.snapshot}"), ('%-8s' % "DDF:#{developer_data_flag.snapshot}"), ('%-8s' % "R: #{reserved.snapshot}"), ('%-8s' % "LMT:#{.snapshot}"), ].join(' ') } end |
#write(io) ⇒ Object
870 871 872 873 874 |
# File 'lib/f4r.rb', line 870 def write(io) super Log.encode [self.class, __method__], to_log_s end |
#write_data_header(io, record) ⇒ Object
Helper method for writing data headers
916 917 918 919 920 921 922 |
# File 'lib/f4r.rb', line 916 def write_data_header(io, record) data_header = self.new data_header.normal = 0 data_header. = 0 data_header. = record[:local_message_number] data_header.write(io) end |