Skip to content

Commit

Permalink
fix influxdb reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jan 8, 2025
1 parent 8cd08ad commit d0bc4d2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
20 changes: 12 additions & 8 deletions alfalfa_worker/jobs/modelica/step_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,18 @@ def advance(self):
point.value = y_output

if self.options.historian_enabled:
influx_points.append({
"measurement": self.run.ref_id,
"time": self.run.sim_time,
"value": value,
"id": point.ref_id,
"point": True,
"source": "alfalfa"
})
influx_points.append({"fields":
{
"value": value,
}, "tags":
{
"id": point.ref_id,
"point": True,
"source": "alfalfa"
},
"measurement": self.run.ref_id,
"time": self.run.sim_time,
})

if self.historian_enabled:
try:
Expand Down
40 changes: 24 additions & 16 deletions alfalfa_worker/jobs/openstudio/step_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,27 +208,35 @@ def ep_read_outputs(self):
raise JobExceptionSimulation(f"EP returned an api error while reading from point: {point.name}")
point.value = value
if self.options.historian_enabled:
influx_points.append({
"measurement": self.run.ref_id,
"time": self.run.sim_time,
"value": value,
"id": point.ref_id,
"point": True,
"source": "alfalfa"
})
influx_points.append({"fields":
{
"value": value
}, "tags":
{
"id": point.ref_id,
"point": True,
"source": "alfalfa"
},
"measurement": self.run.ref_id,
"time": self.run.sim_time,
})
for additional_point in self.additional_points:
value = self.ep_api.exchange.get_meter_value(self.ep_state, additional_point.handle)
value = additional_point.converter(value)
additional_point.point.value = value
if self.options.historian_enabled:
influx_points.append({
"measurement": self.run.ref_id,
"time": self.run.sim_time,
"value": value,
"id": additional_point.point.ref_id,
"point": True,
"source": "alfalfa"
})
influx_points.append({"fields":
{
"value": value
}, "tags":
{
"id": additional_point.point.ref_id,
"point": True,
"source": "alfalfa"
},
"measurement": self.run.ref_id,
"time": self.run.sim_time
})
if self.historian_enabled:
try:
response = self.influx_client.write_points(points=influx_points,
Expand Down

0 comments on commit d0bc4d2

Please sign in to comment.