|
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_OUTPUT_H |
|
27 #define MULTISTATE_OUTPUT_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 Outputs 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_Output_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 /* one entry per priority value */ |
|
58 uint8_t Present_Value[BACNET_MAX_PRIORITY]; |
|
59 /* Writable out-of-service allows others to manipulate our Present Value */ |
|
60 bool Out_Of_Service; |
|
61 char State_Text[MULTISTATE_MAX_NUMBER_OF_STATES][64]; |
|
62 } MULTISTATE_OUTPUT_DESCR; |
|
63 |
|
64 |
|
65 void Multistate_Output_Property_Lists( |
|
66 const int **pRequired, |
|
67 const int **pOptional, |
|
68 const int **pProprietary); |
|
69 |
|
70 bool Multistate_Output_Valid_Instance( |
|
71 uint32_t object_instance); |
|
72 unsigned Multistate_Output_Count( |
|
73 void); |
|
74 uint32_t Multistate_Output_Index_To_Instance( |
|
75 unsigned index); |
|
76 unsigned Multistate_Output_Instance_To_Index( |
|
77 uint32_t instance); |
|
78 |
|
79 int Multistate_Output_Read_Property( |
|
80 BACNET_READ_PROPERTY_DATA * rpdata); |
|
81 |
|
82 bool Multistate_Output_Write_Property( |
|
83 BACNET_WRITE_PROPERTY_DATA * wp_data); |
|
84 |
|
85 /* optional API */ |
|
86 bool Multistate_Output_Object_Name( |
|
87 uint32_t object_instance, |
|
88 BACNET_CHARACTER_STRING * object_name); |
|
89 |
|
90 uint32_t Multistate_Output_Present_Value( |
|
91 uint32_t object_instance); |
|
92 bool Multistate_Output_Present_Value_Set( |
|
93 uint32_t object_instance, |
|
94 uint32_t value, |
|
95 uint8_t priority); |
|
96 |
|
97 bool Multistate_Output_Out_Of_Service( |
|
98 uint32_t object_instance); |
|
99 void Multistate_Output_Out_Of_Service_Set( |
|
100 uint32_t object_instance, |
|
101 bool value); |
|
102 |
|
103 void Multistate_Output_Init( |
|
104 void); |
|
105 |
|
106 |
|
107 #ifdef __cplusplus |
|
108 } |
|
109 #endif /* __cplusplus */ |
|
110 #endif |