class NRB::BreweryControlSystem::API::Ultemp

Public Class Methods

endpoint() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 9
def endpoint; 'ultemp.dat'; end

Private Instance Methods

alarm() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 16
def alarm
  body_array[54].to_s(2).rjust(9,"0")[8] == "1"
end
bit_range(data, range) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 21
def bit_range(data, range)
end
body_array() click to toggle source
Calls superclass method
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 25
def body_array
  super.map { |i| i.to_i }
end
body_array_by_ten(range) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 30
def body_array_by_ten(range)
  collect_body_array(range) { |t| t.to_f / 10.0 }
end
collect_body_array(range, &block) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 35
def collect_body_array(range, &block)
  body_array[range].collect &block
end
decode_current_state(int) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 40
def decode_current_state(int)
  # http://forum.embeddedcc.com/viewtopic.php?f=9&t=484&p=2513
  ( "%08x" % int ).scan(/[0-9a-f\.]{2}/).reverse.collect { |hex| hex == ".." || hex == "ff" ? nil : hex.to_i(16) }
end
input_statuses() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 46
def input_statuses
  unmask_boolean body_array[2], 0..7
end
internal_registers() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 51
def internal_registers
  unmask_boolean body_array[53], 0..15
end
output_statuses() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 56
def output_statuses
  unmask_boolean body_array[1], 0..17
end
parse() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 61
def parse
  return if body_array.nil?
  [ *running_processes,
    *output_statuses,
    *input_statuses,
    *temps,
    *setpoints,
    *processes_current_state,
    *process_timers,
    *internal_registers,
    *process_pause_states,
    alarm
  ]
end
process_pause_states() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 77
def process_pause_states
  unmask_boolean body_array[54], 0..7
end
process_timers() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 87
def process_timers
  body_array[21..52]
end
processes_current_state() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 82
def processes_current_state
  [ *decode_current_state(body_array[19]), *decode_current_state(body_array[20]) ]
end
running_processes() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 92
def running_processes
  unmask_boolean body_array[0], 0..7
end
setpoints() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 102
def setpoints
  body_array_by_ten(11..18)
end
temps() click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 97
def temps
  body_array_by_ten(3..10)
end
unmask(masked, range) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 107
def unmask(masked, range)
  range.collect { |i| masked & (2**i) }
end
unmask_boolean(masked, range) click to toggle source
# File lib/brewery_control_system/api/3.7.0/ultemp.rb, line 112
def unmask_boolean(masked, range)
  unmask(masked, range).collect { |unmasked| unmasked > 0 }
end