Scope
Scope.cpp
1 #include "stdafx.h"
2 #include "parameters/Scope.h"
3 #include "helpers/ScopeException.h"
4 
5 namespace scope {
6 
7 namespace parameters {
8 
9 // Save some typing here...
10 using namespace boost::property_tree;
11 
12 Stimulation::Stimulation()
13  : channel(L"PXI-6259_0/port0/line0", L"Channel")
14  , timingsource(L"OnboardClock", L"Timingsource")
15  , onset(0, 0, 1000, L"Onset_s")
16  , duration(0, 1, 1000, L"Duration_s")
17  , ontime(0.5, 0.001, 1000, L"OnTime_s")
18  , offtime(0.5, 0.001, 1000, L"OffTime_s")
19  , enable(false, false, true, L"Enable") {
20 }
21 
22 void Stimulation::Load(const wptree& pt) {
30 }
31 
32 void Stimulation::Save(wptree& pt) const {
40 }
41 
43  const bool enabler = (_runstate.t==RunStateHelper::Mode::Stopped)?true:false;
44  duration.SetRWState(enabler);
45  enable.SetRWState(enabler);
46  offtime.SetRWState(enabler);
47  onset.SetRWState(enabler);
48  ontime.SetRWState(enabler);
49 }
50 
51 Area::Area(const uint32_t& _area, const bool& _isslave, Area * const _masterarea)
52  : area(_area, 0, 16, L"Area")
53  , histrange(100, 0, 65535, L"HistRange")
54  , isslave(_isslave, false, true, L"IsSlaveArea")
55  , daq(_isslave)
56  , masterarea(_masterarea)
57  , linerate(1, 0, 100000, L"Linerate_Hz")
58  , framerate(1, 0, 1000, L"Framerate_Hz")
59  , frametime(1, 0, 100000, L"Frametime_s")
60  , scanmode(ScannerVectorTypeHelper::Sawtooth, L"ScanMode")
61  , basemicronperpixelx(0.1, 1E-6, 100, L"BaseMicronPerPixelX")
62  , basemicronperpixely(0.1, 1E-6, 100, L"BaseMicronPerPixelY")
63  , micronperpixelx(0.1, 1E-6, 100, L"MicronPerPixelX")
64  , micronperpixely(0.1, 1E-6, 100, L"MicronPerPixelY") {
65 
66  // Make sure the parameter (isslave) equals the compiled logic (ThisIsSlaveArea, which uses the macro definitions of SCOPE_NAREAS etc)
67  assert( isslave() == ThisIsSlaveArea(area) );
68 
69  // Make sure we set the pointer to the masterarea for slave areas
70  assert( (isslave()==true && (masterarea!=nullptr)) || (isslave()==false) );
71 
72  // Insert all possible scannervectors
73  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::Sawtooth, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::Sawtooth));
74  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::Bidirectional, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::Bidirectional));
75  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::Planehopper, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::Planehopper));
76  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::ResonanceBiDi, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::ResonanceBiDi));
77  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::ResonanceHopper, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::ResonanceHopper));
78  scannervectorframesmap.emplace(ScannerVectorTypeHelper::Mode::LineStraight, ScannerVectorFrameBasic::Factory(ScannerVectorTypeHelper::Mode::LineStraight));
79 
81 }
82 
83 Area::Area(const Area& _a)
84  : area(_a.area)
85  , isslave(_a.isslave)
86  , masterarea(_a.masterarea)
87  , daq(_a.daq)
88  , fpuxystage(_a.fpuxystage)
89  , fpuzstage(_a.fpuzstage)
90  , scannervectorframesmap()
91  , scanmode(_a.scanmode(), L"ScanMode")
92  , basemicronperpixelx(_a.basemicronperpixelx)
93  , basemicronperpixely(_a.basemicronperpixely)
94  , micronperpixelx(_a.micronperpixelx)
95  , micronperpixely(_a.micronperpixely)
96  , linerate(_a.linerate)
97  , framerate(_a.framerate)
98  , frametime(_a.frametime) {
99 
100  for ( auto& sv : _a.scannervectorframesmap )
101  scannervectorframesmap.emplace(std::make_pair(sv.first, ScannerVectorFrameBasic::Factory(sv.first, sv.second.get())));
102 
104 }
105 
106 Area& Area::operator=(const Area& _a) {
107  if ( this != &_a ) {
108  area = _a.area;
109  isslave = _a.isslave;
110  masterarea = _a.masterarea;
111  daq = _a.daq;
112  fpuxystage = _a.fpuxystage;
113  fpuzstage = _a.fpuzstage;
114  scanmode = _a.scanmode();
117  micronperpixelx = _a.micronperpixelx;
118  micronperpixely = _a.micronperpixely;
119  linerate = _a.linerate;
120  framerate = _a.framerate;
121  frametime = _a.frametime;
122 
123  for ( auto& sv : _a.scannervectorframesmap )
124  scannervectorframesmap.emplace(std::make_pair(sv.first, ScannerVectorFrameBasic::Factory(sv.first, sv.second.get())));
125 
126  }
127 
128  // Not needed here?!
129  //InitializeConnections();
130 
131  return *this;
132 }
133 
134 void Area::SetMasterArea(Area* const _masterarea) {
135  assert( (isslave()==true && (_masterarea!=nullptr)) || (isslave()==false) );
136  masterarea = _masterarea;
137  if ( isslave() )
139  ChangeScanMode();
140  UpdateRates();
141 }
142 
144  // Iterate over scannervectors
145  for (auto& sv : scannervectorframesmap ) {
146  *sv.second = *masterarea->scannervectorframesmap.at(sv.first);
147  }
148 }
149 
151  return *scannervectorframesmap.at(scanmode.Value()).get();
152 }
153 
155  try {
156  return dynamic_cast<ScannerVectorFrameSaw&>(*scannervectorframesmap.at(ScannerVectorTypeHelper::Mode::Sawtooth).get());
157  } catch (std::bad_cast) { ScopeExceptionHandler("parameters::Area::FrameSaw", true, true, true, true); }
158 }
159 
161  try {
162  return dynamic_cast<ScannerVectorFrameResonance&>(*scannervectorframesmap.at(ScannerVectorTypeHelper::Mode::ResonanceBiDi));
163  } catch (std::bad_cast) { ScopeExceptionHandler("parameters::Area::FrameResonance", true, true, true, true); }
164 }
165 
167  try {
168  return dynamic_cast<ScannerVectorFrameBiDi&>(*scannervectorframesmap.at(ScannerVectorTypeHelper::Mode::Bidirectional));
169  } catch (std::bad_cast) { ScopeExceptionHandler("parameters::Area::FrameBiDi", true, true, true, true); }
170 }
171 
173  try {
174  return dynamic_cast<ScannerVectorFramePlaneHopper&>(*scannervectorframesmap.at(ScannerVectorTypeHelper::Mode::Planehopper));
175  } catch (std::bad_cast) { ScopeExceptionHandler("parameters::Area::FrameHopper", true, true, true, true); }
176 }
177 
178 void Area::Load(const wptree& pt) {
185  scanmode.SetFromPropertyTree(pt);
188  micronperpixelx.SetFromPropertyTree(pt);
189  micronperpixely.SetFromPropertyTree(pt);
190  daq.Load(pt.get_child(L"daq"));
191 
192  for ( auto& sv : scannervectorframesmap ) {
193  sv.second->Load(pt.get_child(ScannerVectorTypeHelper::NameOf(sv.first)));
194  }
195 
196  fpuzstage.Load(pt.get_child(L"fpuzstage"));
197  fpuxystage.Load(pt.get_child(L"fpuxystage"));
198  ChangeScanMode();
199  UpdateRates();
201 }
202 
203 void Area::Save(wptree& pt) const {
210  scanmode.AddToPropertyTree(pt);
213  micronperpixelx.AddToPropertyTree(pt);
214  micronperpixely.AddToPropertyTree(pt);
215  wptree ptdaq;
216  wptree ptpresets;
217  wptree ptfpuzstage;
218  wptree ptfpuxystage;
219 
220  daq.Save(ptdaq);
221  pt.add_child(L"daq", ptdaq);
222 
223  for ( const auto& sv : scannervectorframesmap ) {
224  wptree ptsv;
225  sv.second->Save(ptsv);
226  pt.add_child(ScannerVectorTypeHelper::NameOf(sv.first), ptsv);
227  }
228 
229  fpuzstage.Save(ptfpuzstage);
230  pt.add_child(L"fpuzstage", ptfpuzstage);
231  fpuxystage.Save(ptfpuxystage);
232  pt.add_child(L"fpuxystage", ptfpuxystage);
233 }
234 
235 void Area::SetReadOnlyWhileScanning(const RunState& _runstate) {
236  const bool enabler = (_runstate.t==RunStateHelper::Mode::Stopped)?true:false;
237  scanmode.SetRWState(enabler);
238  fpuxystage.SetReadOnlyWhileScanning(_runstate);
239  fpuzstage.SetReadOnlyWhileScanning(_runstate);
240  daq.SetReadOnlyWhileScanning(_runstate);
241  for ( auto& sv : scannervectorframesmap )
242  sv.second->SetReadOnlyWhileScanning(_runstate);
243 }
244 
245 void Area::SaveToPreset(const std::wstring& _name) {
246  scannervectorframesmap.at(scanmode.Value())->SaveToPreset(_name, daq);
247 }
248 
249 void Area::LoadFromPreset(const std::wstring& _name) {
250  scannervectorframesmap.at(scanmode.Value())->LoadFromPreset(_name, daq);
251 }
252 
253 void Area::DeletePreset(const std::wstring& _name) {
254  scannervectorframesmap.at(scanmode.Value())->DeletePreset(_name);
255 }
256 
257 double Area::FrameTime() const {
258  return scannervectorframesmap.at(scanmode.Value())->TotalPixels() * daq.pixeltime() * 1E-6;
259 }
260 
261 double Area::LineTime() const {
262  return scannervectorframesmap.at(scanmode.Value())->XTotalPixels() * daq.pixeltime() * 1E-6;
263 }
264 
266  return scannervectorframesmap.at(scanmode.Value())->TotalPixels()*daq.inputs->channels();
267 }
268 
269 double Area::XOffsetInMicron() const {
270  // xoffset goes from -1..+1 (maxima of the zoom 1 field of view), thus:
271  return scannervectorframesmap.at(scanmode.Value())->xoffset() * basemicronperpixelx() * 256.0 * 0.5;
272 }
273 
274 double Area::YOffsetInMicron() const {
275  // yoffset goes from -1..+1 (maxima of the zoom 1 field of view), thus:
276  return scannervectorframesmap.at(scanmode.Value())->yoffset() * basemicronperpixely() * 256.0 * 0.5;
277 }
278 
280  scanmode.ConnectOther(std::bind(&Area::ChangeScanMode, this));
281  if ( isslave() ) {
282  // A slave area gets these from the master area. These connection go in the collector so they get disconnected when this
283  // area is destructed
284  // Iterate over all scannervectorsframe
285  for ( auto& masv : masterarea->scannervectorframesmap ) {
286  auto conns = masv.second->ConnectCopyTrigger(std::bind(&Area::CopyFromMasterArea, this));
287  connection_collector.insert(connection_collector.end(), conns.begin(), conns.end());
288  }
290  }
291  else {
292  // Iterate over all scannervectorsframe and connect changes of their parameters to calculating functions in Area
293  for ( auto& sv : scannervectorframesmap ) {
294  sv.second->ConnectRateUpdate(std::bind(&Area::UpdateRates, this));
295  sv.second->ConnectResolutionUpdate(std::bind(&Area::CalculateResolution, this));
296  sv.second->ConnectMicronPerPixelUpdate(std::bind(&Area::CalculateMicronPerPixel, this));
297  }
298  }
299  daq.pixeltime.ConnectOther(std::bind(&Area::UpdateRates, this));
300 
301  ChangeScanMode();
302  UpdateRates();
304 }
305 
307  UpdateRates();
309  if ( isslave() )
311 }
312 
314  framerate = 1/FrameTime();
315  frametime = FrameTime();
316  linerate = 1/LineTime();
317 }
318 
320  DBOUT(L"Area::UpdateFastZCalibration");
321  if (!fpuzstage.calibration.empty()) {
322  for ( auto& sv : scannervectorframesmap )
323  sv.second->fastz.SetLimits(fpuzstage.calibration.begin()->first, (--fpuzstage.calibration.end())->first);
324  }
325 }
326 
328  // basemicronperpixel must be calibrated to zoom 1 256x256 pixel
329  micronperpixelx = basemicronperpixelx() / Currentframe().zoom() * (256.0 / static_cast<double>(Currentframe().xres()));
330  micronperpixely = basemicronperpixely() / Currentframe().zoom() * (256.0 / static_cast<double>(Currentframe().yres()));
331 }
332 
334  scannervectorframesmap.at(scanmode.Value())->xres = static_cast<double>(Currentframe().yres) / Currentframe().yaspectratio * Currentframe().xaspectratio;
335  double xaspectratioboundary = Currentframe().yaspectratio / static_cast<double>(Currentframe().yres) * static_cast<double>(Currentframe().xres);
336  if(Currentframe().xaspectratio < xaspectratioboundary || Currentframe().xaspectratio > xaspectratioboundary) {
337  scannervectorframesmap.at(scanmode.Value())->xaspectratio = xaspectratioboundary;
338  }
339 
340  scannervectorframesmap.at(scanmode.Value())->yres = static_cast<double>(Currentframe().xres) / Currentframe().xaspectratio * Currentframe().yaspectratio;
341  double yaspectratioboundary = Currentframe().xaspectratio / static_cast<double>(Currentframe().xres) * static_cast<double>(Currentframe().yres);
342  if(Currentframe().yaspectratio < yaspectratioboundary || Currentframe().yaspectratio > yaspectratioboundary) {
343  scannervectorframesmap.at(scanmode.Value())->yaspectratio = yaspectratioboundary;
344  }
345 }
346 
347 Scope::Scope()
348  : date(L"", L"Date")
349  , time(L"", L"Time")
350  , scopecommit(std::wstring(CA2W(STR(LASTGITCOMMIT))), L"ScopeCommit")
351  , comment(L"", L"Comment")
352  , scannertype(SCOPE_SCANNERTYPE, L"Scannertype")
353  , startinputsfirst(false, false, true, L"StartInputsFirst")
354  , commontrigger(L"/PXI-6259_0/ao/StartTrigger", L"CommonMasterTrigger")
355  , masterfovsizex(3000.0, 1.0, 20000.0, L"MasterFOVSizeX_um")
356  , masterfovsizey(3000.0, 1.0, 20000.0, L"MasterFOVSizeY_um")
357  , run_state(RunStateHelper::Stopped, L"RunState")
358  , requested_mode(DaqModeHelper::continuous, L"RequestedMode") {
359  date.Set(GetCurrentDateString());
360  time.Set(GetCurrentTimeString());
361 
362  scannertype.SetRWState(false);
363 
364  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
365  // All area masters or first area is master the rest slaves
366  if ( ThisIsSlaveArea(a) )
367  areas[a].reset(new Area(a, true, areas[0].get()));
368  else
369  areas[a].reset(new Area(a, false, nullptr));
370 
371  areas[a]->framerate.ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
372  areas[a]->daq.averages.ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
373  areas[a]->histrange.ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
374  timeseries.frames[a].ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
375  timeseries.totaltimes[a].ConnectOther(std::bind(&Scope::UpdateFramesFromTotaltime, this));
376  }
377 
378  timeseries.repeats.ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
379  timeseries.betweenrepeats.ConnectOther(std::bind(&Scope::UpdateTotaltimeFromFrames, this));
380  UpdateTotaltimeFromFrames();
381 }
382 
383 Scope::Scope(const Scope& _scope)
384  : date(_scope.date)
385  , time(_scope.time)
386  , scopecommit(_scope.scopecommit)
387  , comment(_scope.comment)
388  , scannertype(_scope.scannertype)
389  , storage(_scope.storage)
390  , stack(_scope.stack)
391  , timeseries(_scope.timeseries)
392  , behavior(_scope.behavior)
393  , stage(_scope.stage)
394  , stimulation(_scope.stimulation)
395  , frames(_scope.frames)
396  , startinputsfirst(_scope.startinputsfirst)
397  , commontrigger(_scope.commontrigger)
398  , masterfovsizex(_scope.masterfovsizex)
399  , masterfovsizey(_scope.masterfovsizey)
400  , run_state(_scope.run_state)
401  , requested_mode(_scope.requested_mode){
402 
403  scannertype.SetRWState(false);
404 
405  // Deep copy of Areas
406  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
407  // First areas are masters the rest slaves (if SCOPE_NBEAM_SLAVES > 0)
408  if ( ThisIsSlaveArea(a) ) {
409  areas[a].reset(new Area(*_scope.areas[a].get()));
410  // Fix the pointer to the master area!!!!!
411  areas[a]->SetMasterArea(areas[0].get());
412  }
413  else {
414  areas[a].reset(new Area(*_scope.areas[a].get()));
415  areas[a]->SetMasterArea(nullptr);
416  }
417  }
418 }
419 
420 Scope& Scope::operator=(const Scope& _scope) {
421  date = _scope.date();
422  time = _scope.time();
423  scopecommit = _scope.scopecommit();
424  comment = _scope.comment();
425 
426  ATLASSERT (scannertype() == _scope.scannertype()); // Otherwise something is seriously wrong
427 
428  // Deep copy of Areas
429  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
430  // First areas are masters the rest slaves (if SCOPE_NBEAM_SLAVES > 0)
431  if ( ThisIsSlaveArea(a) ) {
432  areas[a].reset(new Area(*_scope.areas[a].get()));
433  // Fix the pointer to the master area!!!!!
434  areas[a]->SetMasterArea(areas[0].get());
435  }
436  else {
437  areas[a].reset(new Area(*_scope.areas[a].get()));
438  areas[a]->SetMasterArea(nullptr);
439  }
440  }
441 
442  storage = _scope.storage;
443  stack = _scope.stack;
444  timeseries = _scope.timeseries;
445  behavior = _scope.behavior;
446  stage = _scope.stage;
447  stimulation = _scope.stimulation;
448  frames = _scope.frames;
450  commontrigger = _scope.commontrigger;
453  run_state = _scope.run_state;
455 
456  return *this;
457 }
458 
460  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
461  timeseries.totaltimes[a].Set(1/areas[a]->framerate()*areas[ThisAreaOrMasterArea(a)]->daq.averages()*timeseries.frames[a](), true, false);
462 
463  // Time between repeats (start to start) can be minimally duration of one timeseries (+0.1s for overhead)
464  double maxduration = *std::max_element(std::begin(timeseries.totaltimes), std::end(timeseries.totaltimes));
466 
468 }
469 
471  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
472  timeseries.frames[a].Set(round2ui32(timeseries.totaltimes[a]()*areas[a]->framerate()/areas[ThisAreaOrMasterArea(a)]->daq.averages()));
473 }
474 
475 void Scope::Load(const std::wstring& filename) {
476  wptree pt;
477 
478  try {
479  // use the current locale, convert from utf-8 (in file) to wchar_t (here), and skip BOM header
480  std::locale old_locale;
481  std::locale utf8_locale(old_locale, new std::codecvt_utf8<wchar_t, 0x10ffff, std::codecvt_mode::consume_header>); // no leak, std::locale takes responsibility for deleting...
482  // sigh, UTF is never easy...
483 
484  CW2A tmp(filename.c_str());
485  read_xml(std::string(tmp), pt, 0, utf8_locale);
486  date.SetFromPropertyTree(pt.get_child(L"scope"));
487  time.SetFromPropertyTree(pt.get_child(L"scope"));
488  // Do not load scopecommit
489  comment.SetFromPropertyTree(pt.get_child(L"scope"));
490 
491  // Make sure the loaded parameters are for the same scannertype
492  if( pt.get_child(L"scope").get<std::wstring>(L"Scannertype") != scannertype.ToChar() )
493  throw ScopeException("Type of scanner in parameter file does not match the one in scope.exe");
494 
495  startinputsfirst.SetFromPropertyTree(pt.get_child(L"scope"));
496  commontrigger.SetFromPropertyTree(pt.get_child(L"scope"));
497  masterfovsizex.SetFromPropertyTree(pt.get_child(L"scope"));
498  masterfovsizey.SetFromPropertyTree(pt.get_child(L"scope"));
499  // We do not need to Load requested_mode and runstate
500  storage.Load(pt.get_child(L"scope.storage"));
501  stack.Load(pt.get_child(L"scope.stack"));
502  timeseries.Load(pt.get_child(L"scope.timeseries"));
503  behavior.Load(pt.get_child(L"scope.behavior"));
504  stage.Load(pt.get_child(L"scope.stage"));
505  stimulation.Load(pt.get_child(L"scope.stimulation"));
506  frames.Load(pt.get_child(L"scope.frames"));
507  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
508  areas[a]->Load(pt.get_child(boost::str(boost::wformat(L"scope.area%d") % a)));
509  }
510  catch (...) { ScopeExceptionHandler(__FUNCTION__, true, true); }
511 }
512 
513 void Scope::Save(const std::wstring& filename) const {
514  wptree pt;
515  wptree ptroot;
516  std::array<wptree, SCOPE_NAREAS> ptareas;
517  wptree ptstorage;
518  wptree ptstack;
519  wptree pttimeseries;
520  wptree ptbehavior;
521  wptree ptzcontrol;
522  wptree ptstage;
523  wptree ptstimulation;
524  wptree ptframes;
525 
526  try {
527  date.AddToPropertyTree(ptroot);
528  time.AddToPropertyTree(ptroot);
530  comment.AddToPropertyTree(ptroot);
531  scannertype.AddToPropertyTree(ptroot);
536  pt.add_child(L"scope", ptroot);
537  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
538  areas[a]->Save(ptareas[a]);
539  pt.add_child(boost::str(boost::wformat(L"scope.area%d") % a), ptareas[a]);
540  }
541  storage.Save(ptstorage);
542  pt.add_child(L"scope.storage", ptstorage);
543  stack.Save(ptstack);
544  pt.add_child(L"scope.stack", ptstack);
545  timeseries.Save(pttimeseries);
546  pt.add_child(L"scope.timeseries", pttimeseries);
547  behavior.Save(ptbehavior);
548  pt.add_child(L"scope.behavior", ptbehavior);
549  stage.Save(ptstage);
550  pt.add_child(L"scope.stage", ptstage);
551  stimulation.Save(ptstimulation);
552  pt.add_child(L"scope.stimulation", ptstimulation);
553  frames.Save(ptframes);
554  pt.add_child(L"scope.frames", ptframes);
555  // use the current locale, convert from wchar_t (here) to UTF-8 (in file), and and generate a BOM header
556  std::locale old_locale;
557  // Attention: the 'new' here is correct that way (weird as it is...)
558  std::locale utf8_locale(old_locale
559  , new std::codecvt_utf8<wchar_t, 0x10ffff, (std::codecvt_mode)(std::codecvt_mode::consume_header | std::codecvt_mode::generate_header)>); // no leak, std::locale takes responsibility for deleting...
560  CW2A tmp(filename.c_str());
561  write_xml(std::string(tmp), pt, utf8_locale);
562  }
563  catch (...) { ScopeExceptionHandler(__FUNCTION__, true, true); }
564 }
565 
567  for ( auto& a : areas )
568  a->SetReadOnlyWhileScanning(_runstate);
570  stack.SetReadOnlyWhileScanning(_runstate);
572  stage.SetReadOnlyWhileScanning(_runstate);
574 }
575 
576 
577 }
578 
579 }
Scope & operator=(const Scope &_scope)
Supply assignment operator because of unique_ptr (does deep copy of Areas)
Definition: Scope.cpp:420
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Windows.cpp:63
std::vector< boost::signals2::connection > connection_collector
You can put connections between ScopeValues in different classes in here.
Definition: Base.h:27
Parameters for a whole area (includes a daq and a fpu)
Definition: Scope.h:64
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Scope.cpp:32
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Runstates.cpp:226
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Scope.cpp:203
ScopeNumber< double > ontime
on time of one stimulation pulse
Definition: Scope.h:51
ScopeString commontrigger
The trigger channel which is the internal common master trigger for all devices.
Definition: Scope.h:262
ScopeNumber< double > offtime
off time after stimulation pulse
Definition: Scope.h:54
ScopeNumber< double > masterfovsizey
The same for the y direction.
Definition: Scope.h:273
void CopyFromMasterArea()
Copies parts of the ScannerVectorParameters from the master area's.
Definition: Scope.cpp:143
static std::unique_ptr< ScannerVectorFrameBasic > Factory(const ScannerVectorType &_type, const ScannerVectorFrameBasic *const _o=nullptr)
Factory method to generate parameter sets for different scan types and put them into a ScannerVectorF...
Definition: Framescan.cpp:177
Area * masterarea
const pointer to the master area parameters (provided in the constructor through parametes::Scope) ...
Definition: Scope.h:75
virtual void DeletePreset(const std::wstring &_name)
Delete preset in currentframe.
Definition: Scope.cpp:253
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
Definition: IO.h:779
The master parameters class.
Definition: Scope.h:204
Simple exception class for Scope.
Definition: ScopeException.h:9
ScopeString date
current date
Definition: Scope.h:216
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Runstates.cpp:117
std::map< ScannerVectorTypeHelper::Mode, std::unique_ptr< ScannerVectorFrameBasic > > scannervectorframesmap
This map contains all ScannerVectors that are supported by the kind of scanner.
Definition: Scope.h:90
virtual void UpdateFramesFromTotaltime()
Updates number of frames from choosen duration and framerate.
Definition: Scope.cpp:470
virtual void LoadFromPreset(const std::wstring &_name)
Load from preset in currentframe.
Definition: Scope.cpp:249
Parameters for a ScannerVectorFrameBiDi.
Definition: Framescan.h:306
Stack stack
the StackParameters
Definition: Scope.h:237
virtual uint32_t TotalPixelsAllChannels() const
total number of pixels summed over all channels
Definition: Scope.cpp:265
WindowCollection frames
The parameters for windows on the screen.
Definition: Scope.h:252
virtual void InitializeConnections()
Helper for constructors and assignment to connect internal ScopeValues (as the connections in ScopeVa...
Definition: Scope.cpp:279
ScopeString comment
a comment, e.g.
Definition: Scope.h:225
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Storage.cpp:32
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
Definition: ScopeValue.h:103
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
virtual void UpdateTotaltimeFromFrames()
Updates durations of timeseries from choosen frames and framerate.
Definition: Scope.cpp:459
ScopeNumber< uint32_t > repeats
How often should the timeseries be repeated.
Definition: Runstates.h:87
Parameters for a ScannerVectorFrameResonance.
Definition: Framescan.h:439
virtual double FrameTime() const
Time per frame in seconds.
Definition: Scope.cpp:257
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Windows.cpp:51
STL namespace.
ScopeString channel
digital output channel
Definition: Scope.h:33
ScopeNumber< double > xaspectratio
aspect ratio in x direction
Definition: Framescan.h:141
void SetMasterArea(Area *const _masterarea)
(Re)set the pointer to the master area e.g.
Definition: Scope.cpp:134
ScopeNumber< bool > enable
stimulation enabled/disabled
Definition: Scope.h:42
SCOPE_XYZCONTROL_T stage
the parameters for the xyz stage (set type in ScopeDefines.h)
Definition: Scope.h:246
virtual void CalculateResolution()
Calculates the x resolution from the x aspect ratio and the y resolution from the y aspect ratio...
Definition: Scope.cpp:333
virtual double LineTime() const
Time per line in seconds.
Definition: Scope.cpp:261
ScopeNumber< double > onset
onset of stimulation
Definition: Scope.h:45
ScopeNumber< double > framerate
Frame repetition rate in Hertz.
Definition: Scope.h:110
ScopeNumber< uint32_t > xres
x resolution of the image (linewidth)
Definition: Framescan.h:135
void Load(const std::wstring &filename)
Load all from file.
Definition: Scope.cpp:475
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: IO.cpp:662
std::array< ScopeNumber< uint32_t >, SCOPE_NAREAS > frames
number of frames in timeseries for each area
Definition: Runstates.h:72
ScopeNumber< double > yaspectratio
aspect ratio in y direction
Definition: Framescan.h:144
ScopeNumber< double > duration
total duration of stimulation
Definition: Scope.h:48
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
Parameters for a ScannerVectorFramePlaneHopper.
Definition: Framescan.h:391
T SetWithLimits(const T &v, const T &ll, const T &ul)
Sets new value and new limits at the same time.
Definition: ScopeNumber.h:161
ScopeNumber< double > frametime
Time per frame in seconds.
Definition: Scope.h:113
Timeseries timeseries
the TimeseriesParameters
Definition: Scope.h:240
Behavior behavior
the BehaviorParameters
Definition: Scope.h:243
Storage storage
the StorageParameters
Definition: Scope.h:234
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: IO.cpp:692
This is the include file for standard system include files, or project specific include files that ar...
virtual void UpdateFastZCalibration()
Updates fast z boundaries on changed fast Z (ETL) calibration file.
Definition: Scope.cpp:319
T::Mode t
the enum from the template class
ScopeNumber< uint32_t > histrange
Histogram range for the areas.
Definition: Scope.h:116
ScopeValue< DaqMode > requested_mode
requested acquisition mode (see DaqModeHelper)
Definition: Scope.h:279
Describes the data acquisiton mode.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Runstates.cpp:178
ScopeNumber< double > basemicronperpixelx
Base scale in x direction for 256x256 pixels at zoom 1 and the (maxoutput-minoutput) range set in Daq...
Definition: Scope.h:95
virtual void SaveToPreset(const std::wstring &_name)
Save to preset in currentframe.
Definition: Scope.cpp:245
std::wstring GetCurrentDateString()
Definition: helpers.cpp:4
ScopeString scopecommit
Current version (git commit hash) of Scope.
Definition: Scope.h:222
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Runstates.cpp:103
Daq daq
the DaqParameters for this area
Definition: Scope.h:78
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Scope.cpp:566
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Storage.cpp:22
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Runstates.cpp:89
#define DBOUT(s)
A debug output to the debug console.
Definition: helpers.h:153
void Save(const std::wstring &filename) const
Save all to file.
Definition: Scope.cpp:513
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Scope.cpp:235
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.
static std::wstring NameOf(const uint32_t &_n)
ScopeNumber< double > overalltime
time in seconds for all timeseries
Definition: Runstates.h:93
ScannerVectorFrameResonance & FrameResonance() const
pointer to the ScannerVectorFrameResonance if implemented or throwing an exception! ...
Definition: Scope.cpp:160
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Runstates.cpp:249
Parameters for a ScannerVectorFrameSaw.
Definition: Framescan.h:210
ScopeNumber< double > basemicronperpixely
Base scale in y direction for 256x256 pixels at zoom 1 and the (maxoutput-minoutput) range set in Daq...
Definition: Scope.h:97
virtual void CalculateMicronPerPixel()
Current scale calculated from micronperpixelx with the resolution set in currentframe.
Definition: Scope.cpp:327
ScannerVectorFramePlaneHopper & FrameHopper() const
pointer to the ScannerVectorFramePlaneHopper if implemented or throwing an exception! ...
Definition: Scope.cpp:172
ScopeNumber< double > masterfovsizex
Size of the maximally reachable field of view.
Definition: Scope.h:270
std::unique_ptr< Inputs > inputs
the input parameters
Definition: IO.h:764
virtual void ChangeScanMode()
Force update of rates etc.
Definition: Scope.cpp:306
ScopeNumber< double > linerate
Line repetition rate in Hertz.
Definition: Scope.h:107
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Runstates.cpp:205
std::array< ScopeNumber< double >, SCOPE_NAREAS > totaltimes
total acquisition time for each area
Definition: Runstates.h:75
Describes the scanner vector type.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: IO.cpp:676
Area & operator=(const Area &v)
Assignment (deep copy because of the pointers in the map)
Definition: Scope.cpp:106
ScannerVectorFrameSaw & FrameSaw() const
pointer to the ScannerVectorFrameSaw if implemented or throwing an exception!
Definition: Scope.cpp:154
ScopeString time
current time
Definition: Scope.h:219
ScopeValue< RunState > run_state
current RunState
Definition: Scope.h:276
void SetRWState(const bool &_state)
Sets readonly/read-write state.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Scope.cpp:42
Parameters for a ScannerVectorFrameBasic.
Definition: Framescan.h:45
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
Definition: Framescan.h:151
ScannerVectorFrameBasic & Currentframe() const
pointer to the current parameters::frame.
Definition: Scope.cpp:150
ScopeNumber< uint32_t > area
the number of this area
Definition: Scope.h:69
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Scope.cpp:22
ScopeString timingsource
timing source.
Definition: Scope.h:39
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Storage.cpp:42
ScannerVectorFrameBiDi & FrameBiDi() const
pointer to the ScannerVectorFrameBiDi if implemented or throwing an exception!
Definition: Scope.cpp:166
boost::signals2::connection ConnectOther(signalchange_t::slot_type slot)
Connect signal to slot to other stuff.
ScopeNumber< double > betweenrepeats
Time in seconds between the beginning of one and beginning of the next timeseries.
Definition: Runstates.h:90
ScopeNumber< uint32_t > yres
y resolution of the image (lines)
Definition: Framescan.h:138
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
Definition: ScopeValue.h:108
SCOPE_FPUZCONTROL_T fpuzstage
the fast z stage parameters for this FPU (set type in ScopeDefines.h)
Definition: Scope.h:84
ScopeNumber< bool > startinputsfirst
true: start inputs first, then outputs with output of area 0 as last, so it (e.g. ...
Definition: Scope.h:256
virtual double XOffsetInMicron() const
Gives the current framescan X offset in micrometers.
Definition: Scope.cpp:269
Describes the actual state of the scope.
virtual void UpdateRates()
Updates framerate, frametime, and linerate.
Definition: Scope.cpp:313
ScopeValue< ScannerType > scannertype
Type of scanner in the microscope.
Definition: Scope.h:228
ScopeValue< ScannerVectorType > scanmode
the choosen scanner vector type
Definition: Scope.h:87
Stimulation stimulation
the StimulationParameters
Definition: Scope.h:249
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Scope.cpp:178
virtual double YOffsetInMicron() const
Gives the current framescan Y offset in micrometers.
Definition: Scope.cpp:274
ScopeNumber< bool > isslave
true if this area is a slave area (for an n-beam system)
Definition: Scope.h:72
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Runstates.cpp:149
SCOPE_FPUXYCONTROL_T fpuxystage
the xy stage parameters for this FPU (set type in ScopeDefines.h)
Definition: Scope.h:81
std::wstring GetCurrentTimeString(const bool &_filenamecompatible)
Definition: helpers.cpp:12
Area(const uint32_t &_area=0, const bool &_isslave=false, Area *const _masterarea=nullptr)
Definition: Scope.cpp:51