Module: MatrixCreator::Pressure

Defined in:
lib/matrix_creator/pressure.rb

Overview

Module: Pressure

Communicate with the Pressure driver

Constant Summary collapse

PRESSURE_CONFIG =

Configuration values for the Pressure driver

MatrixCreator.settings[:devices][:pressure]
BASE_PORT =

Base port to send data to Pressure driver

PRESSURE_CONFIG[:port]

Class Method Summary collapse

Class Method Details

.detect(options = {}, &block) ⇒ Array

Detects and returns information from the Pressure driver

Examples:

Detect 3 values for the Pressure driver

MatrixCreator::Pressure.detect(max_resp: 3)

Detect values for the Pressure driver for 30 seconds

MatrixCreator::Pressure.detect(max_secs: 30)

Detect values for the Pressure driver with a speed of 0.5 seconds per response

MatrixCreator::Pressure.detect(max_secs: 30, speed: 0.5)

Detect values for the Pressure driver for 15 seconds and process data when received

MatrixCreator::Pressure.detect(max_resp: 10){ |data|
  // Do something with the data
}

Parameters:

  • options (Hash) (defaults to: {})

    of keys and values that can contain speed, max_resp and/or max_secs

Returns:

  • (Array)

    elements detected in JSON format



35
36
37
# File 'lib/matrix_creator/pressure.rb', line 35

def self.detect(options = {}, &block)
  MatrixCreator::DriverBase.detect(BASE_PORT, MatrixMalos::Pressure, options, block)
end

.detect_onceHash

Detects one response from the Pressure driver and returns its value

Returns:

  • (Hash)

    object with the Pressure response values



44
45
46
# File 'lib/matrix_creator/pressure.rb', line 44

def self.detect_once
  detect(max_resp: 1).first
end