# -*- 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 Sfc5xxxCmdSetpointPersistBase(ShdlcCommand):
"""
SHDLC command 0x02: "Setpoint Persist".
"""
[docs] def __init__(self, *args, **kwargs):
"""
Constructor.
"""
super(Sfc5xxxCmdSetpointPersistBase, self).__init__(
0x02, *args, **kwargs)
[docs]class Sfc5xxxCmdSetSetpointPersist(Sfc5xxxCmdSetpointPersistBase):
"""
Set Setpoint Persist Command
Allows to define if a setpoint should persist after a reset (soft or
hardreset) or if it should be set to zero.
.. note:: This configuration is stored in non-volatile memory of the device
and thus persists after a device reset.
"""
[docs] def __init__(self, persist):
"""
Constructor.
:param bool persist:
Whether the setpoint should persist after a reset or not.
"""
super(Sfc5xxxCmdSetSetpointPersist, self).__init__(
data=b"".join([bytes(bytearray([0x00])),
pack(">?", persist)]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=0,
max_response_length=0
)
[docs]class Sfc5xxxCmdGetSetpointPersist(Sfc5xxxCmdSetpointPersistBase):
"""
Get Setpoint Persist Command
Get the setpoint persist configuration.
"""
[docs] def __init__(self):
"""
Constructor.
"""
super(Sfc5xxxCmdGetSetpointPersist, self).__init__(
data=b"".join([bytes(bytearray([0x80]))]),
max_response_time=0.01,
post_processing_time=0.0,
min_response_length=1,
max_response_length=1
)
[docs] @staticmethod
def interpret_response(data):
"""
:return: Whether the setpoint should persist after a reset or not.
:rtype: bool
"""
persist = bool(unpack(">?", data[0:1])[0]) # bool
return persist