ConOpSys V2970  P004.07
ANVILEX control operating system
Function_Block_Digital_Input.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //! @file Function_Block_Digital_Input.h
3 //! @author ANVILEX LLC
4 //! @version V1.0
5 //! @date 26.09.2017
6 //! @brief Discrete delay class header file.
7 //! @attention
8 //!
9 //! COPYRIGHT(C) 2017 ANVILEX GmbH
10 //!
11 //! Redistribution and use in source and binary forms, with or without
12 //! modification, are permitted provided that the following conditions are met:
13 //!
14 //! 1. Redistributions of source code must retain the above copyright notice,
15 //! this list of conditions and the following disclaimer.
16 //!
17 //! 2. Redistributions in binary form must reproduce the above copyright notice,
18 //! this list of conditions and the following disclaimer in the documentation
19 //! and/or other materials provided with the distribution.
20 //!
21 //! 3. Neither the name of ANVILEX nor the names of its contributors may be
22 //! used to endorse or promote products derived from this software without
23 //! specific prior written permission.
24 //!
25 //! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 //! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 //! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 //! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 //! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 //! CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 //! SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 //! INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 //! CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 //! ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 //! POSSIBILITY OF SUCH DAMAGE.
36 //------------------------------------------------------------------------------
37 //
38 // TFunction_Block_Digital_Input_1_T1
39 //
40 //------------------------------------------------------------------------------
41 
42 //------------------------------------------------------------------------------
43 // Protecting header files from mutual, recursive inclusion.
44 //------------------------------------------------------------------------------
45 
46 #pragma once
47 
48 //------------------------------------------------------------------------------
49 // Include standard libraries header files
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 // Include thrid party header files
54 //------------------------------------------------------------------------------
55 
56 //------------------------------------------------------------------------------
57 // Include ConOpSys header files
58 //------------------------------------------------------------------------------
59 
60 #include "Function_Block_Base.h"
61 
62 //------------------------------------------------------------------------------
63 // Include ConOpSys application header files
64 //------------------------------------------------------------------------------
65 
66 //------------------------------------------------------------------------------
67 // Macros
68 //------------------------------------------------------------------------------
69 
70 //------------------------------------------------------------------------------
71 // Class declarations
72 //------------------------------------------------------------------------------
73 
74 //! @brief Digital input, type 2 class description
76 {
77 
78  //----------------------------------------------------------------------------
79  // Public defines, methods and variables
80  //----------------------------------------------------------------------------
81 
82  public:
83 
84  //!-------------------------------------------------------------------------
85  //! @brief Class constructor method.
86  //! @note None
87  //! \par Override
88  //! Not allowed
89  //! @attention Don't call this method directly.
90  //--------------------------------------------------------------------------
91 
93 
94  //!-------------------------------------------------------------------------
95  //! @brief Class destructor method.
96  //! @note None
97  //! \par Override
98  //! Not allowed
99  //! @attention Don't call this method directly.
100  //--------------------------------------------------------------------------
101 
103 
104  //!-------------------------------------------------------------------------
105  //! @brief Function block initialisation method
106  //! @note None
107  //! @return None
108  //! \par Override
109  //! Not allowed
110  //! @attention None
111  //--------------------------------------------------------------------------
112 
113  virtual VOID Init();
114 
115  //!-------------------------------------------------------------------------
116  //! @brief Function block execution method
117  //! @note None
118  //! @return None
119  //! \par Override
120  //! Not allowed
121  //! @attention None
122  //--------------------------------------------------------------------------
123 
124  virtual VOID Execute();
125 
126  //--------------------------------------------------------------------------
127  // Function block parameters
128  //--------------------------------------------------------------------------
129 
130  //--------------------------------------------------------------------------
131  // Function block inputs
132  //--------------------------------------------------------------------------
133 
134  //! @brief Digital input channel connector
136 
137  //! @brief Digital input inversion
139 
140  //! @brief Input signal debounce filter time
142 
143  //! @brief Input signal on delay time
145 
146  //! @brief Input signal off delay time
148 
149  //! @brief Enable counter signal
151 
152  //! @brief Enable counter signal
154 
155  //! @brief Reset counter signal
157 
158  //--------------------------------------------------------------------------
159  // Function block outputs
160  //--------------------------------------------------------------------------
161 
162  //! @brief Digital input ststus signal
164 
165  //! @brief Digital input counter signal
167 
168  //----------------------------------------------------------------------------
169  // Protected methods and variables
170  //----------------------------------------------------------------------------
171 
172  protected:
173 
174  //----------------------------------------------------------------------------
175  // Private methods and variables
176  //----------------------------------------------------------------------------
177 
178  private:
179 
180  //--------------------------------------------------------------------------
181  // Private defines
182  //--------------------------------------------------------------------------
183 
184  //! @brief Internal FSM state definition
185  enum class TDebounce_FSM_State : U8
186  {
187 
188  //! @brief Initialisation state
189  enum_Init = (U8)0,
190 
191  //! @brief Off state
192  enum_Off = (U8)1,
193 
194  //! @brief Off to on transaction state
195  enum_Off_On = (U8)2,
196 
197  //! @brief On state
198  enum_On = (U8)3,
199 
200  //! @brief On to off transaction state
201  enum_On_Off = (U8)4
202 
203  };
204 
205  //! @brief Delay FSM state definition
206  enum class TDelay_FSM_State : U8
207  {
208 
209  //! @brief Off state
210  enum_Off = (U8)0,
211 
212  //! @brief On delay state
213  enum_On_Delay = (U8)1,
214 
215  //! @brief On state
216  enum_On = (U8)2,
217 
218  //! @brief Off delay state
219  enum_Off_Delay = (U8)3
220 
221  };
222 
223  //--------------------------------------------------------------------------
224  // Private variables
225  //--------------------------------------------------------------------------
226 
227  //! @brief Debounce FSM state variable
229 
230  //! @brief Delay FSM state variable
232 
233  //! @brief Delay counter
235 
236  //! @brief Timeout counter
238 
239  //! @brief Edge counter
240  U32 u32_Edge_Counter = (U32)0x00000000;
241 
242  //! @brief Previous input signal
244 
245  //! @brief Delayed input signal
247 
248  //! @brief First loop signal
250 
251 };
252 
253 //------------------------------------------------------------------------------
254 // End of file
255 //------------------------------------------------------------------------------
int BOOL
Boolean datatype definition.
Definition: Defines.h:124
unsigned char U8
Binary 8-Bit unsigned integer datatype defenition.
Definition: Defines.h:183
void VOID
Datatypesess datatype definition.
Definition: Defines.h:105
unsigned long U32
Binary 32-Bit unsigned integer datatype defenition.
Definition: Defines.h:203
unsigned short U16
Binary 16-Bit unsigned integer datatype defenition.
Definition: Defines.h:193
Function block base class header file.
Function block input connector class.
Definition: Block_Input_Connector.h:83
Function block output connector class.
Definition: Block_Output_Connector.h:59
Function block base class for device.
Definition: Function_Block_Base.h:96
Digital input, type 2 class description.
Definition: Function_Block_Digital_Input.h:76
BOOL bool_Delayed_Input_Signal
Delayed input signal.
Definition: Function_Block_Digital_Input.h:246
TBlock_Input_Connector object_u8_Channel
Digital input channel connector.
Definition: Function_Block_Digital_Input.h:135
BOOL bool_Debounced_Input_Signal_Z1
Previous input signal.
Definition: Function_Block_Digital_Input.h:243
TFunction_Block_Digital_Input_T2()
Class constructor method.
Definition: Function_Block_Digital_Input.cpp:68
virtual VOID Init()
Function block initialisation method.
Definition: Function_Block_Digital_Input.cpp:109
virtual VOID Execute()
Function block execution method.
Definition: Function_Block_Digital_Input.cpp:117
U16 u16_Delay_Counter
Delay counter.
Definition: Function_Block_Digital_Input.h:234
TBlock_Input_Connector object_u16_On_Delay_Time
Input signal on delay time.
Definition: Function_Block_Digital_Input.h:144
TBlock_Input_Connector object_bool_Inversion
Digital input inversion.
Definition: Function_Block_Digital_Input.h:138
TDelay_FSM_State
Delay FSM state definition.
Definition: Function_Block_Digital_Input.h:207
BOOL bool_First_Loop
First loop signal.
Definition: Function_Block_Digital_Input.h:249
virtual ~TFunction_Block_Digital_Input_T2()
Class destructor method.
Definition: Function_Block_Digital_Input.cpp:101
TBlock_Output_Connector object_u32_Counter
Digital input counter signal.
Definition: Function_Block_Digital_Input.h:166
TBlock_Input_Connector object_bool_Enable_Counter
Enable counter signal
Definition: Function_Block_Digital_Input.h:153
TBlock_Input_Connector object_u8_Counter_Mode
Enable counter signal
Definition: Function_Block_Digital_Input.h:150
U32 u32_Edge_Counter
Edge counter.
Definition: Function_Block_Digital_Input.h:240
U16 u16_Debounce_Timeout_Counter
Timeout counter.
Definition: Function_Block_Digital_Input.h:237
TBlock_Output_Connector object_bool_Status
Digital input ststus signal.
Definition: Function_Block_Digital_Input.h:163
TDebounce_FSM_State enum_Debounce_FSM_State
Debounce FSM state variable.
Definition: Function_Block_Digital_Input.h:228
TBlock_Input_Connector object_u16_Debounce_Filter_Time
Input signal debounce filter time.
Definition: Function_Block_Digital_Input.h:141
TDelay_FSM_State enum_Delay_State
Delay FSM state variable.
Definition: Function_Block_Digital_Input.h:231
TDebounce_FSM_State
Internal FSM state definition.
Definition: Function_Block_Digital_Input.h:186
TBlock_Input_Connector object_bool_Reset_Counter
Reset counter signal
Definition: Function_Block_Digital_Input.h:156
TBlock_Input_Connector object_u16_Off_Delay_Time
Input signal off delay time
Definition: Function_Block_Digital_Input.h:147