You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be pretty cool to have a full decorator-styled syntax for a server to provide access to the various data points that could be defined for SEL Protocol Regions. Take this for example:
fromselprotopy.serverimportSELProtoServer# Create a simple server listening on all network interfaces on port 23server=SELProtoServer(
host="0.0.0.0",
port=23,
fid="SEL-751....",
)
@server.fast_meter_binary("52A")defserve_52A() ->bool:
"""Respond with a Boolean to Represent the 52A Status."""returnTrue@server.fast_meter_analog("IA")defserve_IA() ->complex:
"""Return the Complex Value for the Phase-A Current."""# Return the static value: 67 /_ 120returncomplex(-33.45+58.024j)
@server.command_response("MET E")defmet_e_command() ->str:
"""Respond to the `MET E` Command with an Appropriate set of Data."""withopen("my_saved_met_e.txt", 'r', encoding='utf-8') asfile:
returnfile.read()
if__name__=="__main__":
server.run()
The text was updated successfully, but these errors were encountered:
Here's a little sample code that could be used as the functional structure of the code being used, above:
classDecoratedRecorder:
def__init__(self) ->None:
"""Set up Storage Facility for Lookups."""self._callbacks= {}
defnew_attachment(self, name):
defdecorator(func):
self._callbacks[name] =funcreturnfuncreturndecoratordefassociate_callback(self, name):
"""Test for Creating an Associative Callback."""print("does something")
returnself.new_attachment(name)
recorder=DecoratedRecorder()
@recorder.associate_callback("test")deftest_this():
"""Test to See What Happens."""return"foo"print(recorder._callbacks)
It would be pretty cool to have a full decorator-styled syntax for a server to provide access to the various data points that could be defined for SEL Protocol Regions. Take this for example:
The text was updated successfully, but these errors were encountered: