Class: PlantWatchdog::Aggregation::Plant
- Inherits:
-
Object
- Object
- PlantWatchdog::Aggregation::Plant
- Includes:
- RuleEvaluation
- Defined in:
- lib/plantwatchdog/aggregation.rb
Instance Method Summary collapse
- #aggregate ⇒ Object
-
#initialize(model_plant, device_aggregates) ⇒ Plant
constructor
A new instance of Plant.
-
#logger ⇒ Object
TODO: better way to access logger.
Methods included from RuleEvaluation
Constructor Details
#initialize(model_plant, device_aggregates) ⇒ Plant
Returns a new instance of Plant.
123 124 125 126 |
# File 'lib/plantwatchdog/aggregation.rb', line 123 def initialize model_plant, device_aggregates @model_plant = model_plant @device_aggregates = device_aggregates end |
Instance Method Details
#aggregate ⇒ Object
128 129 130 131 132 133 134 135 136 137 |
# File 'lib/plantwatchdog/aggregation.rb', line 128 def aggregate result = {} logger.debug "Aggregating plant, aggrules: #{@model_plant.aggrules}" @model_plant.aggrules.each_pair do |agg_key, rule_array| result[agg_key] = eval_rule(rule_array, @device_aggregates) end logger.debug "Aggregation results: " + result.to_s result end |
#logger ⇒ Object
TODO: better way to access logger
140 141 142 |
# File 'lib/plantwatchdog/aggregation.rb', line 140 def logger return ActiveRecord::Base.logger end |