-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathZPiezo.h
130 lines (102 loc) · 4.86 KB
/
ZPiezo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* ZPiezo.h
*
* Created on: May 7, 2010
* Author: Nathan Clack <[email protected]>
*/
/*
* Copyright 2010 Howard Hughes Medical Institute.
* All rights reserved.
* Use is subject to Janelia Farm Research Campus Software Copyright 1.1
* license terms (http://license.janelia.org/license/jfrc_copyright_1_1.html).
*/
#pragma once
#include "DAQChannel.h"
#include "zpiezo.pb.h"
#include "object.h"
namespace fetch
{
bool operator==(const cfg::device::NIDAQZPiezo& a, const cfg::device::NIDAQZPiezo& b);
bool operator==(const cfg::device::SimulatedZPiezo& a, const cfg::device::SimulatedZPiezo& b);
bool operator==(const cfg::device::ZPiezo& a, const cfg::device::ZPiezo& b);
bool operator!=(const cfg::device::NIDAQZPiezo& a, const cfg::device::NIDAQZPiezo& b);
bool operator!=(const cfg::device::SimulatedZPiezo& a, const cfg::device::SimulatedZPiezo& b);
bool operator!=(const cfg::device::ZPiezo& a, const cfg::device::ZPiezo& b);
namespace device
{
class IZPiezo
{
public:
virtual void computeConstWaveform(float64 z_um, float64 *data, int flyback, int n) = 0;
virtual void computeRampWaveform(float64 z_um, float64 step_um, float64 *data, int flyback, int n) = 0;
virtual IDAQPhysicalChannel* physicalChannel() = 0;
virtual int moveTo(f64 z_um) = 0; // should return 1 on success, and 0 on error
};
template<class T>
class ZPiezoBase:public IZPiezo,public IConfigurableDevice<T>
{
public:
ZPiezoBase(Agent *agent) : IConfigurableDevice<T>(agent) {}
ZPiezoBase(Agent *agent, Config *cfg) :IConfigurableDevice<T>(agent,cfg) {}
};
class NIDAQZPiezo:public ZPiezoBase<cfg::device::NIDAQZPiezo>
{
NIDAQChannel daq;
IDAQPhysicalChannel _ao;
public:
NIDAQZPiezo(Agent *agent);
NIDAQZPiezo(Agent *agent, Config *cfg);
unsigned int on_attach();
unsigned int on_detach();
virtual void _set_config(Config IN *cfg) {_ao.set(cfg->channel());}
virtual void _set_config(const Config& cfg) {*_config=cfg; _set_config(_config); }
virtual void computeConstWaveform(float64 z_um, float64 *data, int flyback, int n);
virtual void computeRampWaveform(float64 z_um, float64 step_um, float64 *data, int flyback, int n);
virtual IDAQPhysicalChannel* physicalChannel() {return &_ao;}
virtual int moveTo(f64 z_um); // should return 1 on success, and 0 on error
};
class SimulatedZPiezo:public ZPiezoBase<cfg::device::SimulatedZPiezo>
{
SimulatedDAQChannel _chan;
IDAQPhysicalChannel _ao;
public:
SimulatedZPiezo(Agent *agent);
SimulatedZPiezo(Agent *agent, Config *cfg);
unsigned int on_attach() {return 0;}
unsigned int on_detach() {return 0;}
virtual void computeConstWaveform(float64 z_um, float64 *data, int flyback, int n);
virtual void computeRampWaveform(float64 z_um, float64 step_um, float64 *data, int flyback, int n);
virtual IDAQPhysicalChannel* physicalChannel() {return &_ao;}
void getScanRange(f64 *min_um,f64 *max_um, f64 *step_um);
virtual int moveTo(f64 z_um) {return 1; /* success */}
};
class ZPiezo:public ZPiezoBase<cfg::device::ZPiezo>
{
NIDAQZPiezo *_nidaq;
SimulatedZPiezo *_simulated;
IDevice *_idevice;
IZPiezo *_izpiezo;
public:
ZPiezo(Agent *agent);
ZPiezo(Agent *agent, Config *cfg);
~ZPiezo();
virtual unsigned int on_attach() {return _idevice->on_attach();}
virtual unsigned int on_detach() {return _idevice->on_detach();}
void _set_config( Config IN *cfg );
void _set_config( const Config &cfg );
void setKind(Config::ZPiezoType kind);
virtual void computeConstWaveform(float64 z_um, float64 *data, int flyback, int n) {_izpiezo->computeConstWaveform(z_um,data,flyback,n);}
virtual void computeRampWaveform(float64 z_um, float64 step_um, float64 *data, int flyback, int n) {_izpiezo->computeRampWaveform(z_um,step_um,data,flyback,n);}
virtual void computeRampWaveform(float64 z_um, float64 *data, int flyback, int n) {_izpiezo->computeRampWaveform(z_um,_config->um_step(),data,flyback,n);}
virtual IDAQPhysicalChannel* physicalChannel() {return _izpiezo->physicalChannel();}
void getScanRange(f64 *min_um,f64 *max_um, f64 *step_um);
virtual f64 getMin() {return get_config().um_min();}
virtual f64 getMax() {return get_config().um_max();}
virtual f64 getStep() {return get_config().um_step();}
virtual void setMin(f64 v) {Config c = get_config(); c.set_um_min(v); set_config_nowait(c);}
virtual void setMax(f64 v) {Config c = get_config(); c.set_um_max(v); set_config_nowait(c);}
virtual void setStep(f64 v) {Config c = get_config(); c.set_um_step(v); set_config_nowait(c);}
virtual int moveTo(f64 z_um) {return _izpiezo->moveTo(z_um);}
};
}
}