00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <InterruptibleObject.hxx>
00025
00026
00027 using namespace std;
00028 using namespace cmsg;
00029 using namespace codaObject;
00030
00031
00032
00033
00034
00045 InterruptibleObject::InterruptibleObject(const string& udl, const string& Name, const string& Descr,
00046 InterruptService *IntSvc, const string &cClass,
00047 const cMsgSubscriptionConfig *scfg) throw(CodaException)
00048 : RunObject(udl,Name,Descr,cClass,scfg), dllInterrupt(NULL), intSvc(IntSvc) {
00049
00050
00051
00052 objectType="InterruptibleObject";
00053
00054
00055
00056 if(intSvc!=NULL)intSvc->setInterruptibleObject(this);
00057 }
00058
00059
00060
00061
00062
00066 InterruptibleObject::~InterruptibleObject(void) throw() {}
00067
00068
00069
00070
00071
00078 bool InterruptibleObject::download(const string& s) throw(CodaException) {
00079
00080 bool stat = RunObject::download(s);
00081
00082
00083 #ifndef VXWORKS
00084 if(hasDLL) dllInterrupt = (dllIntFuncPtr)dlsym(dllHandle,"interrupt");
00085 #endif
00086
00087 return(stat);
00088 }
00089
00090
00091
00092
00093
00100 bool InterruptibleObject::prestart(const string& s) throw(CodaException) {
00101
00102 bool stat = true;
00103 changeState("prestarting");
00104
00105 if(intSvc!=NULL) {
00106 stat = intSvc->setupInterrupt();
00107 if(!stat) {
00108 string err = "?InterruptibleObject::prestart...setupInterrupt failure";
00109 cerr << err << endl;
00110 daLogMsg(err,DALOG_ERROR);
00111 return(false);
00112 }
00113 }
00114
00115 stat = RunObject::prestart(s);
00116 return(stat);
00117 }
00118
00119
00120
00121
00122
00129 bool InterruptibleObject::go(const string& s) throw(CodaException) {
00130
00131 bool stat = true;
00132 changeState("going");
00133
00134
00135
00136 eventNumber=0;
00137 dataCount=0;
00138
00139
00140
00141 if(hasDLL&&(dllGo!=NULL)) {
00142 #ifndef VXWORKS
00143 stat=dllGo(s.c_str(),(void *)&dllSysArg,NULL);
00144 #endif
00145 } else {
00146 stat=userGo(s);
00147 }
00148 if(!stat)return(false);
00149
00150
00151 if(intSvc!=NULL) {
00152 stat = intSvc->enableInterrupt();
00153 if(!stat) {
00154 string err = "?InterruptibleObject::go...enableInterrupt failure";
00155 cerr << err << endl;
00156 daLogMsg(err,DALOG_ERROR);
00157 return(false);
00158 }
00159 }
00160
00161
00162 changeState("active");
00163 return(true);
00164 }
00165
00166
00167
00168
00169
00176 bool InterruptibleObject::interrupt(unsigned int flag) throw(CodaException) {
00177
00178 bool stat = false;
00179
00180 if(hasDLL&&(dllInterrupt!=NULL)) {
00181 #ifndef VXWORKS
00182 stat=dllInterrupt(flag,(void *)&dllSysArg,NULL);
00183 #endif
00184 } else {
00185 stat=userInterrupt(flag);
00186 }
00187
00188 return(stat);
00189 }
00190
00191
00192
00193
00194
00201 bool InterruptibleObject::pause(const string& s) throw(CodaException) {
00202
00203 bool stat = true;
00204 changeState("pausing");
00205
00206 if(intSvc!=NULL) {
00207 stat = intSvc->pauseInterrupt();
00208 if(!stat) {
00209 string err = "?InterruptibleObject::pause failure";
00210 cerr << err << endl;
00211 daLogMsg(err,DALOG_ERROR);
00212 return(false);
00213 }
00214 }
00215
00216 stat = RunObject::pause(s);
00217 return(stat);
00218 }
00219
00220
00221
00222
00223
00230 bool InterruptibleObject::resume(const string& s) throw(CodaException) {
00231
00232 bool stat = true;
00233 changeState("resuming");
00234
00235
00236 if(hasDLL&&(dllResume!=NULL)) {
00237 #ifndef VXWORKS
00238 stat=dllResume(s.c_str(),(void *)&dllSysArg,NULL);
00239 #endif
00240 } else {
00241 stat=userResume(s);
00242 }
00243 if(!stat)return(false);
00244
00245
00246 if(intSvc!=NULL) {
00247 stat = intSvc->resumeInterrupt();
00248 if(!stat) {
00249 string err = "?InterruptibleObject::resume failure";
00250 cerr << err << endl;
00251 daLogMsg(err,DALOG_ERROR);
00252 }
00253 }
00254
00255 changeState("active");
00256 return(stat);
00257 }
00258
00259
00260
00261
00262
00269 bool InterruptibleObject::end(const string& s) throw(CodaException) {
00270
00271 bool stat1 = true;
00272 bool stat2 = true;
00273 changeState("ending");
00274
00275 if(intSvc!=NULL) {
00276 stat1 = intSvc->deleteInterrupt();
00277 if(!stat1) {
00278 string err = "?InterruptibleObject::end...deleteInterrupt failure";
00279 cerr << err << endl;
00280 daLogMsg(err,DALOG_ERROR);
00281 }
00282 }
00283
00284
00285 stat2 = RunObject::end(s);
00286 return(stat1&stat2);
00287 }
00288
00289
00290
00291
00292
00299 bool InterruptibleObject::reset(const string& s) throw(CodaException) {
00300
00301 bool stat1 = true;
00302 bool stat2 = true;
00303 changeState("resetting");
00304
00305 if(intSvc!=NULL) {
00306 stat1 = intSvc->deleteInterrupt();
00307 if(!stat1) {
00308 string err = "?InterruptibleObject::reset...deleteInterrupt failure";
00309 cerr << err << endl;
00310 daLogMsg(err,DALOG_ERROR);
00311 }
00312 }
00313
00314
00315 stat2 = RunObject::reset(s);
00316 return(stat1&stat2);
00317 }
00318
00319
00320
00321
00322
00324 bool InterruptibleObject::userInterrupt(unsigned int flag) throw(CodaException) {
00325 return(true);
00326 }
00327
00328
00329
00330