1 /* 2 * Copyright (c) 2023 Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 * 32 * @file : task_system_attribute.h 33 * @date : Set 26, 2023 34 * @author : Juan Manuel Cruz <jcruz@fi.uba.ar> <jcruz@frba.utn.edu.ar> 35 * @version v1.0.0 36 */ 37 38 #ifndef TASK_INC_TASK_SYSTEM_ATTRIBUTE_H_ 39 #define TASK_INC_TASK_SYSTEM_ATTRIBUTE_H_ 40 41 /********************** CPP guard ********************************************/ 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /********************** inclusions *******************************************/ 47 48 /********************** macros ***********************************************/ 49 50 /********************** typedef **********************************************/ 51 /* System Statechart - State Transition Table */ 52 /* +------------------+----------------------- +-------------+------------------+-----------------------+ 53 * | Current | Event | | Next | | 54 * | State | (Parameters) | [Guard] | State | Actions | 55 * |==================+======================= +=============+==================+=======================| 56 * | INICIAL | | | ST_SYS_IDLE | | 57 * |------------------+----------------------- +-------------+------------------+-----------------------| 58 * | ST_SYS_IDLE | EV_SYS_LOOP_DET | | ST_SYS_ACTIVE_01 | | 59 * | | | | | | 60 * |------------------+----------------------- +-------------+------------------+-----------------------| 61 * | ST_SYS_ACTIVE_01 | EV_SYS_MANUAL_BTN | | ST_SYS_ACTIVE_02 | tick = TICK_MAX | 62 * | | | | | put_event_t.._actuator| 63 * | | | | | (event, identifier) | 64 * |------------------+----------------------- +-------------+------------------+-----------------------| 65 * | ST_SYS_ACTIVE_02 | | [tick == 0] | ST_SYS_ACTIVE_03 | put_event_t.._actuator| 66 * | | | | | (event, identifier) | 67 * | | +-------------+------------------+-----------------------| 68 * | | | [tick > 0] | ST_SYS_ACTIVE_02 | tick-- | 69 * | | | | | | 70 * |------------------+----------------------- +-------------+------------------+-----------------------| 71 * | ST_SYS_ACTIVE_03 | EV_SYS_NOT_LOOP_DET | | ST_SYS_ACTIVE_04 | | 72 * | | | | | | 73 * |------------------+----------------------- +-------------+------------------+-----------------------| 74 * | ST_SYS_ACTIVE_04 | EV_SYS_IR_PHO_CELL | | ST_SYS_ACTIVE_05 | | 75 * | | | | | | 76 * |------------------+----------------------- +-------------+------------------+-----------------------| 77 * | ST_SYS_ACTIVE_05 | EV_SYS_IR_NOT_PHO_CELL | | ST_SYS_ACTIVE_06 | tick = TICK_MAX | 78 * | | | | | put_event_t.._actuator| 79 * | | | | | (event, identifier) | 80 * |------------------+----------------------- +-------------+------------------+-----------------------| 81 * | ST_SYS_ACTIVE_06 | | [tick == 0] | ST_SYS_IDLE | put_event_t.._actuator| 82 * | | | | | (event, identifier) | 83 * | | +-------------+------------------+-----------------------| 84 * | | | [tick > 0] | ST_SYS_ACTIVE_06 | tick-- | 85 * | | | | | | 86 * +------------------+----------------------- +-------------+------------------+-----------------------+ 87 */ 88 89 /* Events to excite Task System */ 90 typedef enum 91 { 92 EV_SYS_IDLE, 93 EV_SYS_LOOP_DET, 94 EV_SYS_NOT_LOOP_DET, 95 EV_SYS_MANUAL_BTN, 96 EV_SYS_NOT_MANUAL_BTN, 97 EV_SYS_IR_PHO_CELL, 98 EV_SYS_NOT_IR_PHO_CELL 99 } task_system_ev_t; 100 101 /* State of Task System */ 102 typedef enum 103 { 104 ST_SYS_IDLE, 105 ST_SYS_ACTIVE_01, 106 ST_SYS_ACTIVE_02, 107 ST_SYS_ACTIVE_03, 108 ST_SYS_ACTIVE_04, 109 ST_SYS_ACTIVE_05, 110 ST_SYS_ACTIVE_06 111 } task_system_st_t; 112 113 typedef struct 114 { 115 uint32_t tick; 116 task_system_st_t state; 117 task_system_ev_t event; 118 bool flag; 119 } task_system_dta_t; 120 121 /********************** external data declaration ****************************/ 122 extern task_system_dta_t task_system_dta; 123 124 /********************** external functions declaration ***********************/ 125 126 /********************** End of CPP guard *************************************/ 127 #ifdef __cplusplus 128 } 129 #endif 130 131 #endif /* TASK_INC_TASK_SYSTEM_ATTRIBUTE_H_ */ 132 133 /********************** end of file ******************************************/
