# -*- coding: utf-8 -*-
# (c) Copyright 2020 Sensirion AG, Switzerland
##############################################################################
##############################################################################
# _____ _ _ _______ _____ ____ _ _
# / ____| /\ | | | |__ __|_ _/ __ \| \ | |
# | | / \ | | | | | | | || | | | \| |
# | | / /\ \| | | | | | | || | | | . ` |
# | |____ / ____ \ |__| | | | _| || |__| | |\ |
# \_____/_/ \_\____/ |_| |_____\____/|_| \_|
#
# THIS FILE IS AUTOMATICALLY GENERATED AND MUST NOT BE EDITED MANUALLY!
#
# Generator: sensirion-shdlc-interface-generator 0.8.2
# Product: SFC5xxx
# Version: 0.1.0
#
##############################################################################
##############################################################################
# flake8: noqa
from __future__ import absolute_import, division, print_function
from sensirion_shdlc_driver.command import ShdlcCommand
from struct import pack, unpack
import logging
log = logging.getLogger(__name__)
[docs]class Sfc5xxxCmdSetpointBase(ShdlcCommand):
"""
SHDLC command 0x00: "Setpoint".
"""
[docs] def __init__(self, *args, **kwargs):
"""
Constructor.
"""
super(Sfc5xxxCmdSetpointBase, self).__init__(
0x00, *args, **kwargs)
[docs]class Sfc5xxxCmdGetSetpoint(Sfc5xxxCmdSetpointBase):
"""
Get Setpoint Command
Get the current flow setpoint.
"""
[docs] def __init__(self, scaling):
"""
Constructor.
:param int scaling:
Defines with which scale resp. unit the setpoint should be
returned:
- 0x00: Normalized setpoint in range [0.0 ... 1.0]
- 0x01: Setpoint represents a physical value. The range depends on
the flow unit and calibration range.
- 0x02: Setpoint represents a value in the user defined medium
unit. Requires at least firmware version 1.40.
"""
super(Sfc5xxxCmdGetSetpoint, self).__init__(
data=b"".join([pack(">B", scaling)]),
max_response_time=0.005,
post_processing_time=0.0,
min_response_length=4,
max_response_length=4
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The current setpoint with the specified scaling.
:rtype: float
"""
setpoint = float(unpack(">f", data[0:4])[0]) # float
return setpoint
[docs]class Sfc5xxxCmdSetSetpoint(Sfc5xxxCmdSetpointBase):
"""
Set Setpoint Command
Set the flow setpoint which is used by the flow controller as reference
input.
.. note:: If the "setpoint persists" feature is enabled, the setpoint will
be stored in non-volatile memory and re-applied after a device
reset.
"""
[docs] def __init__(self, scaling, setpoint):
"""
Constructor.
:param int scaling:
Defines with which scale resp. unit the setpoint is transmitted:
- 0x00: Normalized setpoint in range [0.0 ... 1.0]
- 0x01: Setpoint represents a physical value. The range depends on
the flow unit and calibration range.
- 0x02: Setpoint represents a value in the user defined medium
unit. Requires at least firmware version 1.40.
:param float setpoint:
The new setpoint with the specified scaling.
"""
super(Sfc5xxxCmdSetSetpoint, self).__init__(
data=b"".join([pack(">B", scaling),
pack(">f", setpoint)]),
max_response_time=0.005,
post_processing_time=0.0,
min_response_length=0,
max_response_length=0
)