Scope
ScopeController.h
1 #pragma once
2 #include "helpers/ScopeButton.h"
3 #include "helpers/ScopeScanModeButton.h"
4 #include "helpers/ScopeNumber.h"
5 #include "parameters/Scope.h"
6 #include "ScopeDatatypes.h"
7 #include "BaseController.h"
8 #include "BaseController_p.h"
9 
10 // We need the type of the FPGAStatus struct for FPGAFIFOStatus here
11 #include "devices\fpga\FPGAPhotonCounter.h"
12 #include "devices\fpga\FPGADigitalDemultiplexer.h"
13 #include "devices\fpga\FPGAAnalogIntegrator.h"
14 #include "devices\fpga\FPGAAnalogDemultiplexer.h"
15 #include "devices\fpga\FPGANoiseOutput.h"
16 #include "devices\fpga\FPGAResonanceScanner.h"
17 #include "devices\fpga\FPGAResonanceScanner_NI5771.h"
18 
19 // Forward declarations
20 namespace scope {
21  template<class T> class ScopeDatatypeBase;
24  namespace gui {
25  class CChannelFrame;
26  class CHistogramFrame;
27  }
28 }
29 
30 namespace scope {
31 
46  : public BaseController<1, true> {
47 
48 protected:
50  class Impl;
51 
53  class ModeBasicImpl;
54 
56  class ModeLiveImpl;
57 
58 protected:
59  /*ScopeController(ScopeController& other); // we need this copyable for std::bind to work...
60  ScopeController& operator=(ScopeController& other); */
61 
63  Impl& GetImpl();
64 
66  Impl* const Pimpl() const;
67 
68 public:
70  struct FPUButtons {
73  ScopeButton LeftButton;
74  ScopeButton RightButton;
75  ScopeButton UpButton;
76  ScopeButton DownButton;
77  ScopeButton SetZeroButton;
79  };
80 
82  struct ScanModeButtons {
84  std::map<ScannerVectorTypeHelper::Mode, ScopeScanModeButton> map;
85 
88  map.emplace(ScannerVectorTypeHelper::Mode::Bidirectional, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::Bidirectional));
89  map.emplace(ScannerVectorTypeHelper::Mode::LineStraight, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::LineStraight));
90  map.emplace(ScannerVectorTypeHelper::Mode::Planehopper, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::Planehopper));
91  map.emplace(ScannerVectorTypeHelper::Mode::ResonanceBiDi, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::ResonanceBiDi));
92  map.emplace(ScannerVectorTypeHelper::Mode::ResonanceHopper, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::ResonanceHopper));
93  map.emplace(ScannerVectorTypeHelper::Mode::Sawtooth, ScopeScanModeButton(ScannerVectorTypeHelper::Mode::Sawtooth));
94  }
95  };
96 
100 
104 
111  static ScopeButton StartSingleButton;
112  static ScopeButton StartLiveButton;
113  static ScopeButton StartStackButton;
114  static ScopeButton StartTimeseriesButton;
115  static ScopeButton StartBehaviorButton;
116  static ScopeButton StopButton;
117  static ScopeButton QuitButton;
118  static ScopeButton StackStartHereButton;
119  static ScopeButton StackStopHereButton;
120 
122  static std::array<ScopeNumber<double>, SCOPE_NAREAS> SingleFrameProgress;
123 
126 
128  static std::array<ScopeNumber<double>, SCOPE_NAREAS> FrameCounter;
129 
132 
135 
138 
141 
143  static std::array<FPUButtons, SCOPE_NAREAS> FPU;
144 
146  static std::array<ScanModeButtons, SCOPE_NAREAS> ScanMode;
149 public:
151  ScopeController(void);
152 
153  ~ScopeController(void);
154 
158  void Version();
159 
161  std::wstring CurrentConfigFile() const;
162 
165  void PrepareQuit();
166 
168  bool LoadParameters(const std::wstring& filepath);
169 
171  bool SaveParameters(const std::wstring& filepath);
172 
174  void ZeroGalvoOutputs();
175 
177  void OpenCloseShutter(const uint32_t& _area, const bool& _open);
178 
180  bool GetShutterState(const uint32_t& _area) const;
181 
183  void TurnOnOffSwitchResonance(const uint32_t& _area, const bool& _on);
184 
186  bool GetSwitchResonanceState(const uint32_t& _area) const;
187 
190  void AttachFrame(gui::CChannelFrame* const cframe);
191  void DetachFrame(gui::CChannelFrame* const cframe);
192  void AttachFrame(gui::CHistogramFrame* const hframe);
193  bool HistogramAlreadyAttached(const uint32_t& _area);
194  void DetachFrame(gui::CHistogramFrame* const hframe);
200 
202  void SetHistogramLimits(const uint32_t& _area, const uint32_t& _channel, const uint16_t& _lower, const uint16_t& _upper);
203 
205  void SavePreset(const uint32_t& _area, const CString& _name);
206 
208  void SelectPreset(const uint32_t& _area, const size_t& _n);
209 
213  void RegisterScanmodeCallback(std::function<void(const uint32_t&, const ScannerVectorType&)> _callback);
214 };
215 
216 }
Main controller of microscope hardware and acquisition, also interface to the GUI.
std::wstring CurrentConfigFile() const
static ScopeButton StageZeroButton
Button to zero main stage coordinates.
static ScopeNumber< double > TrialCounter
Updated from ScopeControllerImpl::RunBehavior, connected to edit control in CBehaviorSettingsPage.
static std::array< ScopeNumber< double >, SCOPE_NAREAS > FrameCounter
Updated from PipelineControllerImpl::Run, connected to progress indicator in CTimeSeriesSettingsPage ...
The master parameters class.
Definition: Scope.h:204
bool GetShutterState(const uint32_t &_area) const
Current state of the shutter.
void SetHistogramLimits(const uint32_t &_area, const uint32_t &_channel, const uint16_t &_lower, const uint16_t &_upper)
Sets display limits for a certain area and channel.
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
Manages the display of images.
Definition: ChannelFrame.h:26
bool GetSwitchResonanceState(const uint32_t &_area) const
Current state of the resonance scanner relay.
Keeps the buttons controlling scan modes together.
std::map< ScannerVectorTypeHelper::Mode, ScopeScanModeButton > map
A map with buttons for all scan modes.
void RegisterScanmodeCallback(std::function< void(const uint32_t &, const ScannerVectorType &)> _callback)
Registers a function to call when scanmode is changed.
Impl *const Pimpl() const
In here all declarations for all kinds of datatypes Scope needs.
static ScopeNumber< double > PlaneCounter
Updated from ScopeControllerImpl::RunStack, connected to progress indicator in CStackSettingsPage.
bool LoadParameters(const std::wstring &filepath)
Load a complete ScopeParameters set from disk.
Manages the display of histograms.
static ScopeNumber< double > TotalTime
Updated from e.g.
Keeps the buttons controlling FPU movements together.
static std::array< ScanModeButtons, SCOPE_NAREAS > ScanMode
Buttons for switching the scan mode.
Impl & GetImpl()
static local variable for singleton is in there.
The implementation class of the ScopeController.
void SelectPreset(const uint32_t &_area, const size_t &_n)
Writes the parameters of the selected preset into daq and svframe.
void ZeroGalvoOutputs()
Zeros galvo outputs.
Describes the scanner vector type.
bool SaveParameters(const std::wstring &filepath)
Store the current complete ScopeParameters set to disk.
Mimicks a button, glue between the GUI and controller, used in ScopeController.
Definition: ScopeButton.h:7
void SavePreset(const uint32_t &_area, const CString &_name)
Saves the current values as a preset with name _name.
void OpenCloseShutter(const uint32_t &_area, const bool &_open)
Opens/closes the shutter.
static std::array< FPUButtons, SCOPE_NAREAS > FPU
Buttons for FPU nudge.
void SaveCurrentWindowPositions()
Saves current positions of windows by adding frames to WindowCollection of ScopeController::GuiParame...
static std::array< ScopeNumber< double >, SCOPE_NAREAS > SingleFrameProgress
Updated from PipelineControllerImpl::Run.
Button type for scan mode switching.
ScopeController(void)
Injects pimpl of ScopeController into BaseControllers pimpl (saves memory, since pointer is reused fo...
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
Base class for all controllers.
void TurnOnOffSwitchResonance(const uint32_t &_area, const bool &_on)
Turns the resonance scanner relay on and off.
void Version()
Print the current ScopeController version to debug console.
static ScopeNumber< bool > ReadOnlyWhileScanning
Set to true while scanning, GUI elements can connect to this to disable buttons and controls (that ar...
static ScopeNumber< double > RepeatCounter
Updated from ScopeControllerImpl::RunTimeseries, connected to progress indicator in CTimeSeriesSettin...
void PrepareQuit()
Called by CMainDialogFrame::QuitApplication.
The implementation class of the ScopeController.