Class: Simms::Beacon
- Inherits:
-
Object
- Object
- Simms::Beacon
- Defined in:
- lib/simms/beacon.rb
Direct Known Subclasses
ElectricityConfigBeacon, ElectricityDataBeacon, GlobalConfigBeacon
Constant Summary collapse
- CG_GLOBAL =
Command group codes
0xFFFF
- CG_SENSOR =
0x0001
- CG_ELECTRIC =
0x0002
- CG_HVAC =
0x0004
- CG_PULSER =
0x0005
- CG_IRRIGATION =
0x0007
- DC_DATA =
Device commands
0x0001
- DC_GLOBAL_CONFIG =
0x000B
- DC_CONFIG =
0x0022
Instance Attribute Summary collapse
-
#command_group_id ⇒ Object
Attributes.
-
#device_command_id ⇒ Object
Attributes.
-
#timestamp ⇒ Object
Attributes.
-
#uuid ⇒ Object
Attributes.
Class Method Summary collapse
-
.class_for(group, command) ⇒ Object
Find the appropriate beacon class for a given group + command tuple.
Instance Method Summary collapse
- #config? ⇒ Boolean
- #data? ⇒ Boolean
- #group ⇒ Object
-
#initialize(bytes) ⇒ Beacon
constructor
A new instance of Beacon.
- #type ⇒ Object
Constructor Details
#initialize(bytes) ⇒ Beacon
Returns a new instance of Beacon.
46 47 48 |
# File 'lib/simms/beacon.rb', line 46 def initialize(bytes) @bytes = bytes end |
Instance Attribute Details
#command_group_id ⇒ Object
Attributes
7 8 9 |
# File 'lib/simms/beacon.rb', line 7 def command_group_id @command_group_id end |
#device_command_id ⇒ Object
Attributes
7 8 9 |
# File 'lib/simms/beacon.rb', line 7 def device_command_id @device_command_id end |
#timestamp ⇒ Object
Attributes
7 8 9 |
# File 'lib/simms/beacon.rb', line 7 def @timestamp end |
#uuid ⇒ Object
Attributes
7 8 9 |
# File 'lib/simms/beacon.rb', line 7 def uuid @uuid end |
Class Method Details
.class_for(group, command) ⇒ Object
Find the appropriate beacon class for a given group + command tuple
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/simms/beacon.rb', line 23 def self.class_for(group, command) case group when CG_GLOBAL then case command when DC_GLOBAL_CONFIG then return Simms::GlobalConfigBeacon end when CG_ELECTRIC then case command when DC_DATA then return Simms::ElectricityDataBeacon when DC_CONFIG then return Simms::ElectricityConfigBeacon end end # None found! nil end |
Instance Method Details
#config? ⇒ Boolean
76 77 78 |
# File 'lib/simms/beacon.rb', line 76 def config? type == :config end |
#data? ⇒ Boolean
72 73 74 |
# File 'lib/simms/beacon.rb', line 72 def data? type == :data end |
#group ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/simms/beacon.rb', line 50 def group case @command_group_id when CG_GLOBAL then :global when CG_SENSOR then :sensor when CG_ELECTRIC then :electric when CG_HVAC then :hvac when CG_PULSER then :pulser when CG_IRRIGATION then :irrigation else :unknown end end |
#type ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/simms/beacon.rb', line 63 def type case @device_command_id when DC_DATA then :data when DC_CONFIG, DC_GLOBAL_CONFIG then :config else :unknown end end |