Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions gridappsd-field-bus-lib/gridappsd/field_interface/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from cimgraph.loaders.gridappsd import GridappsdConnection
from cimgraph.models import DistributedModel, SecondaryArea, SwitchArea

from gridappsd import DifferenceBuilder
import gridappsd.topics as t
from gridappsd.field_interface.context import LocalContext
from gridappsd.field_interface.gridappsd_field_bus import GridAPPSDMessageBus
Expand Down Expand Up @@ -227,16 +228,22 @@ def publish_upstream(self, message):
self.upstream_message_bus.send(t.field_message_bus_topic(self.upstream_message_bus.id), message)


def send_control_command(self, differenceBuilder : DifferenceBuilder):
if self.simulation_id is not None:
LocalContext.control_command(differenceBuilder)
'''
TODO This block needs to be tested with device interface
else:
self.downstream_message_bus.send(devie_interface_topic, differenceBuilder)
'''

''' TODO this has not been implemented yet, so we are commented them out for now.
# not all agent would use this
def on_control(self, control):
device_id = control.get('device')
command = control.get('command')
self.control_device(device_id, command)

def control_device(self, device_id, command):
device_topic = self.devices.get(device_id)
self.secondary_message_bus.publish(device_topic, command)'''
'''


class FeederAgent(DistributedAgent):
Expand Down
11 changes: 11 additions & 0 deletions gridappsd-field-bus-lib/gridappsd/field_interface/context.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from gridappsd import DifferenceBuilder
from gridappsd.field_interface.interfaces import FieldMessageBus
import dataclasses
import gridappsd.topics as t
Expand Down Expand Up @@ -47,6 +48,16 @@ def get_agents(cls, downstream_message_bus: FieldMessageBus):
"""
request = {'request_type' : 'get_agents'}
return downstream_message_bus.get_response(t.context_request_queue(downstream_message_bus.id), request)

@classmethod
def send_control_command(cls, downstream_message_bus: FieldMessageBus, difference_builder: DifferenceBuilder):
"""
Sends the control command to device

"""
request = {'request_type' : 'control_command'}
downstream_message_bus.send(t.context_request_queue(downstream_message_bus.id),
difference_builder.get_message())

# Provide context based on router (ip trace) or PKI
# Maybe able to emulate/simulate