Scope
FPUController.cpp
1 #include "StdAfx.h"
2 #include "FPUController.h"
3 #include "ScopeDatatypes.h"
4 
5 namespace scope {
6 
8  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
9  theXYStages[a] = std::unique_ptr<SCOPE_FPUXYCONTROL_T>(new SCOPE_FPUXYCONTROL_T());
10  stepsizes[a] = scope_controller.GuiParameters.areas[a]->fpuxystage.buttonstepsize();
11  scope_controller.GuiParameters.areas[a]->fpuxystage.xpos.ConnectOther(std::bind(&FPUController::MoveAbsolute, this, a));
12  scope_controller.GuiParameters.areas[a]->fpuxystage.ypos.ConnectOther(std::bind(&FPUController::MoveAbsolute, this, a));
13  scope_controller.FPU[a].LeftButton.Connect(std::bind(&FPUController::MoveRelative, this, a, FPUMoveDirection(left)));
14  scope_controller.FPU[a].RightButton.Connect(std::bind(&FPUController::MoveRelative, this, a, FPUMoveDirection(right)));
15  scope_controller.FPU[a].UpButton.Connect(std::bind(&FPUController::MoveRelative, this, a, FPUMoveDirection(up)));
16  scope_controller.FPU[a].DownButton.Connect(std::bind(&FPUController::MoveRelative, this, a, FPUMoveDirection(down)));
17  scope_controller.FPU[a].SetZeroButton.Connect(std::bind(&FPUController::SetXYZero, this, a));
18  }
19 }
20 
22  for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
23  theXYStages[a]->Initialize(_params.areas[a]->fpuxystage);
24 }
25 
26 void FPUController::MoveAbsolute(const uint32_t& _area) {
27  DBOUT(L"FPUController::MoveAbsolute");
28  const double newx = scope_controller.GuiParameters.areas[_area]->fpuxystage.xpos();
29  const double newy = scope_controller.GuiParameters.areas[_area]->fpuxystage.ypos();
30  theXYStages[_area]->MoveAbsolute(newx, newy);
31 }
32 
33 void FPUController::MoveRelative(const uint32_t& _area, const FPUMoveDirection& _dir) {
34  DBOUT(L"FPUController::MoveRelative direction " << _dir);
35  switch (_dir) {
36  case left:
37  theXYStages[_area]->MoveRelative(-stepsizes[_area], 0);
38  break;
39  case right:
40  theXYStages[_area]->MoveRelative(stepsizes[_area], 0);
41  break;
42  case up:
43  theXYStages[_area]->MoveRelative(0, -stepsizes[_area]);
44  break;
45  case down:
46  theXYStages[_area]->MoveRelative(0, stepsizes[_area]);
47  }
48 }
49 
50 void FPUController::SetXYZero(const uint32_t& _area) {
51  int ret = ::MessageBox(NULL, L"Do you really want to set the current FPU stage position as zero?", L"Are you sure?", MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2 | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
52  if ( ret == IDYES )
53  theXYStages[_area]->SetZero();
54 }
55 
56 }
std::array< double, SCOPE_NAREAS > stepsizes
step size for a relative movement
Definition: FPUController.h:19
The master parameters class.
Definition: Scope.h:204
void Initialize(const parameters::Scope &_params)
Initialize the FPU's hardware.
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
Definition: Scope.h:231
void MoveAbsolute(const uint32_t &_area)
Move to an absolute position given by the scope_controller's GuiParameters.
This is the include file for standard system include files, or project specific include files that ar...
In here all declarations for all kinds of datatypes Scope needs.
#define DBOUT(s)
A debug output to the debug console.
Definition: helpers.h:153
void MoveRelative(const uint32_t &_area, const FPUMoveDirection &_dir)
Move one stepsize relative to the current position.
void SetXYZero(const uint32_t &_area)
Set the current xy position of the FPU as zero.
FPUController()
Create XYControls and ETLs and connect buttons.
static std::array< FPUButtons, SCOPE_NAREAS > FPU
Buttons for FPU nudge.
static parameters::Scope GuiParameters
The complete pseudo-global parameter set of the microscope.
std::array< std::unique_ptr< SCOPE_FPUXYCONTROL_T >, SCOPE_NAREAS > theXYStages
for xy movement of FPU stages
Definition: FPUController.h:26
ScopeController scope_controller
our ScopeController
Definition: FPUController.h:22