2 #include "parameters/Scope.h"
3 #include "helpers/ScopeException.h"
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") {
43 const bool enabler = (_runstate.
t==RunStateHelper::Mode::Stopped)?
true:
false;
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")
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")
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") {
86 , masterarea(_a.masterarea)
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) {
117 micronperpixelx = _a.micronperpixelx;
118 micronperpixely = _a.micronperpixely;
135 assert( (
isslave()==
true && (_masterarea!=
nullptr)) || (
isslave()==
false) );
157 }
catch (std::bad_cast) {
ScopeExceptionHandler(
"parameters::Area::FrameSaw",
true,
true,
true,
true); }
163 }
catch (std::bad_cast) {
ScopeExceptionHandler(
"parameters::Area::FrameResonance",
true,
true,
true,
true); }
169 }
catch (std::bad_cast) {
ScopeExceptionHandler(
"parameters::Area::FrameBiDi",
true,
true,
true,
true); }
175 }
catch (std::bad_cast) {
ScopeExceptionHandler(
"parameters::Area::FrameHopper",
true,
true,
true,
true); }
190 daq.
Load(pt.get_child(L
"daq"));
196 fpuzstage.Load(pt.get_child(L
"fpuzstage"));
221 pt.add_child(L
"daq", ptdaq);
225 sv.second->Save(ptsv);
230 pt.add_child(L
"fpuzstage", ptfpuzstage);
232 pt.add_child(L
"fpuxystage", ptfpuxystage);
236 const bool enabler = (_runstate.
t==RunStateHelper::Mode::Stopped)?
true:
false;
238 fpuxystage.SetReadOnlyWhileScanning(_runstate);
239 fpuzstage.SetReadOnlyWhileScanning(_runstate);
242 sv.second->SetReadOnlyWhileScanning(_runstate);
320 DBOUT(L
"Area::UpdateFastZCalibration");
323 sv.second->fastz.SetLimits(
fpuzstage.calibration.begin()->first, (--
fpuzstage.calibration.end())->first);
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")
358 , requested_mode(
DaqModeHelper::continuous, L
"RequestedMode") {
362 scannertype.SetRWState(
false);
364 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
366 if ( ThisIsSlaveArea(a) )
367 areas[a].reset(
new Area(a,
true, areas[0].
get()));
369 areas[a].reset(
new Area(a,
false,
nullptr));
380 UpdateTotaltimeFromFrames();
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){
406 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
408 if ( ThisIsSlaveArea(a) ) {
415 areas[a]->SetMasterArea(
nullptr);
429 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
431 if ( ThisIsSlaveArea(a) ) {
438 areas[a]->SetMasterArea(
nullptr);
460 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
471 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ )
480 std::locale old_locale;
481 std::locale utf8_locale(old_locale,
new std::codecvt_utf8<wchar_t, 0x10ffff, std::codecvt_mode::consume_header>);
484 CW2A tmp(filename.c_str());
485 read_xml(std::string(tmp), pt, 0, utf8_locale);
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");
501 stack.
Load(pt.get_child(L
"scope.stack"));
504 stage.Load(pt.get_child(L
"scope.stage"));
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)));
516 std::array<wptree, SCOPE_NAREAS> ptareas;
523 wptree ptstimulation;
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]);
542 pt.add_child(L
"scope.storage", ptstorage);
544 pt.add_child(L
"scope.stack", ptstack);
546 pt.add_child(L
"scope.timeseries", pttimeseries);
548 pt.add_child(L
"scope.behavior", ptbehavior);
550 pt.add_child(L
"scope.stage", ptstage);
552 pt.add_child(L
"scope.stimulation", ptstimulation);
554 pt.add_child(L
"scope.frames", ptframes);
556 std::locale old_locale;
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)>);
560 CW2A tmp(filename.c_str());
561 write_xml(std::string(tmp), pt, utf8_locale);
567 for (
auto& a :
areas )
568 a->SetReadOnlyWhileScanning(_runstate);
572 stage.SetReadOnlyWhileScanning(_runstate);
Scope & operator=(const Scope &_scope)
Supply assignment operator because of unique_ptr
(does deep copy of Areas)
void Save(wptree &pt) const override
save parameters into a boost:property_tree
std::vector< boost::signals2::connection > connection_collector
You can put connections between ScopeValues in different classes in here.
Parameters for a whole area (includes a daq and a fpu)
void Save(wptree &pt) const override
save parameters into a boost:property_tree
void Load(const wptree &pt) override
load parameters from a boost::property_tree
void Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeNumber< double > ontime
on time of one stimulation pulse
ScopeString commontrigger
The trigger channel which is the internal common master trigger for all devices.
ScopeNumber< double > offtime
off time after stimulation pulse
ScopeNumber< double > masterfovsizey
The same for the y direction.
void CopyFromMasterArea()
Copies parts of the ScannerVectorParameters from the master area's.
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...
Area * masterarea
const pointer to the master area parameters (provided in the constructor through parametes::Scope) ...
virtual void DeletePreset(const std::wstring &_name)
Delete preset in currentframe.
ScopeNumber< double > pixeltime
pixel dwell time in microseconds, this is also the analog out sampling interval
The master parameters class.
Simple exception class for Scope.
ScopeString date
current date
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
std::map< ScannerVectorTypeHelper::Mode, std::unique_ptr< ScannerVectorFrameBasic > > scannervectorframesmap
This map contains all ScannerVectors that are supported by the kind of scanner.
virtual void UpdateFramesFromTotaltime()
Updates number of frames from choosen duration and framerate.
virtual void LoadFromPreset(const std::wstring &_name)
Load from preset in currentframe.
Parameters for a ScannerVectorFrameBiDi.
Stack stack
the StackParameters
virtual uint32_t TotalPixelsAllChannels() const
total number of pixels summed over all channels
WindowCollection frames
The parameters for windows on the screen.
virtual void InitializeConnections()
Helper for constructors and assignment to connect internal ScopeValues (as the connections in ScopeVa...
ScopeString comment
a comment, e.g.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
std::array< std::unique_ptr< Area >, SCOPE_NAREAS > areas
holds AreaParameters for all areas.
virtual void UpdateTotaltimeFromFrames()
Updates durations of timeseries from choosen frames and framerate.
ScopeNumber< uint32_t > repeats
How often should the timeseries be repeated.
Parameters for a ScannerVectorFrameResonance.
virtual double FrameTime() const
Time per frame in seconds.
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeString channel
digital output channel
ScopeNumber< double > xaspectratio
aspect ratio in x direction
void SetMasterArea(Area *const _masterarea)
(Re)set the pointer to the master area e.g.
ScopeNumber< bool > enable
stimulation enabled/disabled
SCOPE_XYZCONTROL_T stage
the parameters for the xyz stage (set type in ScopeDefines.h)
virtual void CalculateResolution()
Calculates the x resolution from the x aspect ratio and the y resolution from the y aspect ratio...
virtual double LineTime() const
Time per line in seconds.
ScopeNumber< double > onset
onset of stimulation
ScopeNumber< double > framerate
Frame repetition rate in Hertz.
ScopeNumber< uint32_t > xres
x resolution of the image (linewidth)
void Load(const std::wstring &filename)
Load all from file.
void Load(const wptree &pt) override
load parameters from a boost::property_tree
std::array< ScopeNumber< uint32_t >, SCOPE_NAREAS > frames
number of frames in timeseries for each area
ScopeNumber< double > yaspectratio
aspect ratio in y direction
ScopeNumber< double > duration
total duration of stimulation
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
Parameters for a ScannerVectorFramePlaneHopper.
T SetWithLimits(const T &v, const T &ll, const T &ul)
Sets new value and new limits at the same time.
ScopeNumber< double > frametime
Time per frame in seconds.
Timeseries timeseries
the TimeseriesParameters
Behavior behavior
the BehaviorParameters
Storage storage
the StorageParameters
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
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.
T::Mode t
the enum from the template class
ScopeNumber< uint32_t > histrange
Histogram range for the areas.
ScopeValue< DaqMode > requested_mode
requested acquisition mode (see DaqModeHelper)
Describes the data acquisiton mode.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
ScopeNumber< double > basemicronperpixelx
Base scale in x direction for 256x256 pixels at zoom 1 and the (maxoutput-minoutput) range set in Daq...
virtual void SaveToPreset(const std::wstring &_name)
Save to preset in currentframe.
std::wstring GetCurrentDateString()
ScopeString scopecommit
Current version (git commit hash) of Scope.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Daq daq
the DaqParameters for this area
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
void Load(const wptree &pt) override
load parameters from a boost::property_tree
void Load(const wptree &pt) override
load parameters from a boost::property_tree
#define DBOUT(s)
A debug output to the debug console.
void Save(const std::wstring &filename) const
Save all to file.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
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
ScannerVectorFrameResonance & FrameResonance() const
pointer to the ScannerVectorFrameResonance if implemented or throwing an exception! ...
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Parameters for a ScannerVectorFrameSaw.
ScopeNumber< double > basemicronperpixely
Base scale in y direction for 256x256 pixels at zoom 1 and the (maxoutput-minoutput) range set in Daq...
virtual void CalculateMicronPerPixel()
Current scale calculated from micronperpixelx with the resolution set in currentframe.
ScannerVectorFramePlaneHopper & FrameHopper() const
pointer to the ScannerVectorFramePlaneHopper if implemented or throwing an exception! ...
ScopeNumber< double > masterfovsizex
Size of the maximally reachable field of view.
std::unique_ptr< Inputs > inputs
the input parameters
virtual void ChangeScanMode()
Force update of rates etc.
ScopeNumber< double > linerate
Line repetition rate in Hertz.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
std::array< ScopeNumber< double >, SCOPE_NAREAS > totaltimes
total acquisition time for each area
Describes the scanner vector type.
void Save(wptree &pt) const override
save parameters into a boost:property_tree
Area & operator=(const Area &v)
Assignment (deep copy because of the pointers in the map)
ScannerVectorFrameSaw & FrameSaw() const
pointer to the ScannerVectorFrameSaw if implemented or throwing an exception!
ScopeString time
current time
ScopeValue< RunState > run_state
current RunState
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.
Parameters for a ScannerVectorFrameBasic.
ScopeNumber< double > zoom
current zoom factor (from 1 to 20).
ScannerVectorFrameBasic & Currentframe() const
pointer to the current parameters::frame.
ScopeNumber< uint32_t > area
the number of this area
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeString timingsource
timing source.
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
ScannerVectorFrameBiDi & FrameBiDi() const
pointer to the ScannerVectorFrameBiDi if implemented or throwing an exception!
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.
ScopeNumber< uint32_t > yres
y resolution of the image (lines)
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
SCOPE_FPUZCONTROL_T fpuzstage
the fast z stage parameters for this FPU (set type in ScopeDefines.h)
ScopeNumber< bool > startinputsfirst
true: start inputs first, then outputs with output of area 0 as last, so it (e.g. ...
virtual double XOffsetInMicron() const
Gives the current framescan X offset in micrometers.
Describes the actual state of the scope.
virtual void UpdateRates()
Updates framerate, frametime, and linerate.
ScopeValue< ScannerType > scannertype
Type of scanner in the microscope.
ScopeValue< ScannerVectorType > scanmode
the choosen scanner vector type
Stimulation stimulation
the StimulationParameters
void Load(const wptree &pt) override
load parameters from a boost::property_tree
virtual double YOffsetInMicron() const
Gives the current framescan Y offset in micrometers.
ScopeNumber< bool > isslave
true if this area is a slave area (for an n-beam system)
void Load(const wptree &pt) override
load parameters from a boost::property_tree
SCOPE_FPUXYCONTROL_T fpuxystage
the xy stage parameters for this FPU (set type in ScopeDefines.h)
std::wstring GetCurrentTimeString(const bool &_filenamecompatible)
Area(const uint32_t &_area=0, const bool &_isslave=false, Area *const _masterarea=nullptr)