|
1 /************************************************************************** |
|
2 * |
|
3 * Copyright (C) 2012 Steve Karg <skarg@users.sourceforge.net> |
|
4 * Copyright (C) 2017 Mario de Sousa <msousa@fe.up.pt> |
|
5 * |
|
6 * Permission is hereby granted, free of charge, to any person obtaining |
|
7 * a copy of this software and associated documentation files (the |
|
8 * "Software"), to deal in the Software without restriction, including |
|
9 * without limitation the rights to use, copy, modify, merge, publish, |
|
10 * distribute, sublicense, and/or sell copies of the Software, and to |
|
11 * permit persons to whom the Software is furnished to do so, subject to |
|
12 * the following conditions: |
|
13 * |
|
14 * The above copyright notice and this permission notice shall be included |
|
15 * in all copies or substantial portions of the Software. |
|
16 * |
|
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
24 * |
|
25 *********************************************************************/ |
|
26 #ifndef MULTISTATE_INPUT_H |
|
27 #define MULTISTATE_INPUT_H |
|
28 |
|
29 #include <stdbool.h> |
|
30 #include <stdint.h> |
|
31 #include "bacdef.h" |
|
32 #include "bacerror.h" |
|
33 #include "rp.h" |
|
34 #include "wp.h" |
|
35 |
|
36 #ifdef __cplusplus |
|
37 extern "C" { |
|
38 #endif /* __cplusplus */ |
|
39 |
|
40 |
|
41 /* MultiState Inputs are encoded in unsigned integer |
|
42 * (in BACnet => uint8_t), and can not be 0. |
|
43 * See ASHRAE 135-2016, section 12.20.4 |
|
44 */ |
|
45 #define MULTISTATE_MAX_NUMBER_OF_STATES (255) |
|
46 |
|
47 |
|
48 typedef struct Multistate_Input_descr { |
|
49 /* pointer to IEC 61131-3 located variable that is mapped onto this BACnet object */ |
|
50 uint8_t *Located_Var_ptr; |
|
51 uint32_t Object_Identifier; /* called object 'Instance' in the source code! */ |
|
52 char *Object_Name; |
|
53 char *Description; |
|
54 uint8_t Number_Of_States; |
|
55 |
|
56 /* stores the current value */ |
|
57 uint8_t Present_Value; |
|
58 /* Writable out-of-service allows others to manipulate our Present Value */ |
|
59 bool Out_Of_Service; |
|
60 char State_Text[MULTISTATE_MAX_NUMBER_OF_STATES][64]; |
|
61 } MULTISTATE_INPUT_DESCR; |
|
62 |
|
63 |
|
64 void Multistate_Input_Property_Lists( |
|
65 const int **pRequired, |
|
66 const int **pOptional, |
|
67 const int **pProprietary); |
|
68 |
|
69 bool Multistate_Input_Valid_Instance( |
|
70 uint32_t object_instance); |
|
71 unsigned Multistate_Input_Count( |
|
72 void); |
|
73 uint32_t Multistate_Input_Index_To_Instance( |
|
74 unsigned index); |
|
75 unsigned Multistate_Input_Instance_To_Index( |
|
76 uint32_t instance); |
|
77 |
|
78 int Multistate_Input_Read_Property( |
|
79 BACNET_READ_PROPERTY_DATA * rpdata); |
|
80 |
|
81 bool Multistate_Input_Write_Property( |
|
82 BACNET_WRITE_PROPERTY_DATA * wp_data); |
|
83 |
|
84 /* optional API */ |
|
85 bool Multistate_Input_Object_Name( |
|
86 uint32_t object_instance, |
|
87 BACNET_CHARACTER_STRING * object_name); |
|
88 |
|
89 uint32_t Multistate_Input_Present_Value( |
|
90 uint32_t object_instance); |
|
91 bool Multistate_Input_Present_Value_Set( |
|
92 uint32_t object_instance, |
|
93 uint32_t value); |
|
94 |
|
95 bool Multistate_Input_Out_Of_Service( |
|
96 uint32_t object_instance); |
|
97 void Multistate_Input_Out_Of_Service_Set( |
|
98 uint32_t object_instance, |
|
99 bool value); |
|
100 |
|
101 void Multistate_Input_Init( |
|
102 void); |
|
103 |
|
104 |
|
105 |
|
106 #ifdef __cplusplus |
|
107 } |
|
108 #endif /* __cplusplus */ |
|
109 #endif |