Source code for sensirion_shdlc_svm40.commands.algorithm_states

# -*- 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:      SVM40
# Version:      0.3.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 Svm40CmdAlgorithmStatesBase(ShdlcCommand): """ SHDLC command 0x61: "Algorithm States". """
[docs] def __init__(self, *args, **kwargs): """ Constructor. """ super(Svm40CmdAlgorithmStatesBase, self).__init__( 0x61, *args, **kwargs)
[docs]class Svm40CmdGetVocState(Svm40CmdAlgorithmStatesBase): """ Get Voc State Command Gets the current VOC algorithm state. Retrieved values can be used to set the VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available during measurement mode. .. note:: This feature can only be used after at least 3 hours of continuous operation. """
[docs] def __init__(self): """ Constructor. """ super(Svm40CmdGetVocState, self).__init__( data=b"".join([bytes(bytearray([0x08]))]), max_response_time=0.05, post_processing_time=0.0, min_response_length=8, max_response_length=8 )
[docs] @staticmethod def interpret_response(data): """ :return: Current VOC algorithm state. :rtype: list(int) """ state = [int(ii) for ii in unpack(">{}B".format(len(data[0:8]) // 1), data[0:8])] # list(uint8) return state
[docs]class Svm40CmdSetVocState(Svm40CmdAlgorithmStatesBase): """ Set Voc State Command Set previously retrieved VOC algorithm state to resume operation after a short interruption, skipping initial learning phase. This command is only available in idle mode. .. note:: This feature should not be used after interruptions of more than 10 minutes. """
[docs] def __init__(self, state): """ Constructor. :param list(int) state: Current VOC algorithm state. """ super(Svm40CmdSetVocState, self).__init__( data=b"".join([bytes(bytearray([0x88])), pack(">{}B".format(len(state)), *state)]), max_response_time=0.05, post_processing_time=0.0, min_response_length=0, max_response_length=0 )