00001 #ifndef JobH
00002 #define JobH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00039
00040
00041 #include "CoreMainHeader.h"
00042 #include "ExtObject.h"
00043 #include "SmallString.h"
00044 #include "SmallTime.h"
00045 #include "ContainerEnumerator.h"
00046 #include "MoleculeInfo.h"
00047 #include "Constraint.h"
00048
00049
00050
00051 class CCalculation;
00052 class CPluginObjectInfo;
00053 class CProperty;
00054 class CCalculationProject;
00055 class CXMLElement;
00056
00057
00058
00060
00063 enum EJobStatus{
00064 EJS_NEW = 0,
00065 EJS_SUBMITTED = 1,
00066 EJS_PAUSED = 2,
00067 EJS_STARTED = 3,
00068 EJS_RUN_PAUSED = 4,
00069 EJS_SYNCHRONIZED = 5,
00070 EJS_KILLED = 6,
00071 EJS_FINISHED = 7,
00072 };
00073
00074
00075
00077
00080 class NEMESIS_CORE_PACKAGE CJob : public CExtObject {
00081 public:
00082 __fastcall CJob(CPluginObjectInfo* objectinfo,CCalculation* p_cal);
00083 void __fastcall RemoveFromBaseList(void);
00084
00085 __property CCalculationProject* Project = {read = GetCalculationProject};
00086 __property CCalculation* Calculation = {read = FCalculation};
00087
00088
00089 CProperty* __fastcall AddProperty(const CUUID& uuid,const CSmallString& name,const CSmallString& descrip);
00090 bool __fastcall RemoveProperty(CProperty* p_prop);
00091 inline CSimpleList<CProperty>& __fastcall GetPropertiesList(void);
00092 CProperty* __fastcall FindProperty(int id);
00093
00094
00095
00096 CSmallString __fastcall GetFullCaption(void);
00097
00098 inline const CTime& __fastcall GetQueueInsertTime(void);
00099 inline const CTime& __fastcall GetJobStartTime(void);
00100 inline const CTime& __fastcall GetJobEndTime(void);
00101
00102 inline const int __fastcall GetNumOfCPU(void);
00103 inline const CTime& __fastcall GetCPUTime(void);
00104 inline const CTime& __fastcall GetWallTime(void);
00105 const float __fastcall GetUsageOfCPU(void);
00106
00107 inline int __fastcall GetCharonJobID(void);
00108 inline void __fastcall SetCharonJobID(int id);
00109
00110
00111 bool __fastcall IsActiveJob(void);
00112 inline bool __fastcall CanChangeData(void);
00113
00114
00115 bool __fastcall SetInitialMoleculeInfo(CMoleculeInfo* p_molinfo);
00116 CSmallString __fastcall GetInitialMoleculeInfoDescription(void);
00117
00118 inline CMoleculeInfo* __fastcall GetInitialMoleculeInfo(void);
00119 virtual CMoleculeInfo* __fastcall GetFinalMoleculeInfo(void);
00120 inline CMoleculeInfo* __fastcall GetActiveMoleculeInfo(void);
00121
00122 virtual EMoleculeInfoType __fastcall GetRequestedMoleculeInfoType(void);
00123
00124 inline CSimpleList<CMoleculeInfo>& __fastcall GetMoleculeInfoList(void);
00125 CMoleculeInfo* __fastcall FindMoleculeInfo(int id);
00126
00127
00128
00129 CMoleculeInfo* __fastcall FindInternalMoleculeInfo(int internal_id);
00130
00131 bool __fastcall SetActiveMoleculeInfo(CMoleculeInfo* p_info);
00132
00133 CSmallString __fastcall GetResultFullFileName(const CSmallString& file);
00134
00135 virtual CContainerEnumerator* __fastcall GetJobMolInfoEnumerator(CComObject* p_owner);
00136
00137 CContainerEnumerator* __fastcall GetConstraintsEnumerator(CComObject* p_owner);
00138
00139
00140 inline EJobStatus __fastcall GetCurrentStatus(void);
00141 CSmallString __fastcall GetCurrentStatusString(void);
00142
00143
00144 bool __fastcall Load(CXMLElement* p_el);
00145 bool __fastcall LoadAllResults(void);
00146 bool __fastcall Save(CXMLElement* p_el);
00147
00148
00149 bool __fastcall StartJob(void);
00150 bool __fastcall StartJobTemporary(int comp_id=-1,int queue_id=-1);
00151 bool __fastcall PauseJob(void);
00152 bool __fastcall ResumeJob(void);
00153 bool __fastcall SynchronizeJob(void);
00154 bool __fastcall KillJob(void);
00155 bool __fastcall DeleteJob(void);
00156 bool __fastcall RemoveCalculatedData(void);
00157
00158
00159 bool __fastcall UpdateJobStatus(EJobStatus new_status);
00160
00161
00162 CSmallString __fastcall GetJobWorkDirectory(void);
00163 virtual bool __fastcall PrepareInputData(void);
00164 virtual bool __fastcall ExtractOutputData(bool& completed);
00165 virtual CSmallString __fastcall GetInFilesList(void);
00166 virtual CSmallString __fastcall GetOutFilesList(void);
00167 virtual CSmallString __fastcall GetSyncFilesList(void);
00168 virtual bool __fastcall CheckBeforeStart(void);
00169 virtual bool __fastcall RemoveJobSpecificData(void);
00170 virtual bool __fastcall LoadMolinfoData(CMoleculeInfo* p_info);
00171
00172 bool __fastcall ContainData(void);
00173 void __fastcall SetContainData(void);
00174 inline bool __fastcall IsCompleted(void);
00175
00176 public:
00177 CConstraintsList Constraints;
00178
00179
00180 private:
00181 CSmallString Machine;
00182 CTime QueueInsert;
00183 CTime JobStart;
00184 CTime JobEnd;
00185 CTime CPUTime;
00186 CTime WallTime;
00187 int NumOfCPU;
00188 EJobStatus CurrentStatus;
00189 int TimeStamp;
00190 bool FContainData;
00191 int CharonJobID;
00192 int Temporary;
00193 CSmallString TempJobName;
00194 bool Completed;
00195
00196 CCalculation* FCalculation;
00197 CSimpleList<CProperty> Properties;
00198 CSimpleList<CMoleculeInfo> Geometries;
00199 CMoleculeInfo* ActiveMoleculeInfo;
00200
00201 void __fastcall AddMoleculeInfo(CMoleculeInfo* p_molinfo);
00202
00203 virtual bool __fastcall LoadData(CXMLElement* p_ele);
00204 virtual bool __fastcall SaveData(CXMLElement* p_ele);
00205
00206 inline CCalculationProject* __fastcall GetCalculationProject(void);
00207 friend class CCalculation;
00208
00209 public:
00210 __fastcall ~CJob(void);
00211 };
00212
00213
00214
00215 DECLARE_EVENT(Job_AddProperty);
00216 DECLARE_EVENT(Job_RemoveProperty);
00217
00218 DECLARE_EVENT(Job_AddMoleculeInfo);
00219 DECLARE_EVENT(Job_RemoveMoleculeInfo);
00220
00221 DECLARE_EVENT(Job_ChangeStatus);
00222 DECLARE_EVENT(Job_ActivateGeometry);
00223 DECLARE_EVENT(Job_SetInitialGeometry);
00224
00225 DECLARE_EVENT(Job_SetContainData);
00226
00227
00228
00230
00233 class CJobEnumerator : public CContainerEnumerator {
00234 public:
00235 __fastcall CJobEnumerator(CComObject* owner,CJob* p_job);
00236 __fastcall ~CJobEnumerator(void);
00237
00238 virtual int __fastcall NumOfCommands(void);
00239 virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00240 virtual bool __fastcall DoCommand(int i);
00241
00242 virtual int __fastcall NumOfObjects(void);
00243 virtual bool __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00244 virtual CExtObject* __fastcall GetObject(int pos);
00245
00246
00247 virtual int __fastcall NumOfColumns(void);
00248 virtual const CSmallString __fastcall GetColumnCaption(int index);
00249 virtual const CSmallString __fastcall GetObjectProperty(int index);
00250 virtual int __fastcall GetObjectImageIndex(void);
00251 virtual CExtObject* __fastcall GetCurrentObject(void);
00252 virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00253
00254 virtual CExtObject* __fastcall GetMyMaster(void);
00255
00256 virtual int __fastcall GetImageIndex(void) const;
00257
00258 private:
00259 CJob* Job;
00260 CSimpleIterator<CProperty> Pointer;
00261 CProperty* CurrentObject;
00262 int StartPos;
00263 int EndPos;
00264 bool Changed;
00265 CSimpleList<CProperty> CurrentView;
00266
00267 void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00268 };
00269
00270
00271
00272 extern CPluginObjectInfo JobEnumObjectInfo;
00273 extern CExtUUID ID_JobEnum;
00274
00275
00276
00278
00281 class CJobMolInfoEnumerator : public CContainerEnumerator {
00282 public:
00283 __fastcall CJobMolInfoEnumerator(CComObject* owner,CJob* p_job);
00284 __fastcall ~CJobMolInfoEnumerator(void);
00285
00286 virtual int __fastcall NumOfCommands(void);
00287 virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00288 virtual bool __fastcall DoCommand(int i);
00289
00290 virtual int __fastcall NumOfObjects(void);
00291 virtual bool __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00292 virtual CExtObject* __fastcall GetObject(int pos);
00293
00294
00295 virtual int __fastcall NumOfColumns(void);
00296 virtual const CSmallString __fastcall GetColumnCaption(int index);
00297 virtual const CSmallString __fastcall GetObjectProperty(int index);
00298 virtual int __fastcall GetObjectImageIndex(void);
00299 virtual CExtObject* __fastcall GetCurrentObject(void);
00300 virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00301
00302 virtual CExtObject* __fastcall GetMyMaster(void);
00303
00304 virtual int __fastcall GetImageIndex(void) const;
00305
00306 private:
00307 CJob* Job;
00308 CSimpleIterator<CMoleculeInfo> Pointer;
00309 CMoleculeInfo* CurrentObject;
00310 int StartPos;
00311 int EndPos;
00312 bool Changed;
00313 CSimpleList<CMoleculeInfo> CurrentView;
00314
00315 void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00316 };
00317
00318
00319
00320 extern CPluginObjectInfo JobMolInfoEnumObjectInfo;
00321 extern CExtUUID ID_JobMolInfoEnum;
00322
00323
00324
00325 inline CCalculationProject* __fastcall CJob::GetCalculationProject(void)
00326 {
00327 return((CCalculationProject*)GetProject());
00328 }
00329
00330
00331
00332 inline const CTime& __fastcall CJob::GetQueueInsertTime(void)
00333 {
00334 return(QueueInsert);
00335 }
00336
00337
00338
00339 inline const CTime& __fastcall CJob::GetJobStartTime(void)
00340 {
00341 return(JobStart);
00342 }
00343
00344
00345
00346 inline const CTime& __fastcall CJob::GetJobEndTime(void)
00347 {
00348 return(JobEnd);
00349 }
00350
00351
00352
00353 inline const int __fastcall CJob::GetNumOfCPU(void)
00354 {
00355 return(NumOfCPU);
00356 }
00357
00358
00359
00360 inline const CTime& __fastcall CJob::GetCPUTime(void)
00361 {
00362 return(CPUTime);
00363 }
00364
00365
00366
00367 inline const CTime& __fastcall CJob::GetWallTime(void)
00368 {
00369 return(WallTime);
00370 }
00371
00372
00373
00374 inline EJobStatus __fastcall CJob::GetCurrentStatus(void)
00375 {
00376 return(CurrentStatus);
00377 }
00378
00379
00380
00381 inline int __fastcall CJob::GetCharonJobID(void)
00382 {
00383 return(CharonJobID);
00384 }
00385
00386
00387
00388 inline void __fastcall CJob::SetCharonJobID(int id)
00389 {
00390 CharonJobID = id;
00391 }
00392
00393
00394
00395 inline CMoleculeInfo* __fastcall CJob::GetInitialMoleculeInfo(void)
00396 {
00397 return(Geometries.GetFirst());
00398 }
00399
00400
00401
00402 inline CMoleculeInfo* __fastcall CJob::GetActiveMoleculeInfo(void)
00403 {
00404 return(ActiveMoleculeInfo);
00405 }
00406
00407
00408
00409 inline bool __fastcall CJob::CanChangeData(void)
00410 {
00411 return(CurrentStatus == EJS_NEW);
00412 }
00413
00414
00415
00416 inline CSimpleList<CProperty>& __fastcall CJob::GetPropertiesList(void)
00417 {
00418 return(Properties);
00419 }
00420
00421
00422
00423 inline CSimpleList<CMoleculeInfo>& __fastcall CJob::GetMoleculeInfoList(void)
00424 {
00425 return(Geometries);
00426 }
00427
00428
00429
00430 inline bool __fastcall CJob::IsCompleted(void)
00431 {
00432 return(Completed);
00433 }
00434
00435
00436
00437 #endif