Class: MobyController::QT::Comms::QtMessage
- Inherits:
-
Object
- Object
- MobyController::QT::Comms::QtMessage
- Defined in:
- lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb
Overview
MobyController
Instance Attribute Summary collapse
-
#compression ⇒ Object
readonly
Returns the value of attribute compression.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#flag ⇒ Object
readonly
Returns the value of attribute flag.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
Instance Method Summary collapse
- #crc ⇒ Object
- #deflate(level = 9) ⇒ Object
-
#initialize(message_flag, message_data) ⇒ QtMessage
constructor
A new instance of QtMessage.
- #make_binary_message(message_id) ⇒ Object
Constructor Details
#initialize(message_flag, message_data) ⇒ QtMessage
Returns a new instance of QtMessage.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 116 def initialize( , ) # message flag @flag = # no compression by default @compression = 1 @data = @size = @data.size # calculate crc only when requested @crc = nil end |
Instance Attribute Details
#compression ⇒ Object (readonly)
Returns the value of attribute compression.
112 113 114 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 112 def compression @compression end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
112 113 114 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 112 def data @data end |
#flag ⇒ Object (readonly)
Returns the value of attribute flag.
112 113 114 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 112 def flag @flag end |
#message_id ⇒ Object
Returns the value of attribute message_id.
114 115 116 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 114 def @message_id end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
112 113 114 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 112 def size @size end |
Instance Method Details
#crc ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 133 def crc if @crc.nil? # calculate outgoing message crc; sent in message header to receiver for data validation @crc = TDriver::Checksum.crc16_ibm( @data ) else @crc end end |
#deflate(level = 9) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 155 def deflate( level = 9 ) unless @compression == 2 @compression = 2 data_size = @data.size # qUncompress required the data length at the beginning so append it - the bytes need to be arranged in the below method (see QByteArray::qUncompress) @data = [ ( data_size & 0xff000000 ) >> 24, ( data_size & 0x00ff0000 ) >> 16, ( data_size & 0x0000ff00 ) >> 8, ( data_size & 0x000000ff ), Zlib::Deflate.deflate( @data, level ) ].pack('C4a*') # update data size @size = @data.size # recalculate crc @crc = nil end end |
#make_binary_message(message_id) ⇒ Object
148 149 150 151 152 153 |
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/sut/communication.rb', line 148 def ( ) [ @flag, @size, crc, @compression, , @data ].pack( 'CISCIa*' ) end |