[1274] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * DISCLAIMER * |
---|
| 4 | // * * |
---|
| 5 | // * The following disclaimer summarizes all the specific disclaimers * |
---|
| 6 | // * of contributors to this software. The specific disclaimers,which * |
---|
| 7 | // * govern, are listed with their locations in: * |
---|
| 8 | // * http://cern.ch/geant4/license * |
---|
| 9 | // * * |
---|
| 10 | // * Neither the authors of this software system, nor their employing * |
---|
| 11 | // * institutes,nor the agencies providing financial support for this * |
---|
| 12 | // * work make any representation or warranty, express or implied, * |
---|
| 13 | // * regarding this software system or assume any liability for its * |
---|
| 14 | // * use. * |
---|
| 15 | // * * |
---|
| 16 | // * This code implementation is the intellectual property of the * |
---|
| 17 | // * GEANT4 collaboration. * |
---|
| 18 | // * By copying, distributing or modifying the Program (or any work * |
---|
| 19 | // * based on the Program) you indicate your acceptance of this * |
---|
| 20 | // * statement, and all its terms. * |
---|
| 21 | // ******************************************************************** |
---|
| 22 | // |
---|
| 23 | // |
---|
| 24 | // $Id: G4UIxvt.hh,v 1.5 2003/06/16 16:55:53 gunter Exp $ |
---|
| 25 | // GEANT4 tag $Name: $ |
---|
| 26 | // |
---|
| 27 | //////////////////////////////////////////////////////////////////////// |
---|
| 28 | // XVT driver class header // |
---|
| 29 | // ~~~~~~~~~~~~~~~~~~~~~~~ // |
---|
| 30 | // Written by: Simon Prior // |
---|
| 31 | // Date: 22/04/97 // |
---|
| 32 | // // |
---|
| 33 | // Updated for state machine: 12/08/97 // |
---|
| 34 | // // |
---|
| 35 | //////////////////////////////////////////////////////////////////////// |
---|
| 36 | #ifndef G4UIxvt_h |
---|
| 37 | #define G4UIxvt_h |
---|
| 38 | |
---|
| 39 | #if defined(G4UI_BUILD_XVT_SESSION) || defined(G4UI_USE_XVT) |
---|
| 40 | |
---|
| 41 | //////////////////////////////////////////////////////////////////////// |
---|
| 42 | // define the named pipe names // |
---|
| 43 | //////////////////////////////////////////////////////////////////////// |
---|
| 44 | |
---|
| 45 | #define XvtToGeant "XvtToGeant.tmp" |
---|
| 46 | #define GeantToXvt "GeantToXvt.tmp" |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | //////////////////////////////////////////////////////////////////////// |
---|
| 50 | // mode for opening a named pipe // |
---|
| 51 | //////////////////////////////////////////////////////////////////////// |
---|
| 52 | |
---|
| 53 | #define FILE_MODE (0664 | S_IFIFO) |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | //////////////////////////////////////////////////////////////////////// |
---|
| 57 | // If compiling using AFS different libraries required // |
---|
| 58 | //////////////////////////////////////////////////////////////////////// |
---|
| 59 | |
---|
| 60 | #ifdef _AIX |
---|
| 61 | #include <sys/mode.h> // mkfifo utils |
---|
| 62 | #endif |
---|
| 63 | |
---|
| 64 | #include <unistd.h> // POSIX standards for stdin, out, err. |
---|
| 65 | //#include <values.h> |
---|
| 66 | #include <sys/stat.h> // mkfifo utils for HP |
---|
| 67 | #include <fcntl.h> // Open, Close, Unlink etc |
---|
| 68 | #include <sys/ioctl.h> |
---|
| 69 | #include <stdio.h> // sscanf, sprinf |
---|
| 70 | |
---|
| 71 | #ifndef FIONREAD |
---|
| 72 | #include <sys/filio.h> // FIONREAD defines |
---|
| 73 | #endif |
---|
| 74 | |
---|
| 75 | //////////////////////////////////////////////////////////////////////// |
---|
| 76 | // Geant4 specific includes // |
---|
| 77 | //////////////////////////////////////////////////////////////////////// |
---|
| 78 | |
---|
| 79 | #include "G4UIsession.hh" |
---|
| 80 | #include "G4UImanager.hh" |
---|
| 81 | #include "G4UIcommandTree.hh" |
---|
| 82 | |
---|
| 83 | |
---|
| 84 | //////////////////////////////////////////////////////////////////////// |
---|
| 85 | // State machine Geant4 includes // |
---|
| 86 | //////////////////////////////////////////////////////////////////////// |
---|
| 87 | |
---|
| 88 | #include "G4VStateDependent.hh" |
---|
| 89 | #include <fstream> |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | //////////////////////////////////////////////////////////////////////// |
---|
| 93 | // New data structures, one to hold the parameter information of a // |
---|
| 94 | // command and one to hold information on the command itself. // |
---|
| 95 | //////////////////////////////////////////////////////////////////////// |
---|
| 96 | |
---|
| 97 | typedef struct G4parameterData |
---|
| 98 | { |
---|
| 99 | G4String name; |
---|
| 100 | G4String guidance; |
---|
| 101 | G4String defaultValue; |
---|
| 102 | G4String range; |
---|
| 103 | G4String candidate; |
---|
| 104 | char type; |
---|
| 105 | G4String omittable; |
---|
| 106 | } G4parameterData; |
---|
| 107 | |
---|
| 108 | typedef struct G4commandData |
---|
| 109 | { |
---|
| 110 | int flag; |
---|
| 111 | G4String name; |
---|
| 112 | G4String guidance; |
---|
| 113 | int numOfParameters; |
---|
| 114 | G4parameterData parameters[10]; |
---|
| 115 | |
---|
| 116 | // G4String bitmapName; |
---|
| 117 | |
---|
| 118 | int commandNumber; |
---|
| 119 | } G4commandData; |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | class G4UIxvt : public G4UIsession//, public G4VStateDependent |
---|
| 123 | { |
---|
| 124 | public: |
---|
| 125 | G4UIxvt(); |
---|
| 126 | ~G4UIxvt(); |
---|
| 127 | |
---|
| 128 | //////////////////////////////////////////////////////////////////// |
---|
| 129 | // Inherited virtual functions // |
---|
| 130 | //////////////////////////////////////////////////////////////////// |
---|
| 131 | |
---|
| 132 | // void SessionStart(void); |
---|
| 133 | G4UIsession* SessionStart(void); |
---|
| 134 | G4String GetCommand(void); |
---|
| 135 | void SessionTerminate(void); |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | //////////////////////////////////////////////////////////////////// |
---|
| 139 | // New state machine methods // |
---|
| 140 | //////////////////////////////////////////////////////////////////// |
---|
| 141 | |
---|
| 142 | G4bool Notify(G4ApplicationState requestedState); |
---|
| 143 | |
---|
| 144 | inline void set_breakPointAt(int id,G4bool flg) |
---|
| 145 | { |
---|
| 146 | brktbl[id] = flg; |
---|
| 147 | noBreakFlag = !(brktbl[0]||brktbl[1]||brktbl[2]||brktbl[3]); |
---|
| 148 | }; |
---|
| 149 | |
---|
| 150 | void set_verbose(void); |
---|
| 151 | |
---|
| 152 | private: |
---|
| 153 | |
---|
| 154 | //////////////////////////////////////////////////////////////////// |
---|
| 155 | // Terminal and interface data members (might be taken out as // |
---|
| 156 | // they are not needed for the XVT GUI) // |
---|
| 157 | //////////////////////////////////////////////////////////////////// |
---|
| 158 | |
---|
| 159 | G4UImanager * UI; |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | //////////////////////////////////////////////////////////////////// |
---|
| 163 | // New state machine data members // |
---|
| 164 | //////////////////////////////////////////////////////////////////// |
---|
| 165 | |
---|
| 166 | G4bool iExit; |
---|
| 167 | G4bool iCont; |
---|
| 168 | G4bool brktbl[4]; |
---|
| 169 | G4bool noBreakFlag; |
---|
| 170 | G4bool verboseFlag; |
---|
| 171 | |
---|
| 172 | |
---|
| 173 | //////////////////////////////////////////////////////////////////// |
---|
| 174 | // New state machine methods // |
---|
| 175 | //////////////////////////////////////////////////////////////////// |
---|
| 176 | |
---|
| 177 | void additionalSession(void); |
---|
| 178 | G4bool breakRequested(G4ApplicationState,G4ApplicationState); |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | //////////////////////////////////////////////////////////////////// |
---|
| 182 | // IPC Data Members // |
---|
| 183 | //////////////////////////////////////////////////////////////////// |
---|
| 184 | |
---|
| 185 | int fd_XvtToGeant, fd_GeantToXvt; |
---|
| 186 | char textDump[100]; |
---|
| 187 | int number; |
---|
| 188 | |
---|
| 189 | |
---|
| 190 | //////////////////////////////////////////////////////////////////// |
---|
| 191 | // IPC methods // |
---|
| 192 | //////////////////////////////////////////////////////////////////// |
---|
| 193 | |
---|
| 194 | void openConnections(void); |
---|
| 195 | int checkXvtToGeantPipe(void); |
---|
| 196 | G4String readXvtToGeant(void); |
---|
| 197 | void writeGeantToXvt(const G4String& theString); |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | //////////////////////////////////////////////////////////////////// |
---|
| 201 | // Terminal and TCL methods updated for use with XVT // |
---|
| 202 | //////////////////////////////////////////////////////////////////// |
---|
| 203 | |
---|
| 204 | void codeGen(G4UIcommandTree *,int recursive_level); |
---|
| 205 | void listCurrentDirectory(void); |
---|
| 206 | |
---|
| 207 | |
---|
| 208 | //////////////////////////////////////////////////////////////////// |
---|
| 209 | // Command handling data members // |
---|
| 210 | //////////////////////////////////////////////////////////////////// |
---|
| 211 | |
---|
| 212 | G4commandData commandArray[200]; |
---|
| 213 | int currentPosition, lastPosition; |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | //////////////////////////////////////////////////////////////////// |
---|
| 217 | // Command handling methods // |
---|
| 218 | //////////////////////////////////////////////////////////////////// |
---|
| 219 | |
---|
| 220 | void fillArrayEntries(G4UIcommandTree * tree, int level); |
---|
| 221 | void sendArrayEntriesToXvt(void); |
---|
| 222 | void briefListCommands(void); |
---|
| 223 | |
---|
| 224 | |
---|
| 225 | //////////////////////////////////////////////////////////////////// |
---|
| 226 | // Debugging methods // |
---|
| 227 | //////////////////////////////////////////////////////////////////// |
---|
| 228 | void listCommandArray(void); |
---|
| 229 | void errorHandler(const G4String& theError); |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | }; |
---|
| 233 | |
---|
| 234 | #endif |
---|
| 235 | |
---|
| 236 | #endif |
---|