Class: SDN::Motor
- Inherits:
-
Struct
- Object
- Struct
- SDN::Motor
- Defined in:
- lib/sdn/mqtt_bridge.rb
Instance Attribute Summary collapse
-
#addr ⇒ Object
Returns the value of attribute addr.
-
#bridge ⇒ Object
Returns the value of attribute bridge.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#downlimit ⇒ Object
Returns the value of attribute downlimit.
-
#downspeed ⇒ Object
Returns the value of attribute downspeed.
-
#groups ⇒ Object
Returns the value of attribute groups.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#ip10percent ⇒ Object
Returns the value of attribute ip10percent.
-
#ip10pulses ⇒ Object
Returns the value of attribute ip10pulses.
-
#ip11percent ⇒ Object
Returns the value of attribute ip11percent.
-
#ip11pulses ⇒ Object
Returns the value of attribute ip11pulses.
-
#ip12percent ⇒ Object
Returns the value of attribute ip12percent.
-
#ip12pulses ⇒ Object
Returns the value of attribute ip12pulses.
-
#ip13percent ⇒ Object
Returns the value of attribute ip13percent.
-
#ip13pulses ⇒ Object
Returns the value of attribute ip13pulses.
-
#ip14percent ⇒ Object
Returns the value of attribute ip14percent.
-
#ip14pulses ⇒ Object
Returns the value of attribute ip14pulses.
-
#ip15percent ⇒ Object
Returns the value of attribute ip15percent.
-
#ip15pulses ⇒ Object
Returns the value of attribute ip15pulses.
-
#ip16percent ⇒ Object
Returns the value of attribute ip16percent.
-
#ip16pulses ⇒ Object
Returns the value of attribute ip16pulses.
-
#ip1percent ⇒ Object
Returns the value of attribute ip1percent.
-
#ip1pulses ⇒ Object
Returns the value of attribute ip1pulses.
-
#ip2percent ⇒ Object
Returns the value of attribute ip2percent.
-
#ip2pulses ⇒ Object
Returns the value of attribute ip2pulses.
-
#ip3percent ⇒ Object
Returns the value of attribute ip3percent.
-
#ip3pulses ⇒ Object
Returns the value of attribute ip3pulses.
-
#ip4percent ⇒ Object
Returns the value of attribute ip4percent.
-
#ip4pulses ⇒ Object
Returns the value of attribute ip4pulses.
-
#ip5percent ⇒ Object
Returns the value of attribute ip5percent.
-
#ip5pulses ⇒ Object
Returns the value of attribute ip5pulses.
-
#ip6percent ⇒ Object
Returns the value of attribute ip6percent.
-
#ip6pulses ⇒ Object
Returns the value of attribute ip6pulses.
-
#ip7percent ⇒ Object
Returns the value of attribute ip7percent.
-
#ip7pulses ⇒ Object
Returns the value of attribute ip7pulses.
-
#ip8percent ⇒ Object
Returns the value of attribute ip8percent.
-
#ip8pulses ⇒ Object
Returns the value of attribute ip8pulses.
-
#ip9percent ⇒ Object
Returns the value of attribute ip9percent.
-
#ip9pulses ⇒ Object
Returns the value of attribute ip9pulses.
-
#label ⇒ Object
Returns the value of attribute label.
-
#last_action_cause ⇒ Object
Returns the value of attribute last_action_cause.
-
#last_action_source ⇒ Object
Returns the value of attribute last_action_source.
-
#last_direction ⇒ Object
Returns the value of attribute last_direction.
-
#positionpercent ⇒ Object
Returns the value of attribute positionpercent.
-
#positionpulses ⇒ Object
Returns the value of attribute positionpulses.
-
#slowspeed ⇒ Object
Returns the value of attribute slowspeed.
-
#state ⇒ Object
Returns the value of attribute state.
-
#uplimit ⇒ Object
Returns the value of attribute uplimit.
-
#upspeed ⇒ Object
Returns the value of attribute upspeed.
Instance Method Summary collapse
- #add_group(index, address) ⇒ Object
- #groups_string ⇒ Object
-
#initialize ⇒ Motor
constructor
A new instance of Motor.
- #publish(attribute, value) ⇒ Object
- #set_groups(groups) ⇒ Object
Constructor Details
#initialize ⇒ Motor
Returns a new instance of Motor.
55 56 57 58 59 |
# File 'lib/sdn/mqtt_bridge.rb', line 55 def initialize(*) members.each { |k| self[k] = :nil } @groups = [].fill(nil, 0, 16) super end |
Instance Attribute Details
#addr ⇒ Object
Returns the value of attribute addr
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def addr @addr end |
#bridge ⇒ Object
Returns the value of attribute bridge
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def bridge @bridge end |
#direction ⇒ Object
Returns the value of attribute direction
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def direction @direction end |
#downlimit ⇒ Object
Returns the value of attribute downlimit
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def downlimit @downlimit end |
#downspeed ⇒ Object
Returns the value of attribute downspeed
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def downspeed @downspeed end |
#groups ⇒ Object
Returns the value of attribute groups
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def groups @groups end |
#ip ⇒ Object
Returns the value of attribute ip
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip @ip end |
#ip10percent ⇒ Object
Returns the value of attribute ip10percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip10percent @ip10percent end |
#ip10pulses ⇒ Object
Returns the value of attribute ip10pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip10pulses @ip10pulses end |
#ip11percent ⇒ Object
Returns the value of attribute ip11percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip11percent @ip11percent end |
#ip11pulses ⇒ Object
Returns the value of attribute ip11pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip11pulses @ip11pulses end |
#ip12percent ⇒ Object
Returns the value of attribute ip12percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip12percent @ip12percent end |
#ip12pulses ⇒ Object
Returns the value of attribute ip12pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip12pulses @ip12pulses end |
#ip13percent ⇒ Object
Returns the value of attribute ip13percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip13percent @ip13percent end |
#ip13pulses ⇒ Object
Returns the value of attribute ip13pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip13pulses @ip13pulses end |
#ip14percent ⇒ Object
Returns the value of attribute ip14percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip14percent @ip14percent end |
#ip14pulses ⇒ Object
Returns the value of attribute ip14pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip14pulses @ip14pulses end |
#ip15percent ⇒ Object
Returns the value of attribute ip15percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip15percent @ip15percent end |
#ip15pulses ⇒ Object
Returns the value of attribute ip15pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip15pulses @ip15pulses end |
#ip16percent ⇒ Object
Returns the value of attribute ip16percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip16percent @ip16percent end |
#ip16pulses ⇒ Object
Returns the value of attribute ip16pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip16pulses @ip16pulses end |
#ip1percent ⇒ Object
Returns the value of attribute ip1percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip1percent @ip1percent end |
#ip1pulses ⇒ Object
Returns the value of attribute ip1pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip1pulses @ip1pulses end |
#ip2percent ⇒ Object
Returns the value of attribute ip2percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip2percent @ip2percent end |
#ip2pulses ⇒ Object
Returns the value of attribute ip2pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip2pulses @ip2pulses end |
#ip3percent ⇒ Object
Returns the value of attribute ip3percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip3percent @ip3percent end |
#ip3pulses ⇒ Object
Returns the value of attribute ip3pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip3pulses @ip3pulses end |
#ip4percent ⇒ Object
Returns the value of attribute ip4percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip4percent @ip4percent end |
#ip4pulses ⇒ Object
Returns the value of attribute ip4pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip4pulses @ip4pulses end |
#ip5percent ⇒ Object
Returns the value of attribute ip5percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip5percent @ip5percent end |
#ip5pulses ⇒ Object
Returns the value of attribute ip5pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip5pulses @ip5pulses end |
#ip6percent ⇒ Object
Returns the value of attribute ip6percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip6percent @ip6percent end |
#ip6pulses ⇒ Object
Returns the value of attribute ip6pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip6pulses @ip6pulses end |
#ip7percent ⇒ Object
Returns the value of attribute ip7percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip7percent @ip7percent end |
#ip7pulses ⇒ Object
Returns the value of attribute ip7pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip7pulses @ip7pulses end |
#ip8percent ⇒ Object
Returns the value of attribute ip8percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip8percent @ip8percent end |
#ip8pulses ⇒ Object
Returns the value of attribute ip8pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip8pulses @ip8pulses end |
#ip9percent ⇒ Object
Returns the value of attribute ip9percent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip9percent @ip9percent end |
#ip9pulses ⇒ Object
Returns the value of attribute ip9pulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def ip9pulses @ip9pulses end |
#label ⇒ Object
Returns the value of attribute label
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def label @label end |
#last_action_cause ⇒ Object
Returns the value of attribute last_action_cause
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def last_action_cause @last_action_cause end |
#last_action_source ⇒ Object
Returns the value of attribute last_action_source
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def last_action_source @last_action_source end |
#last_direction ⇒ Object
Returns the value of attribute last_direction
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def last_direction @last_direction end |
#positionpercent ⇒ Object
Returns the value of attribute positionpercent
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def positionpercent @positionpercent end |
#positionpulses ⇒ Object
Returns the value of attribute positionpulses
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def positionpulses @positionpulses end |
#slowspeed ⇒ Object
Returns the value of attribute slowspeed
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def slowspeed @slowspeed end |
#state ⇒ Object
Returns the value of attribute state
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def state @state end |
#uplimit ⇒ Object
Returns the value of attribute uplimit
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def uplimit @uplimit end |
#upspeed ⇒ Object
Returns the value of attribute upspeed
6 7 8 |
# File 'lib/sdn/mqtt_bridge.rb', line 6 def upspeed @upspeed end |
Instance Method Details
#add_group(index, address) ⇒ Object
68 69 70 71 72 |
# File 'lib/sdn/mqtt_bridge.rb', line 68 def add_group(index, address) bridge.add_group(SDN::Message.print_address(address)) if address @groups[index] = address publish(:groups, groups_string) end |
#groups_string ⇒ Object
89 90 91 |
# File 'lib/sdn/mqtt_bridge.rb', line 89 def groups_string @groups.compact.map { |g| SDN::Message.print_address(g) }.sort.uniq.join(',') end |
#publish(attribute, value) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/sdn/mqtt_bridge.rb', line 61 def publish(attribute, value) if self[attribute] != value bridge.publish("#{addr}/#{attribute}", value.to_s) self[attribute] = value end end |
#set_groups(groups) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/sdn/mqtt_bridge.rb', line 74 def set_groups(groups) return unless groups =~ /^(?:\h{2}[:.]?\h{2}[:.]?\h{2}(?:,\h{2}[:.]?\h{2}[:.]?\h{2})*)?$/i groups = groups.split(',').sort.uniq.map { |g| SDN::Message.parse_address(g) } groups.fill(nil, groups.length, 16 - groups.length) = [] sdn_addr = SDN::Message.parse_address(addr) groups.each_with_index do |g, i| if @groups[i] != g << SDN::Message::SetGroupAddr.new(sdn_addr, i, g) << SDN::Message::GetGroupAddr.new(sdn_addr, i) end end end |