00001 //--------------------------------------------------------------------------- 00002 00003 #ifndef InterfaceH 00004 #define InterfaceH 00005 00006 //This section controls dll builds. When using this file in a dll, the dll 00007 //project should define BUILDING_INTERFACE. When building an app that uses the 00008 //resulting DLL and may include this as a header file, the app should define 00009 //GENERATING_DLL_APP. If using this file in a non-DLL app, don't define 00010 //anything. 00011 #if defined(BUILDING_INTERFACE) 00012 #define __INTERFACE_EXPORT_TYPE __declspec(dllexport) 00013 #elif defined(GENERATING_DLL_APP) 00014 #define __INTERFACE_EXPORT_TYPE __declspec(dllimport) 00015 #else 00016 #define __INTERFACE_EXPORT_TYPE 00017 #endif 00018 00019 #include "Messages.h" 00020 00021 /**************************************************************************** 00022 ***************************************************************************** 00023 COMMAND LINE INTERFACE 00024 00025 This DLL contains everything for interfacing the model with the command line. 00026 It contains functions for reading data from and writing data to a console. 00027 00028 **************************************************************************** 00029 ****************************************************************************/ 00030 00031 //Model states - keep synched with the sim manager 00032 enum simState{No_Data, //object managers are created but have no objects - 00033 //system is ready to receive data 00034 Initialized, //sufficient input data has been received - a 00035 //run is possible - object managers have objects and all 00036 //have a status of ready 00037 Paused, //this indicates that there is an unfinished run 00038 Run_Complete //this indicates that a run is complete 00039 }; 00040 00041 /**************************************************************************** 00042 REQUIRED FUNCTIONS 00043 These functions are those which are required to be defined and implemented 00044 in order to make a complete SORTIE interface. 00045 ****************************************************************************/ 00046 00047 /*////////////////////////////////////////////////////////////////////////// 00048 DoIntroduction() 00049 This will be called before anything else is done in a non-batch situation. 00050 It allows the interface to call any introductory screens, or ignore it if 00051 there's nothing to be done. 00053 __INTERFACE_EXPORT_TYPE void DoIntroduction(); 00054 00055 /*////////////////////////////////////////////////////////////////////////// 00056 GetMessage() 00057 This is used when the model is expecting a user message and cannot go on 00058 without one. This function will continue to listen for input until some has 00059 been received. 00061 __INTERFACE_EXPORT_TYPE modelMsg GetMessage(); 00062 00074 __INTERFACE_EXPORT_TYPE modelMsg CheckForMessage(char *cAppPath); 00075 00076 /*////////////////////////////////////////////////////////////////////////// 00077 SendMessage() 00078 This function accepts a message from the sim manager. 00080 __INTERFACE_EXPORT_TYPE void SendMessage(modelMsg msg, bool batch = false); 00081 00082 /*////////////////////////////////////////////////////////////////////////// 00083 ExternalErrorHandler() 00084 This function accepts an error from the sim manager and processes it by 00085 displaying the appropriate error message. If this is batch, different 00086 messages can be written. 00088 __INTERFACE_EXPORT_TYPE void ExternalErrorHandler( 00089 modelErr stcError, int iModelState, bool batch = false); 00090 00091 /*************************************************************************** 00092 INTERFACE-SPECIFIC FUNCTIONS 00093 These functions are specific to this interface. 00094 ****************************************************************************/ 00095 00096 /*/////////////////////////////////////////////////////////////////////////// 00097 WritePrompt() 00098 This writes a prompt to cue the user to input commands. 00100 void WritePrompt(); 00101 00102 /*/////////////////////////////////////////////////////////////////////////// 00103 WriteIntroductoryScreen() 00104 This writes the screen that appears when SORTIE is first started from the 00105 command line. 00107 void WriteIntroductoryScreen(); 00108 00109 /*/////////////////////////////////////////////////////////////////////////// 00110 WriteBadCommand() 00111 This writes an error message if the user types a command that the model 00112 doesn't recognize. 00114 void WriteBadCommand(); 00115 00116 /*/////////////////////////////////////////////////////////////////////////// 00117 WriteGeneralHelp() 00118 This writes the general help screen. 00120 void WriteGeneralHelp(); 00121 00122 /*/////////////////////////////////////////////////////////////////////////// 00123 WriteInputHelp() 00124 This writes the input help screen. 00126 void WriteInputHelp(); 00127 00128 /*/////////////////////////////////////////////////////////////////////////// 00129 WriteRunHelp() 00130 This writes the help screen for the "run" command. 00132 void WriteRunHelp(); 00133 00134 /*/////////////////////////////////////////////////////////////////////////// 00135 WritePauseHelp() 00136 This writes the help screen for the "pause" command. 00138 void WritePauseHelp(); 00139 00140 /*/////////////////////////////////////////////////////////////////////////// 00141 WriteQuitHelp() 00142 This writes the help screen for the "quit" command. 00144 void WriteQuitHelp(); 00145 00146 /*/////////////////////////////////////////////////////////////////////////// 00147 WriteNeedFile() 00148 If the application is expecting a file name and path and doesn't get one, 00149 this prompts the user for one 00151 void WriteNeedFile(); 00152 00153 /*/////////////////////////////////////////////////////////////////////////// 00154 WriteBadFile() 00155 If a user inputs a bad file name, this gives an appropriate error message 00157 void WriteBadFile(modelErr stcErr); 00158 00159 /*/////////////////////////////////////////////////////////////////////////// 00160 WriteModelReady() 00161 This writes a message indicating that the model is ready. 00163 void WriteModelReady(); 00164 00165 /*/////////////////////////////////////////////////////////////////////////// 00166 WriteModelNotReady() 00167 This writes a message indicating that the model is not ready. 00169 void WriteModelNotReady(); 00170 00171 /*/////////////////////////////////////////////////////////////////////////// 00172 WriteBadArgument() 00173 This writes that there is an argument that is not understood. 00175 void WriteBadArgument(modelMsg stcMsg); 00176 00177 /*/////////////////////////////////////////////////////////////////////////// 00178 WriteNotReadyToRun() 00179 If the user has attempted to run the model when the model was not ready, 00180 this writes an error message. 00182 void WriteNotReadyToRun(); 00183 00184 /*/////////////////////////////////////////////////////////////////////////// 00185 WriteRunComplete() 00186 This writes that the requested run is complete. 00188 void WriteRunComplete(int iCurrentTimestep, int iNumTimesteps, unsigned long 00189 iRunTime); 00190 00191 /*/////////////////////////////////////////////////////////////////////////// 00192 WriteModelPaused() 00193 This writes that the model is paused, and what to do to start it again. 00195 void WriteModelPaused(); 00196 00197 /*/////////////////////////////////////////////////////////////////////////// 00198 WriteBadFileType() 00199 This writes that the file type passed is not what was expected. 00201 void WriteBadFileType(modelErr stcErr); 00202 00203 /*/////////////////////////////////////////////////////////////////////////// 00204 WriteBadXMLFile() 00205 This writes that the XML file passed is malformed or invalid. 00207 void WriteBadXMLFile(modelErr stcErr); 00208 00209 /*/////////////////////////////////////////////////////////////////////////// 00210 WriteDataMissingFromFile() 00211 This writes that data was missing from a file passed. 00213 void WriteDataMissingFromFile(modelErr stcErr); 00214 00215 /*/////////////////////////////////////////////////////////////////////////// 00216 WriteBadData() 00217 This writes that a file passed had bad data. 00219 void WriteBadData(modelErr stcErr); 00220 00221 /*/////////////////////////////////////////////////////////////////////////// 00222 WriteIllegalOp() 00223 This writes that an object attempted an illegal operation. 00225 void WriteIllegalOp(modelErr stcErr); 00226 00227 /*/////////////////////////////////////////////////////////////////////////// 00228 WriteDataReadOnly() 00229 This writes that something tried to access read-only data. Not a user- 00230 based error. 00232 void WriteDataReadOnly(modelErr stcErr); 00233 00234 /*/////////////////////////////////////////////////////////////////////////// 00235 WriteCantFindObject() 00236 This writes that a needed object wasn't found. Probably not a user-based 00237 error. 00239 void WriteCantFindObject(modelErr stcErr); 00240 00241 /*/////////////////////////////////////////////////////////////////////////// 00242 WriteTreeWrongType() 00243 This writes that a tree was not the expected type. Probably not a user- 00244 based error. 00246 void WriteTreeWrongType(modelErr stcErr); 00247 00248 /*/////////////////////////////////////////////////////////////////////////// 00249 WriteAccessViolation() 00250 This writes that an access violation has occurred. Not a user-based error. 00252 void WriteAccessViolation(modelErr stcErr); 00253 00254 /*/////////////////////////////////////////////////////////////////////////// 00255 WriteUnknownError() 00256 This writes that an unknown error has occurred. 00258 void WriteUnknownError(modelErr stcErr); 00259 00260 //--------------------------------------------------------------------------- 00261 #endif 00262 00263