Skip to content

Commit

Permalink
site to run
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jan 30, 2024
1 parent 004c9ea commit c0a41c5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions alfalfa_bacnet_bridge/alfalfa_bacnet_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from bacpypes.local.object import AnalogValueCmdObject
from bacpypes.task import recurring_function
from alfalfa_client.alfalfa_client import AlfalfaClient
from alfalfa_client.alfalfa_client import SiteID
from alfalfa_client.alfalfa_client import RunID
from bacpypes.service.device import DeviceCommunicationControlServices
from bacpypes.service.object import ReadWritePropertyMultipleServices
from bacpypes.primitivedata import CharacterString, Date, Time
Expand Down Expand Up @@ -69,10 +69,10 @@ def ReadProperty(self, propid, arrayIndex=None):

class AlfalfaBACnetBridge():

def __init__(self, host, site_id: SiteID) -> None:
def __init__(self, host, run_id: RunID) -> None:
self.client = AlfalfaClient(host)

self.site_id = site_id
self.run_id = run_id

self.device = AlfalfaBACnetDevice(
objectName=os.getenv("ALFALFA_DEVICE_NAME","AlfalfaProxy"),
Expand All @@ -94,9 +94,9 @@ def __init__(self, host, site_id: SiteID) -> None:
self.points = {}

def setup_points(self):
inputs = self.client.get_inputs(self.site_id)
inputs = self.client.get_inputs(self.run_id)
inputs.sort()
outputs = self.client.get_outputs(self.site_id)
outputs = self.client.get_outputs(self.run_id)
output_names = list(outputs.keys())
output_names.sort()

Expand Down Expand Up @@ -129,10 +129,10 @@ def run(self):
@bacpypes_debugging
def main_loop():
try:
inputs = self.client.get_inputs(self.site_id)
outputs = self.client.get_outputs(self.site_id)
inputs = self.client.get_inputs(self.run_id)
outputs = self.client.get_outputs(self.run_id)

sim_time = self.client.get_sim_time(self.site_id)
sim_time = self.client.get_sim_time(self.run_id)
except Exception as e:
logger.error(e)
return
Expand All @@ -158,7 +158,7 @@ def main_loop():
object._had_value = False
if len(set_inputs) > 0:
try:
self.client.set_inputs(self.site_id, set_inputs)
self.client.set_inputs(self.run_id, set_inputs)
except Exception as e:
logger.error(e)

Expand All @@ -167,8 +167,8 @@ def main_loop():
run()

if __name__ == "__main__":
site_id = sys.argv[2]
run_id = sys.argv[2]
host = sys.argv[1]
bridge = AlfalfaBACnetBridge(host, site_id)
bridge = AlfalfaBACnetBridge(host, run_id)
bridge.setup_points()
bridge.run()

0 comments on commit c0a41c5

Please sign in to comment.