ICP  1
isisdae.cpp
Go to the documentation of this file.
1 /*
2  * This file contains the RIO interface that is callable from FORTRAN
3  *
4  * Author: Freddie Akeroyd
5  */
6 #include "stdafx.h"
7 
8 #include "DAEstatus.h"
9 #include "isisdae.h"
10 #include "detector_card.h"
11 #include "MuonDetectorCard.h"
12 #include "environment_card.h"
13 //#include "period_card.h"
14 #include "env_period_card.h"
15 #include "nivisa.h"
16 #include "vme_simulation.h"
17 #include "icputils.h"
18 #include "QxtrmInterface.h"
19 
20 
21 #define END_IMMEDIATELY_FILE "c:\\data\\end_now.dae"
22 
23 #define ENV_FUNCTION(__func) \
24  ( (m_envCards.size() > 0) ? (m_envCards[0]->__func) : \
25  ((m_envPeriodCards.size() > 0) ? (m_envPeriodCards[0]->__func) : 0) )
26 
27 #define PERIOD_FUNCTION(__func) \
28  ((m_envPeriodCards.size() > 0) ? (m_envPeriodCards[0]->__func) : 0)
29 
30 
31 class ClearHistogramMemoryTask : public Poco::Task
32 {
34  std::vector<DetectorCardIntf*>& m_detCards;
35 public:
36  ClearHistogramMemoryTask(const std::string& name, std::vector<DetectorCardIntf*>& det_cards, DAEstatus& status) : Poco::Task(name), m_detCards(det_cards), m_status(status) { }
37 
38  void runTask()
39  {
40  m_status.addInfoVa(FAC_DAE, "Starting clear of DAE memory, thread ID %u", Poco::Thread::currentTid());
41  int ncards = m_detCards.size();
42  for(int i=0; i<ncards; ++i)
43  {
44  m_detCards[i]->clearHistogramMemoryStart(m_status);
45  }
46  int ncomplete = 0;
47  while(ncomplete < ncards)
48  {
49  ncomplete = 0;
50  for(int i=0; i<ncards; ++i)
51  {
52  if (m_detCards[i]->isClearHistogramMemoryComplete(m_status))
53  {
54  ++ncomplete;
55  }
56  }
57  setProgress((float)ncomplete / (float)ncards);
58  if (isCancelled())
59  {
60  m_status.addInfo(FAC_DAE, "Cancelled clear of DAE memory");
61  return;
62  }
63  if (ncomplete < ncards)
64  {
65  if (sleep(200)) // sleep returns true if we are cancelled
66  {
67  m_status.addInfo(FAC_DAE, "Cancelled clear of DAE memory");
68  return;
69  }
70  }
71  }
72  m_status.addInfo(FAC_DAE, "Finished clear of DAE memory");
73  }
74 
75  void cancel()
76  {
77  Poco::Task::cancel();
78  }
79 };
80 
81 class ReadAllDAE1SpectraTask : public Poco::Task
82 {
86  int m_nbuffer;
88  int m_persize;
89 
90 public:
91  ReadAllDAE1SpectraTask(const std::string& name, DetectorCardIntf* dc, isisU32_t* buffer, int nbuffer,
92  const int* spec_to_crpt_offset, int persize, DAEstatus& status) : Poco::Task(name), m_dc(dc), m_buffer(buffer), m_nbuffer(nbuffer),
93  m_spec_to_crpt_offset(spec_to_crpt_offset), m_persize(persize), m_status(status) { }
94 
95  void runTask()
96  {
97 // m_status.addInfoVa(FAC_DAE, "Starting ReadAllDAE1SpectraTask, thread id %u", Poco::Thread::currentTid());
98 // setProgress(0.0);
100 // setProgress(100.0);
101 // cannot use isCancelled() at moment
102 // m_status.addInfo(FAC_DAE, "Finished ReadAllDAE1SpectraTask");
103  }
104 
105  void cancel()
106  {
107  Poco::Task::cancel();
108  }
109 };
110 
111 
112 ISISDAE::ISISDAE(DAEType type, DAEstatus& status, bool endian_workaround, bool simulate) :
113  m_lenAddmap(0), m_dae_type(type), m_period_mode(ISISDAE::PeriodTypeSoftware), m_simulate(simulate),
114  m_num_async_requests(0),m_async_complete_event(NULL), m_uamp_scale(1.0),m_event_mode(false)
115 {
116 // m_dae_type = UnknownDAE;
117  setLoggerName("ISISDAE");
118  LOGSTR_INFORMATION("Creating DAE");
119  static SECURITY_ATTRIBUTES sec_attr = { sizeof(SECURITY_ATTRIBUTES), NULL, FALSE };
120  InitializeCriticalSection(&m_dae_cs);
121  switch(m_dae_type)
122  {
123  case MuonDAE2:
124  case MuonDAE3:
125  m_clock_frequency = 2; // 2GHz
126  break;
127  case NeutronDAE2:
128  case NeutronDAE3:
129  m_clock_frequency = 32; // 32 Mhz
130  break;
131  default:
132  m_clock_frequency = 32;
133  break;
134  }
135  NIVisa::setEndianWorkaround(endian_workaround);
137  m_async_complete_event = CreateEvent(&sec_attr, FALSE, FALSE, NULL);
138  const Poco::AbstractObserver& on_progress = Poco::Observer<DAEProgressHandler, Poco::TaskProgressNotification>(m_task_ph, &DAEProgressHandler::onProgress);
139  const Poco::AbstractObserver& on_finished = Poco::Observer<DAEProgressHandler, Poco::TaskFinishedNotification>(m_task_ph, &DAEProgressHandler::onFinished);
140  m_taskmgr.addObserver(on_progress);
141  m_taskmgr.addObserver(on_finished);
142 }
143 
144 template <typename T>
145 static void deletePtr(T* pCard)
146 {
147  delete pCard;
148 }
149 
151 {
152  DAEstatus status;
153  const Poco::AbstractObserver& on_progress = Poco::Observer<DAEProgressHandler, Poco::TaskProgressNotification>(m_task_ph, &DAEProgressHandler::onProgress);
154  const Poco::AbstractObserver& on_finished = Poco::Observer<DAEProgressHandler, Poco::TaskFinishedNotification>(m_task_ph, &DAEProgressHandler::onFinished);
155  m_taskmgr.removeObserver(on_progress);
156  m_taskmgr.removeObserver(on_finished);
157  close(status);
158  std::for_each(m_detCards.begin(), m_detCards.end(), deletePtr<DetectorCardIntf>);
159  std::for_each(m_envCards.begin(), m_envCards.end(), deletePtr<EnvironmentCardIntf>);
160  std::for_each(m_envPeriodCards.begin(), m_envPeriodCards.end(), deletePtr<EnvPeriodCardIntf>);
161  std::for_each(m_vme.begin(), m_vme.end(), deletePtr<ISISVME>);
162  delete []m_addmap;
163  m_addmap = 0;
164  DeleteCriticalSection(&m_dae_cs);
165  CloseHandle(m_async_complete_event);
166 }
167 
169 {
170  bool done = false;
171  while(!done)
172  {
173  // use an explicit timeout - might be you get two SetEvents at same time and miss something?
174  DWORD ret = WaitForSingleObject(m_async_complete_event, 10000 /*INFINITE*/ );
175  if ((ret == WAIT_OBJECT_0) && (m_num_async_requests == 0))
176  {
177  done = true;
178  }
179  if ((ret == WAIT_TIMEOUT) && (m_num_async_requests == 0))
180  {
181  done = true;
182  }
183  }
184  return 0;
185 }
186 
189 {
190  InterlockedDecrement(&m_num_async_requests);
191  SetEvent(m_async_complete_event);
192  return 0;
193 }
194 
195 
196 DWORD __stdcall ISISDAE::readDCHistogramThread(void* arg)
197 {
199  his->dc->readHistogramMemory(his->start, his->buffer, his->len, his->status);
200  his->dae->doneAsync();
201  delete his;
202  return 0;
203 }
204 
205 int ISISDAE::readDCHistogramAsync(DetectorCardIntf* dc, unsigned long start, isisU32_t* buffer, int len, DAEstatus& dstatus)
206 {
207  histogram_async_t* arg = new histogram_async_t(this, dc, start, buffer, len, dstatus);
208  InterlockedIncrement(&m_num_async_requests);
209  if (QueueUserWorkItem(readDCHistogramThread, arg, WT_EXECUTEDEFAULT) != 0)
210  {
211  return DAEstatus::Success;
212  }
213  else
214  {
215  InterlockedDecrement(&m_num_async_requests);
216  return DAEstatus::Failure;
217  }
218 }
219 
220 
221 int ISISDAE::changePeriod(int period, int daq_period, DAEstatus& status)
222 {
223  ICPCritical cs(&m_dae_cs);
224  for(det_list_t::iterator it = m_detCards.begin(); it != m_detCards.end(); ++it)
225  {
226  (*it)->changePeriod(daq_period, status);
227  }
228  return 0;
229 }
230 
231 int ISISDAE::changeNumberOfPeriods(int nperiod, DAEstatus& status)
232 {
233  ICPCritical cs(&m_dae_cs);
234  for(det_list_t::iterator it = m_detCards.begin(); it != m_detCards.end(); ++it)
235  {
236  (*it)->changeNumberOfPeriods(nperiod, status);
237  }
238  return 0;
239 }
240 
241 void ISISDAE::printStatus(std::ostream& os, DAEstatus& status)
242 {
243  int i;
244  os << "VME DAE with " << m_envCards.size() << " ENVIRONMENT card(s), "
245  << m_envPeriodCards.size() << " ENVPERIOD card(s) and "
246  << m_detCards.size() << " DETECTOR card(s)\n";
247  os << "Number of DAE crates = " << m_vme.size() << "\n";
248  os << "DAE Type = " << DAEType_desc[m_dae_type] << std::endl;
249  os << "Period mode = " << PeriodType_desc[m_period_mode] << std::endl;
250  os << "Number of DAE1 spectra = " << m_lenAddmap << "\n";
251  os << "UAmp scale = " << m_uamp_scale << "\n";
252  for(i=0; i<m_envCards.size(); i++)
253  {
254  m_envCards[i]->printStatus(os, status);
255  }
256  for(i=0; i<m_envPeriodCards.size(); i++)
257  {
258  m_envPeriodCards[i]->printStatus(os, status);
259  }
260  for(i=0; i<m_detCards.size(); i++)
261  {
262  m_detCards[i]->printStatus(os, status);
263 // m_detCards[i]->printPOSLUT(os, status);
264  }
265 // printAddmap(os, status);
266 }
267 
268 void ISISDAE::printAddmap(std::ostream& os, DAEstatus& )
269 {
270  int i;
271  os << "DAE Address map" << std::endl;
272  os << "dae1_spec dae1_add dae2_card dae2_spec dae2_add dae2_len" << std::endl;
273  for(i=0; i<m_lenAddmap; i++)
274  {
275  os << i << " " << m_addmap[i].dae1add << " " << m_addmap[i].card
276  << " " << m_addmap[i].spec << " " << m_addmap[i].dae2add << " " << m_addmap[i].len << "\n";
277  }
278 }
279 
280 void ISISDAE::printSpectrum(int spec, std::ostream& os, DAEstatus& status)
281 {
282  isisU32_t i, nchan;
283  getSpectrumSize(spec, &nchan, status);
284  isisU32_t* buffer = new isisU32_t[nchan];
285  isisU32_t* tcb = new isisU32_t[nchan];
286  readDAE1Spectrum(spec, buffer, nchan, status);
287 // readHistogramMemory(4*spec*nchan, buffer, nchan)
288  getTimeChannels(spec, tcb, nchan-1, status);
289  os << "Spectrum " << spec << "\n";
290  os << "Channel 0 contains " << buffer[0] << " counts" << "\n";
291  for(i=0; i < nchan-1; i++)
292  {
293  os << (double)tcb[i] / (double)m_clock_frequency << " - " << (double)tcb[i+1] / m_clock_frequency << " = " << buffer[i+1] << "\n";
294  }
295  delete []buffer;
296  delete []tcb;
297 }
298 
299 int ISISDAE::getSpectrumSize(int spec, isisU32_t* nchan, DAEstatus& status)
300 {
302  return (dc != NULL ? dc->getSpectrumSize(nchan, status) : 0);
303 }
304 
305 int ISISDAE::getNTimeChannels(int spec, isisU32_t* ntc, DAEstatus& status)
306 {
308  return (dc != NULL ? dc->getNTimeChannels(ntc, status) : 0);
309 }
310 
311 int ISISDAE::getTimeChannels(int spec, isisU32_t* tcb, int ntc, DAEstatus& status)
312 {
314  return (dc != NULL ? dc->getTimeChannels(tcb, ntc, status) : 0);
315 }
316 
317 int ISISDAE::setTimeChannels(int crat, int start[], int nbound[],
318  int step[], int nblocks, DAEstatus& status)
319 {
320  int ntcb, i, j, k;
321  ntcb = 0;
322  for(i=0; i<nblocks; i++)
323  {
324  ntcb += nbound[i];
325  }
326  isisU32_t* tcb = new isisU32_t[ntcb];
327  k = 0;
328  for(i=0; i<nblocks; i++)
329  {
330  for(j=0; j<nbound[i]; j++)
331  {
332  tcb[k++] = start[i] + j * step[i];
333  }
334  }
335  setTimeChannels(crat, tcb, ntcb-1, status);
336  delete[] tcb;
337  return 0;
338 }
339 
340 // tcb array is size ntc+1 i.e. array of boundaries
341 int ISISDAE::setTimeChannels(int crat, isisU32_t* tcb, int ntc, DAEstatus& status)
342 {
343  DetectorCardIntf* dc = findDetectorCard(crat, status);
344  if (dc != NULL)
345  {
346  dc->setTimeChannels(tcb, ntc, status);
347  }
348  else
349  {
350  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_OUTOFMEM, "Cannot find card for crate %d", crat);
351  }
352  return 0;
353 }
354 
356 {
357  int i;
358  for(i=0; i<m_detCards.size(); i++)
359  {
360  m_detCards[i]->clearPOSLUTMemory(status);
361  }
362  return 0;
363 }
364 
365 int ISISDAE::programDAE1POSLUT(int crat[], int maxcrate, int modn[],
366  int mpos[], int spec[], int ndet,
367  int nper_daq, DAEstatus& status)
368 {
369  int i, specmax, dae1persize;
370  DetectorCardIntf* dc;
371  specmax = 0;
372  for(i=0; i<ndet; i++)
373  {
374  if (specmax < spec[i])
375  {
376  specmax = spec[i];
377  }
378  }
380  {
381  dae1persize = specmax + 1; // spectrum 0 is at end
382  }
383  else
384  {
385  dae1persize = specmax + 1;
386  }
387  int* crate_used = new int[maxcrate+1];
388  for(i=0; i<=maxcrate; i++)
389  {
390  crate_used[i] = 0;
391  }
392  for(i=0; i<ndet; i++)
393  {
394  crate_used[crat[i]] = 1;
395  }
396  for(i=0; i<=maxcrate; i++)
397  {
398  dc = findDetectorCard(i,status);
399  if ( (dc == 0) && (crate_used[i] == 1) )
400  {
401  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_INVCARD,"Attempt to use missing detector card/crate %d", i);
402  }
403  }
404  delete []crate_used;
405  for(i=0; i<m_detCards.size(); i++)
406  {
407  m_detCards[i]->programDAE1POSLUT(crat, modn, mpos, spec, ndet, nper_daq, dae1persize, status);
408  }
409  updateAddmap(status);
410  return 0;
411 }
412 
413 int ISISDAE::programPOSLUT(int cards[], int dims[], int pos_start[],
414  int npos[], int spec[], int spec_step[],
415  int nblocks, DAEstatus& status)
416 {
417  int i;
418  for(i=0; i<m_detCards.size(); i++)
419  {
420  m_detCards[i]->programPOSLUT(cards, dims, pos_start, npos, spec, spec_step, nblocks, 1, 0, status);
421  }
422  updateAddmap(status);
423  return 0;
424 }
425 
427 {
428  int i, j, len_used;
429  isisU32_t nchan;
430 // int len_specmap;
431  m_lenAddmap = 0;
432  memset(m_addmap, 0, DAE2DetCardPolicy::DAESPECMAX*sizeof(MyAddmap));
433  for(i=0; i<m_detCards.size(); i++)
434  {
435  len_used = m_detCards[i]->fillAddmap(m_addmap, DAE2DetCardPolicy::DAESPECMAX, status);
436  if (len_used > m_lenAddmap)
437  {
438  m_lenAddmap = len_used;
439  }
440  }
441  // muons have no real spectrum 0 so we might need to invent one
442  if ( (m_addmap[0].dc == NULL) && (m_detCards.size() > 0) )
443  {
444  status.addInfo(FAC_DAE, "adding spec 0");
445  m_detCards[0]->getSpectrumSize(&nchan, status);
446  m_addmap[0].card = m_detCards[0]->position();
447  m_addmap[0].dae1add = 0;
448  m_addmap[0].dae2add = 0;
449  m_addmap[0].dc = m_detCards[0];
450  m_addmap[0].len = nchan;
451  m_addmap[0].spec = 0;
452  }
453  m_dae1_spec_map.clear();
454  m_dae2_spec_map.clear();
455  for(i=0; i<m_detCards.size(); i++)
456  {
457  DetectorCardIntf* dc = m_detCards[i];
458  int pos = dc->position();
459  const int* spec_map = dc->getDAE2SpecMap();
460  m_dae2_spec_map[pos].resize(dc->highspec() + 1);
461  std::vector<int>& vec = m_dae2_spec_map[pos];
462  for(j=0; j <= dc->highspec(); ++j)
463  {
464  vec[j] = spec_map[j];
465  if ( spec_map[j] != DetectorCardIntf::NOSPECTRUM )
466  {
467  m_dae1_spec_map[ spec_map[j] ] = spec_map_info(dc, dc->position(), j);
468  }
469  }
470  }
471 #if 0
472  len_specmap = m_nDetCards * (3+DAESPECMAX);
473  int *specmap_array = new int[len_specmap];
474  int offset = 0;
475  for(i=0; i<m_nDetCards; i++)
476  {
477  offset = m_detCards[i]->saveDAE2SpecmapToArray(specmap_array, offset, len_specmap);
478  }
479  FILE* f = fopen("c:\\daevme_specmap.dat", "wb");
480  if (f != NULL)
481  {
482  if (fwrite(specmap_array, sizeof(int), offset, f) != offset)
483  {
484  *m_pErr << "Error updating addmap" << std::endl;
485  };
486  fclose(f);
487  }
488  else
489  {
490  *m_pErr << "error updating addmap" << std::endl;
491  }
492  delete []specmap_array;
493 #endif /* 0 */
494  return 0;
495 }
496 
498 int ISISDAE::readDAE1Spectrum(int dae1_spectrum, isisU32_t* buffer, int nbuffer, DAEstatus& status)
499 {
500  int i, j;
501  isisU32_t* tmp_buffer;
502 // spectrum 0 is special in that it is a junk spectrum which exists on all cards
503  if (dae1_spectrum == 0)
504  {
505  memset(buffer, 0, nbuffer * sizeof(isisU32_t));
506  tmp_buffer = new isisU32_t[nbuffer];
507  for(i=0; i<m_detCards.size(); i++)
508  {
509  if (m_detCards[i]->readDAE1Spectrum(0, tmp_buffer, nbuffer, status) != -1)
510  {
511  for(j=0; j<nbuffer; j++)
512  {
513  buffer[j] += tmp_buffer[j];
514  }
515  }
516  }
517  delete[] tmp_buffer;
518  return 0;
519  }
520 // standard spectrum, number unique across all cards
521  for(i=0; i<m_detCards.size(); i++)
522  {
523  if (m_detCards[i]->readDAE1Spectrum(dae1_spectrum, buffer, nbuffer, status) != -1)
524  {
525  return 0;
526  }
527  }
528 // std::cerr << "Spectra not found " << dae1_spectrum << std::endl;
529  return -1;
530 }
531 
532 
535 int ISISDAE::readDAE1Spectra(isisU32_t* buffer, int nbuffer, int spec_to_crpt_offset[], int spec_start, int nspec, int period, int persize, DAEstatus& status)
536 {
537  isisU32_t nchan, spec0 = 0;
538  if (spec_start == 0)
539  {
540  spec0 = 1;
541  }
542  for(int i=0; i<m_detCards.size(); i++)
543  {
544  m_detCards[i]->readDAE1Spectra(buffer, nbuffer, spec_to_crpt_offset, spec_start + spec0, nspec - spec0, period, persize, status);
545  }
546 // re-read and correct spectrum 0
547  if (spec_start == 0)
548  {
549  getSpectrumSize(0, &nchan, status);
550  if ( nchan != spec_to_crpt_offset[1] )
551  {
552  status.addInfoVa(FAC_DAE, "Correcting spectrum 0 size from %d to %d", nchan, spec_to_crpt_offset[1]);
553  nchan = spec_to_crpt_offset[1];
554  }
555  readDAE1Spectrum(0, buffer, nchan, status);
556  }
557  return 0;
558 }
559 
561 int ISISDAE::readAllDAE1Spectra(isisU32_t* buffer, int nbuffer, int spec_to_crpt_offset[], int persize, DAEstatus& status)
562 {
563  int i;
564  isisU32_t nchan;
565  for(i=0; i<m_detCards.size(); i++)
566  {
567  m_taskmgr.start(new ReadAllDAE1SpectraTask(Poco::format("ReadAllDAE1Spectra %d", i), m_detCards[i],
568  buffer, nbuffer, spec_to_crpt_offset, persize, status)); // doesn't read spectrum 0
569  }
571 // re-read and correct spectrum 0
572  getSpectrumSize(0, &nchan, status);
573  if ( nchan != spec_to_crpt_offset[1] )
574  {
575  status.addInfoVa(FAC_DAE, "Correcting spectrum 0 size from %d to %d", nchan, spec_to_crpt_offset[1]);
576  nchan = spec_to_crpt_offset[1];
577  }
578  readDAE1Spectrum(0, buffer, nchan, status);
579  // check
580  if (Poco::Util::Application::instance().config().getBool("isisicp.testHistogramCheck", false))
581  {
582  DAEstatus stat;
583  isisU32_t* dat1 = new isisU32_t[nbuffer];
584  memset(dat1, 4, nbuffer*sizeof(isisU32_t));
585  readHistogramMemory(0, dat1, nbuffer, stat);
586  compareBuffers("readHistogramMemory", dat1, buffer, nbuffer, status);
587  memset(dat1, 4, nbuffer*sizeof(isisU32_t));
588  int nperiod = nbuffer / persize;
589  int perspec = (1 + m_dae1_spec_map.rbegin()->first) / nperiod; // dae1specmap contains spectra for higher periods
590  for(i=0; i < nperiod; ++i)
591  {
592  readDAE1Spectra(dat1, nbuffer, spec_to_crpt_offset, 0, perspec, i, persize, status);
593  }
594  compareBuffers("readDAE1Spectra", dat1, buffer, nbuffer, status);
595  memset(dat1, 4, nbuffer*sizeof(isisU32_t));
596  readDAE1Spectra(dat1, nbuffer, spec_to_crpt_offset, 0, perspec*nperiod, 0, persize, status);
597  compareBuffers("readDAE1Spectra2", dat1, buffer, nbuffer, status);
598  delete[] dat1;
599  }
600  return 0;
601 }
602 
603 
604 isis32_t ISISDAE::openBackplane(const char* dae_name_bp, DAEstatus& status)
605 {
606  status.addInfoVa(FAC_DAE, "Opening connection to VISA resource %s\n", dae_name_bp);
607  ISISVME* vme = m_vme.front();
608  vme->openBackplane(dae_name_bp, status);
610  return ISISVME::Success;
611 }
612 
613 isis32_t ISISDAE::open(const char* dae_name, DAEstatus& status)
614 {
615  bool dae3 = (m_dae_type == NeutronDAE3 || m_dae_type == MuonDAE3);
616  LOGSTR_INFORMATION("Opening connection to VISA resource " << dae_name);
617  status.addInfoVa(FAC_DAE, "Opening connection to VISA resource %s\n", dae_name);
618  if (m_simulate)
619  {
620  status.addInfo(FAC_DAE, "Created VME simulation DAE");
621  if (dae3)
622  {
623  m_vme.push_back(new VMESimulation<DAE3Policy>(status));
624  }
625  else
626  {
627  m_vme.push_back(new VMESimulation<DAE2Policy>(status));
628  }
629  }
630  else
631  {
632  if (dae3)
633  {
634  m_vme.push_back(new QxtrmInterface(status));
635  }
636  else
637  {
638  m_vme.push_back(new NIVisa(status));
639  }
640  }
641  ISISVME* vme = m_vme.back();
642  int dae_number = static_cast<int>(m_vme.size() - 1); // first dae is 0
643  if (vme->initOK())
644  {
645 // vme->resetBus();
646  if (getenv("ISISVME_SCANBUS") != NULL)
647  {
648  int i = vme->scanBus(status);
649  if (i < 3)
650  {
652  "SCAN ERROR - there should be 3 VXI?::*::INSTR devices on the VME bus\n"
653  "You must add a dummy device covering the whole A32 address range\n"
654  "Using the T&M explorer National Instruments program");
655  }
656  }
657  else
658  {
659  status.addInfo(FAC_DAE, "ScanBus skipped - set ISISVME_SCANBUS environment variable to enable");
660  }
661  }
662  vme->open(dae_name, status);
663  if (dae3)
664  {
665  locateCards<DAE3Policy>(vme, dae_number, status);
666  }
667  else
668  {
669  locateCards<DAE2Policy>(vme, dae_number, status);
670  }
671  return vme->lockDevice(5, status);
672 }
673 
674 // trig_id 8 is frame sync, 9 is run
675 int ISISDAE::daeTriggerFunc(void* arg, time_t the_secs, unsigned short the_ms, int trig_id)
676 {
677  static long frame_count = 0;
678  static long run_count = 0;
679  ISISDAE* the_dae = (ISISDAE*)arg;
680  if (trig_id == 8) // frame sync
681  {
682  ++frame_count;
683  }
684  if (trig_id == 9) // run bit
685  {
686  ++run_count;
687  }
688  return DAEstatus::Success;
689 }
690 
692 {
693  size_t i;
694  if ( (i = m_envCards.size() + m_envPeriodCards.size()) != 1 )
695  {
697  "Error - Found %u environment cards (must have 1) and %u detector cards", i, m_detCards.size());
698  return DAEstatus::Failure;
699  }
700  if ( (i = m_envPeriodCards.size()) > 1 )
701  {
703  "Error - Found %u period cards (only 0 or 1 allowed) and %u detector cards", i, m_detCards.size());
704  return DAEstatus::Failure;
705  }
706  return DAEstatus::Success;
707 }
708 
709 
711 {
712 // std::for_each(m_vme.begin(), m_vme.end(), std::bind2nd(std::mem_fun(&ISISVME::unLock),status));
713  for(vme_list_t::iterator it = m_vme.begin(); it != m_vme.end(); ++it)
714  {
715  (*it)->unlockDevice(status);
716  (*it)->close(status);
717  }
718  // m_vme->unLock(status);
719  return status.result();
720 }
721 
722 template <class DAEPolicy>
723 int ISISDAE::locateCards(ISISVME* vme, int dae_number, DAEstatus& status)
724 {
725  typedef DAE2Card<DAEPolicy::card_t> MyDAE2Card;
726  DAE2CardIntf::CardType card_type;
727  int i, j, len_specmap = 0, num_neutron_dc = 0, num_muon_dc = 0;
728 
729 // struct stat st;
730  int *specmap_array = 0;
731  std::ostringstream message;
732 #if 0
733  FILE* f = fopen("c:\\daevme_specmap.dat", "rb");
734  if (f != NULL)
735  {
736  if (fstat(fileno(f), &st) == 0)
737  {
738  len_specmap = st.st_size / sizeof(int);
739  specmap_array = new int[len_specmap];
740  std::cerr << "Reading saved specmap length " << len_specmap << std::endl;
741  fread(specmap_array, sizeof(int), len_specmap, f);
742  }
743  fclose(f);
744  }
745  else
746  {
747  std::cerr << "No previous daevme_specmap.dat found" << std::endl;
748  }
749 #endif /* 0 */
750  // 4 bits are allocated for card ID -> 16 cards max
751 
752  for(j=0; j<16; j++)
753  {
754  i = j + MyDAE2Card::CRATE_MOD * dae_number;
755  if (MyDAE2Card::isCardPresent(i, vme, status))
756  {
757  message << "Card " << j << " is present on dae " << dae_number << " (" << vme->device() << ")";
758  card_type = MyDAE2Card::getCardType(i, vme, status);
759  switch(card_type)
760  {
761  message << "(" << MyDAE2Card::card_type;
762  case MyDAE2Card::EnvCard:
763  message << " Environment card)\n";
764  m_envCards.push_back(new EnvironmentCard<DAEPolicy::env_t>(i, vme, status));
765  break;
766 
767  case MyDAE2Card::NeutronDetectorCard:
768  message << " Neutron Detector card)\n";
769  m_detCards.push_back(new DetectorCard<DAEPolicy::det_t>(i, vme, specmap_array, len_specmap, status));
770  m_es.addCard(m_detCards.back());
771  ++num_neutron_dc;
772  break;
773 
774  case MyDAE2Card::MuonDetectorCard:
775  message << " Muon Detector card)\n";
776  m_detCards.push_back(new MuonDetectorCard(i, vme, specmap_array, len_specmap, status));
777  ++num_muon_dc;
778  break;
779 
780  case MyDAE2Card::EnvPeriodCard:
781  message << " Combined Environment and Period card)\n";
782  m_envPeriodCards.push_back(new EnvPeriodCard<DAEPolicy::env_t>(i, vme, status));
783  break;
784 
785  default:
786  message << " *UNKNOWN*)\n";
787  break;
788  }
789  }
790  }
791  status.addInfo(FAC_DAE, message.str());
792  if (specmap_array != 0)
793  {
794  delete []specmap_array;
795  }
796  if ( (num_muon_dc > 0) && (num_neutron_dc > 0) ) // mixing neutron and muon detector cards is not allowed
797  {
798  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_OUTOFMEM, "ERROR: Found both muon and neutron detector cards in DAE");
799  }
800 // if (m_envCards[0]->isRunning())
801 // {
802 // m_envCards[0]->stopRun();
803 // recreatemap(); /* create DAE-I to DAE-II map from POSLUTs */
804 // m_envCards[0]->startRun();
805 //
806 // }
807 // else
808 // {
809 // m_envCards[0]->resetRunController();
810 // defaultmap(); /* create default DAE-I to DAE-II map */
811 // }
812  return 0;
813 }
814 
816 {
817  m_taskmgr.start(new ClearHistogramMemoryTask("clear", m_detCards, status));
819  return 0;
820 }
821 
822 int ISISDAE::clearCounters(int run_number, DAEstatus& status)
823 {
824  clearCounters(status);
825  if (m_event_mode)
826  {
827  m_es.setOutputFileName(run_number, true, status);
828  }
829  else
830  {
831  m_es.closeAndDeleteOutputFile(run_number, status); // clear out any old event files
832  }
833  return 0;
834 }
835 
837 {
838  clearFramesVetosAndPPP(status);
840  return 0;
841 }
842 
843 int ISISDAE::startRun(bool clear_counters, int run_number, time_t& start_time, DAEstatus& status)
844 {
845  remove(END_IMMEDIATELY_FILE);
846  if (clear_counters)
847  {
848  clearCounters(run_number, status);
849  }
850  if (m_event_mode)
851  {
852  PERIOD_FUNCTION(enableEventMode(status));
853  }
854  else
855  {
856  PERIOD_FUNCTION(disableEventMode(status));
857  }
858  if (m_event_mode)
859  {
860  m_es.setOutputFileName(run_number, clear_counters, status);
861  m_es.start();
862  }
863  else
864  {
865  m_es.closeAndDeleteOutputFile(run_number, status); // clear out any old event files
866  }
867  time(&start_time);
868  ENV_FUNCTION(startRun(status));
869  return 0;
870 }
871 
873 {
874  m_es.closeOutputFile(status);
875 }
876 
878 {
879  std::ostringstream message;
880  unsigned per_seq_check_counter = 0;
881  int i;
882  uint64_t nremain = 0;
883  FILE* f;
884  isisU32_t value, total_veto;
885  bool early_exit = false;
887  {
888  if ( (mode == StopRunClean) && (m_envPeriodCards.size() > 0) )
889  {
890  PERIOD_FUNCTION(endRunAfterSequenceCompletes(status));
891  while(!early_exit && !(PERIOD_FUNCTION(isRunEndedAndSequenceComplete(status))))
892  {
893  Sleep(500);
894  ++per_seq_check_counter;
895  if ( per_seq_check_counter % 120 == 0 )
896  {
897  LOGSTR_WARNING("Still waiting for period card to complete hardware period sequence - restart and use END/IMMEDIATE to finish early");
898  }
899  f = _fsopen(END_IMMEDIATELY_FILE, "rN", _SH_DENYNO);
900  if (f != NULL)
901  {
902  fclose(f);
903  early_exit = true;
904  }
905  }
906  }
907  PERIOD_FUNCTION(abortSequenceCompleteWait(status));
908  }
909  remove(END_IMMEDIATELY_FILE);
910  ENV_FUNCTION(stopRun(status));
911  if (m_event_mode)
912  {
913  nremain = m_es.nNewEventWords(status);
914  if ( mode == StopRunClean || mode == StopRunFast )
915  {
916  for(i = 0; (i < 250) && ( (nremain = m_es.nNewEventWords(status)) > 0 ); ++i)
917  {
918 // LOGSTR_INFORMATION("... still reading DAE, remaining unread events = " << nremain);
919  Poco::Thread::sleep(200);
920  }
921 // wait long enough to clear a whole DAE of event data (worse possible case)
922 // for(i = 0; (i < 3000) && (m_es.nNewEventWords(status) > 0); ++i)
923 // {
924 // Poco::Thread::sleep(200);
925 // }
926  if (nremain > 0)
927  {
928  LOGSTR_WARNING("Unread events in DAE " << nremain);
929  }
930  }
931  else
932  {
933  LOGSTR_INFORMATION("StopRunDiscard mode - ignoring unread dae data events " << nremain);
934  }
935  // need to wait long enough for last block of events from above to get processes
936  if ( mode == StopRunClean )
937  {
938  for(i = 0; (i < 100) && !m_es.endHeaderSeen(); ++i)
939  {
940  Poco::Thread::sleep(200);
941  }
942  if (!m_es.endHeaderSeen())
943  {
944  LOGSTR_WARNING("No end header seen");
945  }
946  }
947  else
948  {
949  Poco::Thread::sleep(1000); // but give chance for end header to appear
950  LOGSTR_INFORMATION("Not StopRunClean mode - not waiting for event mode end run header, present=" << (m_es.endHeaderSeen() ? "YES" : "NO") );
951  }
952  m_es.stop( false );
953  }
954  total_veto = value = 0;
955  std::string veto_text;
956  getVetoStatus(veto_text, status);
957  message << veto_text << "\n";
958  ENV_FUNCTION(getSMPVetoedFrames(&value, status));
959  total_veto += value;
961  ENV_FUNCTION(getExternalVetoedFrames(0, &value, status));
962  total_veto += value;
963  ENV_FUNCTION(getFIFOVetoedFrames(&value, status));
964  total_veto += value;
965  ENV_FUNCTION(getTS2PulseVetoedFrames(&value, status));
966  total_veto += value;
967  ENV_FUNCTION(getISIS50HzVetoedFrames(&value, status));
968  total_veto += value;
970  ENV_FUNCTION(getFChopperVetoedFrames(0, &value, status));
971  total_veto += value;
972  for(i=0; i<m_detCards.size(); i++)
973  {
974  m_detCards[i]->printVetoStatus(message, true, status);
975  }
976  if (m_envPeriodCards.size() > 0)
977  {
978  m_envPeriodCards[0]->getInternalVetoedFrames(&value, status);
979 // message << "Internal vetoed frames = " << value << "\n";
980  total_veto += value;
981  }
982 // message << "TOTAL of VETO counters from all sources = " << total_veto << "\n";
983  status.addInfo(FAC_DAE, message.str());
984  return 0;
985 }
986 
988 {
989  return ENV_FUNCTION(resetRunController(status));
990 }
991 
992 //int ISISDAE::clearPPP(DAEstatus& status)
993 //{
994 // return m_envCards[0]->clearPPP(status);
995 //}
996 
998 {
999  return ENV_FUNCTION(getRawFrames(value, status));
1000 }
1001 
1002 int ISISDAE::getRawFramesPeriod(isisU32_t* value, int period, DAEstatus& status)
1003 {
1004  if ((m_period_mode != ISISDAE::PeriodTypeSoftware) /* && (m_periodCards.size() > 0) */)
1005  {
1006  return PERIOD_FUNCTION(getPeriodRawFrames(period, value, status));
1007  }
1008  else
1009  {
1010  *value = 0;
1011  return ISISVME::Success;
1012  }
1013 }
1014 
1015 int ISISDAE::getGoodFramesPeriod(isisU32_t* value, int period, DAEstatus& status)
1016 {
1017  if ((m_period_mode != ISISDAE::PeriodTypeSoftware) /* && (m_periodCards.size() > 0)*/ )
1018  {
1019  return PERIOD_FUNCTION(getPeriodGoodFrames(period, value, status));
1020  }
1021  else
1022  {
1023  *value = 0;
1024  return ISISVME::Success;
1025  }
1026 }
1027 
1029 {
1030  return ENV_FUNCTION(getGoodFrames(value, status));
1031 }
1032 
1034 {
1035  return ENV_FUNCTION(getRawPPPLower(value, status));
1036 }
1037 
1039 {
1040  return ENV_FUNCTION(getRawPPPUpper(value, status));
1041 }
1042 
1044 {
1045  return ENV_FUNCTION(getGoodPPPLower(value, status));
1046 }
1047 
1049 {
1050  return ENV_FUNCTION(getGoodPPPUpper(value, status));
1051 }
1052 
1053 float ISISDAE::getRawUAmpHoursPeriod(int period, DAEstatus& status)
1054 {
1055  if (m_envPeriodCards.size() > 0)
1056  {
1057  return m_envPeriodCards[0]->getRawUAmpHoursPeriod(period, status) * m_uamp_scale;
1058  }
1059  else
1060  {
1061  return 0.0;
1062  }
1063 }
1064 
1065 float ISISDAE::getGoodUAmpHoursPeriod(int period, DAEstatus& status)
1066 {
1067  if (m_envPeriodCards.size() > 0)
1068  {
1069  return m_envPeriodCards[0]->getGoodUAmpHoursPeriod(period, status) * m_uamp_scale;
1070  }
1071  else
1072  {
1073  return 0.0;
1074  }
1075 }
1076 
1077 int ISISDAE::getRawPPPLowerPeriod(int period, isisU32_t* value, DAEstatus& status)
1078 {
1079  if (m_envPeriodCards.size() > 0)
1080  {
1081  return m_envPeriodCards[0]->getRawPPPLowerPeriod(period, value, status);
1082  }
1083  else
1084  {
1085  *value = 0;
1086  return DAEstatus::Failure;
1087  }
1088 }
1089 
1090 int ISISDAE::getRawPPPUpperPeriod(int period, isisU32_t* value, DAEstatus& status)
1091 {
1092  if (m_envPeriodCards.size() > 0)
1093  {
1094  return m_envPeriodCards[0]->getRawPPPUpperPeriod(period, value, status);
1095  }
1096  else
1097  {
1098  *value = 0;
1099  return DAEstatus::Failure;
1100  }
1101 }
1102 
1103 int ISISDAE::getGoodPPPLowerPeriod(int period, isisU32_t* value, DAEstatus& status)
1104 {
1105  if (m_envPeriodCards.size() > 0)
1106  {
1107  return m_envPeriodCards[0]->getGoodPPPLowerPeriod(period, value, status);
1108  }
1109  else
1110  {
1111  *value = 0;
1112  return DAEstatus::Failure;
1113  }
1114 }
1115 
1116 int ISISDAE::getGoodPPPUpperPeriod(int period, isisU32_t* value, DAEstatus& status)
1117 {
1118  if (m_envPeriodCards.size() > 0)
1119  {
1120  return m_envPeriodCards[0]->getGoodPPPUpperPeriod(period, value, status);
1121  }
1122  else
1123  {
1124  *value = 0;
1125  return DAEstatus::Failure;
1126  }
1127 }
1128 
1130 {
1131  return ENV_FUNCTION(isRunning(status)); // test m_run?
1132 }
1133 
1134 // find card given crate card number
1136 {
1137  int i;
1138  for(i=0; i<m_detCards.size(); i++)
1139  {
1140  if (m_detCards[i]->position() == position)
1141  {
1142  return m_detCards[i];
1143  }
1144  }
1145  return 0;
1146 }
1147 
1148 #if 0
1149 // read len 32bit words
1150 // DAE1 spectra are contiguous in memory
1151 // DAE2 spectra are contiguous on a card
1152 int ISISDAE::readHistogramMemory(unsigned long address,
1153  isisU32_t* buffer, int len)
1154 {
1155  int i, offset, n, start = -1, end = -1;
1156  int keep_len = len;
1157  for(i=0; (i<m_lenAddmap) && (start == -1 || end == -1); i++)
1158  {
1159  if (start == -1)
1160  {
1161  if (address == m_addmap[i].dae1add)
1162  {
1163  start = i;
1164  }
1165  else if (address < m_addmap[i].dae1add)
1166  {
1167  start = i - 1;
1168  }
1169  }
1170  if ((end == -1) && ((address + 4*len) <=
1171  (m_addmap[i].dae1add + 4*m_addmap[i].len)))
1172  {
1173  end = i;
1174  }
1175  }
1176  if (start == -1)
1177  {
1178  OUTPUT_MESSAGE(*m_pErr , "readHistogramMemory error - cannot find start address " << address << " in map" << std::endl);
1179  return -1;
1180  }
1181  if (end == -1)
1182  {
1183  OUTPUT_MESSAGE(*m_pErr , "readHistogramMemory error - cannot find end address in map" << std::endl);
1184  end = m_lenAddmap - 1;
1185  }
1186  for(i=start; i<=end; i++)
1187  {
1188  offset = address - m_addmap[i].dae1add;
1189  if (offset/4 + len > m_addmap[i].len)
1190  {
1191  n = m_addmap[i].len - offset/4;
1192  }
1193  else
1194  {
1195  n = len;
1196  }
1197  if (offset < 0)
1198  {
1199  OUTPUT_MESSAGE(*m_pErr , "readHistogramMemory error - offset < 0" << std::endl);
1200  return -1;
1201  }
1202  m_addmap[i].dc->readHistogramMemory(m_addmap[i].dae2add + offset, buffer, n);
1203  buffer += n;
1204  address += n*4;
1205  len -= n;
1206  }
1207  if (len != 0)
1208  {
1209  OUTPUT_MESSAGE(*m_pErr , "readHistogramMemory error: only read " << keep_len - len <<
1210  "/" << keep_len << " words" << std::endl);
1211  return -1;
1212  }
1213  return 0;
1214 }
1215 #endif /* 0 */
1216 
1217 // read len 32bit words
1218 // DAE1 spectra are contiguous in memory
1219 // DAE2 spectra are contiguous on a card
1220 int ISISDAE::readHistogramMemory(unsigned long address,
1221  isisU32_t* buffer, int len, DAEstatus& status)
1222 {
1223  int i = 0, j = 0, offset_i, offset_j, n, nj, len_j;
1224  int keep_len = len;
1225  isisU32_t nchan;
1226  isisU32_t* buffer_start = buffer;
1227  unsigned long address_j;
1228  bool do_spec0 = (address == 0);
1229  while( (i < m_lenAddmap) && (len > 0) )
1230  {
1231  offset_i = address - m_addmap[i].dae1add;
1232  // std::cerr << "offset i" << offset_i << std::endl;
1233  if (offset_i < 0)
1234  {
1235  // std::cerr << "offset i < 0" << std::endl;
1236  i++;
1237  continue;
1238  }
1239  if (offset_i/4 + len > m_addmap[i].len)
1240  {
1241  n = m_addmap[i].len - offset_i/4;
1242  }
1243  else
1244  {
1245  n = len;
1246  }
1247  if (n <= 0)
1248  {
1249  // std::cerr << "n < 0" << std::endl;
1250  i++;
1251  continue;
1252  }
1253 // look for a continuous region
1254  j = i;
1255  address_j = address;
1256  len_j = len;
1257  nj = 0;
1258  while( (j < m_lenAddmap) && (len_j > 0) &&
1259  (m_addmap[j].card == m_addmap[i].card) &&
1260  (m_addmap[i].spec + (j - i) == m_addmap[j].spec) &&
1261  (address + 4*len > m_addmap[j].dae1add) )
1262  {
1263  offset_j = address_j - m_addmap[j].dae1add;
1264  if (offset_j < 0)
1265  {
1266  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "readHistogramMemory error");
1267  j++;
1268  continue;
1269  }
1270  if (offset_j/4 + len_j > m_addmap[j].len)
1271  {
1272  n = m_addmap[j].len - offset_j/4;
1273  }
1274  else
1275  {
1276  n = len_j;
1277  }
1278  if (n <= 0)
1279  {
1280  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "readHistogramMemory error");
1281  j++;
1282  continue;
1283  }
1284  nj += n;
1285  address_j += n*4;
1286  len_j -= n;
1287  j++;
1288 // std::cerr << " j read of " << n << std::endl;
1289  }
1290 // std::cerr << "Reading " << nj << " words from card " << m_addmap[i].card << std::endl;
1291  if (true)
1292  {
1293  readDCHistogramAsync(m_addmap[i].dc, m_addmap[i].dae2add + offset_i, buffer, nj, status);
1294  }
1295  else
1296  {
1297  m_addmap[i].dc->readHistogramMemory(m_addmap[i].dae2add + offset_i, buffer, nj, status);
1298  SetEvent(m_async_complete_event); // needed so waitForAsync does not hang
1299  }
1300  buffer += nj;
1301  address += nj*4;
1302  len -= nj;
1303  i = j;
1304  }
1305  waitForAsync();
1306  if (len != 0)
1307  {
1308  std::ostringstream message;
1309  message << "readHistogramMemory error: only read " << keep_len - len <<
1310  "/" << keep_len << " words";
1311  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, message.str());
1312  return -1;
1313  }
1314  // correct for spectrum 0
1315  if (do_spec0)
1316  {
1317  getSpectrumSize(0, &nchan, status);
1318  readDAE1Spectrum(0, buffer_start, nchan, status);
1319  }
1320  return 0;
1321 }
1322 
1324 {
1325  int i;
1326  isisU32_t sum = 0;
1327  for(i=0; i<m_detCards.size(); i++)
1328  {
1329  sum += m_detCards[i]->sumHistogramMemory(status);
1330  }
1331  return sum;
1332 }
1333 
1335 {
1336  return m_detCards[det_card]->readDescriptorTimeBinLimitRegister(value, status);
1337 }
1338 
1340 {
1341  return m_detCards[det_card]->writeDescriptorTimeBinLimitRegister(value, status);
1342 }
1343 
1345 {
1346  return m_detCards[det_card]->readTCGTimeBinLimitRegister(value, status);
1347 }
1348 
1350 {
1351  return m_detCards[det_card]->writeTCGTimeBinLimitRegister(value, status);
1352 }
1353 
1354 //int ISISDAE::writeHistogramMemory(unsigned long start, isisU32_t* buffer, int len)
1355 //{
1356 // return 0;
1357 //}
1358 
1359 
1360 // vetos: SMP, EXTERNAL1
1361 // FIFO always enabled
1362 int ISISDAE::setDAE1Vetos(int vetos[], int n, DAEstatus& status)
1363 {
1364  int i;
1365 // FIFO
1366  status.addInfo(FAC_DAE, "Enabling FIFO veto");
1367  ENV_FUNCTION(enableFIFOVeto(status));
1368 // SMP
1369  if ( (n > 0) && (vetos[0] == 1) )
1370  {
1371  status.addInfo(FAC_DAE, "Enabling SMP veto");
1372  ENV_FUNCTION(enableSMPVeto(status));
1373  }
1374  else
1375  {
1376  status.addInfo(FAC_DAE, "Disabling SMP veto");
1377  ENV_FUNCTION(disableSMPVeto(status));
1378  }
1379 // 4 possible External vetos
1380  for(i=1; i <= 4; i++)
1381  {
1382  if ( (n > i) && (vetos[i] == 1) )
1383  {
1384  status.addInfoVa(FAC_DAE, "Enabling EXTERNAL veto %d", i-1);
1385  ENV_FUNCTION(enableExternalVeto(i-1, status));
1386  }
1387  else
1388  {
1389  status.addInfoVa(FAC_DAE, "Disabling EXTERNAL veto %d", i-1);
1390  ENV_FUNCTION(disableExternalVeto(i-1, status));
1391  }
1392  }
1393 // Fermi (Fast) Chopper
1394  if ( (n > 7) && (vetos[5] == 1) )
1395  {
1396  status.addInfo(FAC_DAE, "Enabling Fermi Chopper veto 0"); // delay + width printed by called function
1397  ENV_FUNCTION(enableFChopperVeto(0, vetos[6], vetos[7], status));
1398  }
1399  else
1400  {
1401  status.addInfo(FAC_DAE, "Disabling Fermi Chopper veto 0");
1402  ENV_FUNCTION(disableFChopperVeto(0, status));
1403  }
1404 // TS2 Pulse
1405  if ( (n > 8) && (vetos[8] == 1) )
1406  {
1407  status.addInfo(FAC_DAE, "Enabling TS2 Pulse veto");
1408  ENV_FUNCTION(enableTS2PulseVeto(status));
1409  }
1410  else
1411  {
1412  status.addInfo(FAC_DAE, "Disabling TS2 Pulse veto");
1413  ENV_FUNCTION(disableTS2PulseVeto(status));
1414  }
1415 // 50 Hz
1416  if ( (n > 9) && (vetos[9] == 1) )
1417  {
1418  status.addInfo(FAC_DAE, "Enabling ISIS 50Hz veto");
1419  ENV_FUNCTION(enableISIS50HzVeto(status));
1420  }
1421  else
1422  {
1423  status.addInfo(FAC_DAE, "Disabling ISIS 50Hz veto");
1424  ENV_FUNCTION(disableISIS50HzVeto(status));
1425  }
1426 // Detector Card
1427  for(i=0; i<m_detCards.size(); i++)
1428  {
1429  m_detCards[i]->clearVetoOccurredFlag(status);
1430  m_detCards[i]->enableDIMVetos(0xffff, status); // on all 16 dims
1431  m_detCards[i]->enableVeto(DetectorCardIntf::FrameOverflowVeto, status);
1432  m_detCards[i]->enableVeto(DetectorCardIntf::MemoryFullVeto, status);
1433  m_detCards[i]->enableVeto(DetectorCardIntf::FIFOLateVeto, status);
1434  }
1435 // if (m_envPeriodCards.size() > 0)
1436 // {
1437 // m_envPeriodCards[0]->disableFermiChopperVeto(status);
1438 // }
1439  return 0;
1440 }
1441 
1442 
1445 };
1446 
1447 int ISISDAE::setVeto(const std::string& name, bool enable, DAEstatus& status)
1448 {
1449  bool done = false;
1450  for(int i=0; i < sizeof(veto_setters) / sizeof(veto_desc); i++)
1451  {
1452  if (name == veto_setters[i].name)
1453  {
1454  if (m_envCards.size() > 0)
1455  {
1456  if (enable)
1457  {
1458  (m_envCards[0]->*(veto_setters[i].ec_enable))(status);
1459  }
1460  else
1461  {
1462  (m_envCards[0]->*(veto_setters[i].ec_disable))(status);
1463  }
1464  done = true;
1465  }
1466  else if (m_envPeriodCards.size() > 0)
1467  {
1468  if (enable)
1469  {
1470  (m_envPeriodCards[0]->*(veto_setters[i].pc_enable))(status);
1471  }
1472  else
1473  {
1474  (m_envPeriodCards[0]->*(veto_setters[i].pc_disable))(status);
1475  }
1476  done = true;
1477  }
1478  else
1479  {
1480  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_OUTOFMEM, "No env or period cards");
1481  }
1482  }
1483  }
1484  if (!done)
1485  {
1486  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_OUTOFMEM, "Unknown veto %s", name.c_str());
1487  }
1488  return 0;
1489 }
1490 
1491 int ISISDAE::setFrameSync(FrameSync fs, int muon_pulse, DAEstatus& status)
1492 {
1493  ENV_FUNCTION(setFrameSync(fs, status));
1494  if (m_envPeriodCards.size() > 0)
1495  {
1496  m_envPeriodCards[0]->setMuonPulse(muon_pulse, status);
1497  }
1498  return DAEstatus::Success;
1499 }
1500 
1501 int ISISDAE::setFrameSyncDelay(isisU32_t delay, DAEstatus& status) // in us
1502 {
1503  return ENV_FUNCTION(setFrameSyncDelay(delay, status));
1504 }
1505 
1507 double ISISDAE::frameTimerDrift(DAEstatus& status) // icp - dae
1508 {
1509  if (m_envPeriodCards.size() > 0)
1510  {
1511  return m_envPeriodCards[0]->frameTimerDrift(status);
1512  }
1513  else
1514  {
1515  return 1.0e38;
1516  }
1517 }
1518 
1519 int ISISDAE::getFrameSyncDelay(isisU32_t* delay, DAEstatus& status) // in us
1520 {
1521  return ENV_FUNCTION(getFrameSyncDelay(delay, status));
1522 }
1523 
1524 int ISISDAE::setDCFrameSyncDelay(int crat, isisU32_t delay, DAEstatus& status) // in us
1525 {
1526  DetectorCardIntf* dc = findDetectorCard(crat, status);
1527  if (dc != NULL)
1528  {
1529  dc->setFrameSyncDelay(delay, status);
1530  }
1531  else
1532  {
1533  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "Unknown detector card %d", crat);
1534  }
1535  return status.result();
1536 }
1537 
1538 int ISISDAE::getDCFrameSyncDelay(int crat, isisU32_t* delay, DAEstatus& status) // in us
1539 {
1540  DetectorCardIntf* dc = findDetectorCard(crat, status);
1541  if (dc != NULL)
1542  {
1543  dc->getFrameSyncDelay(delay, status);
1544  }
1545  else
1546  {
1547  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "Unknown detector card %d", crat);
1548  }
1549  return status.result();
1550 }
1551 
1553 {
1554  return ENV_FUNCTION(getGoodUAmpHours(status)) * m_uamp_scale;
1555 }
1556 
1558 {
1559  return ENV_FUNCTION(getRawUAmpHours(status)) * m_uamp_scale;
1560 }
1561 
1563 {
1564  int i;
1565  for(i=0; i<m_envPeriodCards.size(); i++)
1566  {
1567  m_envPeriodCards[i]->zeroPeriodFrameCounters(status);
1568  }
1569 // for(i=0; i<m_detCards.size(); i++)
1570 // {
1571 // m_detCards[i]->clearVetoOccurredFlag(status);
1572 // }
1573  return ENV_FUNCTION(ClearFramesAndPPP(status));
1574 }
1575 
1576 int ISISDAE::setPeriodType(ISISDAE::PeriodType type, bool single_daq_period, DAEstatus& status)
1577 {
1578  m_period_mode = type;
1579  bool hardware_periods = (type != ISISDAE::PeriodTypeSoftware);
1580  int i;
1582  {
1583  ENV_FUNCTION(enableHardwarePeriods(status));
1584  status.addInfo(FAC_DAE, "Enabling EC delayed start");
1585  }
1586  else
1587  {
1588  ENV_FUNCTION(disableHardwarePeriods(status));
1589  }
1590  for(i=0; i<m_detCards.size(); i++)
1591  {
1592  m_detCards[i]->setPeriodType(hardware_periods, single_daq_period, status);;
1593  }
1594  return 0;
1595 }
1596 
1598 {
1600  (m_detCards.size() > 0) )
1601  {
1602  *period = PERIOD_FUNCTION(getCurrentPeriodNumber(status));
1603  return status.result();
1604 // return m_detCards[0]->getCurrentHardwarePeriod(period, status); // would be same if no dwells
1605  }
1606  else if ( (m_period_mode == ISISDAE::PeriodTypeHardwareInternal) /* && (m_periodCards.size() > 0) */)
1607  {
1608  *period = PERIOD_FUNCTION(getCurrentPeriodNumber(status));
1609  return status.result();
1610  }
1611  else
1612  {
1613  *period = 0;
1614 // status.addWarning(FAC_DAE, "getCurrentHardwarePeriod error - not using hardware periods");
1615  return ISISVME::Error;
1616  }
1617 }
1618 
1620 {
1621  if ((m_period_mode != ISISDAE::PeriodTypeSoftware) && (m_detCards.size() > 0))
1622  {
1623  return m_detCards[0]->getCurrentHardwarePeriod(period, status);
1624  }
1625  else
1626  {
1627  *period = 0;
1628 // status.addWarning(FAC_DAE, "getCurrentDAQHardwarePeriod error - not using hardware periods");
1629  return ISISVME::Error;
1630  }
1631 }
1632 
1633 int ISISDAE::getTimeChannels(int spec, double* tcb, int ntc, DAEstatus& status)
1634 {
1635  isisU32_t i, nchan;
1636  getSpectrumSize(spec, &nchan, status);
1637  isisU32_t* itcb = new isisU32_t[nchan];
1638  getTimeChannels(spec, itcb, nchan-1, status);
1639  for(i=0; i < ntc+1; i++)
1640  {
1641  tcb[i] = itcb[i] / (double)m_clock_frequency; // need to add FS delay
1642  }
1643  delete []itcb;
1644  return 0;
1645 }
1646 
1648 {
1649  return ENV_FUNCTION(getSMPVetoedFrames(value, status));
1650 }
1651 
1653 {
1654  return ENV_FUNCTION(getTS2PulseVetoedFrames(value, status));
1655 }
1656 
1658 {
1659  return ENV_FUNCTION(getISIS50HzVetoedFrames(value, status));
1660 }
1661 
1662 int ISISDAE::getExternalVetoedFrames(int veto_number, isisU32_t* value, DAEstatus& status)
1663 {
1664  return ENV_FUNCTION(getExternalVetoedFrames(veto_number, value, status));
1665 }
1666 
1668 {
1669  return ENV_FUNCTION(getFIFOVetoedFrames(value, status));
1670 }
1671 
1673 {
1674  if (m_envPeriodCards.size() > 0)
1675  {
1676  return m_envPeriodCards[0]->getMSModeVetoedFrames(value, status);
1677  }
1678  else
1679  {
1680  return 0;
1681  }
1682 }
1683 
1684 
1685 int ISISDAE::getTotalCounts(int64_t* value, DAEstatus& status)
1686 {
1687  int i;
1688  isisU32_t counts;
1689  *value = 0;
1690  for(i=0; i<m_detCards.size(); i++)
1691  {
1692  m_detCards[i]->getTotalCounts(&counts, status);
1693  *value = *value + counts;
1694  }
1695  return 0;
1696 }
1697 
1699 {
1700  int i;
1701  for(i=0; i<m_detCards.size(); i++)
1702  {
1703  m_detCards[i]->clearTotalCountsRegister(status);
1704  }
1705  return 0;
1706 }
1707 
1708 // need to call setPeriodType(HardwareInternal) after this - you need to call setPeriodType() after
1709 // the detector card is programmed so that it knows the period size
1710 int ISISDAE::programPeriodCard(PeriodType period_type, int nper, int nperseq_request, isisU32_t* outputs, isisU16_t *dwell_flags, isisU16_t *frames,
1711  int period_output_delay, DAEstatus& status)
1712 {
1713  if (m_envPeriodCards.size() != 1)
1714  {
1715 // status.add(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "No period card present");
1716  status.addInfo(FAC_DAE, "No period card present");
1717 // return DAEstatus::Failure;
1718  return status.result();
1719  }
1720  if (m_envPeriodCards.size() == 1)
1721  {
1723  epc->resetPeriodCard(status);
1724  epc->clearPeriodCounters(status);
1725  epc->setPeriodControlBits(0, false, status); // zero register
1726  if (epc->getFrameSync(status) == FrameSyncMuonMS)
1727  {
1728  epc->enableMSMode(status);
1729  }
1730  else
1731  {
1732  epc->disableMSMode(status);
1733  }
1734  epc->setNumberOfPeriods(0, status);
1735  epc->zeroPeriodFrameCounters(status);
1736  epc->zeroPeriodProtonCounters(status);
1737 // epc->zeroPeriodExtraCounters(status);
1738  epc->setNumberOfPeriods(nper, status);
1739  epc->programOUTLUT(outputs, nper, status);
1740  epc->programPERLUT(dwell_flags, frames, nper, status);
1741  if (nperseq_request > 0)
1742  {
1743  epc->setMultiplePeriodSequenceMode(nperseq_request, status);
1744  }
1745  else
1746  {
1747  epc->setSinglePeriodSequenceMode(status);
1748  }
1749  epc->enablePeriodMode((period_type == ISISDAE::PeriodTypeHardwareExternal ? true : false), status);
1750  epc->setPeriodOutputDelay(period_output_delay, status);
1751  }
1752  return status.result();
1753 }
1754 
1756 {
1757  if (m_envPeriodCards.size() > 0)
1758  {
1759  PERIOD_FUNCTION(disablePeriodMode(status));
1760  }
1761  return status.result();
1762 }
1763 
1765 {
1766  if (m_envPeriodCards.size() > 0)
1767  {
1768  *period_sequence = PERIOD_FUNCTION(getCurrentPeriodSequence(status));
1769  }
1770  else
1771  {
1772  *period_sequence = 0;
1773  }
1774  return status.result();
1775 }
1776 
1778 {
1779  if (m_envPeriodCards.size() > 0)
1780  {
1781  return m_envPeriodCards[0]->isMultipleSequenceComplete(status);
1782  }
1783  else
1784  {
1785  return false;
1786  }
1787 }
1788 
1789 template <class DAECardPolicy>
1790 int ISISDAE::VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus& status)
1791 {
1792  unsigned long add = DAE2Card<DAECardPolicy>::makeAddress(card_id, card_address);
1793  unsigned long old_value;
1794  isisU16_t old16;
1795  isisU32_t old32;
1796  ISISVME* vme = m_vme[card_id / DAECardPolicy::CRATE_MOD];
1797  if (sixteen_bit)
1798  {
1799  vme->readU16(add, &old16, ISISVME::TransferNoOptions, status);
1800  old_value = old16;
1801  }
1802  else
1803  {
1804  vme->readU32(add, &old32, ISISVME::TransferNoOptions, status);
1805  old_value = old32;
1806  }
1807  switch(mode)
1808  {
1809  case 0: // SET
1810  break;
1811 
1812  case 1: // AND
1813  old_value &= value;
1814  value = old_value;
1815  break;
1816 
1817  case 2: // OR
1818  old_value |= value;
1819  value = old_value;
1820  break;
1821 
1822  case 3: // XOR
1823  old_value ^= value;
1824  value = old_value;
1825  break;
1826 
1827  default:
1828  break;
1829  }
1830  status.addInfoVa(FAC_DAE, "Setting 0x%x = 0x%x (%s bit)", add, value, (sixteen_bit ? "16" : "32"));
1831  if (sixteen_bit)
1832  {
1833  vme->writeU16(add, static_cast<isisU16_t>(value), ISISVME::TransferNoOptions, status);
1834  }
1835  else
1836  {
1837  vme->writeU32(add, value, ISISVME::TransferNoOptions, status);
1838  }
1839  return 0;
1840 }
1841 
1842 template <class DAECardPolicy>
1843 int ISISDAE::VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long* value, DAEstatus& status)
1844 {
1845  int stat;
1846  unsigned long add = DAE2Card<DAECardPolicy>::makeAddress(card_id, card_address);
1847  ISISVME* vme = m_vme[card_id / DAECardPolicy::CRATE_MOD];
1848  isisU16_t old16;
1849  isisU32_t old32;
1850  if (sixteen_bit)
1851  {
1852  stat = vme->readU16(add, &old16, ISISVME::TransferNoOptions, status);
1853  *value = old16;
1854  }
1855  else
1856  {
1857  stat = vme->readU32(add, &old32, ISISVME::TransferNoOptions, status);
1858  *value = old32;
1859  }
1860  return stat;
1861 }
1862 
1863 
1864 template <class DAECardPolicy>
1865 int ISISDAE::VMEWriteArray(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status)
1866 {
1867  unsigned long add = DAE2Card<DAECardPolicy>::makeAddress(card_id, card_address);
1868  ISISVME* vme = m_vme[card_id / DAECardPolicy::CRATE_MOD];
1869  return vme->writeBlockU32(add, values, num_values, ISISVME::TransferBlock | ISISVME::TransferLittleEndian, status);
1870 }
1871 
1872 template <class DAECardPolicy>
1873 int ISISDAE::VMEReadArray(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status)
1874 {
1875  unsigned long add = DAE2Card<DAECardPolicy>::makeAddress(card_id, card_address);
1876  ISISVME* vme = m_vme[card_id / DAECardPolicy::CRATE_MOD];
1877  return vme->readBlockU32(add, values, num_values, ISISVME::TransferBlock | ISISVME::TransferLittleEndian, status);
1878 }
1879 
1880 const char* ISISDAE::PeriodType_desc[] = {
1881  "Software",
1882  "HardwareInternal (period card)",
1883  "HardwareExternal (period card)"
1884 };
1885 
1886 const char* ISISDAE::DAEType_desc[] = {
1887  "Unknown",
1888  "Neutron DAE2",
1889  "Muon DAE2",
1890  "Neutron DAE3",
1891  "Muon DAE3"
1892 };
1893 
1894 
1895 DWORD __stdcall ISISDAE::checkTestPatternThread(void* arg)
1896 {
1897  test_async_t* his = (test_async_t*)arg;
1898  his->dc->checkTestPattern(his->pattern, his->status);
1899  his->dae->doneAsync();
1900  delete his;
1901  return 0;
1902 }
1903 
1904 int ISISDAE::checkTestPatternAsync(unsigned long pattern, DAEstatus& status)
1905 {
1906  ICPTimer icptimer;
1907  for(int i=0; i<m_detCards.size(); i++)
1908  {
1909  test_async_t* arg = new test_async_t(this, m_detCards[i], pattern, status);
1910  InterlockedIncrement(&m_num_async_requests);
1911  if (QueueUserWorkItem(checkTestPatternThread, arg, WT_EXECUTEDEFAULT) != 0)
1912  {
1913  ;
1914  }
1915  else
1916  {
1917  InterlockedDecrement(&m_num_async_requests);
1918  status.add(FAC_DAE, SEV_ERROR, ERRTYPE_OUTOFMEM, "error queueing work item");
1919  }
1920  }
1921  icptimer.info("Async checks queued...", status);
1922  waitForAsync();
1923  icptimer.info("checkTestPatternAsync", status);
1924  return ISISVME::Success;
1925 }
1926 
1927 int ISISDAE::fillWithTestPattern(unsigned long pattern, DAEstatus& status)
1928 {
1929  ICPTimer icptimer("fillWithTestPattern", status);
1930  for(int i=0; i<m_detCards.size(); i++)
1931  {
1932  m_detCards[i]->fillWithTestPattern(pattern, status);
1933  }
1934  status.addInfoVa(FAC_DAE, "Memory filled with test pattern %lu ready for checking", pattern);
1935  return ISISVME::Success;
1936 }
1937 
1938 int ISISDAE::checkTestPattern(unsigned long pattern, DAEstatus& status)
1939 {
1940  ICPTimer icptimer("checkTestPattern", status);
1941  std::ostringstream oss;
1942  for(int i=0; i<m_detCards.size(); i++)
1943  {
1944  m_detCards[i]->checkTestPattern(pattern, status);
1945  }
1946  return ISISVME::Success;
1947 }
1948 
1949 
1950 int ISISDAE::getVetoStatus(std::string& veto_text, DAEstatus& status)
1951 {
1952  std::ostringstream oss;
1953  ENV_FUNCTION(printVetoDetails(oss, status));
1954  veto_text = oss.str();
1955  return ISISVME::Success;
1956 }
1957 
1958 int ISISDAE::whichVeto(std::string& veto_text, DAEstatus& status)
1959 {
1960  std::ostringstream oss;
1961  ENV_FUNCTION(whichVeto(oss, status));
1962  for(int i=0; i<m_detCards.size(); i++)
1963  {
1964  m_detCards[i]->whichVeto(oss, status);
1965  }
1966  veto_text = oss.str();
1967  return ISISVME::Success;
1968 }
1969 
1970 int ISISDAE::writePOSLUTMemory(int card_id, isisU32_t* buffer, int len, DAEstatus& status)
1971 {
1972  DetectorCardIntf* dc = findDetectorCard(card_id, status);
1973  if (dc != NULL)
1974  {
1975  dc->writePOSLUTMemory(0, buffer, len, status);
1976  return ISISVME::Success;
1977  }
1978  else
1979  {
1980  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "writePOSLUTMemory: Unknown detector card %d", card_id);
1981  return DAEstatus::Failure;
1982  }
1983 }
1984 
1985 int ISISDAE::writeHistogramMemory(int card_id, isisU32_t* buffer, int start, int len, DAEstatus& status)
1986 {
1987  DetectorCardIntf* dc = findDetectorCard(card_id, status);
1988  if (dc != NULL)
1989  {
1990  dc->writeHistogramMemory(start, buffer, len, status);
1991  return ISISVME::Success;
1992  }
1993  else
1994  {
1995  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "writeHistogramMemory: Unknown detector card %d", card_id);
1996  return DAEstatus::Failure;
1997  }
1998  return ISISVME::Success;
1999 }
2000 
2002 {
2003  if (m_envCards.size() > 0)
2004  {
2005  status.addInfo(FAC_DAE, "Enabling EC delayed start");
2006  m_envCards[0]->enableHardwarePeriods(status);
2007  }
2008  if (m_envPeriodCards.size() > 0)
2009  {
2010  status.addInfo(FAC_DAE, "Enabling PC delayed start");
2011  m_envPeriodCards[0]->enableDelayedStart(status);
2012  }
2013  return ISISVME::Success;
2014 }
2015 
2017 {
2018  if (m_envCards.size() > 0)
2019  {
2020  m_envCards[0]->disableHardwarePeriods(status);
2021  }
2022  if (m_envPeriodCards.size() > 0)
2023  {
2024  m_envPeriodCards[0]->disableDelayedStart(status);
2025  }
2026  return ISISVME::Success;
2027 }
2028 
2029 void ISISDAE::setDCEventMode(unsigned long card_id, bool value, DAEstatus& status)
2030 {
2031  DetectorCardIntf* dc = findDetectorCard(card_id, status);
2032  if (dc != NULL)
2033  {
2034  dc->setEventCollectionMode(value, status);
2035  m_es.setCardStatus(card_id, value);
2036  }
2037  else
2038  {
2039  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "setDCEventMode: Unknown detector card %d", card_id);
2040  }
2041 }
2042 
2043 void ISISDAE::setDCCardMode(unsigned long card_id, bool neutron_data, DAEstatus& status)
2044 {
2045  DetectorCardIntf* dc = findDetectorCard(card_id, status);
2046  if (dc != NULL)
2047  {
2049  }
2050  else
2051  {
2052  status.addVa(FAC_DAE, SEV_ERROR, ERRTYPE_SPECREAD, "setDCCardMode: Unknown detector card %d", card_id);
2053  }
2054 }
2055 
2057 {
2058  std::for_each(m_detCards.begin(), m_detCards.end(), boost::bind(&DetectorCardIntf::setEventCollectionMode, _1, false, boost::ref(status)));
2059  m_es.setCardStatus(false);
2060 }
2061 
2063 {
2065  {
2066  if (m_envPeriodCards.size() > 0)
2067  {
2068  PERIOD_FUNCTION(endRunAfterSequenceCompletes(status));
2069  }
2070  }
2071  return DAEstatus::Success;
2072 }
2073 
2075 {
2076  if ( (m_envPeriodCards.size() > 0) &&
2078  )
2079  {
2080  return !PERIOD_FUNCTION(isEndRunAfterSequenceCompletesInProgress(status));
2081  }
2082  return true;
2083 }
2084 
2085 int ISISDAE::getExternalResetCommands(std::list< std::pair<std::string,std::string> >& commands, DAEstatus& status)
2086 {
2087  static std::string detectorcmd = Poco::Util::Application::instance().config().getString("isisicp.daereset.detectorcmd");
2088  static std::string environmentcmd = Poco::Util::Application::instance().config().getString("isisicp.daereset.environmentcmd");
2089  static std::string envperiodcmd = Poco::Util::Application::instance().config().getString("isisicp.daereset.envperiodcmd");
2090  commands.clear();
2091  // seems to cause problems in CreateProcess() if we put "" around the daeDevice name string, looks like
2092  // it then get interpreted as a path. As daeDevice should not contain spaces, we are OK
2093  BOOST_FOREACH(const env_list_t::value_type& c, m_envCards)
2094  {
2095  commands.push_back(std::pair<std::string,std::string>(environmentcmd, Poco::format("%s %d", c->daeDevice(), c->position())));
2096  }
2097  BOOST_FOREACH(const env_period_list_t::value_type& c, m_envPeriodCards)
2098  {
2099  commands.push_back(std::pair<std::string,std::string>(envperiodcmd, Poco::format("%s %d", c->daeDevice(), c->position())));
2100  }
2101  BOOST_FOREACH(const det_list_t::value_type& c, m_detCards)
2102  {
2103  commands.push_back(std::pair<std::string,std::string>(detectorcmd, Poco::format("%s %d", c->daeDevice(), c->position())));
2104  }
2105  return DAEstatus::Success;
2106 }
2107 
2108 template int ISISDAE::VMEWriteValue<DAE3CardPolicy>(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus& status);
2109 template int ISISDAE::VMEReadValue<DAE3CardPolicy>(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus& status);
2110 template int ISISDAE::VMEWriteArray<DAE3CardPolicy>(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
2111 template int ISISDAE::VMEReadArray<DAE3CardPolicy>(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
2112 
2113 template int ISISDAE::VMEWriteValue<DAE2CardPolicy>(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus& status);
2114 template int ISISDAE::VMEReadValue<DAE2CardPolicy>(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus& status);
2115 template int ISISDAE::VMEWriteArray<DAE2CardPolicy>(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
2116 template int ISISDAE::VMEReadArray<DAE2CardPolicy>(unsigned long card_id, unsigned long card_address, isisU32_t* values, unsigned long num_values, DAEstatus& status);
env_veto_set_func_t ec_disable
Definition: isisdae.h:111
env_list_t m_envCards
Definition: isisdae.h:121
int getVetoStatus(std::string &veto_text, DAEstatus &status)
Definition: isisdae.cpp:1950
int setPeriodType(ISISDAE::PeriodType type, bool single_daq_period, DAEstatus &status)
Definition: isisdae.cpp:1576
virtual int resetPeriodCard(DAEstatus &status)=0
CRITICAL_SECTION m_dae_cs
Definition: isisdae.h:139
#define FAC_DAE
bool isMultiplePeriodSequenceComplete(DAEstatus &status)
Definition: isisdae.cpp:1777
virtual int zeroPeriodFrameCounters(DAEstatus &status)=0
#define ERRTYPE_OUTOFMEM
int setVeto(const std::string &name, bool enable, DAEstatus &status)
Definition: isisdae.cpp:1447
void pollUntilTasksComplete(const Poco::TaskManager &tm, int poll_time_in_ms)
Definition: icputils.cpp:1100
virtual int openBackplane(const char *device_bp, DAEstatus &status)=0
int m_clock_frequency
Definition: isisdae.h:131
float getGoodUAmpHoursPeriod(int period, DAEstatus &status)
Definition: isisdae.cpp:1065
int whichVeto(std::string &veto_text, DAEstatus &status)
Definition: isisdae.cpp:1958
virtual int clearPeriodCounters(DAEstatus &status)=0
virtual int readU32(unsigned long address, isisU32_t *data32, TransferProps props, DAEstatus &status)=0
int addVa(int facility, int severity, int errtype, const char *format,...)
Definition: DAEstatus.cpp:54
int getRawPPPLowerPeriod(int period, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1077
int setDAE1Vetos(int vetos[], int n, DAEstatus &status)
Definition: isisdae.cpp:1362
int getGoodPPPLower(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1043
int writePOSLUTMemory(int card_id, isisU32_t *buffer, int len, DAEstatus &status)
Definition: isisdae.cpp:1970
PeriodType
Definition: isisdae.h:67
float getRawUAmpHoursPeriod(int period, DAEstatus &status)
Definition: isisdae.cpp:1053
void printAddmap(std::ostream &os, DAEstatus &status)
Definition: isisdae.cpp:268
int compareBuffers(const std::string &title, const isisU32_t *buffer1, const isisU32_t *buffer2, int nbuffer, DAEstatus &status)
Definition: icputils.cpp:748
DAEstatus & m_status
Definition: isisdae.cpp:33
virtual int enablePeriodMode(bool external_mode, DAEstatus &status)=0
int getGoodPPPUpperPeriod(int period, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1116
env_period_list_t m_envPeriodCards
Definition: isisdae.h:122
virtual int highspec() const =0
int stopRun(StopRunMode mode, DAEstatus &status)
Definition: isisdae.cpp:877
const int * m_spec_to_crpt_offset
Definition: isisdae.cpp:87
int getGoodPPPUpper(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1048
bool isFinalSequenceComplete(DAEstatus &status)
Definition: isisdae.cpp:2074
StopRunMode
Definition: isisdae.h:154
int readDAE1Spectra(isisU32_t *buffer, int nbuffer, int spec_to_crpt_offset[], int spec_start, int nspec, int period, int persize, DAEstatus &status)
Definition: isisdae.cpp:535
int getNTimeChannels(int spectrum, isisU32_t *ntc, DAEstatus &status)
Definition: isisdae.cpp:305
virtual int setTimeChannels(isisU32_t *tcb, int ntc, DAEstatus &status)=0
DAEType m_dae_type
Definition: isisdae.h:137
void clearDCEventMode(DAEstatus &status)
Definition: isisdae.cpp:2056
unsigned long dae1add
Definition: detector_card.h:13
bool isRunning(DAEstatus &status)
Definition: isisdae.cpp:1129
float m_uamp_scale
Definition: isisdae.h:132
void onFinished(Poco::TaskFinishedNotification *pNf)
Definition: isisdae.h:45
void setDCEventMode(unsigned long card_id, bool value, DAEstatus &status)
Definition: isisdae.cpp:2029
virtual int writeBlockU32(unsigned long address, isisU32_t *data32, long nitems, TransferProps props, DAEstatus &status)=0
virtual bool initOK()=0
virtual void setCardMode(DetectorCardMode mode)=0
void setDCCardMode(unsigned long card_id, bool neutron_data, DAEstatus &status)
Definition: isisdae.cpp:2043
unsigned long isisU32_t
Definition: isisvme_types.h:8
int getRawFramesPeriod(isisU32_t *value, int period, DAEstatus &status)
Definition: isisdae.cpp:1002
unsigned long start
Definition: isisdae.h:89
virtual int setMultiplePeriodSequenceMode(int nseq, DAEstatus &status)=0
isis32_t open(const char *dae_name, DAEstatus &status)
Definition: isisdae.cpp:613
static const int Failure
Definition: DAEstatus.h:141
det_list_t m_detCards
Definition: isisdae.h:120
int add(DAEstatus &dstatus, bool clear)
Definition: DAEstatus.cpp:131
int programPOSLUT(int cards[], int dims[], int pos_start[], int npos[], int spec[], int spec_step[], int nblocks, DAEstatus &status)
Definition: isisdae.cpp:413
bool m_simulate
Definition: isisdae.h:140
int m_lenAddmap
Definition: isisdae.h:127
virtual int getTimeChannels(isisU32_t *tcb, int ntc, DAEstatus &status)=0
virtual int readAllDAE1Spectra(isisU32_t *buffer, int nbuffer, const int spec_to_crpt_offset[], int persize, DAEstatus &status)=0
HANDLE m_async_complete_event
Definition: isisdae.h:144
int clearHistogramMemory(DAEstatus &status)
Definition: isisdae.cpp:815
int clearCounters(DAEstatus &status)
Definition: isisdae.cpp:836
static DWORD __stdcall readDCHistogramThread(void *arg)
Definition: isisdae.cpp:196
virtual int writePOSLUTMemory(unsigned long start, isisU32_t *buffer, int len, DAEstatus &status)=0
int getTotalCounts(int64_t *value, DAEstatus &status)
Definition: isisdae.cpp:1685
int getExternalResetCommands(std::list< std::pair< std::string, std::string > > &commands, DAEstatus &status)
Definition: isisdae.cpp:2085
env_pc_veto_set_func_t pc_enable
Definition: isisdae.h:110
static const int Success
Definition: DAEstatus.h:140
#define ERRTYPE_NODAE
#define ENV_FUNCTION(__func)
Definition: isisdae.cpp:23
virtual int setSinglePeriodSequenceMode(DAEstatus &status)=0
int spec
Definition: detector_card.h:14
int getRawPPPLower(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1033
std::vector< DetectorCardIntf * > & m_detCards
Definition: isisdae.cpp:34
int getSMPVetoedFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1647
virtual int readU16(unsigned long address, isisU16_t *data16, TransferProps props, DAEstatus &status)=0
#define SEV_FATAL
void setOutputFileName(int run_number, bool new_run, DAEstatus &status)
int locateCards(ISISVME *vme, int dae_number, DAEstatus &status)
Definition: isisdae.cpp:723
virtual int writeU16(unsigned long address, isisU16_t data16, TransferProps props, DAEstatus &status)=0
#define PERIOD_FUNCTION(__func)
Definition: isisdae.cpp:27
void setCardStatus(int id, bool enable)
void addCard(DAEEventSource *det_card, bool enable=false)
int writeHistogramMemory(int card_id, isisU32_t *buffer, int start, int len, DAEstatus &status)
Definition: isisdae.cpp:1985
int changeNumberOfPeriods(int nperiod, DAEstatus &status)
Definition: isisdae.cpp:231
#define LOGSTR_WARNING(__arg)
Definition: IsisBase.h:92
DetectorCardIntf * dc
Definition: isisdae.h:99
static veto_desc veto_setters[]
Definition: isisdae.h:114
int VMEWriteArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
Definition: isisdae.cpp:1865
static const char * DAEType_desc[]
Definition: isisdae.h:66
Poco::TaskManager m_taskmgr
Definition: isisdae.h:133
DetectorCardIntf * m_dc
Definition: isisdae.cpp:84
int getExternalVetoedFrames(int veto_number, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1662
int getGoodFramesPeriod(isisU32_t *value, int period, DAEstatus &status)
Definition: isisdae.cpp:1015
void closeOutputFile(DAEstatus &status)
void stop(bool immediate)
virtual int position() const =0
static void setEndianWorkaround(bool endian_workaround)
Definition: nivisa.h:99
EventStore m_es
Definition: isisdae.h:126
virtual int disableMSMode(DAEstatus &status)=0
int resetRunController(DAEstatus &status)
Definition: isisdae.cpp:987
int clearTotalCountsRegisters(DAEstatus &status)
Definition: isisdae.cpp:1698
virtual int disableFIFOVeto(DAEstatus &status)=0
virtual int writeU32(unsigned long address, isisU32_t data32, TransferProps props, DAEstatus &status)=0
static const unsigned DAESPECMAX
should be same as ISISCRPT_MAX_DETECTOR
Definition: dae2_policy.h:142
ClearHistogramMemoryTask(const std::string &name, std::vector< DetectorCardIntf * > &det_cards, DAEstatus &status)
Definition: isisdae.cpp:36
isisU32_t * m_buffer
Definition: isisdae.cpp:85
#define END_IMMEDIATELY_FILE
Definition: isisdae.cpp:21
#define SEV_ERROR
int getTS2PulseVetoedFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1652
volatile LONG m_num_async_requests
Definition: isisdae.h:145
virtual int readBlockU32(unsigned long address, isisU32_t *data32, long nitems, TransferProps props, DAEstatus &status)=0
int setDCFrameSyncDelay(int crat, isisU32_t delay, DAEstatus &status)
Definition: isisdae.cpp:1524
static void deletePtr(T *pCard)
Definition: isisdae.cpp:145
uint64_t nNewEventWords(DAEstatus &status)
Definition: event_store.cpp:24
int getTimeChannels(int spec, isisU32_t *tcb, int ntc, DAEstatus &status)
Definition: isisdae.cpp:311
int setTimeChannels(int crat, isisU32_t *tcb, int ntc, DAEstatus &status)
Definition: isisdae.cpp:341
virtual int disableFIFOVeto(DAEstatus &status)=0
int getFIFOVetoedFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1667
int writeTCGTimeBinLimitRegister(int det_card, isisU32_t value, DAEstatus &status)
Definition: isisdae.cpp:1349
virtual int getSpectrumSize(isisU32_t *value, DAEstatus &status)=0
int getISIS50HzVetoedFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1657
#define LOGSTR_INFORMATION(__arg)
Definition: IsisBase.h:78
bool endHeaderSeen()
int getSpectrumSize(int spectrum, isisU32_t *nchan, DAEstatus &status)
Definition: isisdae.cpp:299
void printStatus(std::ostream &os, DAEstatus &status)
Definition: isisdae.cpp:241
unsigned long pattern
Definition: isisdae.h:100
virtual int lockDevice(int timeout, DAEstatus &dstatus)=0
int startRun(bool clear_counters, int run_number, time_t &start_time, DAEstatus &status)
Definition: isisdae.cpp:843
int readAllDAE1Spectra(isisU32_t *buffer, int nbuffer, int spec_to_crpt_offset[], int persize, DAEstatus &status)
@ todo specttrum 0 may have differet size for time regimes
Definition: isisdae.cpp:561
env_pc_veto_set_func_t pc_disable
Definition: isisdae.h:112
#define ERRTYPE_SPECREAD
vme_list_t m_vme
Definition: isisdae.h:119
virtual int programPERLUT(isisU16_t *dwell_flags, isisU16_t *frames, int nperiod, DAEstatus &status)=0
isis32_t openBackplane(const char *dae_name_bp, DAEstatus &status)
Definition: isisdae.cpp:604
int VMEReadValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long *value, DAEstatus &status)
Definition: isisdae.cpp:1843
int getRawFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:997
unsigned short isisU16_t
Definition: isisvme_types.h:7
DetectorCardIntf * dc
Definition: detector_card.h:11
int enableDelayedStart(DAEstatus &status)
Definition: isisdae.cpp:2001
FrameSync
Definition: isiscrpt_types.h:5
virtual int setNumberOfPeriods(isisU16_t n, DAEstatus &status)=0
int getGoodPPPLowerPeriod(int period, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1103
env_veto_set_func_t ec_enable
Definition: isisdae.h:109
double info(const char *title, std::ostream &os, bool add_nl=true)
Definition: icptimer.h:83
PeriodType m_period_mode
Definition: isisdae.h:138
int clearFramesVetosAndPPP(DAEstatus &status)
Definition: isisdae.cpp:1562
int checkTestPattern(unsigned long pattern, DAEstatus &status)
Definition: isisdae.cpp:1938
DAEProgressHandler m_task_ph
Definition: isisdae.h:134
virtual int scanBus(DAEstatus &status)=0
int disablePeriodCard(DAEstatus &status)
Definition: isisdae.cpp:1755
bool m_event_mode
Definition: isisdae.h:141
int clearPOSLUTMemory(DAEstatus &status)
Definition: isisdae.cpp:355
void closeAndDeleteOutputFile(int run_number, DAEstatus &status)
virtual int programOUTLUT(isisU32_t *outputs, int nperiod, DAEstatus &status)=0
Definition: nivisa.h:7
int disableDelayedStart(DAEstatus &status)
Definition: isisdae.cpp:2016
int waitForAsync()
Definition: isisdae.cpp:168
int updateAddmap(DAEstatus &status)
Definition: isisdae.cpp:426
DetectorCardIntf * dc
Definition: isisdae.h:88
int VMEWriteValue(unsigned long card_id, unsigned long card_address, bool sixteen_bit, unsigned long value, unsigned long mode, DAEstatus &status)
Definition: isisdae.cpp:1790
isis32_t close(DAEstatus &status)
Definition: isisdae.cpp:710
virtual int readHistogramMemory(unsigned long start, isisU32_t *buffer, int len, DAEstatus &status)=0
static const int NOSPECTRUM
static const char * PeriodType_desc[]
Definition: isisdae.h:68
isis32_t check(DAEstatus &status)
Definition: isisdae.cpp:691
float getRawUAmpHours(DAEstatus &status)
Definition: isisdae.cpp:1557
virtual int enableMSMode(DAEstatus &status)=0
static unsigned long makeAddress(int position, unsigned long address)
Definition: dae2_card.h:83
float getGoodUAmpHours(DAEstatus &status)
Definition: isisdae.cpp:1552
static DWORD __stdcall checkTestPatternThread(void *arg)
Definition: isisdae.cpp:1895
dae2spec_map_t m_dae2_spec_map
Definition: isisdae.h:125
unsigned long dae2add
Definition: detector_card.h:12
int changePeriod(int period, int daq_period, DAEstatus &status)
Definition: isisdae.cpp:221
virtual int setFrameSyncDelay(isisU32_t value, DAEstatus &status)=0
DetectorCardIntf * findDetectorCard(int position, DAEstatus &status)
Definition: isisdae.cpp:1135
virtual FrameSync getFrameSync(DAEstatus &status)=0
int fillWithTestPattern(unsigned long pattern, DAEstatus &status)
Definition: isisdae.cpp:1927
virtual int enableFIFOVeto(DAEstatus &status)=0
int getRawPPPUpperPeriod(int period, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1090
#define ERRTYPE_INVCARD
MyAddmap * m_addmap
Definition: isisdae.h:123
virtual int setPeriodOutputDelay(isisU32_t delay, DAEstatus &status)=0
isisU32_t sumAllHistogramMemory(DAEstatus &status)
Definition: isisdae.cpp:1323
static int daeTriggerFunc(void *arg, time_t the_secs, unsigned short the_ms, int trig_id)
Definition: isisdae.cpp:675
int getFrameSyncDelay(isisU32_t *delay, DAEstatus &status)
Definition: isisdae.cpp:1519
void setLoggerName(const std::string &logger_name)
Definition: IsisBase.h:17
virtual const int * getDAE2SpecMap()=0
int getRawPPPUpper(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1038
int setFrameSync(FrameSync fs, int muon_pulse, DAEstatus &status)
Definition: isisdae.cpp:1491
virtual int setEventCollectionMode(bool enable, DAEstatus &status)=0
virtual ~ISISDAE()
Definition: isisdae.cpp:150
int requestEndRunAfterNextSequenceCompletes(DAEstatus &status)
Definition: isisdae.cpp:2062
void closeEventFiles(DAEstatus &status)
Definition: isisdae.cpp:872
DAEstatus & status
Definition: isisdae.h:101
int programDAE1POSLUT(int crat[], int maxcrate, int modn[], int mpos[], int spec[], int ndet, int nper_daq, DAEstatus &status)
Definition: isisdae.cpp:365
void onProgress(Poco::TaskProgressNotification *pNf)
Definition: isisdae.h:40
int readDAE1Spectrum(int dae1_spectrum, isisU32_t *buffer, int nbuffer, DAEstatus &status)
Definition: isisdae.cpp:498
int programPeriodCard(PeriodType period_type, int nper, int nperseq_request, isisU32_t *outputs, isisU16_t *dwell_flags, isisU16_t *frames, int period_output_delay, DAEstatus &status)
Definition: isisdae.cpp:1710
int readHistogramMemory(unsigned long start, isisU32_t *buffer, int len, DAEstatus &status)
Definition: isisdae.cpp:1220
int addInfo(int facility, const std::string &text)
Definition: DAEstatus.cpp:86
DAEstatus & m_status
Definition: isisdae.cpp:83
int setFrameSyncDelay(isisU32_t delay, DAEstatus &status)
Definition: isisdae.cpp:1501
int writeDescriptorTimeBinLimitRegister(int det_card, isisU32_t value, DAEstatus &status)
Definition: isisdae.cpp:1339
virtual int writeHistogramMemory(unsigned long start, isisU32_t *buffer, int len, DAEstatus &status)=0
int getDCFrameSyncDelay(int crat, isisU32_t *delay, DAEstatus &status)
Definition: isisdae.cpp:1538
void start()
virtual int zeroPeriodProtonCounters(DAEstatus &status)=0
virtual const char * device()=0
virtual int getNTimeChannels(isisU32_t *ntc, DAEstatus &status)=0
long isis32_t
Definition: isisvme_types.h:14
virtual int open(const char *device, DAEstatus &status)=0
ISISDAE()
Definition: isisdae.h:60
int doneAsync()
called by async worker thread when it has completed its work
Definition: isisdae.cpp:188
int card
dae2 spectrum;
Definition: detector_card.h:15
int result()
Definition: DAEstatus.h:144
dae1spec_map_t m_dae1_spec_map
Definition: isisdae.h:124
int addInfoVa(int facility, const char *format,...)
Definition: DAEstatus.cpp:91
int checkTestPatternAsync(unsigned long pattern, DAEstatus &status)
Definition: isisdae.cpp:1904
int getCurrentPeriodSequence(isisU32_t *period_sequence, DAEstatus &status)
Definition: isisdae.cpp:1764
double frameTimerDrift(DAEstatus &status)
frame timer drift (icp - dae)
Definition: isisdae.cpp:1507
int readDescriptorTimeBinLimitRegister(int det_card, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1334
int VMEReadArray(unsigned long card_id, unsigned long card_address, isisU32_t *values, unsigned long num_values, DAEstatus &status)
Definition: isisdae.cpp:1873
void printSpectrum(int spec, std::ostream &os, DAEstatus &status)
Definition: isisdae.cpp:280
int getCurrentHardwarePeriod(isisU32_t *period, DAEstatus &status)
Definition: isisdae.cpp:1597
int getCurrentDAQHardwarePeriod(isisU32_t *period, DAEstatus &status)
Definition: isisdae.cpp:1619
virtual void setTriggerFunc(trigger_func_t *func, void *arg)=0
int readDCHistogramAsync(DetectorCardIntf *dc, unsigned long start, isisU32_t *buffer, int len, DAEstatus &dstatus)
Definition: isisdae.cpp:205
ReadAllDAE1SpectraTask(const std::string &name, DetectorCardIntf *dc, isisU32_t *buffer, int nbuffer, const int *spec_to_crpt_offset, int persize, DAEstatus &status)
Definition: isisdae.cpp:91
virtual int getFrameSyncDelay(isisU32_t *value, DAEstatus &status)=0
virtual int enableFIFOVeto(DAEstatus &status)=0
int getMSModeVetoedFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1672
int getGoodFrames(isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1028
virtual int setPeriodControlBits(isisU32_t mask, bool preserve, DAEstatus &status)=0
DetectorCardIntf * getDCForSpectrum(int spec) const
Definition: isisdae.h:320
int readTCGTimeBinLimitRegister(int det_card, isisU32_t *value, DAEstatus &status)
Definition: isisdae.cpp:1344
DAEType
Definition: isisdae.h:63
virtual int checkTestPattern(unsigned long pattern, DAEstatus &status)=0