system.h
1 /***************************************************************************
2  system.h - description
3  -------------------
4  begin : Wed Jun 29 2005
5  copyright : (C) 2000-2015 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 SYSTEM_H
19 #define SYSTEM_H
20 
21 #include <tjutils/tjhandler.h>
22 
23 #include <odinpara/ldrblock.h>
24 #include <odinpara/ldrnumbers.h>
25 #include <odinpara/ldrarrays.h>
26 #include <odinpara/odinpara.h>
27 
28 
29 // defaults for systemInfo
30 #define _DEFAULT_B0_ 3000 // 3 Tesla
31 #define _DEFAULT_MAX_SYSTEM_GRADIENT_ 0.04
32 #define _DEFAULT_MAX_SYSTEM_SLEWRATE_ 0.2
33 
34 
39 enum odinPlatform {standalone=0, paravision, numaris_4, epic, numof_platforms};
40 
46 enum objCategory {unknownObj=0,delayObj,pulsObj,gradObj,loopObj,acqObj,freqObj,syncObj,endObj};
47 
49 
54 class Nuclei {
55 
56  public:
57  Nuclei();
58 
62  double get_gamma(const STD_string& nucName) const;
63 
67  double get_nuc_freq(const STD_string& nucName,float B0) const;
68 
69 
73  LDRenum get_nuc_enum() const;
74 
75  private:
76  typedef STD_pair<STD_string, double> Nucleus;
77  typedef STD_list<Nucleus> NucList; // do not use std::map since we do not want unsorted list
78 
79  NucList nuclist;
80 };
81 
83 
91 class System : public LDRblock {
92 
93  public:
94 
98  System(const STD_string& object_label="unnamedSystem");
99 
104 
108  System& operator = (const System& s);
109 
113  odinPlatform get_platform() const;
114 
118  STD_string get_platform_str() const {return platformstr;}
119 
123  STD_string get_transmit_coil_name() const {return transmit_coil_name;}
124 
128  System& set_transmit_coil_name(const STD_string& tcname);
129 
133  STD_string get_receive_coil_name() const {return receive_coil_name;}
134 
138  System& set_receive_coil_name(const STD_string& rcname);
139 
143  STD_string get_main_nucleus() const {return main_nucleus;}
144 
148  System& set_main_nucleus(const STD_string& nucname);
149 
153  float get_max_grad() const {return max_grad;}
154 
158  float get_max_slew_rate() const {return max_slew_rate;}
159 
163  float get_grad_switch_time(float graddiff) const;
164 
168  float get_inter_grad_delay() const {return inter_grad_delay;}
169 
173  System& set_scandir(const STD_string& dir);
174 
178  STD_string get_scandir() const;
179 
180 
184  float get_grad_shift_delay() const {return grad_shift;}
185 
189  double get_B0() const {return B0;}
190 
194  System& set_B0(double b0) {B0=b0; return *this;}
195 
200  System& set_B0_from_freq(double freq, const STD_string& nucName="");
201 
205  double get_gamma(const STD_string& nucName="") const;
206 
210  System& set_reference_gain(float refgain);
211 
215  float get_reference_gain() const {return reference_gain;}
216 
220  double get_nuc_freq(const STD_string& nucName="") const;
221 
222 
226  LDRenum get_nuc_enum() const;
227 
231  double get_min_duration(objCategory c) const {return min_duration[c];}
232 
236  double get_min_grad_rastertime() const {return min_grad_rastertime;}
237 
241  double get_rastertime(objCategory cat) const;
242 
246  double get_rasteredtime(objCategory cat, double time) const;
247 
251  int get_max_rf_samples() const {return max_rf_samples;}
252 
256  int get_max_grad_samples() const {return max_grad_samples;}
257 
261  System& set_data_type(const STD_string& type) {datatype=type; return *this;}
262 
266  STD_string get_data_type() const {return datatype;}
267 
268 
274  bool allowed_grad_freq(double freq, double& low, double& upp) const;
275 
276 
277  private:
278  friend class SeqMethod;
279  friend class SeqIdea;
280  friend class SeqParavision;
281  friend class SeqStandAlone;
282  friend class SeqEpic;
283 
284  // overwriting virtual functions from LDRbase
285  int load(const STD_string &filename, const LDRserBase& serializer=LDRserJDX());
286 
287 
288 
289 
290  int append_all_members();
291 
292  Nuclei nuc;
293 
294  LDRstring platformstr;
295  LDRenum main_nucleus;
296  LDRdouble max_grad;
297  LDRdouble max_slew_rate;
298  LDRdouble grad_shift;
299  LDRdouble inter_grad_delay;
300  LDRdouble B0;
301  LDRdouble reference_gain;
302  LDRstring transmit_coil_name;
303  LDRstring receive_coil_name;
304 
305  LDRdouble delay_rastertime;
306  LDRdouble rf_rastertime;
307  LDRdouble grad_rastertime;
308  LDRdouble min_grad_rastertime;
309  LDRdouble acq_rastertime;
310 
311  LDRint max_rf_samples;
312  LDRint max_grad_samples;
313  LDRstring datatype;
314 
315  LDRdoubleArr grad_reson_center;
316  LDRdoubleArr grad_reson_width;
317 
318 
319  STD_string scandir;
320 
321  dvector min_duration;
322 
323 };
324 
325 
327 
333 class SystemInterface : public StaticHandler<SystemInterface> {
334  public:
335 
336  SystemInterface() {}
337 
338  System& operator * () {return *get_sysinfo_ptr();}
339  const System& operator * () const {return *get_const_sysinfo_ptr();}
340 
341  System* operator -> () {return get_sysinfo_ptr();}
342  const System* operator -> () const {return get_const_sysinfo_ptr();}
343 
344  // functions to initialize/delete static members by the StaticHandler template class
345  static void init_static();
346  static void destroy_static();
347 
348  static void set_current_pf(odinPlatform pf);
349 
350  static odinPlatform get_current_pf() { // make it inline to speed up driver access
351  if(current_pf) return odinPlatform(current_pf->operator int ());
352 // else STD_cerr << "ERROR: SystemInterface::get_current_pf: current_pf not yet initialized" << STD_endl;
353  return odinPlatform(0);
354  }
355 
356 
357  private:
358 // friend class System;
359  friend class SeqIdea;
360  friend class SeqParavision;
361  friend class SeqStandAlone;
362  friend class SeqEpic;
363 // friend class SeqPlatformInstances;
364 
365 
366  static System* get_sysinfo_ptr();
367  static const System* get_const_sysinfo_ptr();
368 
369  // the actual platform
370  static SingletonHandler<LDRint,false> current_pf;
371 
372  // separate systemInfo for each platform
373  static SingletonHandler<System,false>* systemInfo_platform;
374 };
375 
376 
377 
378 #endif
double get_min_grad_rastertime() const
Definition: system.h:236
STD_string get_receive_coil_name() const
Definition: system.h:133
float get_max_slew_rate() const
Definition: system.h:158
odinPlatform
Definition: system.h:39
System proxy.
Definition: system.h:91
Definition: system.h:54
int get_max_grad_samples() const
Definition: system.h:256
LDRenum get_nuc_enum() const
int get_max_rf_samples() const
Definition: system.h:251
STD_string get_platform_str() const
Definition: system.h:118
float get_inter_grad_delay() const
Definition: system.h:168
double get_gamma(const STD_string &nucName) const
float get_max_grad() const
Definition: system.h:153
STD_string get_transmit_coil_name() const
Definition: system.h:123
System & set_data_type(const STD_string &type)
Definition: system.h:261
TinyVector< T, N_rows > operator*(const TinyMatrix< T, N_rows, N_columns > &matrix, const TinyVector< T, N_columns > &vector)
Definition: utils.h:149
System(const System &s)
Definition: system.h:103
int load(STD_string &str, const STD_string &filename)
STD_string get_main_nucleus() const
Definition: system.h:143
float get_reference_gain() const
Definition: system.h:215
Base class for methods (sequences)
Definition: seqmeth.h:155
double get_B0() const
Definition: system.h:189
double get_min_duration(objCategory c) const
Definition: system.h:231
STD_string get_data_type() const
Definition: system.h:266
objCategory
Definition: system.h:46
float get_grad_shift_delay() const
Definition: system.h:184
System & operator=(const System &s)
System & set_B0(double b0)
Definition: system.h:194
double get_nuc_freq(const STD_string &nucName, float B0) const