00001 /** @file IFInterpreter.h 00002 * @author Gabor Madl 00003 * @date Created 11/2005 00004 * @brief This interpreter generates input for the IF toolset from the DREAM models. 00005 * 00006 * 00007 * ================================================================= 00008 * DREAM License v2.0 00009 * 00010 * DREAM - Distributed Real-time Embedded Analysis Method 00011 * http://dre.sourceforge.net. 00012 * Copyright (c) 2005-2007 Gabor Madl, All Rights Reserved. 00013 * 00014 * This file is part of DREAM. 00015 * 00016 * DREAM is free software; you can redistribute it and/or modify it 00017 * under the terms of the GNU General Public License version 2 as 00018 * published by the Free Software Foundation. No future versions of 00019 * the GPL license may be automatically applied to DREAM. It is in 00020 * the sole discretion of the copyright holder to determine whether 00021 * DREAM may be released under a different license or terms. There 00022 * are no restrictions on the use of DREAM for any purpose. 00023 * 00024 * DREAM is distributed in the hope that it will be useful, 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00027 * GNU General Public License for more details. 00028 * 00029 * You should have received a copy of the GNU General Public License 00030 * along with this program; if not, write to the Free Software 00031 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00032 * MA 02110-1301, USA. 00033 * 00034 * By submitting comments, suggestions, code, code snippets, 00035 * techniques (including that of usage), and algorithms, submitters 00036 * acknowledge that they have the right to do so, that any such 00037 * submissions are given freely and unreservedly, and that they 00038 * waive any claims to copyright or ownership. In addition, 00039 * submitters acknowledge that any such submission might become 00040 * part of the copyright maintained on the overall body of code, 00041 * which comprises DREAM. By making a submission, submitter agrees 00042 * to these terms. Furthermore, submitters acknowledge that the 00043 * incorporation or modification of such submissions is entirely 00044 * at the discretion of the moderators of the DREAM project. 00045 * 00046 * DREAM links to the Libxml2 third party library. Please see 00047 * COPYING-libxml for the copyright information of Libxml2. 00048 * ================================================================= 00049 */ 00050 00051 #ifndef DREAM_IFINTERPRETER 00052 #define DREAM_IFINTERPRETER 00053 00054 #include "../core/System.h" 00055 00056 namespace DREAM 00057 { 00058 00059 /** The IFInterpreter class generates input for the IF toolset from the DREAM models. */ 00060 class IFInterpreter 00061 { 00062 public: 00063 /** Constructor. 00064 * @param system_ptr is the pointer to the system to be output. 00065 */ 00066 IFInterpreter (DREAM::System* system_ptr); 00067 00068 /** Destructor. */ 00069 ~IFInterpreter (); 00070 00071 /** Generates the IF system description. 00072 * It uses the visitor pattern to get the data from the DREAM models. 00073 * @param outputFile specifies the output file to be generated. 00074 */ 00075 void visitor_if (char* outputFile) 00076 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING 00077 throw (DREAM::Exception) 00078 #endif 00079 ; 00080 00081 private: 00082 00083 /** Creates an assignment that preempts lower priority tasks to model fixed-priority scheduling based on priorities. 00084 * @param node_map contains the Nodes in the Scheduler. 00085 * @param scheduler_id specifies the Scheduler id. 00086 * @param node is used to calculate the priority level used in the guard. 00087 */ 00088 std::string create_fixedpriority_exec_assignment (NODE_MAP* node_map, std::string scheduler_id, const DREAM::Node* const node) 00089 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING 00090 throw (DREAM::Exception) 00091 #endif 00092 ; 00093 00094 /** Creates guard condition to model fixed-priority scheduling based on priorities. 00095 * @param node_map contains the Nodes in the Scheduler. 00096 * @param scheduler_id specifies the Scheduler id. 00097 * @param node is used to calculate the priority level used in the guard. 00098 */ 00099 std::string create_fixedpriority_guard (NODE_MAP* node_map, std::string scheduler_id, const DREAM::Node* const node) 00100 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING 00101 throw (DREAM::Exception) 00102 #endif 00103 ; 00104 00105 /** Creates guard condition for going back to the initial state to model fixed-priority scheduling based on priorities. 00106 * @param node_map contains the Nodes in the Scheduler. 00107 * @param scheduler_id specifies the Scheduler id. 00108 * @param node is used to calculate the priority level used in the guard. 00109 */ 00110 std::string create_fixedpriority_back_guard (NODE_MAP* node_map, std::string scheduler_id, const DREAM::Node* const node) 00111 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING 00112 throw (DREAM::Exception) 00113 #endif 00114 ; 00115 00116 /** Creates guard condition for the preemptions within schedule_ states. 00117 * @param node_map contains the Nodes in the Scheduler. 00118 * @param scheduler_id specifies the Scheduler id. 00119 * @param node is used to calculate the priority level used in the guard. 00120 */ 00121 std::string create_fixedpriority_preemption_guard (NODE_MAP* node_map, std::string scheduler_id, const DREAM::Node* const node) 00122 #ifdef DREAM_ENHANCED_EXCEPTION_CHECKING 00123 throw (DREAM::Exception) 00124 #endif 00125 ; 00126 00127 /** Determines whether the Task is the highest priority Task in the Scheduler. 00128 * Used to reduce state space caused by preemptions. 00129 * @param task_ptr is a pointer to the Task to be checked. 00130 * @return true if the Task is the highest priority Task in the Scheduler, false otherwise. 00131 */ 00132 bool highestpriority (DREAM::Node* task_ptr); 00133 00134 /** Determines whether the Task is the lowest priority Task in the Scheduler. 00135 * Used to reduce state space caused by preemptions. 00136 * @param task_ptr is a pointer to the Task to be checked. 00137 * @return true if the Task is the lowest priority Task in the Scheduler, false otherwise. 00138 */ 00139 bool lowestpriority (DREAM::Node* task_ptr); 00140 00141 /** Pointer to store the DREAM system */ 00142 DREAM::System* system_ptr_; 00143 00144 /** String storing the name of the generated file. */ 00145 std::string filename_; 00146 }; 00147 00148 }; 00149 00150 #endif 00151