Пример #1
0
    def Subscribe_IsInitialized(self, request, context: grpc.ServicerContext) \
            -> ContinuousFlowInitializationController_pb2.Subscribe_IsInitialized_Responses:
        """
        Requests the observable property Is Initialized
            Returns true, if the continuous fow pump is initialized and ready for continuous flow start.
            Use this function to check if the pump is initialized before you start a continuous flow. If you change and continuous flow parameter, like valve settings, cross flow duration and so on, the pump will leave the initialized state. That means, after each parameter change, an initialization is required. Changing the flow rate or the dosing volume does not require and initialization.


        :param request: An empty gRPC request object (properties have no parameters)
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A response object with the following fields:
            IsInitialized (Is Initialized): Returns true, if the continuous fow pump is initialized and ready for continuous flow start.
            Use this function to check if the pump is initialized before you start a continuous flow. If you change and continuous flow parameter, like valve settings, cross flow duration and so on, the pump will leave the initialized state. That means, after each parameter change, an initialization is required. Changing the flow rate or the dosing volume does not require and initialization.
        """

        # initialise the return value
        return_value: ContinuousFlowInitializationController_pb2.Subscribe_IsInitialized_Responses = None

        # we could use a timeout here if we wanted
        while True:
            # TODO:
            #   Add implementation of Simulation for property IsInitialized here and write the resulting
            #   response in return_value

            # create the default value
            if return_value is None:
                return_value = ContinuousFlowInitializationController_pb2.Subscribe_IsInitialized_Responses(
                    #**default_dict['Subscribe_IsInitialized_Responses']
                    IsInitialized=silaFW_pb2.Boolean(value=False))

            yield return_value
    def Subscribe_IsInitialized(self, request, context: grpc.ServicerContext) \
            -> ContinuousFlowInitializationController_pb2.Subscribe_IsInitialized_Responses:
        """
        Requests the observable property Is Initialized
            Returns true, if the continuous fow pump is initialized and ready for continuous flow start.
            Use this function to check if the pump is initialized before you start a continuous flow. If you change and continuous flow parameter, like valve settings, cross flow duration and so on, the pump will leave the initialized state. That means, after each parameter change, an initialization is required. Changing the flow rate or the dosing volume does not require and initialization.


        :param request: An empty gRPC request object (properties have no parameters)
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A response object with the following fields:
            IsInitialized (Is Initialized): Returns true, if the continuous fow pump is initialized and ready for continuous flow start.
            Use this function to check if the pump is initialized before you start a continuous flow. If you change and continuous flow parameter, like valve settings, cross flow duration and so on, the pump will leave the initialized state. That means, after each parameter change, an initialization is required. Changing the flow rate or the dosing volume does not require and initialization.
        """

        new_is_initialized = self.pump.is_initialized()
        is_initialized = not new_is_initialized  # force sending the first value
        while not self.system.state.shutting_down():
            new_is_initialized = self.pump.is_initialized()
            if new_is_initialized != is_initialized:
                is_initialized = new_is_initialized
                yield ContinuousFlowInitializationController_pb2.Subscribe_IsInitialized_Responses(
                    IsInitialized=silaFW_pb2.Boolean(value=is_initialized))
            time.sleep(0.1)  # give client a chance to keep up
