UltraScan III
us_worker_pc.h
Go to the documentation of this file.
1 #ifndef US_THREAD_WORKER_H
3 #define US_THREAD_WORKER_H
4 
5 #include <QtCore>
6 
7 #include "us_extern.h"
8 #include "us_dataIO.h"
9 #include "us_simparms.h"
10 #include "us_model.h"
11 #include "us_noise.h"
12 #include "us_zsolute.h"
13 #include "us_solve_sim.h"
14 
15 #ifndef DbgLv
16 #define DbgLv(a) if(dbg_level>=a)qDebug()
17 #endif
18 
20 typedef struct work_packet_pc_s
21 {
22  int thrn;
23  int taskx;
24  int depth;
25  int state;
26  int noisf;
27 
28  double str_y;
29  double end_y;
30  double par1;
31  double par2;
32  double par3;
33 
34  QVector< US_ZSolute > isolutes;
35  QVector< US_ZSolute > csolutes;
36  QVector< double > ti_noise;
37  QVector< double > ri_noise;
38  QVector< double >* psv_nnls_a;
39  QVector< double >* psv_nnls_b;
40 
41  QList< US_SolveSim::DataSet* > dsets;
43 
44 } WorkPacketPc;
45 
47 
51 class WorkerThreadPc : public QThread
52 {
53  Q_OBJECT
54 
55  public:
56  WorkerThreadPc( QObject* parent = 0 );
58 
59  public slots:
62  void define_work ( WorkPacketPc& );
65  void get_result ( WorkPacketPc& );
67  void run ();
69  void flag_abort ();
71  void forward_progress( int );
72 
73  signals:
74  void work_progress ( int );
75  void work_complete ( WorkerThreadPc* );
76 
77  private:
78 
79  void calc_residuals ( void );
80  void calc_resids_ratio( void );
81  long int max_rss ( void );
82  void apply_alpha ( const double,
83  QVector< double >*, QVector< double >*,
84  const int, const int, const int, double&, double& );
85 
86  QMutex mutex; // mutex
87 
88  long int maxrss; // maximum rss memory used
89 
90  double str_y; // start model y value
91  double end_y; // end model y value
92  double par1; // task par1 value
93  double par2; // task par2 value
94  double par3; // task par3 value
95 
96  int thrn; // thread number (1,...)
97  int taskx; // grid refinement task index
98  int depth; // depth index
99  int iter; // iteration index
100  int menmcx; // meniscus / monte carlo index
101  int typeref; // type of refinement (0=UGRID, ...)
102  int nscans; // number of scans in experiment
103  int npoints; // number of radius points in experiment
104  int nsolutes; // number of input solutes for this task
105  int noisflag; // noise flag (0-3 for NONE|TI|RI|BOTH)
106  int dbg_level; // debug flag
107 
108  bool abort; // should this thread be aborted?
109 
110  US_DataIO::EditedData* edata; // experiment data (pointer)
111  US_DataIO::RawData sdata; // simulation data
112  US_DataIO::RawData rdata; // residuals
113  US_Model model; // output model
114  US_Noise ri_noise; // computed radially-invariant noise
115  US_Noise ti_noise; // computed time-invariant noise
116  US_Noise ra_noise; // computed random noise
117  US_SimulationParameters simparms; // simulation parameters
118 
119  QList< US_SolveSim::DataSet* > dsets; // list of data set obj. ptrs.
120  US_SolveSim::Simulation sim_vals; // simulation values
121  US_SolveSim* solvesim; // object for calc_residuals()
122  US_SolveSim::DataSet dset_wk; // local copy of data set
123 
124  QVector< US_ZSolute > solutes_i; // solutes input
125  QVector< US_ZSolute > solutes_c; // solutes computed
126 
127  QVector< double >* psv_nnls_a; // pointer to saved nnls A matrix
128  QVector< double >* psv_nnls_b; // pointer to saved nnls B matrix
129 };
130 
131 #endif