# -*- 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 Sfc5xxxCmdGetCurrentGasDescription(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Gas Description Command
Get the gas description string of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentGasDescription, self).__init__(
data=b"".join([bytes(bytearray([0x11]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=255
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The read gas description string.
:rtype: str
"""
gas_description = str(data[0:].decode('utf-8').rstrip('\0')) # string
return gas_description
[docs]class Sfc5xxxCmdGetCurrentGasId(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Gas Id Command
Get the gas ID of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentGasId, self).__init__(
data=b"".join([bytes(bytearray([0x12]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=4,
max_response_length=4
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The read gas ID.
:rtype: int
"""
gas_id = int(unpack(">I", data[0:4])[0]) # uint32
return gas_id
[docs]class Sfc5xxxCmdGetCurrentGasUnit(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Gas Unit Command
Get the gas unit of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentGasUnit, self).__init__(
data=b"".join([bytes(bytearray([0x13]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=3,
max_response_length=3
)
[docs] @staticmethod
def interpret_response(data):
"""
:return:
- prefix (int) -
Medium unit prefix, see appendix for encoding.
- unit (int) -
Medium unit, see appendix for encoding.
- timebase (int) -
Timebase, see appendix for encoding.
:rtype: tuple
"""
prefix = int(unpack(">b", data[0:1])[0]) # int8
unit = int(unpack(">B", data[1:2])[0]) # uint8
timebase = int(unpack(">B", data[2:3])[0]) # uint8
return prefix,\
unit,\
timebase
[docs]class Sfc5xxxCmdGetCurrentFullscale(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Fullscale Command
Get the fullscale flow of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentFullscale, self).__init__(
data=b"".join([bytes(bytearray([0x14]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=4,
max_response_length=4
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: The read fullscale flow in the unit of the corresponding
calibration.
:rtype: float
"""
fullscale = float(unpack(">f", data[0:4])[0]) # float
return fullscale
[docs]class Sfc5xxxCmdGetCurrentInitialCalibrationConditions(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Initial Calibration Conditions Command
Get the initial calibration conditions of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentInitialCalibrationConditions, self).__init__(
data=b"".join([bytes(bytearray([0x15]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=127,
max_response_length=127
)
[docs] @staticmethod
def interpret_response(data):
"""
:return:
- company (str) -
The company which has created the calibration.
- operator (str) -
The operator who has created the calibration.
- year (int) -
Year of the calibration date.
- month (int) -
Month of the calibration date.
- day (int) -
Day of the calibration date.
- hour (int) -
Hour of the calibration time.
- minute (int) -
Minute of the calibration time.
- temperature (float) -
System/gas temperature [°C] of calibration.
- inlet_pressure (float) -
Absolute pressure of gas inlet [bar].
- differential_pressure (float) -
Pressure difference between inlet and outlet [bar].
- is_real_gas_calibration (bool) -
Whether the calibration was performed with the real process gas
(true) or if it was calculated from a different gas (false).
- accuracy_setpoint (float) -
Calibration accuracy in percent of the setpoint. This accuracy is
valid if larger than the accuracy of fullscale.
- accuracy_fullscale (float) -
Calibration accuracy in percent of fullscale. This value is valid
if larger than the accuracy of the setpoint.
:rtype: tuple
"""
company = str(data[0:50].decode('utf-8').rstrip('\0')) # string<50>
operator = str(data[50:100].decode('utf-8').rstrip('\0')) # string<50>
year = int(unpack(">H", data[100:102])[0]) # uint16
month = int(unpack(">B", data[102:103])[0]) # uint8
day = int(unpack(">B", data[103:104])[0]) # uint8
hour = int(unpack(">B", data[104:105])[0]) # uint8
minute = int(unpack(">B", data[105:106])[0]) # uint8
temperature = float(unpack(">f", data[106:110])[0]) # float
inlet_pressure = float(unpack(">f", data[110:114])[0]) # float
differential_pressure = float(unpack(">f", data[114:118])[0]) # float
is_real_gas_calibration = bool(unpack(">?", data[118:119])[0]) # bool
accuracy_setpoint = float(unpack(">f", data[119:123])[0]) # float
accuracy_fullscale = float(unpack(">f", data[123:127])[0]) # float
return company,\
operator,\
year,\
month,\
day,\
hour,\
minute,\
temperature,\
inlet_pressure,\
differential_pressure,\
is_real_gas_calibration,\
accuracy_setpoint,\
accuracy_fullscale
[docs]class Sfc5xxxCmdGetCurrentRecalibrationConditions(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Recalibration Conditions Command
Get the recalibration conditions of the currently active calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentRecalibrationConditions, self).__init__(
data=b"".join([bytes(bytearray([0x16]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=127,
max_response_length=127
)
[docs] @staticmethod
def interpret_response(data):
"""
:return:
- company (str) -
The company which has created the recalibration.
- operator (str) -
The operator who has created the recalibration.
- year (int) -
Year of the recalibration date.
- month (int) -
Month of the recalibration date.
- day (int) -
Day of the recalibration date.
- hour (int) -
Hour of the recalibration time.
- minute (int) -
Minute of the recalibration time.
- temperature (float) -
System/gas temperature [°C] of recalibration.
- inlet_pressure (float) -
Absolute pressure of gas inlet [bar].
- differential_pressure (float) -
Pressure difference between inlet and outlet [bar].
- is_real_gas_calibration (bool) -
Whether the recalibration was performed with the real process gas
(true) or if it was calculated from a different gas (false).
- accuracy_setpoint (float) -
Calibration accuracy in percent of the setpoint. This accuracy is
valid if larger than the accuracy of fullscale.
- accuracy_fullscale (float) -
Calibration accuracy in percent of fullscale. This value is valid
if larger than the accuracy of the setpoint.
:rtype: tuple
"""
company = str(data[0:50].decode('utf-8').rstrip('\0')) # string<50>
operator = str(data[50:100].decode('utf-8').rstrip('\0')) # string<50>
year = int(unpack(">H", data[100:102])[0]) # uint16
month = int(unpack(">B", data[102:103])[0]) # uint8
day = int(unpack(">B", data[103:104])[0]) # uint8
hour = int(unpack(">B", data[104:105])[0]) # uint8
minute = int(unpack(">B", data[105:106])[0]) # uint8
temperature = float(unpack(">f", data[106:110])[0]) # float
inlet_pressure = float(unpack(">f", data[110:114])[0]) # float
differential_pressure = float(unpack(">f", data[114:118])[0]) # float
is_real_gas_calibration = bool(unpack(">?", data[118:119])[0]) # bool
accuracy_setpoint = float(unpack(">f", data[119:123])[0]) # float
accuracy_fullscale = float(unpack(">f", data[123:127])[0]) # float
return company,\
operator,\
year,\
month,\
day,\
hour,\
minute,\
temperature,\
inlet_pressure,\
differential_pressure,\
is_real_gas_calibration,\
accuracy_setpoint,\
accuracy_fullscale
[docs]class Sfc5xxxCmdGetCurrentThermalConductivityReference(Sfc5xxxCmdGetCurrentCalibrationInformationBase):
"""
Get Current Thermal Conductivity Reference Command
Get the thermal conductivity reference value of the currently active
calibration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetCurrentThermalConductivityReference, self).__init__(
data=b"".join([bytes(bytearray([0x17]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=2,
max_response_length=2
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: Thermal conductivity reference value for the gas.
:rtype: int
"""
reference_value = int(unpack(">H", data[0:2])[0]) # uint16
return reference_value