Пример #3
0
    def Subscribe_FaultState(self, request, context: grpc.ServicerContext) \
            -> PumpDriveControlService_pb2.Subscribe_FaultState_Responses:
        """
        Requests the observable property Fault State
            Returns if the pump is in fault state. If the value is true (i.e. the pump is in fault state), it can be cleared by calling EnablePumpDrive.

        :param request: An empty gRPC request object (properties have no parameters)
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A response object with the following fields:
            FaultState (Fault State): Returns if the pump is in fault state. If the value is true (i.e. the pump is in fault state), it can be cleared by calling EnablePumpDrive.
        """

        logging.debug("Pump is in fault state: %s",
                      self.pump.is_in_fault_state())

        new_is_in_fault_state = self.pump.is_in_fault_state()
        is_in_fault_state = not new_is_in_fault_state  # force sending the first value
        while not self.system.state.shutting_down():
            if self.system.state.is_operational():
                new_is_in_fault_state = self.pump.is_in_fault_state()
            if new_is_in_fault_state != is_in_fault_state:
                is_in_fault_state = new_is_in_fault_state
                yield PumpDriveControlService_pb2.Subscribe_FaultState_Responses(
                    FaultState=silaFW_pb2.Boolean(value=is_in_fault_state))
            # we add a small delay to give the client a chance to keep up.
            time.sleep(0.1)
    def Subscribe_FaultState(self, request, context: grpc.ServicerContext) \
            -> PumpDriveControlService_pb2.Subscribe_FaultState_Responses:
        """
        Requests the observable property Fault State
            Returns if the pump is in fault state. If the value is true (i.e. the pump is in fault state), it can be cleared by calling EnablePumpDrive.

        :param request: An empty gRPC request object (properties have no parameters)
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A response object with the following fields:
            FaultState (Fault State): Returns if the pump is in fault state. If the value is true (i.e. the pump is in fault state), it can be cleared by calling EnablePumpDrive.
        """

        # initialise the return value
        return_value: PumpDriveControlService_pb2.Subscribe_FaultState_Responses = None

        # we could use a timeout here if we wanted
        while True:
            # TODO:
            #   Add implementation of Simulation for property FaultState here and write the resulting
            #   response in return_value

            # create the default value
            if return_value is None:
                return_value = PumpDriveControlService_pb2.Subscribe_FaultState_Responses(
                    #**default_dict['Subscribe_FaultState_Responses']
                    FaultState=silaFW_pb2.Boolean(value=False)
                )


            yield return_value
# import the required packages
import sila2lib.framework.SiLAFramework_pb2 as silaFW_pb2
import sila2lib.framework.SiLABinaryTransfer_pb2 as silaBinary_pb2
from .gRPC import PumpDriveControlService_pb2 as pb2

# initialise the default dictionary so we can add keys.
#   We need to do this separately/add keys separately, so we can access keys already defined e.g.
#   for the use in data type identifiers
default_dict = dict()

default_dict['InitializePumpDrive_Parameters'] = {}

default_dict['InitializePumpDrive_Responses'] = {}

default_dict['EnablePumpDrive_Parameters'] = {}

default_dict['EnablePumpDrive_Responses'] = {}

default_dict['DisablePumpDrive_Parameters'] = {}

default_dict['DisablePumpDrive_Responses'] = {}

default_dict['Subscribe_PumpDriveState_Responses'] = {
    'PumpDriveState': silaFW_pb2.String(value='default string')
}

default_dict['Subscribe_FaultState_Responses'] = {
    'FaultState': silaFW_pb2.Boolean(value=False)
}
Пример #6
0
# This file contains default values that are used for the implementations to supply them with
#   working, albeit mostly useless arguments.
#   You can also use this file as an example to create your custom responses. Feel free to remove
#   Once you have replaced every occurrence of the defaults with more reasonable values.
#   Or you continue using this file, supplying good defaults..

# import the required packages
import sila2lib.framework.SiLAFramework_pb2 as silaFW_pb2
import sila2lib.framework.SiLABinaryTransfer_pb2 as silaBinary_pb2
from .gRPC import ContinuousFlowInitializationController_pb2 as pb2

# initialise the default dictionary so we can add keys.
#   We need to do this separately/add keys separately, so we can access keys already defined e.g.
#   for the use in data type identifiers
default_dict = dict()

default_dict['InitializeContiflow_Parameters'] = {}

default_dict['InitializeContiflow_Responses'] = {}

default_dict['Subscribe_IsInitialized_Responses'] = {
    'IsInitialized': silaFW_pb2.Boolean(value=False)
}