00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SEQGRADTRAPEZ_H
00019 #define SEQGRADTRAPEZ_H
00020
00021 #include <odinseq/seqgradchanlist.h>
00022 #include <odinseq/seqgradchanparallel.h>
00023 #include <odinseq/seqgradramp.h>
00024 #include <odinseq/seqdriver.h>
00025
00026
00028
00029
00034 class SeqGradTrapezDriver : public SeqDriverBase {
00035
00036 public:
00037 SeqGradTrapezDriver() {}
00038 virtual ~SeqGradTrapezDriver() {}
00039
00051 virtual bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing) = 0;
00052
00053 virtual float get_onramp_integral (double tmin, double tmax) const = 0;
00054 virtual float get_offramp_integral(double tmin, double tmax) const = 0;
00055
00056 virtual const fvector& get_onramp() const = 0;
00057 virtual const fvector& get_offramp() const = 0;
00058
00059 virtual SeqGradChanList get_driverchanlist() = 0;
00060
00061 virtual bool check_ramptype(rampType type) const = 0;
00062
00063 virtual SeqGradTrapezDriver* clone_driver() const = 0;
00064 };
00065
00067
00072 class SeqGradTrapezDefault : public SeqGradTrapezDriver, public SeqGradChan {
00073
00074 public:
00075
00076 SeqGradTrapezDefault();
00077
00078 SeqGradTrapezDefault(const SeqGradTrapezDefault& sgtd);
00079
00080 ~SeqGradTrapezDefault() {}
00081
00082
00083
00084 bool update_driver(direction channel, double onrampdur, double constdur, double offrampdur, float strength, double timestep, rampType type, bool exclude_offramp_from_timing);
00085 float get_onramp_integral (double tmin, double tmax) const {return onramp_cache. get_integral(tmin,tmax);}
00086 float get_offramp_integral(double tmin, double tmax) const {return offramp_cache.get_integral(tmin,tmax);}
00087 const fvector& get_onramp() const {return onramp_cache.get_wave();}
00088 const fvector& get_offramp() const {return offramp_cache.get_wave();}
00089 SeqGradChanList get_driverchanlist();
00090 bool check_ramptype(rampType type) const {return true;}
00091 SeqGradTrapezDriver* clone_driver() const {return new SeqGradTrapezDefault(*this);}
00092
00093
00094 odinPlatform get_driverplatform() const {return standalone;}
00095
00096 private:
00097
00098 bool prep();
00099
00100
00101 STD_string get_properties() const;
00102
00103
00104 SeqGradInterface& set_strength(float gradstrength);
00105 SeqGradInterface& invert_strength();
00106 float get_strength() const {return onramp_cache.get_strength();}
00107 double get_gradduration() const;
00108 SeqGradInterface& set_gradrotmatrix(const RotMatrix& matrix);
00109
00110
00111
00112 STD_string get_grdpart(float matrixfactor) const {return graddriver->get_trapez_program(get_strength(),matrixfactor);}
00113 SeqGradChan& get_subchan(double starttime, double endtime) const;
00114 direction get_channel() const {return onramp_cache.get_channel();}
00115 float get_integral() const;
00116
00117 SeqGradRamp onramp_cache;
00118 SeqGradRamp offramp_cache;
00119
00120 double const_dur;
00121 bool exclude_offramp;
00122
00123 };
00124
00125
00126
00128
00141 class SeqGradTrapez : public SeqGradChanList {
00142
00143 public:
00144
00157 SeqGradTrapez(const STD_string& object_label,direction gradchannel,
00158 float gradstrength, double constgradduration, double timestep=0.01,
00159 rampType type = linear, double minrampduration=0.0, float steepness=1.0);
00160
00173 SeqGradTrapez(const STD_string& object_label,float gradintegral,
00174 direction gradchannel, double constgradduration,
00175 double timestep=0.01, rampType type = linear, double minrampduration=0.0, float steepness=1.0);
00176
00177
00190 SeqGradTrapez(const STD_string& object_label,float gradintegral,
00191 float gradstrength, direction gradchannel,
00192 double timestep=0.01, rampType type = linear, double minrampduration=0.0, float steepness=1.0);
00193
00194
00198 SeqGradTrapez(const SeqGradTrapez& sgt);
00199
00203 SeqGradTrapez(const STD_string& object_label = "unnamedSeqGradTrapez");
00204
00208 SeqGradTrapez& operator = (const SeqGradTrapez& sgt);
00209
00210
00214 SeqGradTrapez& set_constgrad_duration(double duration);
00215
00219 double get_onramp_duration() const {return onrampdur;}
00220
00221
00225 double get_constgrad_duration() const {return constdur;}
00226
00227
00231 double get_offramp_duration() const {return offrampdur;}
00232
00233
00237 float get_onramp_integral(double tmin, double tmax) const {return trapezdriver->get_onramp_integral(tmin,tmax);}
00238
00242 float get_onramp_integral() const {return get_onramp_integral(0.0,get_onramp_duration());}
00243
00247 float get_constgrad_integral() const {return constdur*trapezstrength;}
00248
00252 float get_offramp_integral(double tmin, double tmax) const {return trapezdriver->get_offramp_integral(tmin,tmax);}
00253
00257 float get_offramp_integral() const {return get_offramp_integral(0.0,get_offramp_duration());}
00258
00262 SeqGradTrapez& set_integral(float gradintegral);
00263
00267 float get_integral() const;
00268
00272 unsigned int get_onramp_npts() const;
00273
00277 unsigned int get_const_npts() const;
00278
00282 unsigned int get_offramp_npts() const;
00283
00287 unsigned int get_npts() const;
00288
00289
00293 fvector get_onramp() const {return trapezdriver->get_onramp();}
00294
00298 fvector get_offramp() const {return trapezdriver->get_offramp();}
00299
00303 fvector get_trapezshape() const;
00304
00308 double get_timestep() const {return dt;}
00309
00313 rampType get_ramptype() const {return rampMode;}
00314
00318 SeqGradTrapez& exclude_offramp_from_timing(bool flag);
00319
00320
00321
00322 float get_strength() const {return trapezstrength;}
00323 double get_gradduration() const {return get_onramp_duration()+get_constgrad_duration()+get_offramp_duration();}
00324
00325
00326 private:
00327 void common_init();
00328
00329 void check_platform();
00330 void update_driver();
00331 void build_seq();
00332
00333 static void get_ramps(const STD_string& label, float& rampintegral, double& rampondur, double& rampoffdur, float strength, double dwelltime, rampType ramptype, float steepness, double mindur);
00334
00335
00336 mutable SeqDriverInterface<SeqGradTrapezDriver> trapezdriver;
00337
00338 rampType rampMode;
00339 double dt;
00340 float steepnessfactor;
00341 bool exclude_offramp_timing;
00342
00343 direction trapezchannel;
00344 double onrampdur;
00345 double constdur;
00346 double offrampdur;
00347 float trapezstrength;
00348 };
00349
00351
00352
00359 class SeqGradTrapezParallel : public SeqGradChanParallel {
00360
00361 public:
00362
00373 SeqGradTrapezParallel(const STD_string& object_label,
00374 float gradintegral_read, float gradintegral_phase, float gradintegral_slice,
00375 float maxgradstrength, double timestep=0.01,
00376 rampType type = linear, double minrampduration=0.0);
00377
00381 SeqGradTrapezParallel(const SeqGradTrapezParallel& sgtp);
00382
00386 SeqGradTrapezParallel(const STD_string& object_label = "unnamedSeqGradTrapezParallel");
00387
00391 SeqGradTrapezParallel& operator = (const SeqGradTrapezParallel& sgtp);
00392
00393
00394 private:
00395 void build_seq();
00396
00397 SeqGradTrapez readgrad;
00398 SeqGradTrapez phasegrad;
00399 SeqGradTrapez slicegrad;
00400
00401
00402 };
00403
00408 #endif