Edouard@2020: /**************************************************************************
Edouard@2020: *
Edouard@2020: * Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net>
Edouard@2020: * Copyright (C) 2017 Mario de Sousa <msousa@fe.up.pt>
Edouard@2020: *
Edouard@2020: * Permission is hereby granted, free of charge, to any person obtaining
Edouard@2020: * a copy of this software and associated documentation files (the
Edouard@2020: * "Software"), to deal in the Software without restriction, including
Edouard@2020: * without limitation the rights to use, copy, modify, merge, publish,
Edouard@2020: * distribute, sublicense, and/or sell copies of the Software, and to
Edouard@2020: * permit persons to whom the Software is furnished to do so, subject to
Edouard@2020: * the following conditions:
Edouard@2020: *
Edouard@2020: * The above copyright notice and this permission notice shall be included
Edouard@2020: * in all copies or substantial portions of the Software.
Edouard@2020: *
Edouard@2020: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Edouard@2020: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Edouard@2020: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Edouard@2020: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
Edouard@2020: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
Edouard@2020: * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
Edouard@2020: * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Edouard@2020: *
Edouard@2020: *********************************************************************/
Edouard@2020: #ifndef MULTISTATE_INPUT_H
Edouard@2020: #define MULTISTATE_INPUT_H
Edouard@2020: 
Edouard@2020: #include <stdbool.h>
Edouard@2020: #include <stdint.h>
Edouard@2020: #include "bacdef.h"
Edouard@2020: #include "bacerror.h"
Edouard@2020: #include "rp.h"
Edouard@2020: #include "wp.h"
Edouard@2020: 
Edouard@2020: #ifdef __cplusplus
Edouard@2020: extern "C" {
Edouard@2020: #endif /* __cplusplus */
Edouard@2020: 
Edouard@2020: 
Edouard@2020: /* MultiState Inputs are encoded in unsigned integer
Edouard@2020:  * (in BACnet => uint8_t), and can not be 0.
Edouard@2020:  * See ASHRAE 135-2016, section 12.20.4
Edouard@2020:  */
Edouard@2020: #define MULTISTATE_MAX_NUMBER_OF_STATES (255)
Edouard@2020: 
Edouard@2020: 
Edouard@2020:     typedef struct Multistate_Input_descr {
Edouard@2020:         /* pointer to IEC 61131-3 located variable that is mapped onto this BACnet object */
Edouard@2020:         uint8_t *Located_Var_ptr;
Edouard@2020:         uint32_t Object_Identifier;  /* called object 'Instance' in the source code! */
Edouard@2020:         char    *Object_Name;   
Edouard@2020:         char    *Description;
Edouard@2020:         uint8_t  Number_Of_States;
Edouard@2020: 
Edouard@2020:         /* stores the current value */
Edouard@2020:         uint8_t Present_Value;
Edouard@2020:         /* Writable out-of-service allows others to manipulate our Present Value */
Edouard@2020:         bool Out_Of_Service;
Edouard@2020:         char State_Text[MULTISTATE_MAX_NUMBER_OF_STATES][64];
Edouard@2020:     } MULTISTATE_INPUT_DESCR;
Edouard@2020: 
Edouard@2020: 
Edouard@2020:     void Multistate_Input_Property_Lists(
Edouard@2020:         const int **pRequired,
Edouard@2020:         const int **pOptional,
Edouard@2020:         const int **pProprietary);
Edouard@2020: 
Edouard@2020:     bool Multistate_Input_Valid_Instance(
Edouard@2020:         uint32_t object_instance);
Edouard@2020:     unsigned Multistate_Input_Count(
Edouard@2020:         void);
Edouard@2020:     uint32_t Multistate_Input_Index_To_Instance(
Edouard@2020:         unsigned index);
Edouard@2020:     unsigned Multistate_Input_Instance_To_Index(
Edouard@2020:         uint32_t instance);
Edouard@2020: 
Edouard@2020:     int Multistate_Input_Read_Property(
Edouard@2020:         BACNET_READ_PROPERTY_DATA * rpdata);
Edouard@2020: 
Edouard@2020:     bool Multistate_Input_Write_Property(
Edouard@2020:         BACNET_WRITE_PROPERTY_DATA * wp_data);
Edouard@2020: 
Edouard@2020:     /* optional API */
Edouard@2020:     bool Multistate_Input_Object_Name(
Edouard@2020:         uint32_t object_instance,
Edouard@2020:         BACNET_CHARACTER_STRING * object_name);
Edouard@2020: 
Edouard@2020:     uint32_t Multistate_Input_Present_Value(
Edouard@2020:         uint32_t object_instance);
Edouard@2020:     bool Multistate_Input_Present_Value_Set(
Edouard@2020:         uint32_t object_instance,
Edouard@2020:         uint32_t value);
Edouard@2020: 
Edouard@2020:     bool Multistate_Input_Out_Of_Service(
Edouard@2020:         uint32_t object_instance);
Edouard@2020:     void Multistate_Input_Out_Of_Service_Set(
Edouard@2020:         uint32_t object_instance,
Edouard@2020:         bool value);
Edouard@2020: 
Edouard@2020:     void Multistate_Input_Init(
Edouard@2020:         void);
Edouard@2020: 
Edouard@2020: 
Edouard@2020: 
Edouard@2020: #ifdef __cplusplus
Edouard@2020: }
Edouard@2020: #endif /* __cplusplus */
Edouard@2020: #endif