Scope
Framescan.cpp
1 #include "stdafx.h"
2 #include "Framescan.h"
3 #include "Scope.h"
4 
5 namespace scope {
6 
7 namespace parameters {
8 
9 // Save some typing here...
10 using namespace boost::property_tree;
11 
12 ScannerVectorFrameBasic::Preset::Preset()
13  : name(L"None", L"Name")
14  , pixeltime(10, 0.4, 15, L"Pixeltime_us")
15  , scannerdelay(0, -1000, 1000, L"Scannerdelay_us")
16  , averages(1, 1, 32, L"Averages")
17  , xres(256, 16, 10000, L"XResolution_Pixel")
18  , yres(256, 16, 10000, L"YResolution_Pixel")
19  , xaspectratio(1, 0.0001, 10000, L"XAspectRatio")
20  , yaspectratio(1, 0.0001, 10000, L"YAspectRatio")
21  , squarepixels(false, false, true, L"SquarePixels") {
22 }
23 
24 void ScannerVectorFrameBasic::Preset::Load(const wptree& pt) {
34 }
35 
36 void ScannerVectorFrameBasic::Preset::Save(wptree& pt) const {
37  name.AddToPropertyTree(pt);
38  pixeltime.AddToPropertyTree(pt);
39  scannerdelay.AddToPropertyTree(pt);
40  averages.AddToPropertyTree(pt);
46 }
47 
48 ScannerVectorFrameBasic::ScannerVectorFrameBasic()
49  : presets(0)
50  , xres(256, 16, 10000, L"XResolution_Pixel")
51  , yres(256, 16, 10000, L"YResolution_Pixel")
52  , xaspectratio(1, 0.0001, 10000, L"XAspectRatio")
53  , yaspectratio(1, 0.0001, 10000, L"YAspectRatio")
54  , squarepixels(false, false, true, L"SquarePixels")
55  , zoom(1.0, 1.0 , 20.0, L"Zoom")
56  , xoffset(0.0, -1.0, 1.0, L"XOffset_Fraction")
57  , yoffset(0.0, -1.0, 1.0, L"YOffset_Fraction")
58  , fastz(0.0, -5.0, 5.0, L"FastZ_um")
59  , pockels(0.0, 0.0, 1.0, L"Pockels_Fraction")
60  , xrotation(0.0, 0.0, 90.0, L"XRotation_Degree")
61  , yrotation(0.0, 0.0, 90.0, L"YRotation_Degree") {
63  CoerceOffset();
64 }
65 
66 void ScannerVectorFrameBasic::Load(const wptree& pt) {
79  try {
80  wptree presetstree = pt.get_child(L"presets");
81  for ( auto subtree : presetstree ) {
82  // Call make preset (could be from derived class) to generate the correct (derived) Preset, and downcast it to
83  // ScannerVectorFrameBasic::Preset
84  std::shared_ptr<ScannerVectorFrameBasic::Preset> p = MakePreset();
85  p->Load(subtree.second);
86  presets.push_back(p);
87  }
88  } catch (boost::property_tree::ptree_bad_path) {
89  DBOUT(L"Bad path while loading presets");
90  }
91 }
92 
93 void ScannerVectorFrameBasic::Save(wptree& pt) const {
106  wptree ptpresets;
107  uint32_t i = 0;
108  CString name(L"");
109  for ( auto p : presets ) {
110  wptree subtree;
111  p->Save(subtree);
112  name.Format(L"preset%d", i++);
113  ptpresets.add_child(name.GetString(), subtree);
114  }
115  pt.add_child(L"presets", ptpresets);
116 }
117 
119  switch ( static_cast<RunStateHelper::Mode>(_runstate) ) {
120  case RunStateHelper::Mode::Stopped:
121  zoom.SetRWState(true);
122  pockels.SetRWState(true);
123  fastz.SetRWState(true);
124  xoffset.SetRWState(true);
125  yoffset.SetRWState(true);
126  xrotation.SetRWState(true);
127  yrotation.SetRWState(true);
128  xres.SetRWState(true);
129  yres.SetRWState(true);
130  xaspectratio.SetRWState(true);
131  yaspectratio.SetRWState(true);
132  squarepixels.SetRWState(true);
133  xrotation.SetRWState(true);
134  yrotation.SetRWState(true);
135  break;
136  case RunStateHelper::Mode::RunningSingle:
137  case RunStateHelper::Mode::RunningStack:
138  case RunStateHelper::Mode::RunningTimeseries:
139  zoom.SetRWState(false);
140  pockels.SetRWState(false);
141  fastz.SetRWState(false);
142  xoffset.SetRWState(false);
143  yoffset.SetRWState(false);
144  xrotation.SetRWState(false);
145  yrotation.SetRWState(false);
146  // Do not call break, but do the rest too
147  case RunStateHelper::Mode::RunningContinuous:
148  default:
149  xres.SetRWState(false);
150  yres.SetRWState(false);
151  xaspectratio.SetRWState(false);
152  yaspectratio.SetRWState(false);
153  squarepixels.SetRWState(false);
154  xrotation.SetRWState(false);
155  yrotation.SetRWState(false);
156  }
157 }
158 
159 std::unique_ptr<ScannerVectorFrameBasic::Preset> ScannerVectorFrameBasic::MakePreset() const {
160  return std::unique_ptr<ScannerVectorFrameBasic::Preset>(new ScannerVectorFrameBasic::Preset());
161 }
162 
163 void ScannerVectorFrameBasic::DeletePreset(const std::wstring& _name) {
164  auto samename = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
165  { return _pres->name() == _name; } );
166  if ( presets.end() != samename )
167  presets.erase(samename); // If name exists, delete
168 }
169 
171  xoffset.SetLimits(-1+1/zoom(), 1-1/zoom());
172  yoffset.SetLimits(-1+1/zoom(), 1-1/zoom());
173  // SetLimits call change signals, thus xoffset and yoffset get updated on GUI etc.
174 }
175 
176 
177 std::unique_ptr<ScannerVectorFrameBasic> ScannerVectorFrameBasic::Factory(const ScannerVectorType& _type, const ScannerVectorFrameBasic* const _o) {
178  switch ( _type.t ) {
179  case ScannerVectorTypeHelper::Sawtooth:
180  return (_o==nullptr)?ScannerVectorFrameSaw::Create():ScannerVectorFrameSaw::Create(*dynamic_cast<const ScannerVectorFrameSaw*>(_o));
181  case ScannerVectorTypeHelper::Bidirectional:
182  return (_o==nullptr)?ScannerVectorFrameBiDi::Create():ScannerVectorFrameBiDi::Create(*dynamic_cast<const ScannerVectorFrameBiDi*>(_o));
183  case ScannerVectorTypeHelper::Planehopper:
184  return (_o==nullptr)?ScannerVectorFramePlaneHopper::Create():ScannerVectorFramePlaneHopper::Create(*dynamic_cast<const ScannerVectorFramePlaneHopper*>(_o));
185  default:
186  return (_o==nullptr)?ScannerVectorFrameBasic::Create():ScannerVectorFrameBasic::Create(*dynamic_cast<const ScannerVectorFrameBasic*>(_o));
187  }
188 }
189 
190 std::vector<boost::signals2::connection> ScannerVectorFrameBasic::ConnectCopyTrigger(signalchange_t::slot_type _slot) {
191  std::vector<boost::signals2::connection> conns;
192  conns.push_back(xres.ConnectOther(_slot));
193  conns.push_back(yres.ConnectOther(_slot));
194  conns.push_back(zoom.ConnectOther(_slot));
195  conns.push_back(xaspectratio.ConnectOther(_slot));
196  conns.push_back(yaspectratio.ConnectOther(_slot));
197  conns.push_back(squarepixels.ConnectOther(_slot));
198  return conns;
199 }
200 
201 void ScannerVectorFrameBasic::ConnectRateUpdate(signalchange_t::slot_type _slot) {
202  xres.ConnectOther(_slot);
203  yres.ConnectOther(_slot);
204 }
205 
206 void ScannerVectorFrameBasic::ConnectResolutionUpdate(signalchange_t::slot_type _slot) {
207  xaspectratio.ConnectOther(_slot);
208  yaspectratio.ConnectOther(_slot);
209 }
210 
211 void ScannerVectorFrameBasic::ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) {
212  xres.ConnectOther(_slot);
213  yres.ConnectOther(_slot);
214  zoom.ConnectOther(_slot);
215 }
216 
217 void ScannerVectorFrameBasic::ConnectResolutionChange(signalchange_t::slot_type _slot) {
218  xres.ConnectOther(_slot);
219  yres.ConnectOther(_slot);
220 }
221 
222 void ScannerVectorFrameBasic::ConnectOnlineUpdate(signalchange_t::slot_type _slot) {
223  zoom.ConnectOther(_slot);
224  fastz.ConnectOther(_slot);
225  pockels.ConnectOther(_slot);
226  xoffset.ConnectOther(_slot);
227  yoffset.ConnectOther(_slot);
228  xrotation.ConnectOther(_slot);
229  yrotation.ConnectOther(_slot);
230 }
231 
232 ScannerVectorFrameSaw::ScannerVectorFrameSaw()
233  : xcutoff(0.1, 0, 0.5, L"XCutoff_Fraction")
234  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
235  , xretrace(0.1, 0, 0.5, L"XRetrace_Fraction")
236  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction") {
237 }
238 
239 std::vector<boost::signals2::connection> ScannerVectorFrameSaw::ConnectCopyTrigger(signalchange_t::slot_type _slot) {
240  std::vector<boost::signals2::connection> conns(ScannerVectorFrameBasic::ConnectCopyTrigger(_slot));
241  conns.push_back(xcutoff.ConnectOther(_slot));
242  conns.push_back(ycutoff.ConnectOther(_slot));
243  conns.push_back(xretrace.ConnectOther(_slot));
244  conns.push_back(yretrace.ConnectOther(_slot));
245  return conns;
246 }
247 
248 void ScannerVectorFrameSaw::ConnectRateUpdate(signalchange_t::slot_type _slot) {
250  xcutoff.ConnectOther(_slot);
251  ycutoff.ConnectOther(_slot);
252  xretrace.ConnectOther(_slot);
253  yretrace.ConnectOther(_slot);
254 }
255 
256 void ScannerVectorFrameSaw::ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) {
258  xcutoff.ConnectOther(_slot);
259  ycutoff.ConnectOther(_slot);
260  xretrace.ConnectOther(_slot);
261  yretrace.ConnectOther(_slot);
262 }
263 
264 void ScannerVectorFrameSaw::ConnectOnlineUpdate(signalchange_t::slot_type _slot) {
266  xcutoff.ConnectOther(_slot);
267  ycutoff.ConnectOther(_slot);
268  xretrace.ConnectOther(_slot);
269  yretrace.ConnectOther(_slot);
270 }
271 
272 ScannerVectorFrameSaw::Preset::Preset()
273  : xcutoff(0.1, 0, 0.5, L"XCutoff_Fraction")
274  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
275  , xretrace(0.1, 0, 0.5, L"XRetrace_Fraction")
276  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction") {
277 }
278 
279 void ScannerVectorFrameSaw::Preset::Load(const wptree& pt) {
285 }
286 
287 void ScannerVectorFrameSaw::Preset::Save(wptree& pt) const {
293 }
294 
295 void ScannerVectorFrameSaw::Load(const wptree& pt) {
301 }
302 
303 void ScannerVectorFrameSaw::Save(wptree& pt) const {
309 }
310 
313  bool enabler = (static_cast<RunStateHelper::Mode>(_runstate)==RunStateHelper::Mode::Stopped)?true:false;
314  xcutoff.SetRWState(enabler);
315  ycutoff.SetRWState(enabler);
316  xretrace.SetRWState(enabler);
317  yretrace.SetRWState(enabler);
318 
319 }
320 
321 std::unique_ptr<ScannerVectorFrameBasic::Preset> ScannerVectorFrameSaw::MakePreset() const {
322  return std::unique_ptr<ScannerVectorFrameBasic::Preset>(new ScannerVectorFrameSaw::Preset());
323 }
324 
325 void ScannerVectorFrameSaw::SaveToPreset(const std::wstring& _name, const Daq& _daq) {
326  std::shared_ptr<Preset> p = std::make_shared<Preset>();
327  p->name = _name;
328  p->pixeltime = _daq.pixeltime();
329  p->scannerdelay = _daq.scannerdelay();
330  p->averages = _daq.averages();
331  p->xres = xres();
332  p->yres = yres();
333  p->xcutoff = xcutoff();
334  p->ycutoff = ycutoff();
335  p->xretrace = xretrace();
336  p->yretrace = yretrace();
337  auto samename = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
338  { return _pres->name() == _name; } );
339  if ( presets.end() != samename )
340  presets.erase(samename); // If name already exists, delete the old (thus overwrite)
341  presets.push_back(p);
342 }
343 
344 void ScannerVectorFrameSaw::LoadFromPreset(const std::wstring& _name, Daq& _daq) {
345  auto which = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
346  { return _pres->name() == _name; } );
347  if ( which == std::end(presets) )
348  return ;
349 
350  _daq.pixeltime = (*which)->pixeltime();
351  _daq.scannerdelay = (*which)->scannerdelay();
352  _daq.averages = (*which)->averages();
353  xres = (*which)->xres();
354  yres = (*which)->yres();
355 
356  // This is one of the few locations where not everything is compile-time type-safe
357  // Casting from ScannerVectorFrameBasic::Preset to ScannerVectorFrameSaw::Preset
358  xcutoff = dynamic_cast<ScannerVectorFrameSaw::Preset*>(which->get())->xcutoff();
359  ycutoff = dynamic_cast<ScannerVectorFrameSaw::Preset*>(which->get())->ycutoff();
360  xretrace = dynamic_cast<ScannerVectorFrameSaw::Preset*>(which->get())->xretrace();
361  yretrace = dynamic_cast<ScannerVectorFrameSaw::Preset*>(which->get())->yretrace();
362 }
363 
364 ScannerVectorFrameBiDi::ScannerVectorFrameBiDi()
365  : xturnfraction(0.1, 0, 0.5, L"XTurning_Fraction")
366  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
367  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction") {
368 }
369 
370 std::vector<boost::signals2::connection> ScannerVectorFrameBiDi::ConnectCopyTrigger(signalchange_t::slot_type _slot) {
371  std::vector<boost::signals2::connection> conns(ScannerVectorFrameBasic::ConnectCopyTrigger(_slot));
372  conns.push_back(xturnfraction.ConnectOther(_slot));
373  conns.push_back(ycutoff.ConnectOther(_slot));
374  conns.push_back(yretrace.ConnectOther(_slot));
375  return conns;
376 }
377 
378 void ScannerVectorFrameBiDi::ConnectRateUpdate(signalchange_t::slot_type _slot) {
381  ycutoff.ConnectOther(_slot);
382  yretrace.ConnectOther(_slot);
383 }
384 
385 void ScannerVectorFrameBiDi::ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) {
388  ycutoff.ConnectOther(_slot);
389  yretrace.ConnectOther(_slot);
390 }
391 
392 void ScannerVectorFrameBiDi::ConnectOnlineUpdate(signalchange_t::slot_type _slot) {
395  ycutoff.ConnectOther(_slot);
396  yretrace.ConnectOther(_slot);
397 }
398 
399 ScannerVectorFrameBiDi::Preset::Preset()
400  : xturnfraction(0.1, 0, 0.5, L"XTurning_Fraction")
401  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
402  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction") {
403 }
404 
405 void ScannerVectorFrameBiDi::Preset::Load(const wptree& pt) {
410 }
411 
412 void ScannerVectorFrameBiDi::Preset::Save(wptree& pt) const {
417 }
418 
419 void ScannerVectorFrameBiDi::Load(const wptree& pt) {
424 }
425 
426 void ScannerVectorFrameBiDi::Save(wptree& pt) const {
431 }
432 
435  bool enabler = (static_cast<RunStateHelper::Mode>(_runstate)==RunStateHelper::Mode::Stopped)?true:false;
436  xturnfraction.SetRWState(enabler);
437  ycutoff.SetRWState(enabler);
438  yretrace.SetRWState(enabler);
439 }
440 
441 std::unique_ptr<ScannerVectorFrameBasic::Preset> ScannerVectorFrameBiDi::MakePreset() const {
442  return std::unique_ptr<ScannerVectorFrameBasic::Preset>(new ScannerVectorFrameBiDi::Preset());
443 }
444 
445 void ScannerVectorFrameBiDi::SaveToPreset(const std::wstring& _name, const Daq& _daq) {
446  std::shared_ptr<Preset> p = std::make_shared<Preset>();
447  p->name = _name;
448  p->pixeltime = _daq.pixeltime();
449  p->scannerdelay = _daq.scannerdelay();
450  p->averages = _daq.averages();
451  p->xres = xres();
452  p->yres = yres();
453  p->xturnfraction = xturnfraction();
454  p->ycutoff = ycutoff();
455  p->yretrace = yretrace();
456  auto samename = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
457  { return _pres->name() == _name; } );
458  if ( presets.end() != samename )
459  presets.erase(samename); // If name already exists, delete the old (thus overwrite)
460  presets.push_back(p);
461 }
462 
463 void ScannerVectorFrameBiDi::LoadFromPreset(const std::wstring& _name, Daq& _daq) {
464  auto which = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
465  { return _pres->name() == _name; } );
466  if ( which == std::end(presets) )
467  return ;
468  _daq.pixeltime = (*which)->pixeltime();
469  _daq.scannerdelay = (*which)->scannerdelay();
470  _daq.averages = (*which)->averages();
471  xres = (*which)->xres();
472  yres = (*which)->yres();
473  // Casting from ScannerVectorFrameBasic::Preset to ScannerVectorFrameBidi::Preset
474  xturnfraction = dynamic_cast<ScannerVectorFrameBiDi::Preset*>(which->get())->xturnfraction();
475  ycutoff = dynamic_cast<ScannerVectorFrameBiDi::Preset*>(which->get())->ycutoff();
476  yretrace = dynamic_cast<ScannerVectorFrameBiDi::Preset*>(which->get())->yretrace();
477 }
478 
479 ScannerVectorFramePlaneHopper::Preset::Preset()
480  : planes(0) {
481 }
482 
483 std::vector<boost::signals2::connection> ScannerVectorFramePlaneHopper::ConnectCopyTrigger(signalchange_t::slot_type _slot) {
484  std::vector<boost::signals2::connection> conns(ScannerVectorFrameBasic::ConnectCopyTrigger(_slot));
485  for ( auto& p : planes ) {
486  conns.push_back(p.pockels.ConnectOther(_slot));
487  conns.push_back(p.position.ConnectOther(_slot));
488  }
489 
490  return conns;
491 }
492 
493 void ScannerVectorFramePlaneHopper::ConnectRateUpdate(signalchange_t::slot_type _slot) {
495  for ( auto& p : planes ) {
496  p.pockels.ConnectOther(_slot);
497  p.position.ConnectOther(_slot);
498  }
499 }
500 
501 void ScannerVectorFramePlaneHopper::ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) {
503  for ( auto& p : planes ) {
504  p.pockels.ConnectOther(_slot);
505  p.position.ConnectOther(_slot);
506  }
507 }
508 
509 void ScannerVectorFramePlaneHopper::ConnectOnlineUpdate(signalchange_t::slot_type _slot) {
511  for ( auto& p : planes ) {
512  p.pockels.ConnectOther(_slot);
513  p.position.ConnectOther(_slot);
514  }
515 }
516 
519 
520 }
521 
524 
525 }
526 
527 ScannerVectorFramePlaneHopper::ScannerVectorFramePlaneHopper()
528  : planes(0) {
529 }
530 
531 void ScannerVectorFramePlaneHopper::Load(const wptree& pt) {
534  // problem is to find out how many planes are in the xml, use different version of Load from ptree which throws on not found?!
535 // pt.get_optional(
536 }
537 
538 void ScannerVectorFramePlaneHopper::Save(wptree& pt) const {
540  std::wstring name(L"");
541  uint32_t i = 0;
542  for ( const auto& p : planes ) {
543  //name.Format(L"Plane%d", i++);
544  p.position.AddToPropertyTree(pt);
545  p.pockels.AddToPropertyTree(pt);
546  }
547 }
548 
551 }
552 
553 std::unique_ptr<ScannerVectorFrameBasic::Preset> ScannerVectorFramePlaneHopper::MakePreset() const {
554  return std::unique_ptr<ScannerVectorFrameBasic::Preset>(new ScannerVectorFramePlaneHopper::Preset());
555 }
556 
557 void ScannerVectorFramePlaneHopper::SaveToPreset(const std::wstring& _name, const Daq& _daq) {
558  std::shared_ptr<Preset> p = std::make_shared<Preset>();
559  p->name = _name;
560  p->pixeltime = _daq.pixeltime();
561  p->scannerdelay = _daq.scannerdelay();
562  p->averages = _daq.averages();
563  p->xres = xres();
564  p->yres = yres();
565  p->planes = planes;
566  auto samename = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
567  { return _pres->name() == _name; } );
568  if ( presets.end() != samename )
569  presets.erase(samename); // If name already exists, delete the old (thus overwrite)
570  presets.push_back(p);
571 }
572 
573 
574 void ScannerVectorFramePlaneHopper::LoadFromPreset(const std::wstring& _name, Daq& _daq) {
575  auto which = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
576  { return _pres->name() == _name; } );
577  if ( which == std::end(presets) )
578  return ;
579  _daq.pixeltime = (*which)->pixeltime();
580  _daq.scannerdelay = (*which)->scannerdelay();
581  _daq.averages = (*which)->averages();
582  xres = (*which)->xres();
583  yres = (*which)->yres();
584  // Casting from ScannerVectorFrameBasic::Preset to ScannerVectorFramePlaneHopper::Preset
585  planes = dynamic_cast<ScannerVectorFramePlaneHopper::Preset*>(which->get())->planes;
586 }
587 
588 
589 ScannerVectorFrameResonance::ScannerVectorFrameResonance()
590  : xturnfraction(0.1, 0, 0.5, L"XTurning_Fraction")
591  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
592  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction")
593  , waitafterenqueuestorage(2, 0, 1000, L"WaitAfterEnqueueStorage_Millisecond")
594  , waitafterenqueuedisplay(5, 0, 1000, L"WaitAfterEnqueueDisplay_Millisecond") {
597  zoom.SetLimits(1, 4);
598 }
599 
600 std::vector<boost::signals2::connection> ScannerVectorFrameResonance::ConnectCopyTrigger(signalchange_t::slot_type _slot) {
601  std::vector<boost::signals2::connection> conns(ScannerVectorFrameBasic::ConnectCopyTrigger(_slot));
602  conns.push_back(xturnfraction.ConnectOther(_slot));
603  conns.push_back(ycutoff.ConnectOther(_slot));
604  conns.push_back(yretrace.ConnectOther(_slot));
605  conns.push_back(waitafterenqueuestorage.ConnectOther(_slot));
606  conns.push_back(waitafterenqueuedisplay.ConnectOther(_slot));
607  return conns;
608 }
609 
610 void ScannerVectorFrameResonance::ConnectRateUpdate(signalchange_t::slot_type _slot) {
613  ycutoff.ConnectOther(_slot);
614  yretrace.ConnectOther(_slot);
617 }
618 
619 void ScannerVectorFrameResonance::ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) {
622  ycutoff.ConnectOther(_slot);
623  yretrace.ConnectOther(_slot);
626 }
627 
628 void ScannerVectorFrameResonance::ConnectOnlineUpdate(signalchange_t::slot_type _slot) {
631  ycutoff.ConnectOther(_slot);
632  yretrace.ConnectOther(_slot);
633  // No online update of waitafters possible
634 }
635 
636 ScannerVectorFrameResonance::Preset::Preset()
637  : xturnfraction(0.1, 0, 0.5, L"XTurning_Fraction")
638  , ycutoff(0.1, 0, 0.5, L"YCutoff_Fraction")
639  , yretrace(0.1, 0, 0.5, L"YRetrace_Fraction")
640  , waitafterenqueuestorage(2, 0, 1000, L"WaitAfterEnqueueStorage_Millisecond")
641  , waitafterenqueuedisplay(5, 0, 1000, L"WaitAfterEnqueueDisplay_Millisecond") {
642 }
643 
651 }
652 
660 }
661 
662 void ScannerVectorFrameResonance::Load(const wptree& pt) {
669 }
670 
671 void ScannerVectorFrameResonance::Save(wptree& pt) const {
678 }
679 
682  bool enabler = (static_cast<RunStateHelper::Mode>(_runstate)==RunStateHelper::Mode::Stopped)?true:false;
683  ycutoff.SetRWState(enabler);
684  yretrace.SetRWState(enabler);
685  zoom.SetRWState(enabler);
688 }
689 
690 std::unique_ptr<ScannerVectorFrameBasic::Preset> ScannerVectorFrameResonance::MakePreset() const {
691  return std::unique_ptr<ScannerVectorFrameBasic::Preset>(new ScannerVectorFrameResonance::Preset());
692 }
693 
694 void ScannerVectorFrameResonance::SaveToPreset(const std::wstring& _name, const Daq& _daq) {
695  std::shared_ptr<Preset> p = std::make_shared<Preset>();
696  p->name = _name;
697  p->pixeltime = _daq.pixeltime();
698  p->scannerdelay = _daq.scannerdelay();
699  p->averages = _daq.averages();
700  p->xres = xres();
701  p->yres = yres();
702  p->xturnfraction = xturnfraction();
703  p->ycutoff = ycutoff();
704  p->yretrace = yretrace();
705  p->waitafterenqueuestorage = waitafterenqueuestorage();
706  p->waitafterenqueuedisplay = waitafterenqueuedisplay();
707  auto samename = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
708  { return _pres->name() == _name; } );
709  if ( presets.end() != samename )
710  presets.erase(samename); // If name already exists, delete the old (thus overwrite)
711  presets.push_back(p);
712 }
713 
714 void ScannerVectorFrameResonance::LoadFromPreset(const std::wstring& _name, Daq& _daq) {
715  auto which = std::find_if(std::begin(presets), std::end(presets), [&](std::shared_ptr<ScannerVectorFrameBasic::Preset> _pres)
716  { return _pres->name() == _name; } );
717  if ( which == std::end(presets) )
718  return ;
719  _daq.pixeltime = (*which)->pixeltime();
720  _daq.scannerdelay = (*which)->scannerdelay();
721  _daq.averages = (*which)->averages();
722  xres = (*which)->xres();
723  yres = (*which)->yres();
724  // Casting from ScannerVectorFrameBasic::Preset to ScannerVectorFrameResonance::Preset
725  xturnfraction = dynamic_cast<ScannerVectorFrameResonance::Preset*>(which->get())->xturnfraction();
726  ycutoff = dynamic_cast<ScannerVectorFrameResonance::Preset*>(which->get())->ycutoff();
727  yretrace = dynamic_cast<ScannerVectorFrameResonance::Preset*>(which->get())->yretrace();
730 }
731 
733  // only even values are allowed, because the image gets divided into two parts (forward/backward lines)
734  yres.Set(yres - yres%2);
735 }
736 
738  xturnfraction.Set(static_cast<double>((XTotalPixels() - XImagePixels())) / XImagePixels());
739 }
740 
741 
742 }
743 
744 }
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
Definition: Framescan.h:56
virtual void ConnectRateUpdate(signalchange_t::slot_type _slot)
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:201
void ConnectOnlineUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector (which is displayed on the GUI) chang...
Definition: Framescan.cpp:264
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Framescan.cpp:538
std::unique_ptr< ScannerVectorFrameBasic::Preset > MakePreset() const override
Since preset loading is done in base class (here), we need to generate a derived preset, this can be done by calling this function and overriding it in derived classes.
Definition: Framescan.cpp:441
ScopeNumber< double > xcutoff
Cutoff fraction at beginning of line, total pixels per line = xres * (1 + xcutoff + xretrace) ...
Definition: Framescan.h:219
virtual void ConnectResolutionUpdate(signalchange_t::slot_type _slot)
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:206
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Framescan.cpp:311
virtual std::vector< boost::signals2::connection > ConnectCopyTrigger(signalchange_t::slot_type _slot)
Connect a slot that is called if some member parameter changes, this can be used to copy certain chan...
Definition: Framescan.cpp:190
ScopeNumber< uint32_t > averages
number of images to average
Definition: Framescan.h:62
ScopeNumber< uint32_t > yres
y resolution of the image (lines)
Definition: Framescan.h:68
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Framescan.cpp:680
virtual T Set(const T &_v, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the value and calls both change signals if the value actually changed.
Definition: ScopeValue.h:67
ScopeString name
name of the preset
Definition: Framescan.h:53
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
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
Definition: IO.h:779
virtual void CoerceYResolution()
Changes the y resolution to the allowed values for the resonance scanner.
Definition: Framescan.cpp:732
ScopeNumber< double > pockels
pockels cell value
Definition: Framescan.h:163
ScopeNumber< uint32_t > waitafterenqueuestorage
Time (in milliseconds) to wait after the PipelineController has enqueued the image to the storage que...
Definition: Framescan.h:457
ScopeNumber< double > yrotation
Rotation angle around the Y axis in degrees.
Definition: Framescan.h:169
virtual void DeletePreset(const std::wstring &_name)
Deletes a preset.
Definition: Framescan.cpp:163
void Load(const wptree &pt) override
Load from boost property tree.
Definition: Framescan.cpp:279
ScopeNumber< double > scannerdelay
compensate, by waiting, that scanners lag behind the command voltage
Definition: Framescan.h:59
void ConnectOnlineUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector (which is displayed on the GUI) chang...
Definition: Framescan.cpp:628
static std::unique_ptr< ScannerVectorFrameBasic > Create()
Create function for factory.
Definition: Framescan.h:411
void ConnectRateUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:493
ScopeNumber< double > yaspectratio
aspect ratio in y direction
Definition: Framescan.h:74
void LoadFromPreset(const std::wstring &_name, Daq &_daq) override
Load parameters from a preset.
Definition: Framescan.cpp:463
std::vector< boost::signals2::connection > ConnectCopyTrigger(signalchange_t::slot_type _slot) override
Connect a slot that is called if some member parameter changes, this can be used to copy certain chan...
Definition: Framescan.cpp:239
void Save(wptree &pt) const override
Save to boost property tree.
Definition: Framescan.cpp:412
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
virtual uint32_t XImagePixels() const
Definition: Framescan.h:172
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:222
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:262
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Framescan.cpp:93
virtual void ConnectResolutionChange(signalchange_t::slot_type _slot)
Connect a slot that is called if xres or yres in the ScannerVector are changed This usually is ScopeC...
Definition: Framescan.cpp:217
virtual void Save(wptree &pt) const
Save to boost property tree.
Definition: Framescan.cpp:36
ScopeNumber< double > xturnfraction
fraction spent for turning the x galvo around
Definition: Framescan.h:346
ScopeNumber< uint32_t > xres
x resolution of the image (linewidth)
Definition: Framescan.h:65
All parameters for scanner data generation and pixel acquisition If you add/remove parameters or deri...
Definition: IO.h:747
ScopeNumber< double > xturnfraction
fraction spent for turning the x resonance scanner around
Definition: Framescan.h:485
T SetLimits(const T &_ll, const T &_ul, const bool &_callguisignal=true, const bool &_callothersignal=true, const bool &_callatnochange=false)
Sets the limits and coerces the value accordingly change signal is called if value has to be coerced...
Definition: ScopeNumber.h:174
ScopeNumber< double > xaspectratio
aspect ratio in x direction
Definition: Framescan.h:141
std::vector< boost::signals2::connection > ConnectCopyTrigger(signalchange_t::slot_type _slot) override
Connect a slot that is called if some member parameter changes, this can be used to copy certain chan...
Definition: Framescan.cpp:370
ScopeNumber< double > xretrace
Cutoff fraction for retrace at end of line.
Definition: Framescan.h:259
virtual void UpdateXTurnFraction()
Updates the x turn fraction for the resonance scanner.
Definition: Framescan.cpp:737
ScopeNumber< double > xrotation
Rotation angle around the X axis in degrees.
Definition: Framescan.h:166
ScopeNumber< uint32_t > xres
x resolution of the image (linewidth)
Definition: Framescan.h:135
ScopeNumber< double > yaspectratio
aspect ratio in y direction
Definition: Framescan.h:144
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:256
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Framescan.cpp:531
static std::unique_ptr< ScannerVectorFrameBasic > Create()
Create function for factory.
Definition: Framescan.h:332
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:349
void ConnectOnlineUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector (which is displayed on the GUI) chang...
Definition: Framescan.cpp:509
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:228
virtual std::unique_ptr< ScannerVectorFrameBasic::Preset > MakePreset() const
Since preset loading is done in base class (here), we need to generate a derived preset, this can be done by calling this function and overriding it in derived classes.
Definition: Framescan.cpp:159
std::vector< std::shared_ptr< Preset > > presets
A vector with presets.
Definition: Framescan.h:89
ScopeNumber< double > xturnfraction
fraction spent for turning the x galvo around
Definition: Framescan.h:315
void ConnectOnlineUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector (which is displayed on the GUI) chang...
Definition: Framescan.cpp:392
void ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:256
This is the include file for standard system include files, or project specific include files that ar...
std::vector< PlaneProperties > planes
vector with properties for all planes
Definition: Framescan.h:425
T::Mode t
the enum from the template class
void Save(wptree &pt) const override
Save to boost property tree.
Definition: Framescan.cpp:522
virtual void ConnectOnlineUpdate(signalchange_t::slot_type _slot)
Connect a slot that is called if something in the ScannerVector (which is displayed on the GUI) chang...
Definition: Framescan.cpp:222
ScopeNumber< bool > squarepixels
pixels are square (thus FOV rectangular) when true, when false pixels are rectangular (thus FOV squar...
Definition: Framescan.h:147
ScopeNumber< uint32_t > waitafterenqueuedisplay
Time (in milliseconds) to wait after the PipelineController has enqueued the image to the display que...
Definition: Framescan.h:460
uint32_t XTotalPixels() const override
Definition: Framescan.h:509
void ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:385
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:488
void ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:619
std::unique_ptr< ScannerVectorFrameBasic::Preset > MakePreset() const override
Since preset loading is done in base class (here), we need to generate a derived preset, this can be done by calling this function and overriding it in derived classes.
Definition: Framescan.cpp:553
void ConnectRateUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:248
void Load(const wptree &pt) override
Load from boost property tree.
Definition: Framescan.cpp:405
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Framescan.cpp:295
ScopeNumber< double > xturnfraction
fraction spent for turning the x resonance scanner around
Definition: Framescan.h:448
ScopeNumber< double > xoffset
x offset
Definition: Framescan.h:154
#define DBOUT(s)
A debug output to the debug console.
Definition: helpers.h:153
std::unique_ptr< ScannerVectorFrameBasic::Preset > MakePreset() const override
Since preset loading is done in base class (here), we need to generate a derived preset, this can be done by calling this function and overriding it in derived classes.
Definition: Framescan.cpp:690
void ConnectRateUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:610
void SaveToPreset(const std::wstring &_name, const Daq &_daq) override
Save parameters into a preset.
Definition: Framescan.cpp:694
std::unique_ptr< ScannerVectorFrameBasic::Preset > MakePreset() const override
Since preset loading is done in base class (here), we need to generate a derived preset, this can be done by calling this function and overriding it in derived classes.
Definition: Framescan.cpp:321
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Framescan.cpp:662
void ConnectRateUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:378
static std::unique_ptr< ScannerVectorFrameBasic > Create()
Create function for factory.
Definition: Framescan.h:94
virtual void Load(const wptree &pt)
Load from boost property tree.
Definition: Framescan.cpp:24
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Framescan.cpp:426
void SaveToPreset(const std::wstring &_name, const Daq &_daq) override
Save parameters into a preset.
Definition: Framescan.cpp:325
void SaveToPreset(const std::wstring &_name, const Daq &_daq) override
Save parameters into a preset.
Definition: Framescan.cpp:445
void LoadFromPreset(const std::wstring &_name, Daq &_daq) override
Load parameters from a preset.
Definition: Framescan.cpp:344
ScopeNumber< uint32_t > averages
number of images to average
Definition: IO.h:785
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Framescan.cpp:419
ScopeNumber< double > yoffset
y offset
Definition: Framescan.h:157
std::vector< boost::signals2::connection > ConnectCopyTrigger(signalchange_t::slot_type _slot) override
Connect a slot that is called if some member parameter changes, this can be used to copy certain chan...
Definition: Framescan.cpp:600
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: Framescan.cpp:118
Parameters for a ScannerVectorFrameBasic.
Definition: Framescan.h:45
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:318
void Save(wptree &pt) const override
Save to boost property tree.
Definition: Framescan.cpp:653
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
Definition: Framescan.h:151
static std::unique_ptr< ScannerVectorFrameBasic > Create()
Create function for factory.
Definition: Framescan.h:239
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Framescan.cpp:549
ScopeNumber< double > fastz
current fast z position
Definition: Framescan.h:160
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:352
virtual void CoerceOffset()
Changes the limits of xoffset and yoffset to account for the maximum allowed offset depending on zoom...
Definition: Framescan.cpp:170
ScopeNumber< uint32_t > waitafterenqueuedisplay
Time (in milliseconds) to wait after the PipelineController has enqueued the image to the display que...
Definition: Framescan.h:497
ScopeNumber< double > ycutoff
Cutoff fraction at beginning of frame, total lines per frame = yres * (1 + ycutoff + yretrace) ...
Definition: Framescan.h:451
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
Definition: Framescan.cpp:433
Mode
Enum for the run state of the scope, stopped, continuously scanning, single scan, stack scan...
std::vector< boost::signals2::connection > ConnectCopyTrigger(signalchange_t::slot_type _slot) override
Connect a slot that is called if some member parameter changes, this can be used to copy certain chan...
Definition: Framescan.cpp:483
boost::signals2::connection ConnectOther(signalchange_t::slot_type slot)
Connect signal to slot to other stuff.
ScopeNumber< uint32_t > waitafterenqueuestorage
Time (in milliseconds) to wait after the PipelineController has enqueued the image to the storage que...
Definition: Framescan.h:494
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
void Load(const wptree &pt) override
Load from boost property tree.
Definition: Framescan.cpp:644
void Save(wptree &pt) const override
Save to boost property tree.
Definition: Framescan.cpp:287
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:491
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Framescan.cpp:671
void ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot) override
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:501
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:321
ScopeNumber< bool > squarepixels
pixels are square (thus FOV rectangular) when true, when false pixels are rectangular (thus FOV squar...
Definition: Framescan.h:77
ScopeNumber< double > scannerdelay
compensate, by waiting, the time that scanners lag behind the command voltage, in microseconds ...
Definition: IO.h:782
ScopeNumber< double > xcutoff
Cutoff fraction at beginning of line, total pixels per line = xres * (1 + xcutoff + xretrace) ...
Definition: Framescan.h:253
void LoadFromPreset(const std::wstring &_name, Daq &_daq) override
Load parameters from a preset.
Definition: Framescan.cpp:714
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Definition: Framescan.cpp:303
void Load(const wptree &pt) override
Load from boost property tree.
Definition: Framescan.cpp:517
void SaveToPreset(const std::wstring &_name, const Daq &_daq) override
Save parameters into a preset.
Definition: Framescan.cpp:557
void Load(const wptree &pt) override
load parameters from a boost::property_tree
Definition: Framescan.cpp:66
void LoadFromPreset(const std::wstring &_name, Daq &_daq) override
Load parameters from a preset.
Definition: Framescan.cpp:574
ScopeNumber< double > yretrace
Cutoff fraction for retrace at end of frame.
Definition: Framescan.h:454
virtual void ConnectMicronPerPixelUpdate(signalchange_t::slot_type _slot)
Connect a slot that is called if something in the ScannerVector changes that renders a recalculation ...
Definition: Framescan.cpp:211
ScopeNumber< double > xaspectratio
aspect ratio in x direction
Definition: Framescan.h:71
ScopeNumber< double > xretrace
Cutoff fraction for retrace at end of line.
Definition: Framescan.h:225