Class: MaxCube::Messages::UDP::Serializer
- Inherits:
-
Object
- Object
- MaxCube::Messages::UDP::Serializer
- Includes:
- Serializer, Handler
- Defined in:
- lib/maxcube/messages/udp/serializer.rb
Overview
Extends Serializer and Handler of routines connected to UDP Cube messages serializing.
Constant Summary
- MSG_TYPES =
Known message types in the direction client -> Cube.
%w[I N h c R].freeze
- MSG_PREFIX =
MSG_PREFIX with a suffix.
(UDP::MSG_PREFIX + "*\x00").freeze
Constants included from Handler
Constants included from MaxCube::Messages
DAYS_OF_WEEK, DEVICE_MODE, DEVICE_TYPE
Instance Method Summary collapse
-
#msg_msg_type(msg) ⇒ String
private
Tells how to get message type from a message.
-
#serialize_udp_hash(hash) ⇒ String
Serializes data from a single hash into UDP Cube message.
Methods included from Serializer
#serialize, #serialize_bounds, #serialize_hash_body, #write
Methods included from Handler
#check_data_type, #check_hash, #check_hash_keys, #check_hash_msg_type, #check_hash_values, #check_msg, #check_msg_msg_type, #check_msg_part_lengths, #check_msg_type, #decode, #encode, #maybe_check_valid_hash_keys, #maybe_check_valid_msg_type, #msg_type_hash_keys, #msg_type_hash_opt_keys, #msg_type_which_hash_keys, #msg_types, #valid_data_type, #valid_hash, #valid_hash_keys, #valid_hash_msg_type, #valid_hash_values, #valid_msg, #valid_msg_msg_type, #valid_msg_part_lengths, #valid_msg_type
Methods included from MaxCube::Messages
#ary_elem, #ary_elem_id, #conv_args, #day_of_week, #day_of_week_id, #device_mode, #device_mode_id, #device_type, #device_type_id, #to_bool, #to_bools, #to_datetime, #to_datetimes, #to_float, #to_floats, #to_int, #to_ints
Methods included from Handler
#check_udp_hash, #check_udp_msg, #check_udp_msg_prefix, #valid_udp_hash, #valid_udp_msg, #valid_udp_msg_prefix
Instance Method Details
#msg_msg_type(msg) ⇒ String (private)
Tells how to get message type from a message.
40 41 42 |
# File 'lib/maxcube/messages/udp/serializer.rb', line 40 def msg_msg_type(msg) msg[18] end |
#serialize_udp_hash(hash) ⇒ String
Serializes data from a single hash into UDP Cube message. Calls Handler#check_udp_hash at the begin and Handler#check_udp_msg at the end.
28 29 30 31 32 33 |
# File 'lib/maxcube/messages/udp/serializer.rb', line 28 def serialize_udp_hash(hash) check_udp_hash(hash) serial_number = hash[:serial_number] || '*' * 10 msg = MSG_PREFIX + serial_number << @msg_type check_udp_msg(msg) end |