Skip to content

Commit

Permalink
updating setup.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Vignesh2208 committed Sep 27, 2020
1 parent 65b238c commit 98a8855
Show file tree
Hide file tree
Showing 5 changed files with 378 additions and 1 deletion.
5 changes: 4 additions & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ if [ "$1" == "install" ]; then
bazel build :example_hmi
sudo cp bazel-bin/example_hmi /usr/bin

sudo cp bazel-genfiles/py_access_service_proto_pb/src/pc_emulator/proto/*.py src/pc_emulator/proto
sudo chmod 777 src/pc_emulator/proto/*.py

echo "Build and Install finished ..."
else
if [ "$1" == "uninstall" ]; then
Expand All @@ -44,7 +47,7 @@ else
rm /usr/bin/modbus_comm_module || true
rm /usr/bin/plc_runner || true
rm /usr/bin/example_hmi || true

rm src/pc_emulator/proto/*.py
cd contrib/libmodbus && make uninstall
cd ../../
echo "Cleanup finished ..."
Expand Down
1 change: 1 addition & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals
1 change: 1 addition & 0 deletions src/pc_emulator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from __future__ import division, absolute_import, print_function, unicode_literals
303 changes: 303 additions & 0 deletions src/pc_emulator/proto/mem_access_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions src/pc_emulator/proto/mem_access_pb2_grpc.py
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,))

0 comments on commit 98a8855

Please sign in to comment.