-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65b238c
commit 98a8855
Showing
5 changed files
with
378 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from __future__ import division, absolute_import, print_function, unicode_literals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from __future__ import division, absolute_import, print_function, unicode_literals |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
import grpc | ||
|
||
from src.pc_emulator.proto import mem_access_pb2 as src_dot_pc__emulator_dot_proto_dot_mem__access__pb2 | ||
|
||
|
||
class AccessServiceStub(object): | ||
"""This service is exposed by a GRPC server. The GRPC server would attach | ||
to all spawned PLCs and provide an interface to access each PLC's input | ||
and output memory values | ||
""" | ||
|
||
def __init__(self, channel): | ||
"""Constructor. | ||
Args: | ||
channel: A grpc.Channel. | ||
""" | ||
self.SetSensorInput = channel.unary_unary( | ||
'/mem_access.AccessService/SetSensorInput', | ||
request_serializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.SensorInput.SerializeToString, | ||
response_deserializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.Status.FromString, | ||
) | ||
self.GetActuatorOutput = channel.unary_unary( | ||
'/mem_access.AccessService/GetActuatorOutput', | ||
request_serializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.ActuatorOutput.SerializeToString, | ||
response_deserializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.Result.FromString, | ||
) | ||
|
||
|
||
class AccessServiceServicer(object): | ||
"""This service is exposed by a GRPC server. The GRPC server would attach | ||
to all spawned PLCs and provide an interface to access each PLC's input | ||
and output memory values | ||
""" | ||
|
||
def SetSensorInput(self, request, context): | ||
"""This rpc call can be leveraged by a sensor implementation to set values | ||
of a PLC's input memory | ||
""" | ||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) | ||
context.set_details('Method not implemented!') | ||
raise NotImplementedError('Method not implemented!') | ||
|
||
def GetActuatorOutput(self, request, context): | ||
"""This rpc call can be leveraged by an actuator implementation to get values | ||
of a PLC's output memory | ||
""" | ||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) | ||
context.set_details('Method not implemented!') | ||
raise NotImplementedError('Method not implemented!') | ||
|
||
|
||
def add_AccessServiceServicer_to_server(servicer, server): | ||
rpc_method_handlers = { | ||
'SetSensorInput': grpc.unary_unary_rpc_method_handler( | ||
servicer.SetSensorInput, | ||
request_deserializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.SensorInput.FromString, | ||
response_serializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.Status.SerializeToString, | ||
), | ||
'GetActuatorOutput': grpc.unary_unary_rpc_method_handler( | ||
servicer.GetActuatorOutput, | ||
request_deserializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.ActuatorOutput.FromString, | ||
response_serializer=src_dot_pc__emulator_dot_proto_dot_mem__access__pb2.Result.SerializeToString, | ||
), | ||
} | ||
generic_handler = grpc.method_handlers_generic_handler( | ||
'mem_access.AccessService', rpc_method_handlers) | ||
server.add_generic_rpc_handlers((generic_handler,)) |