two stage matching
This commit is contained in:
@@ -47,7 +47,6 @@ class InSyncState < StatePattern::State
|
|||||||
end
|
end
|
||||||
|
|
||||||
def handle_frame(frame_lines)
|
def handle_frame(frame_lines)
|
||||||
gas_pattern = /^([0-1:24\.2\.1]+)\((\d{12}[SW])\)\((\d{5}\.\d{3})\*m3\)$/
|
|
||||||
|
|
||||||
# prepare DB record
|
# prepare DB record
|
||||||
last_reading = Reading.last
|
last_reading = Reading.last
|
||||||
@@ -82,11 +81,10 @@ class InSyncState < StatePattern::State
|
|||||||
end
|
end
|
||||||
if line.match(/0-1:24.2.1/)
|
if line.match(/0-1:24.2.1/)
|
||||||
p "Gas reading found."
|
p "Gas reading found."
|
||||||
p "Reading time: #{line.split(/0-1:24.2.1\(|\)/).join}"
|
|
||||||
end
|
match = line.match(/^([0-1:24\.2\.1]+)\(([^)]+)\)\(([\d.]+)\*m3\)$/) # Gas verbruik (1x per uur een nieuwe stand)
|
||||||
if match = line.match(gas_pattern) # Gas verbruik (1x per uur een nieuwe stand)
|
p "Gas reading: #{match[1]} (#{match[2]})"
|
||||||
p "Gas reading: #{match[1]} (#{match[2]})"
|
reading.total_m3_gas_consumed = match[3].to_f
|
||||||
reading.total_m3_gas_consumed = match[3].to_f
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user