Changeset 2815 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jul 8, 2005, 5:26:49 PM (20 years ago)
Author:
ansari
Message:

Suite correction PIAFitter en multithread - ajout mutex d'execution pour PIAFitter , cmv+Reza 8 Juillet 2005

Location:
trunk/SophyaPI/PIext
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piafitting.cc

    r2813 r2815  
    205205, mUFNVar(0), mUFNPar(0)
    206206{
     207// Flag de controle d'execution depuis la boucle d'evts
     208  SetFgEvtLoopFlag(false);
     209
    207210// Init et Set des options
    208211mPar=0.; mStep=1.; mMin=1.; mMax=-1.; mFix=0.;
     
    496499{
    497500mNObj = "";
    498 AnyDataObj* mobj = mApp->ObjMgr()->GetObj(obj);
     501AnyDataObj* mobj = NULL;
     502if ( fg_evtloop )  mobj = mApp->ObjMgr()->GetObj(obj);
     503else {
     504  NamedObjMgr omg;
     505  mobj = omg.GetObj(obj);
     506}
    499507if(mobj == NULL)
    500508  {cout<<"PIAFitter::DecodeObject Error , Pas d'objet de nom "<<obj<<endl;
     
    540548mNVar = mNData = 0;
    541549
    542 mAdObj = mApp->ObjMgr()->GetObjAdapter(mNObj); // Ne pas deleter
     550mAdObj = NULL;
     551if ( fg_evtloop )  mAdObj = mApp->ObjMgr()->GetObjAdapter(mNObj); // Ne pas deleter
     552else {
     553  NamedObjMgr omg;
     554  mAdObj = omg.GetObjAdapter(mNObj); // Ne pas deleter
     555}
     556
    543557if(mAdObj == NULL) {
    544558  cout<<"PIAFitter::DecodeObject Error , ObjAdapter==NULL for "<<mNObj<<endl;
     
    874888  nomresfun = mNObj + "_res";
    875889  AnyDataObj* ob = mAdObj->FitResidusObj(*mFit);
    876   if(ob) mApp->ObjMgr()->AddObj(ob,nomresfun);
     890  if(ob) {
     891    if ( fg_evtloop )  mApp->ObjMgr()->AddObj(ob,nomresfun);
     892    else {
     893      NamedObjMgr omg;
     894      omg.AddObj(ob,nomresfun);
     895    }
     896  }
    877897}
    878898
     
    880900  nomresfun = mNObj + "_fun";
    881901  AnyDataObj* ob = mAdObj->FitFunctionObj(*mFit);
    882   if(ob) mApp->ObjMgr()->AddObj(ob,nomresfun);
     902  if(ob) {
     903    if ( fg_evtloop )  mApp->ObjMgr()->AddObj(ob,nomresfun);
     904    else {
     905      NamedObjMgr omg;
     906      omg.AddObj(ob,nomresfun);
     907    }
     908  }
    883909}
    884910
     
    10541080DecodeParam(mSp,mSs,mSm,mSM,mSf);
    10551081if(kw == "fit") {
     1082  ZSync zs(getMutex());   // On s'assure
     1083  SetFgEvtLoopFlag(false);  // l'origine n'est pas la boucle d'evts
    10561084  int rc = DoFit();
    10571085  if(rc>=0) FitFunRes();
     1086  zs.NOp();
    10581087} else if(kw == "fitlin") {
     1088  ZSync zs(getMutex());
     1089  SetFgEvtLoopFlag(false);  // l'origine n'est pas la boucle d'evts
    10591090  LinFit();
    10601091} else if ((kw == "fitw") && (mApp != NULL) ) {
     
    14501481void PIAFitterWind::Process(PIMessage msg, PIMsgHandler* sender, void* data)
    14511482{
    1452 int lp = (mFitter->mOpt.lp>2)?1:0;
    1453 int npar = mFitter->mNPar;
    14541483
    14551484// Decodage des messages, init et dismiss
    14561485msg = UserMsg(msg);
    14571486if(msg ==777) {
    1458   if(lp) cout<<"Dismiss"<<endl;
     1487  // cout<<"Dismiss"<<endl;
    14591488  //mDap->SetReady();
    14601489  Hide();
     
    14621491}
    14631492
     1493mFitter->SetFgEvtLoopFlag(true); // On indique que l'origine est la boucle d'evts
     1494ZSync zs(mFitter->getMutex());   // On s'assure d'une seule execution du code PIAFitting
     1495
     1496int lp = (mFitter->mOpt.lp>2)?1:0;
     1497int npar = mFitter->mNPar;
    14641498// L'objet existe t-il encore?
    14651499if(mDap->ObjMgr()->GetObj(mFitter->mNObj) == NULL) {
    14661500  cout<<"PIAFitterWind::Process Error , Pas d'objet de nom "
    14671501      <<mFitter->mNObj<<endl;
     1502  mFitter->SetFgEvtLoopFlag(false); 
    14681503  return;
    14691504}
     
    16341669if(mFitter->mOpt.lp>1) mFitter->PrintOptions();
    16351670
    1636 return;
    1637 }
     1671zs.NOp();
     1672mFitter->SetFgEvtLoopFlag(false);
     1673return;
     1674}
  • trunk/SophyaPI/PIext/piafitting.h

    r1268 r2815  
    1616#include "dlftypes.h"
    1717#include "piacmd.h"
     18#include "zthread.h"
    1819
    1920class PIStdImgApp;
     
    4243                                  ,int nvar,int npar);
    4344
     45  inline void  SetFgEvtLoopFlag(bool fg=false) { fg_evtloop = fg; }
     46  inline ZMutex &   getMutex() { return singlefit_mutex; }
     47
    4448friend class PIAFitterWind;
    4549
    4650protected :
     51bool fg_evtloop;   // true : appel depuis Boucle d'evts, PIAFitterWind
     52// Attributs pour controle de thread
     53ZMutex singlefit_mutex;  // Pour empecher l'execution simultanee de deux fits
    4754
    4855typedef struct DFOptions {
Note: See TracChangeset for help on using the changeset viewer.