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
- #group_objects ⇒ 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.
77 78 79 80 81 |
# File 'lib/sdn/mqtt_bridge.rb', line 77 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
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def addr @addr end |
#bridge ⇒ Object
Returns the value of attribute bridge
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def bridge @bridge end |
#direction ⇒ Object
Returns the value of attribute direction
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def direction @direction end |
#downlimit ⇒ Object
Returns the value of attribute downlimit
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def downlimit @downlimit end |
#downspeed ⇒ Object
Returns the value of attribute downspeed
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def downspeed @downspeed end |
#groups ⇒ Object
Returns the value of attribute groups
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def groups @groups end |
#ip ⇒ Object
Returns the value of attribute ip
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip @ip end |
#ip10percent ⇒ Object
Returns the value of attribute ip10percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip10percent @ip10percent end |
#ip10pulses ⇒ Object
Returns the value of attribute ip10pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip10pulses @ip10pulses end |
#ip11percent ⇒ Object
Returns the value of attribute ip11percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip11percent @ip11percent end |
#ip11pulses ⇒ Object
Returns the value of attribute ip11pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip11pulses @ip11pulses end |
#ip12percent ⇒ Object
Returns the value of attribute ip12percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip12percent @ip12percent end |
#ip12pulses ⇒ Object
Returns the value of attribute ip12pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip12pulses @ip12pulses end |
#ip13percent ⇒ Object
Returns the value of attribute ip13percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip13percent @ip13percent end |
#ip13pulses ⇒ Object
Returns the value of attribute ip13pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip13pulses @ip13pulses end |
#ip14percent ⇒ Object
Returns the value of attribute ip14percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip14percent @ip14percent end |
#ip14pulses ⇒ Object
Returns the value of attribute ip14pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip14pulses @ip14pulses end |
#ip15percent ⇒ Object
Returns the value of attribute ip15percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip15percent @ip15percent end |
#ip15pulses ⇒ Object
Returns the value of attribute ip15pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip15pulses @ip15pulses end |
#ip16percent ⇒ Object
Returns the value of attribute ip16percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip16percent @ip16percent end |
#ip16pulses ⇒ Object
Returns the value of attribute ip16pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip16pulses @ip16pulses end |
#ip1percent ⇒ Object
Returns the value of attribute ip1percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip1percent @ip1percent end |
#ip1pulses ⇒ Object
Returns the value of attribute ip1pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip1pulses @ip1pulses end |
#ip2percent ⇒ Object
Returns the value of attribute ip2percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip2percent @ip2percent end |
#ip2pulses ⇒ Object
Returns the value of attribute ip2pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip2pulses @ip2pulses end |
#ip3percent ⇒ Object
Returns the value of attribute ip3percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip3percent @ip3percent end |
#ip3pulses ⇒ Object
Returns the value of attribute ip3pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip3pulses @ip3pulses end |
#ip4percent ⇒ Object
Returns the value of attribute ip4percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip4percent @ip4percent end |
#ip4pulses ⇒ Object
Returns the value of attribute ip4pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip4pulses @ip4pulses end |
#ip5percent ⇒ Object
Returns the value of attribute ip5percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip5percent @ip5percent end |
#ip5pulses ⇒ Object
Returns the value of attribute ip5pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip5pulses @ip5pulses end |
#ip6percent ⇒ Object
Returns the value of attribute ip6percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip6percent @ip6percent end |
#ip6pulses ⇒ Object
Returns the value of attribute ip6pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip6pulses @ip6pulses end |
#ip7percent ⇒ Object
Returns the value of attribute ip7percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip7percent @ip7percent end |
#ip7pulses ⇒ Object
Returns the value of attribute ip7pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip7pulses @ip7pulses end |
#ip8percent ⇒ Object
Returns the value of attribute ip8percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip8percent @ip8percent end |
#ip8pulses ⇒ Object
Returns the value of attribute ip8pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip8pulses @ip8pulses end |
#ip9percent ⇒ Object
Returns the value of attribute ip9percent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip9percent @ip9percent end |
#ip9pulses ⇒ Object
Returns the value of attribute ip9pulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def ip9pulses @ip9pulses end |
#label ⇒ Object
Returns the value of attribute label
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def label @label end |
#last_action_cause ⇒ Object
Returns the value of attribute last_action_cause
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def last_action_cause @last_action_cause end |
#last_action_source ⇒ Object
Returns the value of attribute last_action_source
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def last_action_source @last_action_source end |
#last_direction ⇒ Object
Returns the value of attribute last_direction
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def last_direction @last_direction end |
#positionpercent ⇒ Object
Returns the value of attribute positionpercent
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def positionpercent @positionpercent end |
#positionpulses ⇒ Object
Returns the value of attribute positionpulses
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def positionpulses @positionpulses end |
#slowspeed ⇒ Object
Returns the value of attribute slowspeed
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def slowspeed @slowspeed end |
#state ⇒ Object
Returns the value of attribute state
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def state @state end |
#uplimit ⇒ Object
Returns the value of attribute uplimit
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def uplimit @uplimit end |
#upspeed ⇒ Object
Returns the value of attribute upspeed
28 29 30 |
# File 'lib/sdn/mqtt_bridge.rb', line 28 def upspeed @upspeed end |
Instance Method Details
#add_group(index, address) ⇒ Object
90 91 92 93 94 |
# File 'lib/sdn/mqtt_bridge.rb', line 90 def add_group(index, address) bridge.add_group(SDN::Message.print_address(address)) if address @groups[index] = address publish(:groups, groups_string) end |
#group_objects ⇒ Object
115 116 117 |
# File 'lib/sdn/mqtt_bridge.rb', line 115 def group_objects groups_string.split(',').map { |addr| bridge.groups[addr.gsub('.', '')] } end |
#groups_string ⇒ Object
111 112 113 |
# File 'lib/sdn/mqtt_bridge.rb', line 111 def groups_string @groups.compact.map { |g| SDN::Message.print_address(g) }.sort.uniq.join(',') end |
#publish(attribute, value) ⇒ Object
83 84 85 86 87 88 |
# File 'lib/sdn/mqtt_bridge.rb', line 83 def publish(attribute, value) if self[attribute] != value bridge.publish("#{addr}/#{attribute}", value.to_s) self[attribute] = value end end |
#set_groups(groups) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sdn/mqtt_bridge.rb', line 96 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 |