ODIN
seqgradtrapez.h
1 /***************************************************************************
2  seqgradtrapez.h - description
3  -------------------
4  begin : Tue Apr 27 2004
5  copyright : (C) 2000-2021 by Thies H. Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef SEQGRADTRAPEZ_H
19 #define SEQGRADTRAPEZ_H
20 
21 #include <odinseq/seqgradchanlist.h>
22 #include <odinseq/seqgradchanparallel.h>
23 #include <odinseq/seqgradramp.h>
24 #include <odinseq/seqdriver.h>
25 
26 
28 
29 
34 class SeqGradTrapezDriver : public SeqDriverBase {
35 
36  public:
38  virtual ~SeqGradTrapezDriver() {}
39 
51  virtual bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing) = 0;
52 
53  virtual float get_onramp_integral (double tmin, double tmax) const = 0;
54  virtual float get_offramp_integral(double tmin, double tmax) const = 0;
55 
56  virtual const fvector& get_onramp() const = 0;
57  virtual const fvector& get_offramp() const = 0;
58 
59  virtual SeqGradChanList get_driverchanlist() = 0;
60 
61  virtual bool check_ramptype(rampType type) const = 0;
62 
63  virtual SeqGradTrapezDriver* clone_driver() const = 0;
64 };
65 
67 
73 
74  public:
75 
77 
79 
81 
82 
83  // overloading virtual functions from SeqGradTrapezDriver
84  bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing);
85  float get_onramp_integral (double tmin, double tmax) const {return onramp_cache. get_integral(tmin,tmax);}
86  float get_offramp_integral(double tmin, double tmax) const {return offramp_cache.get_integral(tmin,tmax);}
87  const fvector& get_onramp() const {return onramp_cache.get_wave();}
88  const fvector& get_offramp() const {return offramp_cache.get_wave();}
89  SeqGradChanList get_driverchanlist();
90  bool check_ramptype(rampType type) const {return true;}
91  SeqGradTrapezDriver* clone_driver() const {return new SeqGradTrapezDefault(*this);}
92 
93  // overloading virtual functions from SeqDriverBase
94  odinPlatform get_driverplatform() const {return standalone;}
95 
96  private:
97  // overwriting virtual functions from SeqClass
98  bool prep();
99 
100  // overloading virtual function from SeqTreeObj
101  STD_string get_properties() const;
102 
103  // overloading virtual functions from SeqGradInterface
104  SeqGradInterface& set_strength(float gradstrength);
105  SeqGradInterface& invert_strength();
106  float get_strength() const {return onramp_cache.get_strength();}
107  double get_gradduration() const;
108  SeqGradInterface& set_gradrotmatrix(const RotMatrix& matrix);
109 
110 
111  // overloading virtual functions from SeqGradChan
112  STD_string get_grdpart(float matrixfactor) const {return graddriver->get_trapez_program(get_strength(),matrixfactor);}
113  SeqGradChan& get_subchan(double starttime, double endtime) const;
114  direction get_channel() const {return onramp_cache.get_channel();}
115  float get_integral() const;
116 
117  SeqGradRamp onramp_cache;
118  SeqGradRamp offramp_cache;
119 
120  double const_dur;
121  bool exclude_offramp;
122 
123 };
124 
125 
126 
128 
142 
143  public:
144 
157  SeqGradTrapez(const STD_string& object_label,direction gradchannel,
158  float gradstrength, double constgradduration, double timestep=0.01,
159  rampType type = linear, double minrampduration=0.0, float steepness=1.0);
160 
173  SeqGradTrapez(const STD_string& object_label,float gradintegral,
174  direction gradchannel, double constgradduration,
175  double timestep=0.01, rampType type = linear, double minrampduration=0.0, float steepness=1.0);
176 
177 
190  SeqGradTrapez(const STD_string& object_label,float gradintegral,
191  float gradstrength, direction gradchannel,
192  double timestep=0.01, rampType type = linear, double minrampduration=0.0, float steepness=1.0);
193 
194 
199 
203  SeqGradTrapez(const STD_string& object_label = "unnamedSeqGradTrapez");
204 
209 
210 
215 
219  double get_onramp_duration() const {return onrampdur;}
220 
221 
225  double get_constgrad_duration() const {return constdur;}
226 
227 
231  double get_offramp_duration() const {return offrampdur;}
232 
233 
237  float get_onramp_integral(double tmin, double tmax) const {return trapezdriver->get_onramp_integral(tmin,tmax);}
238 
243 
247  float get_constgrad_integral() const {return constdur*trapezstrength;}
248 
252  float get_offramp_integral(double tmin, double tmax) const {return trapezdriver->get_offramp_integral(tmin,tmax);}
253 
258 
262  SeqGradTrapez& set_integral(float gradintegral);
263 
267  float get_integral() const;
268 
272  unsigned int get_onramp_npts() const;
273 
277  unsigned int get_const_npts() const;
278 
282  unsigned int get_offramp_npts() const;
283 
287  unsigned int get_npts() const;
288 
289 
293  fvector get_onramp() const {return trapezdriver->get_onramp();}
294 
298  fvector get_offramp() const {return trapezdriver->get_offramp();}
299 
304 
308  double get_timestep() const {return dt;}
309 
313  rampType get_ramptype() const {return rampMode;}
314 
319 
320 
321  // overloading virtual function from SeqGradInterface
322  float get_strength() const {return trapezstrength;}
323  double get_gradduration() const {return get_onramp_duration()+get_constgrad_duration()+get_offramp_duration();} // override result of SeqGradChanList which may differ due to concatenating other SeqGradChans
324 
325 
326  private:
327  void common_init();
328 
329  void check_platform();
330  void update_driver();
331  void build_seq();
332 
333  static void get_ramps(const STD_string& label, float& rampintegral, double& rampondur, double& rampoffdur, float strength, double dwelltime, rampType ramptype, float steepness, double mindur);
334 
335 
336  mutable SeqDriverInterface<SeqGradTrapezDriver> trapezdriver;
337 
338  rampType rampMode;
339  double dt;
340  float steepnessfactor;
341  bool exclude_offramp_timing;
342 
343  direction trapezchannel;
344  double onrampdur;
345  double constdur;
346  double offrampdur;
347  float trapezstrength;
348 };
349 
351 
352 
360 
361  public:
362 
373  SeqGradTrapezParallel(const STD_string& object_label,
374  float gradintegral_read, float gradintegral_phase, float gradintegral_slice,
375  float maxgradstrength, double timestep=0.01,
376  rampType type = linear, double minrampduration=0.0);
377 
382 
386  SeqGradTrapezParallel(const STD_string& object_label = "unnamedSeqGradTrapezParallel");
387 
392 
393 
394  private:
395  void build_seq();
396 
397  SeqGradTrapez readgrad;
398  SeqGradTrapez phasegrad;
399  SeqGradTrapez slicegrad;
400 
401 
402 };
403 
408 #endif
Rotation Matrix.
Definition: geometry.h:67
virtual direction get_channel() const
float get_strength() const
Gradient Ramp.
Definition: seqgradramp.h:52
bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing)
virtual bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing)=0
3 simultaneous trapezoids
SeqGradTrapezParallel(const STD_string &object_label, float gradintegral_read, float gradintegral_phase, float gradintegral_slice, float maxgradstrength, double timestep=0.01, rampType type=linear, double minrampduration=0.0)
SeqGradTrapezParallel(const SeqGradTrapezParallel &sgtp)
SeqGradTrapezParallel & operator=(const SeqGradTrapezParallel &sgtp)
SeqGradTrapezParallel(const STD_string &object_label="unnamedSeqGradTrapezParallel")
Trapezoidal gradient.
SeqGradTrapez(const STD_string &object_label, direction gradchannel, float gradstrength, double constgradduration, double timestep=0.01, rampType type=linear, double minrampduration=0.0, float steepness=1.0)
fvector get_onramp() const
unsigned int get_npts() const
double get_offramp_duration() const
SeqGradTrapez(const STD_string &object_label, float gradintegral, direction gradchannel, double constgradduration, double timestep=0.01, rampType type=linear, double minrampduration=0.0, float steepness=1.0)
unsigned int get_onramp_npts() const
float get_integral() const
double get_constgrad_duration() const
rampType get_ramptype() const
SeqGradTrapez & set_integral(float gradintegral)
float get_onramp_integral(double tmin, double tmax) const
double get_onramp_duration() const
unsigned int get_offramp_npts() const
float get_strength() const
fvector get_offramp() const
SeqGradTrapez & set_constgrad_duration(double duration)
fvector get_trapezshape() const
unsigned int get_const_npts() const
double get_timestep() const
double get_gradduration() const
float get_offramp_integral() const
SeqGradTrapez & operator=(const SeqGradTrapez &sgt)
float get_offramp_integral(double tmin, double tmax) const
SeqGradTrapez(const STD_string &object_label="unnamedSeqGradTrapez")
SeqGradTrapez(const STD_string &object_label, float gradintegral, float gradstrength, direction gradchannel, double timestep=0.01, rampType type=linear, double minrampduration=0.0, float steepness=1.0)
SeqGradTrapez & exclude_offramp_from_timing(bool flag)
SeqGradTrapez(const SeqGradTrapez &sgt)
float get_constgrad_integral() const
float get_onramp_integral() const
const fvector & get_wave() const
Definition: seqgradwave.h:69
float get_integral(double tmin, double tmax) const
odinPlatform
Definition: system.h:39
direction
Definition: odinpara.h:41
rampType
Definition: seqgradramp.h:42