2 #include "parameters/Runstates.h"
3 #include "helpers/ScopeException.h"
13 : spacing(1, 0.1, 50, L
"Spacing_um")
14 , zdevicetype(ZDeviceHelper::ZStage, L
"ZDeviceType")
15 , overalltime(1, 1, 2000, L
"OverallTime_s") {
18 for (
auto& s : startat ) {
22 for (
auto& s : stopat ) {
30 uint32_t maxplanes = 0;
31 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
33 uint32_t areaplanes =
static_cast<uint32_t
>(floor(
Range(a) /
spacing()) + 1);
34 maxplanes = (areaplanes > maxplanes)?areaplanes:maxplanes;
40 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
42 double c = stopat[a].pockels()*exp(-l*stopat[a].position());
44 uint32_t areaplanes =
static_cast<uint32_t
>(floor(
Range(a) /
spacing()) + 1);
45 DBOUT(L
"Stack::UpdatePlanes area " << a << L
" lambda: " <<
Lambda(a) << L
" c: " << c);
49 for ( ; p < areaplanes ; p++ ) {
54 for ( ; p < maxplanes ; p++ ) {
63 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
65 stopat[a].position.Set(0,
true,
false);
66 stopat[a].pockels.Set(0,
true,
false);
67 startat[a].position.Set(0,
true,
false);
68 startat[a].pockels.Set(0,
true,
false);
74 return abs(stopat[_area].position() - startat[_area].position());
78 return (stopat[_area].position()>startat[_area].position())?
spacing():-1.0*
spacing();
82 if ( (stopat[_area].pockels() == 0) || (startat[_area].pockels() == 0) )
84 if ( startat[_area].position() == stopat[_area].position() )
86 return log(startat[_area].pockels()/stopat[_area].pockels()) / (startat[_area].position()-stopat[_area].position());
92 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
93 startat[a].Load(pt.get_child(boost::str(boost::wformat(L
"startat%d") % a)));
94 stopat[a].Load(pt.get_child(boost::str(boost::wformat(L
"stopat%d") % a)));
104 std::array<wptree, SCOPE_NAREAS> ptstartat;
105 std::array<wptree, SCOPE_NAREAS> ptstopat;
106 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
107 startat[a].Save(ptstartat[a]);
108 pt.add_child(boost::str(boost::wformat(L
"startat%d") % a), ptstartat[a]);
109 stopat[a].Save(ptstopat[a]);
110 pt.add_child(boost::str(boost::wformat(L
"stopat%d") % a), ptstopat[a]);
118 bool enabler =
false;
120 if ( (_runstate.
t == RunStateHelper::Mode::Stopped) || (_runstate.
t == RunStateHelper::Mode::RunningContinuous) )
122 for (
auto& s : startat )
123 s.SetReadOnlyWhileScanning(_runstate);
124 for (
auto& s : stopat )
125 s.SetReadOnlyWhileScanning(_runstate);
130 Timeseries::Timeseries()
131 : triggerchannel(L
"/PXI-6259_0/PFI0", L
"Triggerchannel")
132 , triggered(false, false, true, L
"Triggered")
133 , alltriggered(false, false, true, L
"AllTriggered")
134 , repeats(1, 1, 100, L
"Repeats")
135 , betweenrepeats(5, 1, 600, L
"BetweenRepeats_s")
136 , overalltime(1, 1, 2000, L
"OverallTime_s") {
137 std::wostringstream stream;
139 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
141 stream << L
"Frames" << a;
144 stream << L
"Totaltimes_s" << a;
151 f.SetFromPropertyTree(pt);
153 t.SetFromPropertyTree(pt);
165 const wptree planetree = pt.get_child(boost::str(boost::wformat(L
"plane%d") % p));
167 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
169 plane.
Load(planetree.get_child(boost::str(boost::wformat(L
"area%d") % a)));
179 for (
const auto& f :
frames )
180 f.AddToPropertyTree(pt);
182 t.AddToPropertyTree(pt);
192 for (
const auto& p :
planes ) {
194 std::array<wptree, SCOPE_NAREAS> areatree;
196 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
197 p[a].Save(areatree[a]);
198 planetree.add_child(boost::str(boost::wformat(L
"area%d") % a), areatree[a]);
200 pt.add_child(boost::str(boost::wformat(L
"plane%d") % ip), planetree);
206 const bool enabler = (_runstate.
t==RunStateHelper::Mode::Stopped)?
true:
false;
208 f.SetRWState(enabler);
210 t.SetRWState(enabler);
221 , unlimited_repeats(true, false, true, L
"UnlimitedRepeats")
222 , repeats(1, 1, 10000, L
"Repeats")
223 , gateline(L
"PXI-6229/port0/line0", L
"GateLine") {
227 mode.SetFromPropertyTree(pt);
236 const wptree planetree = pt.get_child(boost::str(boost::wformat(L
"plane%d") % p));
238 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
240 plane.
Load(planetree.get_child(boost::str(boost::wformat(L
"area%d") % a)));
250 mode.AddToPropertyTree(pt);
256 for (
const auto& p :
planes ) {
258 std::array<wptree, SCOPE_NAREAS> areatree;
260 for ( uint32_t a = 0 ; a < SCOPE_NAREAS ; a++ ) {
261 p[a].Save(areatree[a]);
262 planetree.add_child(boost::str(boost::wformat(L
"area%d") % a), areatree[a]);
264 pt.add_child(boost::str(boost::wformat(L
"plane%d") % ip), planetree);
270 const bool enabler = (_runstate.
t==RunStateHelper::Mode::Stopped)?
true:
false;
271 mode.SetRWState(enabler);
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeNumber< bool > unlimited_repeats
Should acquisition go on until Stop pressed (true) or until repeats done (false)? ...
ScopeValue< ZDevice > zdevicetype
type of z device to use
void SetReadOnlyWhileScanning(const RunState &_runstate) override
set values that must not be changed to read-only during scanning.
void AddToPropertyTree(boost::property_tree::wptree &pt) const
Adds the value to a Boost property tree, using its name and value.
ScopeNumber< uint32_t > repeats
How often should the timeseries be repeated.
Parameters of a single plane for fast plane hopping/switching.
void Load(const wptree &pt) override
load parameters from a boost::property_tree
ScopeString triggerchannel
channel name for trigger input
std::array< ScopeNumber< uint32_t >, SCOPE_NAREAS > frames
number of frames in timeseries for each area
Base class for all Scope datatypes here, provides a uniform interface (and saves typing...).
ScopeNumber< double > overalltime
time in seconds for all timeseries
virtual void ResetPlanes()
Resets start/stop and all planes.
std::vector< std::array< PlaneProperties, SCOPE_NAREAS > > planes___
Vector with properties for every plane.
virtual double Increment(const uint32_t &_area)
distance between planes
ScopeNumber< double > spacing
Spacing between planes in microns.
This is the include file for standard system include files, or project specific include files that ar...
T::Mode t
the enum from the template class
ScopeNumber< uint32_t > repeats
How many repeats should be acquired if not unlimited_repeats?
void Save(wptree &pt) const override
save parameters into a boost:property_tree
How does the animal behavior trigger/gate acquisition?
virtual double Range(const uint32_t &_area)
total span of z stack
ScopeNumber< bool > triggered
the current/first repeat is triggered on triggerchannel
void Save(wptree &pt) const override
save parameters into a boost:property_tree
virtual void UpdatePlanes()
Updates planes with positions and pockels adjustment etc.
void Load(const wptree &pt) override
load parameters from a boost::property_tree
#define DBOUT(s)
A debug output to the debug console.
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.
ScopeNumber< double > overalltime
time in seconds for all timeseries
void Save(wptree &pt) const override
save parameters into a boost:property_tree
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
void SetRWState(const bool &_state)
Sets readonly/read-write state.
std::vector< std::array< PlaneProperties, SCOPE_NAREAS > > planes
vector with properties for all planes, for alternating planes on alternating repeats, one for each area
std::vector< std::array< PlaneProperties, SCOPE_NAREAS > > planes
vector with properties for all planes, for alternating planes on repeating timeseries, one for each area
ScopeNumber< double > betweenrepeats
Time in seconds between the beginning of one and beginning of the next timeseries.
void SetFromPropertyTree(const boost::property_tree::wptree &pt)
Set value from a Boost property, using its name as a key.
virtual double Lambda(const uint32_t &_area)
space constant for exponential pockels interpolation
ScopeNumber< bool > alltriggered
every repeat is triggered
ScopeString gateline
The DAQmx digital line for gating.
ScopeValue< BehaviorMode > mode
Which mode to use.
void Load(const wptree &pt) override
load parameters from a boost::property_tree