• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List

seqfreq.h

00001 /***************************************************************************
00002                           seqfreq.h  -  description
00003                              -------------------
00004     begin                : Wed Aug 14 2002
00005     copyright            : (C) 2001 by Thies H. Jochimsen
00006     email                : jochimse@cns.mpg.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 
00020 #ifndef SEQFREQ_H
00021 #define SEQFREQ_H
00022 
00023 #include <odinseq/seqclass.h>
00024 #include <odinseq/seqvec.h>
00025 #include <odinseq/seqphase.h>
00026 #include <odinseq/seqdriver.h>
00027 
00028 
00030 
00036 class SeqFreqChanInterface : public virtual SeqClass  {
00037 
00038  public:
00042   virtual SeqFreqChanInterface& set_nucleus(const STD_string& nucleus) {if(marshall) marshall->set_nucleus(nucleus); else marshall_error(); return *this;}
00043 
00044 
00048   virtual SeqFreqChanInterface& set_freqlist(const dvector& freqlist) {if(marshall) marshall->set_freqlist(freqlist); else marshall_error(); return *this;}
00049 
00053   virtual SeqFreqChanInterface& set_phaselist(const dvector& phaselist) {if(marshall) marshall->set_phaselist(phaselist); else marshall_error(); return *this;}
00054 
00058   virtual const SeqVector& get_freqlist_vector() const {if(marshall) return marshall->get_freqlist_vector(); else marshall_error(); return get_dummyvec();}
00059 
00060 
00064   virtual const SeqVector& get_phaselist_vector() const {if(marshall) return marshall->get_phaselist_vector(); else marshall_error(); return get_dummyvec();}
00065 
00069   operator const SeqVector& () const {return get_freqlist_vector();}
00070 
00074   virtual SeqFreqChanInterface& set_encoding_scheme(encodingScheme scheme) {if(marshall) marshall->get_mutable_freqlist_vector().set_encoding_scheme(scheme); else marshall_error(); return *this;}
00075 
00079   virtual SeqFreqChanInterface& set_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1) {if(marshall) marshall->get_mutable_freqlist_vector().set_reorder_scheme(scheme,nsegments); else marshall_error(); return *this;}
00080 
00084   virtual const SeqVector& get_reorder_vector() const {if(marshall) return marshall->get_freqlist_vector().get_reorder_vector(); else marshall_error(); return get_dummyvec();}
00085 
00089   virtual SeqFreqChanInterface& set_phaselist_encoding_scheme(encodingScheme scheme) {if(marshall) marshall->get_mutable_phaselist_vector().set_encoding_scheme(scheme); else marshall_error(); return *this;}
00090 
00094   virtual SeqFreqChanInterface& set_phaselist_reorder_scheme(reorderScheme scheme, unsigned int nsegments=1) {if(marshall) marshall->get_mutable_phaselist_vector().set_reorder_scheme(scheme,nsegments); else marshall_error(); return *this;}
00095 
00099   virtual const SeqVector& get_phaselist_reorder_vector() const {if(marshall) return marshall->get_phaselist_vector().get_reorder_vector(); else marshall_error(); return get_dummyvec();}
00100 
00101 
00105   SeqFreqChanInterface& set_freqoffset(double freqoffset);
00106 
00110   SeqFreqChanInterface& set_phase(double phaseval);
00111 
00116   SeqFreqChanInterface& set_phasespoiling(unsigned int size=80, double incr=117.0, double offset=0.0);
00117 
00118  protected:
00119   SeqFreqChanInterface() {}
00120   virtual ~SeqFreqChanInterface() {}
00121 
00122   void set_marshall(SeqFreqChanInterface* mymarshall) {marshall=mymarshall;} // to be used in constructor code
00123 
00124  private:
00125   friend class SeqAcqEPI; // to allow SeqAcqEPI full access to its driver
00126 
00127   SeqFreqChanInterface* marshall; // for marshalling member functions to a sub-object
00128 
00129 
00130   virtual SeqVector& get_mutable_freqlist_vector() {if(marshall) return marshall->get_mutable_freqlist_vector(); else marshall_error(); return get_dummyvec();}
00131   virtual SeqVector& get_mutable_phaselist_vector() {if(marshall) return marshall->get_mutable_phaselist_vector(); else marshall_error(); return get_dummyvec();}
00132 
00133 };
00134 
00135 
00137 
00142 class SeqFreqChanDriver : public SeqDriverBase {
00143 
00144  public:
00145   SeqFreqChanDriver() {}
00146   virtual ~SeqFreqChanDriver() {}
00147 
00148   virtual bool prep_driver(const STD_string& nucleus, const dvector& freqlist) = 0;
00149   virtual void prep_iteration(double current_frequency, double current_phase, double freqchan_duration) const = 0;
00150   virtual int get_channel() const = 0;
00151 
00152   virtual STD_string get_iteratorcommand(objCategory cat,int freqlistindex) const = 0;
00153   virtual svector get_freqvec_commands(const STD_string& iterator, const STD_string& instr) const = 0;
00154 
00155   virtual STD_string get_pre_program(programContext& context, objCategory cat, const STD_string& instr_label, double default_frequency, double default_phase) const = 0;
00156 
00157 
00158   virtual SeqFreqChanDriver* clone_driver() const = 0;
00159 
00160   virtual void pre_event (eventContext& context,double starttime) const = 0;
00161   virtual void post_event(eventContext& context,double starttime) const = 0;
00162 };
00163 
00165 
00171 class SeqFreqChan : public SeqVector, public virtual SeqFreqChanInterface {
00172 
00173  public:
00177   SeqFreqChan(const STD_string& object_label="unnamedSeqFreqChan");
00178 
00179 
00189   SeqFreqChan(const STD_string& object_label,const STD_string& nucleus,
00190                   const dvector& freqlist=0,const dvector& phaselist=0);
00191 
00192 
00196   SeqFreqChan(const SeqFreqChan& sfc);
00197 
00198 
00202   virtual ~SeqFreqChan() {}
00203 
00204 
00208   SeqFreqChan& operator = (const SeqFreqChan& sfc);
00209 
00210 
00214   int get_channel() const {return freqdriver->get_channel();}
00215 
00216 
00220   dvector get_freqlist() const {return frequency_list;}
00221 
00222 
00226   double get_phase() const {return phaselistvec.get_phase();}
00227 
00228 
00232   virtual double get_frequency() const;
00233 
00234 
00238   unsigned int get_phaselistindex() const {return phaselistvec.get_phaselistindex();}
00239 
00240 
00244   virtual unsigned int get_freqlistindex() const {return 1;}
00245 
00246 
00250   STD_string get_iteratorcommand(objCategory cat) const;
00251 
00252 
00253 
00254   // overloaded virtual functions of SeqFreqChanInterface
00255   SeqFreqChanInterface& set_nucleus(const STD_string& nucleus);
00256   SeqFreqChanInterface& set_freqlist (const dvector& freqlist) {frequency_list=freqlist; return *this;}
00257   SeqFreqChanInterface& set_phaselist(const dvector& phaselist) {phaselistvec.set_phaselist(phaselist); return *this;}
00258   const SeqVector& get_freqlist_vector() const {return *this;}
00259   const SeqVector& get_phaselist_vector() const {return phaselistvec;}
00260 
00261 
00262   // overloaded virtual functions of SeqVector
00263   unsigned int get_vectorsize() const {return frequency_list.size();}
00264   bool prep_iteration() const;
00265   bool is_qualvector() const {return false;}
00266   svector get_vector_commands(const STD_string& iterator) const {return freqdriver->get_freqvec_commands(iterator,get_driver_instr_label());}
00267 
00268   // overloaded functions for SeqTreeObj
00269   SeqValList get_freqvallist(freqlistAction action) const;
00270 
00271 
00272  protected:
00273 
00274   STD_string get_pre_program(programContext& context, objCategory cat, const STD_string& instr_label) const;
00275 
00276   void pre_event (eventContext& context,double starttime) const {freqdriver->pre_event(context,starttime);}
00277   void post_event(eventContext& context,double starttime) const {freqdriver->post_event(context,starttime);}
00278 
00283   virtual double get_freqchan_duration() const {return 0.0;}
00284 
00285   // overwriting virtual functions from SeqClass
00286   bool prep();
00287 
00288  private:
00289   friend class SeqPhaseListVector;
00290 
00291   // overloaded virtual functions of SeqFreqChanInterface
00292   SeqVector& get_mutable_freqlist_vector() {return *this;}
00293   SeqVector& get_mutable_phaselist_vector() {return phaselistvec;}
00294 
00295 
00296   double get_default_phase() const {return closest2zero(phaselistvec.get_phaselist());}
00297   double get_default_frequency() const {return closest2zero(frequency_list);}
00298 
00299   static double closest2zero(const dvector& v);
00300 
00301   // for EPIC
00302   virtual STD_string get_driver_instr_label() const {return "";}
00303 
00304 
00305   // the hardware driver
00306   mutable SeqDriverInterface<SeqFreqChanDriver> freqdriver;
00307 
00308   // the nucleus of this freq/phase object
00309   STD_string nucleusName;
00310 
00311   // the frequency list to iterate through
00312   dvector frequency_list;
00313 
00314   // the phaselist associated with this freq/phase object
00315   SeqPhaseListVector phaselistvec;
00316 };
00317 
00319 
00320 #endif

Generated on Tue Dec 18 2012 15:11:14 by  doxygen 1.7.1