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 * | ST_SYS_ACTIVE_03 | EV_SYS_NOT_LOOP_DET | | ST_SYS_ACTIVE_04 | | 71 * | | | | | | 72 * |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------| 73 * | ST_SYS_ACTIVE_04 | EV_SYS_IR_PHO_CELL | | ST_SYS_ACTIVE_05 | | 74 * | | | | | | 75 * |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------| 76 * | ST_SYS_ACTIVE_05 | EV_SYS_IR_NOT_PHO_CELL| | ST_SYS_ACTIVE_06 | tick = TICK_MAX | 77 * | | | | | put_event_t.._actuator| 78 * | | | | | (event, identifier) | 79 * |-----------------------+-----------------------+-----------------------+-----------------------+-----------------------| 80 * | ST_SYS_ACTIVE_06 | | [tick == 0] | ST_SYS_IDLE | put_event_t.._actuator| 81 * | | | | | (event, identifier) | 82 * | | +-----------------------+-----------------------+-----------------------| 83 * | | | [tick > 0] | ST_SYS_ACTIVE_06 | tick-- | 84 * ------------------------+-----------------------+-----------------------+-----------------------+------------------------ 85 */ 86 87 /* Events to excite Task System */ 88 typedef enum task_system_ev {EV_SYS_IDLE, 89 EV_SYS_LOOP_DET, 90 EV_SYS_NOT_LOOP_DET, 91 EV_SYS_MANUAL_BTN, 92 EV_SYS_NOT_MANUAL_BTN, 93 EV_SYS_IR_PHO_CELL, 94 EV_SYS_NOT_IR_PHO_CELL} task_system_ev_t; 95 96 /* State of Task System */ 97 typedef enum task_system_st {ST_SYS_IDLE, 98 ST_SYS_ACTIVE_01, 99 ST_SYS_ACTIVE_02, 100 ST_SYS_ACTIVE_03, 101 ST_SYS_ACTIVE_04, 102 ST_SYS_ACTIVE_05, 103 ST_SYS_ACTIVE_06} task_system_st_t; 104 105 typedef struct 106 { 107 uint32_t tick; 108 task_system_st_t state; 109 task_system_ev_t event; 110 bool flag; 111 } task_system_dta_t; 112 113 /********************** external data declaration ****************************/ 114 extern task_system_dta_t task_system_dta; 115 116 /********************** external functions declaration ***********************/ 117 118 /********************** End of CPP guard *************************************/ 119 #ifdef __cplusplus 120 } 121 #endif 122 123 #endif /* TASK_INC_TASK_SYSTEM_ATTRIBUTE_H_ */ 124 125 /********************** end of file ******************************************/
