Module: Tdms::Streaming
- Included in:
- File
- Defined in:
- lib/tdms/streaming.rb
Instance Method Summary collapse
- #read_bool ⇒ Object
- #read_double ⇒ Object
- #read_i16 ⇒ Object
- #read_i32 ⇒ Object
- #read_i64 ⇒ Object
- #read_i8 ⇒ Object
- #read_property ⇒ Object
- #read_single ⇒ Object
- #read_timestamp ⇒ Object
- #read_u16 ⇒ Object
- #read_u32 ⇒ Object
- #read_u64 ⇒ Object
- #read_u8 ⇒ Object
- #read_utf8_string ⇒ Object
Instance Method Details
#read_bool ⇒ Object
14 15 16 |
# File 'lib/tdms/streaming.rb', line 14 def read_bool read(1) == "\001" end |
#read_double ⇒ Object
55 56 57 |
# File 'lib/tdms/streaming.rb', line 55 def read_double read(8).unpack("E")[0] end |
#read_i16 ⇒ Object
39 40 41 |
# File 'lib/tdms/streaming.rb', line 39 def read_i16 read(2).unpack("s")[0] # TODO little endian not native end |
#read_i32 ⇒ Object
43 44 45 |
# File 'lib/tdms/streaming.rb', line 43 def read_i32 read(4).unpack("l")[0] # TODO little endian not native end |
#read_i64 ⇒ Object
47 48 49 |
# File 'lib/tdms/streaming.rb', line 47 def read_i64 read(8).unpack("q")[0] # TODO little endian not native end |
#read_i8 ⇒ Object
35 36 37 |
# File 'lib/tdms/streaming.rb', line 35 def read_i8 read(2).unpack("c")[0] end |
#read_property ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/tdms/streaming.rb', line 6 def read_property name = read_utf8_string type_id = read_u32 data = Tdms::DataType.find_by_id(type_id).read_from_stream(self) Tdms::Property.new(name, data) end |
#read_single ⇒ Object
51 52 53 |
# File 'lib/tdms/streaming.rb', line 51 def read_single read(4).unpack("e")[0] end |
#read_timestamp ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/tdms/streaming.rb', line 64 def positive_fractions_of_second = read_u64 # ignored seconds_since_labview_epoch = read(8).unpack("q")[0] # TODO little endian not native labview_epoch = ::DateTime.new(1904, 1, 1) labview_epoch + Rational(seconds_since_labview_epoch, 86400) end |
#read_u16 ⇒ Object
22 23 24 |
# File 'lib/tdms/streaming.rb', line 22 def read_u16 read(2).unpack("v")[0] end |
#read_u32 ⇒ Object
26 27 28 |
# File 'lib/tdms/streaming.rb', line 26 def read_u32 read(4).unpack("V")[0] end |
#read_u64 ⇒ Object
30 31 32 33 |
# File 'lib/tdms/streaming.rb', line 30 def read_u64 lo_hi = read(8).unpack("VV") lo_hi[0] + (lo_hi[1] << 32) end |
#read_u8 ⇒ Object
18 19 20 |
# File 'lib/tdms/streaming.rb', line 18 def read_u8 read(1).unpack("C")[0] end |
#read_utf8_string ⇒ Object
59 60 61 62 |
# File 'lib/tdms/streaming.rb', line 59 def read_utf8_string length = read_u32 read length end |