Exemplo n.º 1
0
    def Subscribe_SyringeFillLevel(self, request, context: grpc.ServicerContext) \
            -> PumpFluidDosingService_pb2.Subscribe_SyringeFillLevel_Responses:
        """
        Requests the observable property Syringe Fill Level
            The current amount of fluid left in the syringe.

        :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 stream with the following fields:
            SyringeFillLevel (Syringe Fill Level): The current amount of fluid left in the syringe.
        """

        logging.debug(
            "Property SyringeFillLevel requested in {current_mode} mode".
            format(current_mode=(
                'simulation' if self.simulation_mode else 'real')))

        try:
            for value in self.implementation.Subscribe_SyringeFillLevel(
                    request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
Exemplo n.º 2
0
    def SetFlowUnit(self, request, context: grpc.ServicerContext) \
            -> PumpUnitController_pb2.SetFlowUnit_Responses:
        """
        Executes the unobservable command "Set Flow Unit"
            Sets the flow unit for the pump. The flow unit defines the unit to be used for all flow values passed to or retrieved from the pump.

        :param request: gRPC request containing the parameters passed:
            request.FlowUnit (Flow Unit): The flow unit to be set.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("SetFlowUnit called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.SetFlowUnit(request, context)
        except (SiLAError, UnitConversionError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def StopMoving(self, request, context: grpc.ServicerContext) \
            -> AxisPositionController_pb2.StopMoving_Responses:
        """
        Executes the unobservable command "Stop Moving"
            Immediately stops axis movement of a single axis

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("StopMoving called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.StopMoving(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    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 stream 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.
        """

        logging.debug(
            "Property IsInitialized requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))
        try:
            for value in self.implementation.Subscribe_IsInitialized(
                    request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def SwitchToPosition(self, request, context: grpc.ServicerContext) \
            -> ValvePositionController_pb2.SwitchToPosition_Responses:
        """
        Executes the unobservable command "Switch To Position"
            Switches the valve to the specified position. The given position has to be less than the NumberOfPositions or else a ValidationError is thrown.

        :param request: gRPC request containing the parameters passed:
            request.Position (Position): The target position that the valve should be switched to.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug(
            "SwitchToPosition called in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.SwitchToPosition(request, context)
        except (SiLAFrameworkError, ValvePositionOutOfRangeError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
Exemplo n.º 6
0
    def MoveToHomePosition(self, request, context: grpc.ServicerContext) \
            -> AxisSystemPositionController_pb2.MoveToHomePosition_Responses:
        """
        Executes the unobservable command "Move To Home Position"
            Move the axis system to its home position. The axis system should manage the order of the movement and should know how to move all axes into a home state.

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug(
            "MoveToHomePosition called in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.MoveToHomePosition(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
Exemplo n.º 7
0
    def GenerateFlow(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.CommandConfirmation:
        """
        Executes the observable command "Generate Flow"
            Generate a continuous flow with the given flow rate. Dosing continues until it gets stopped manually by calling StopDosage or until the pusher reached one of its limits.

        :param request: gRPC request containing the parameters passed:
            request.FlowRate (Flow Rate):
            The flow rate at which the pump should dose the fluid. This value can be negative. In that case the pump aspirates the fluid.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A command confirmation object with the following information:
            commandId: A command id with which this observable command can be referenced in future calls
            lifetimeOfExecution: The (maximum) lifetime of this command call.
        """

        logging.debug("GenerateFlow called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.GenerateFlow(request, context)
        except (SiLAError, DeviceError) as err:
            self.implementation.StopDosage(None, None)
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
Exemplo n.º 8
0
    def WriteSetPoint(self, request, context: grpc.ServicerContext) \
            -> ControlLoopService_pb2.WriteSetPoint_Responses:
        """
        Executes the unobservable command "Write Set Point"
            Write a Set Point value to the Controller Device

        :param request: gRPC request containing the parameters passed:
            request.SetPointValue (Set Point Value): The Set Point value to write
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("WriteSetPoint called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        try:
            controller = self._get_channel(context.invocation_metadata(),
                                           "Command")
            return self.implementation.WriteSetPoint(request, controller,
                                                     context)
        except (SiLAError, DeviceError, DecoratorInvalidChannelIndex) as err:
            if isinstance(err, QmixSDKSiLAError):
                err = QmixSDKSiLAError(err)
            elif isinstance(err, DecoratorInvalidChannelIndex):
                err = InvalidChannelIndexError(
                    err.invalid_index,
                    f"The index has to be between 0 and {self.num_channels - 1}."
                )
            err.raise_rpc_error(context=context)
Exemplo n.º 9
0
    def MoveToPosition(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.CommandConfirmation:
        """
        Executes the observable command "Move To Position"
            Move the axis system to the given position with a certain velocity

        :param request: gRPC request containing the parameters passed:
            request.Position (Position): The position to move to
            request.Velocity (Velocity): A real value between 0 (exclusive) and 100 (inclusive) defining the relative speed at which all axes of the axis system should move.The velocity value is multiplied with the maximum velocity value of each axis. So a value of 100 means, all axes travel with their maximum velocity. A value of 50 means, all axes travel with the half of the maximum velocity.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A command confirmation object with the following information:
            commandId: A command id with which this observable command can be referenced in future calls
            lifetimeOfExecution: The (maximum) lifetime of this command call.
        """

        logging.debug("MoveToPosition called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.MoveToPosition(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def Subscribe_MaxPistonStroke(self, request, context: grpc.ServicerContext) \
            -> SyringeConfigurationController_pb2.Subscribe_MaxPistonStroke_Responses:
        """
        Requests the observable property Max Piston Stroke
            The maximum piston stroke defines the maximum position the piston can be moved to before it slips out of the syringe tube. The maximum piston stroke limits the maximum travel range of the syringe pump pusher.

        :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 stream with the following fields:
            MaxPistonStroke (Max Piston Stroke): The maximum piston stroke defines the maximum position the piston can be moved to before it slips out of the syringe tube. The maximum piston stroke limits the maximum travel range of the syringe pump pusher.
        """

        logging.debug(
            "Property MaxPistonStroke requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        try:
            for value in self.implementation.Subscribe_MaxPistonStroke(
                    request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def Subscribe_BatteryVoltage(self, request, context: grpc.ServicerContext) \
            -> BatteryProvider_pb2.Subscribe_BatteryVoltage_Responses:
        """
        Requests the observable property Battery Voltage
            The current voltage of the battery

        :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 stream with the following fields:
            BatteryVoltage (Battery Voltage): The current voltage of the battery
        """

        logging.debug(
            "Property BatteryVoltage requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))
        try:
            for value in self.implementation.Subscribe_BatteryVoltage(
                    request, context):
                yield value
        except (DeviceError, SiLAError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def SetSyringeParameters(self, request, context: grpc.ServicerContext) \
            -> SyringeConfigurationController_pb2.SetSyringeParameters_Responses:
        """
        Executes the unobservable command "Set Syringe Parameters"
            Set syringe parameters.
            If you change the syringe in one device, you need to setup the new syringe parameters to get proper conversion of flow rate und volume units.

        :param request: gRPC request containing the parameters passed:
            request.InnerDiameter (Inner Diameter): Inner diameter of the syringe tube in millimetres.
            request.MaxPistonStroke (Max Piston Stroke): The maximum piston stroke defines the maximum position the piston can be moved to before it slips out of the syringe tube. The maximum piston stroke limits the maximum travel range of the syringe pump pusher.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug(
            "SetSyringeParameters called in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.SetSyringeParameters(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def Subscribe_InnerDiameter(self, request, context: grpc.ServicerContext) \
            -> SyringeConfigurationController_pb2.Subscribe_InnerDiameter_Responses:
        """
        Requests the observable property Inner Diameter
            Inner diameter of the syringe tube in millimetres.

        :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 stream with the following fields:
            InnerDiameter (Inner Diameter): Inner diameter of the syringe tube in millimetres.
        """

        logging.debug(
            "Property InnerDiameter requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        try:
            for value in self.implementation.Subscribe_InnerDiameter(
                    request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def Subscribe_AxesInFaultState(self, request, context: grpc.ServicerContext) \
            -> AxisSystemControlService_pb2.Subscribe_AxesInFaultState_Responses:
        """
        Requests the observable property Axes In Fault State
            Returns all axes of the system that are currently in fault state. The fault state of all axes can be cleared by calling ClearFaultState.

        :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 stream with the following fields:
            AxesInFaultState (Axes In Fault State): Returns all axes of the system that are currently in fault state. The fault state of all axes can be cleared by calling ClearFaultState.
        """

        logging.debug(
            "Property AxesInFaultState requested in {current_mode} mode".
            format(current_mode=(
                'simulation' if self.simulation_mode else 'real')))
        try:
            for value in self.implementation.Subscribe_AxesInFaultState(
                    request, context):
                yield value
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def ClearFaultState(self, request, context: grpc.ServicerContext) \
            -> AxisSystemControlService_pb2.ClearFaultState_Responses:
        """
        Executes the unobservable command "Clear Fault State"
            Clears the fault condition of all axes. This is some kind of error acknowledge that clears the last fault and sets the device in an error-free state.

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("ClearFaultState called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.ClearFaultState(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def TogglePosition(self, request, context: grpc.ServicerContext) \
            -> ValvePositionController_pb2.TogglePosition_Responses:
        """
        Executes the unobservable command "Toggle Position"
            This command only applies for 2-way valves to toggle between its two different positions. If the command is called for any other valve type a ValveNotToggleable error is thrown.

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug(
            "TogglePosition called in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.TogglePosition(request, context)
        except (SiLAFrameworkError, ValvePositionNotAvailableError, ValveNotToggleableError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def Subscribe_Position(self, request, context: grpc.ServicerContext) \
            -> AxisPositionController_pb2.Subscribe_Position_Responses:
        """
        Requests the observable property Position
            The current position of an axis

        :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 stream with the following fields:
            Position (Position): The current position of an axis
        """

        logging.debug(
            "Property Position requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))
        try:
            for value in self.implementation.Subscribe_Position(
                    request, context):
                yield value
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
Exemplo n.º 18
0
    def Subscribe_FlowRate(self, request, context: grpc.ServicerContext) \
            -> PumpFluidDosingService_pb2.Subscribe_FlowRate_Responses:
        """
        Requests the observable property Flow Rate
            The current value of the flow rate. It is 0 if the pump does not dose any fluid.

        :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 stream with the following fields:
            FlowRate (Flow Rate): The current value of the flow rate. It is 0 if the pump does not dose any fluid.
        """

        logging.debug(
            "Property FlowRate requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        try:
            for value in self.implementation.Subscribe_FlowRate(
                    request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def InitializeContiflow(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.CommandConfirmation:
        """
        Executes the observable command "Initialize Contiflow"
            Initialize the continuous flow pump.
            Call this command after all parameters have been set, to prepare the conti flow pump for the start of the continuous flow. The initialization procedure ensures, that the syringes are sufficiently filled to start the continuous flow. So calling this command may cause a syringe refill if the syringes are not sufficiently filled. So before calling this command you should ensure, that syringe refilling properly works an can be executed. If you have a certain syringe refill procedure, you can also manually refill the syringes with the normal syringe pump functions. If the syringes are sufficiently filled if you call this function, no refilling will take place.

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A command confirmation object with the following information:
            commandId: A command id with which this observable command can be referenced in future calls
            lifetimeOfExecution: The (maximum) lifetime of this command call.
        """

        logging.debug(
            "InitializeContiflow called in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.InitializeContiflow(request, context)
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
Exemplo n.º 20
0
    def Subscribe_VolumeUnit(self, request, context: grpc.ServicerContext) \
            -> PumpUnitController_pb2.Subscribe_VolumeUnit_Responses:
        """
        Requests the observable property Volume Unit
            The currently used volume unit.

        :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 stream with the following fields:
            VolumeUnit (Volume Unit): The currently used volume unit.
        """

        logging.debug(
            "Property VolumeUnit requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))

        try:
            for value in self.implementation.Subscribe_VolumeUnit(
                    request, context):
                yield value
        except (SiLAError, UnitConversionError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
Exemplo n.º 21
0
    def SetOutputValue(self, request, context: grpc.ServicerContext) \
            -> AnalogOutChannelController_pb2.SetOutputValue_Responses:
        """
        Executes the unobservable command "Set Output Value"
            Set the value of the analog output channel.

        :param request: gRPC request containing the parameters passed:
            request.Value (Value): The value to set.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("SetOutputValue called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        try:
            channel: AnalogOutChannel = self._get_channel(
                context.invocation_metadata(), "Command")
            return self.implementation.SetOutputValue(request, channel,
                                                      context)
        except (SiLAError, DeviceError,
                DecoratorInvalidChannelIndexError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            elif isinstance(err, DecoratorInvalidChannelIndexError):
                err = InvalidChannelIndexError(
                    err.invalid_index,
                    f"The index has to be between 0 and {self.num_channels - 1}."
                )
            err.raise_rpc_error(context=context)
Exemplo n.º 22
0
    def Subscribe_Value(self, request, context: grpc.ServicerContext) \
            -> AnalogOutChannelController_pb2.Subscribe_Value_Responses:
        """
        Requests the observable property Value
            The value of the analog output channel.

        :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 stream with the following fields:
            Value (Value): The value of the analog output channel.
        """

        logging.debug("Property Value requested in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))
        try:
            channel = self._get_channel(context.invocation_metadata(),
                                        "Property")
            for value in self.implementation.Subscribe_Value(
                    request, channel, context):
                yield value
        except (SiLAError, DeviceError,
                DecoratorInvalidChannelIndexError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            elif isinstance(err, DecoratorInvalidChannelIndexError):
                err = InvalidChannelIndexError(
                    err.invalid_index,
                    f"The index has to be between 0 and {self.num_channels - 1}."
                )
            err.raise_rpc_error(context=context)
    def Subscribe_PumpDriveState(self, request, context: grpc.ServicerContext) \
            -> PumpDriveControlService_pb2.Subscribe_PumpDriveState_Responses:
        """
        Requests the observable property Pump Drive State
            The current state of the pump. This is either 'Enabled' or 'Disabled'. Only if the sate is 'Enabled', the pump can dose fluids.

        :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 stream with the following fields:
            PumpDriveState (Pump Drive State): The current state of the pump. This is either 'Enabled' or 'Disabled'. Only if the sate is 'Enabled', the pump can dose fluids.
        """

        logging.debug(
            "Property PumpDriveState requested in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        try:
            for value in self.implementation.Subscribe_PumpDriveState(request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    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 stream 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(
            "Property FaultState requested in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        try:
            for value in self.implementation.Subscribe_FaultState(request, context):
                yield value
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def DisablePumpDrive(self, request, context: grpc.ServicerContext) \
            -> PumpDriveControlService_pb2.DisablePumpDrive_Responses:
        """
        Executes the unobservable command "Disable Pump Drive"
            Set the pump into disabled state.

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug(
            "DisablePumpDrive called in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.DisablePumpDrive(request, context)
        except DeviceError as err:
            err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context)
    def InitializePumpDrive_Info(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.ExecutionInfo:
        """
        Returns execution information regarding the command call :meth:`~.InitializePumpDrive`.

        :param request: A request object with the following properties
            CommandExecutionUUID: The UUID of the command executed.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: An ExecutionInfo response stream for the command with the following fields:
            commandStatus: Status of the command (enumeration)
            progressInfo: Information on the progress of the command (0 to 1)
            estimatedRemainingTime: Estimate of the remaining time required to run the command
            updatedLifetimeOfExecution: An update on the execution lifetime
        """

        logging.debug(
            "InitializePumpDrive_Info called in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )
        try:
            return self.implementation.InitializePumpDrive_Info(request, context)
        except (DeviceError, SiLAError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def InitializePumpDrive(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.CommandConfirmation:
        """
        Executes the observable command "Initialize Pump Drive"
            Initialize the pump drive (e.g. by executing a reference move).

        :param request: gRPC request containing the parameters passed:
            request.EmptyParameter (Empty Parameter): An empty parameter data type used if no parameter is required.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A command confirmation object with the following information:
            commandId: A command id with which this observable command can be referenced in future calls
            lifetimeOfExecution: The (maximum) lifetime of this command call.
        """

        logging.debug(
            "InitializePumpDrive called in {current_mode} mode".format(
                current_mode=('simulation' if self.simulation_mode else 'real')
            )
        )

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.InitializePumpDrive(request, context)
        except (DeviceError, SiLAError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def MoveToPosition(self, request, context: grpc.ServicerContext) \
            -> silaFW_pb2.CommandConfirmation:
        """
        Executes the observable command "Move To Position"
            Move the axis to the given position with a certain velocity

        :param request: gRPC request containing the parameters passed:
            request.Position (Position): The position to move to. Has to be in the range between MinimumPosition and MaximumPosition. See PositionUnit for the unit that is used for a specific axis. E.g. for rotational axis systems one of the axes needs a position specified in radians.
            request.Velocity (Velocity): The velocity value for the movement. Has to be in the range between MinimumVelocity and MaximumVelocity.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: A command confirmation object with the following information:
            commandId: A command id with which this observable command can be referenced in future calls
            lifetimeOfExecution: The (maximum) lifetime of this command call.
        """

        logging.debug("MoveToPosition called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            return self.implementation.MoveToPosition(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
    def Get_MaximumVelocity(self, request, context: grpc.ServicerContext) \
            -> AxisPositionController_pb2.Get_MaximumVelocity_Responses:
        """
        Requests the unobservable property Maximum Velocity
            The maximum velocity limit of an axis

        :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:
            MaximumVelocity (Maximum Velocity): The maximum velocity limit of an axis
        """

        logging.debug(
            "Property MaximumVelocity requested in {current_mode} mode".format(
                current_mode=(
                    'simulation' if self.simulation_mode else 'real')))
        try:
            return self.implementation.Get_MaximumVelocity(request, context)
        except (SiLAError, DeviceError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            err.raise_rpc_error(context=context)
Exemplo n.º 30
0
    def SetOutput(self, request, context: grpc.ServicerContext) \
            -> DigitalOutChannelController_pb2.SetOutput_Responses:
        """
        Executes the unobservable command "Set Output"
            Switch a digital output channel on or off.

        :param request: gRPC request containing the parameters passed:
            request.State (State): The state to set.
        :param context: gRPC :class:`~grpc.ServicerContext` object providing gRPC-specific information

        :returns: The return object defined for the command with the following fields:
            EmptyResponse (Empty Response): An empty response data type used if no response is required.
        """

        logging.debug("SetOutput called in {current_mode} mode".format(
            current_mode=('simulation' if self.simulation_mode else 'real')))

        # parameter validation
        # if request.my_paramameter.value out of scope :
        #        sila_val_err = SiLAValidationError(parameter="myParameter",
        #                                           msg=f"Parameter {request.my_parameter.value} out of scope!")
        #        sila_val_err.raise_rpc_error(context)

        try:
            channel = self._get_channel(context.invocation_metadata(),
                                        "Command")
            return self.implementation.SetOutput(request, channel, context)
        except (SiLAError, DeviceError,
                DecoratorInvalidChannelIndexError) as err:
            if isinstance(err, DeviceError):
                err = QmixSDKSiLAError(err)
            elif isinstance(err, DecoratorInvalidChannelIndexError):
                err = InvalidChannelIndexError(
                    err.invalid_index,
                    f"The index has to be between 0 and {self.num_channels - 1}."
                )
            err.raise_rpc_error(context=context)