diff --git a/Examples/17a_zeromq_simple.py b/Examples/17a_zeromq_simple.py index 6966fec5..ad5e2dad 100644 --- a/Examples/17a_zeromq_simple.py +++ b/Examples/17a_zeromq_simple.py @@ -37,17 +37,28 @@ def run_zmq(logfile=None): network_address = "tcp://*:5555" server = wfc_zmq_server(network_address, timeout=60.0, verbose=False, logfile=logfile) - # Provide the wind farm control algorithm as the wfc_controller method of the server + # Provide the wind farm control algorithm as the wfc_controller subclass of the server server.wfc_controller = wfc_controller() # Run the server to receive measurements and send setpoints server.runserver() class wfc_controller(): + """ + Users needs to define this class to implement wind farm controller. + This class should contain a method named update_setpoints that + should take as argument the turbine id, the current time and current + measurements and return the setpoints for the particular turbine for + the current time. It should ouput the setpoints as a dictionary whose + keys should be as defined in wfc_zmq_server.wfc_interface. + The wfc_controller subclass of the wfc_zmq_server should be overwriten + with this class, otherwise, an exception is raised and the simulation stops. + """ + def __init__(self): return None - def update(self, id,current_time,measurements): + def update_setpoints(self, id,current_time,measurements): if current_time <= 10.0: yaw_setpoint = 0.0 else: diff --git a/Examples/17b_zeromq_multi_openfast.py b/Examples/17b_zeromq_multi_openfast.py index 2e3eb08d..7a320857 100644 --- a/Examples/17b_zeromq_multi_openfast.py +++ b/Examples/17b_zeromq_multi_openfast.py @@ -22,7 +22,7 @@ def run_zmq(logfile=None): network_address = "tcp://*:5555" server = wfc_zmq_server(network_address, timeout=60.0, verbose=False, logfile = logfile) - # Provide the wind farm control algorithm as the wfc_controller method of the server + # Provide the wind farm control algorithm as the wfc_controller subclass of the server server.wfc_controller = wfc_controller() # Run the server to receive measurements and send setpoints @@ -30,20 +30,21 @@ def run_zmq(logfile=None): class wfc_controller(): + """ + Users needs to define this class to implement wind farm controller. + This class should contain a method named update_setpoints that + should take as argument the turbine id, the current time and current + measurements and return the setpoints for the particular turbine for + the current time. It should ouput the setpoints as a dictionary whose + keys should be as defined in wfc_zmq_server.wfc_interface. + The wfc_controller subclass of the wfc_zmq_server should be overwriten + with this class, otherwise, an exception is raised and the simulation stops. + """ + def __init__(self): return None - def update(self, id, current_time, measurements): - """ - Users needs to define this function to implement wind farm controller. - The user defined function should take as argument the turbine id, the - current time and current measurements and return the setpoints - for the particular turbine for the current time. It should ouput the - setpoints as a dictionary whose keys should be as defined in - wfc_zmq_server.wfc_interface. The wfc_controller method of the wfc_zmq_server - should be overwriten with this fuction, otherwise, an exception is raised and - the simulation stops. - """ + def update_setpoints(self, id, current_time, measurements): if current_time <= 10.0: YawOffset = 0.0 col_pitch_command = 0.0 diff --git a/rosco/toolbox/control_interface.py b/rosco/toolbox/control_interface.py index ea2ddbbf..f2d45e72 100644 --- a/rosco/toolbox/control_interface.py +++ b/rosco/toolbox/control_interface.py @@ -418,7 +418,7 @@ def _get_setpoints(self, id, measurements): logger.debug( f"Asking wfc_controller for setpoints at time = {current_time} for id = {id}" ) - setpoints = self.wfc_controller.update(id, current_time, measurements) + setpoints = self.wfc_controller.update_setpoints(id, current_time, measurements) logger.info(f"Received setpoints {setpoints} from wfc_controller for time = {current_time} and id = {id}") for s in self.wfc_interface["setpoints"]: