Skip to content

Commit

Permalink
add check for non-finite floats before writing to Alfalfa
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Aug 18, 2023
1 parent 48ec2b1 commit 60eb92e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import datetime
import math
import sys
import os
from bacpypes.app import BIPSimpleApplication
Expand Down Expand Up @@ -63,7 +64,7 @@ def __init__(self, host, site_id: SiteID) -> None:
maxApduLengthAccepted=int(1024),
segmentationSupported="segmentedBoth",
vendorIdentifier=555,
vendorName=CharacterString("NREL"),
vendorName=CharacterString("NREL"),
modelName=CharacterString("Alfalfa BACnet Bridge"),
systemStatus=DeviceStatus(1),
description=CharacterString("BACpypes (Python) based tool for exposing alfalfa models to real world BAS systems via BACnet"),
Expand Down Expand Up @@ -127,13 +128,20 @@ def main_loop():
if point in inputs:
current_value, value_type = object._highest_priority_value()
if value_type is not None:
set_inputs[point] = current_value
object._had_value = True
if math.isfinite(current_value):
set_inputs[point] = current_value
object._had_value = True
else:
print(f"Got non-finite value {current_value} for point {point}")
elif object._had_value:
set_inputs[point] = None
object._had_value = False
if len(set_inputs) > 0:
self.client.set_inputs(self.site_id, set_inputs)
try:
self.client.set_inputs(self.site_id, set_inputs)
except Exception as e:
print(e)


deferred(main_loop)
run()
Expand Down

0 comments on commit 60eb92e

Please sign in to comment.