Changeset f7133bb in tol


Ignore:
Timestamp:
Aug 25, 2009, 11:33:23 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
aa7b978
Parents:
ba4e2ac
Message:

Creating Class Notifier.DB inherited from Notifier to handle with database notifications

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1242 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/math/stat/models/bayesian/bysMcmc/_notifier.tol

    rba4e2ac rf7133bb  
    2323};
    2424
     25////////////////////////////////////////////////////////////////////////////
     26Class Notifier.DB : Notifier
     27////////////////////////////////////////////////////////////////////////////
     28{
     29  Text _.dbName;
     30  Text _.model;
     31  Text _.session;
     32  Real _.nErr = Copy(NError);
     33  Real _.nWar = Copy(NWarning);
     34  NameBlock _table = BysMcmc::Bsr::DynHlm::DBApi::_.table;
     35
     36  //Generic events notifier
     37  Real notify_messages(Real unused)
     38  {
     39    Real DBExecQuery(
     40    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     41    "SET nu_error = "+IntText(NError-_.nErr)+" \n"+
     42    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     43    Real DBExecQuery(
     44    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     45    "SET nu_warning = "+IntText(NWarning-_.nWar)+" \n"+
     46    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     47    1
     48  };
     49  //Generic events notifier
     50  Real notify_process(Text processField)
     51  {
     52    WriteLn("[dbNotifier] notify_process("+processField+")");
     53    Real notify_messages(0);
     54    Real DBExecQuery(
     55    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     56    "SET "+processField+" = "+
     57    BysMcmc::Bsr::DynHlm::DBApi::SqlFormatDate(Now)+" \n"+
     58    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     59    1
     60  };
     61
     62  //Model load event notifier
     63  Real loading(Real unused)
     64  {
     65    Real notify_process("dh_loading")
     66  };
     67
     68  //Model parser event notifier
     69  Real parsing(Real unused)
     70  {
     71    Real notify_process("dh_parsing")
     72  };
     73
     74  //Initialization event notifier
     75  Real initializing(Real numVar, Text path)
     76  {
     77    Real notify_process("dh_initializing");
     78    Real DBExecQuery(
     79    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     80    "SET nu_mcmc_var = "+IntText(numVar)+" \n"+
     81    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     82    Real DBExecQuery(
     83    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     84    "SET te_path_data_out = '"+path+"' \n"+
     85    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     86    1
     87  };
     88
     89  //Simulation events notifier
     90  Real simulating(Real numSim, Real timeAvg)
     91  {
     92    Real If(!numSim, notify_process("dh_simulating"), notify_messages(0));
     93    Real DBExecQuery(
     94    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     95    "SET nu_mcmc_currentLength = "+IntText(numSim)+" \n"+
     96    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     97    Real DBExecQuery(
     98    "UPDATE "+_.dbName+"."+_table::EstimStatus+"\n"+
     99    "SET vl_mcmc_time_avg = "<<timeAvg+" \n"+
     100    "WHERE id_model='"+_.model+"' AND id_session='"+_.session+"';");
     101    1
     102  };
     103
     104  //Report event notifier
     105  Real reporting(Real unused)
     106  {
     107    Real notify_process("dh_reporting")
     108  };
     109
     110  //Evaluation event notifier
     111  Real evaluating(Real unused)
     112  {
     113    Real notify_process("dh_evaluating")
     114  };
     115
     116  //Evaluation event notifier
     117  Real saving(Real unused)
     118  {
     119    Real notify_process("dh_saving")
     120  };
     121
     122  //Process termination event notifier
     123  Real ending(Real unused)
     124  {
     125    Real notify_process("dh_ending");
     126    BysMcmc::Bsr::DynHlm::DBApi::ModSes.SetBlocked(
     127      _.dbName, _.model, _.session, false);
     128    1
     129  }
     130};
     131
     132////////////////////////////////////////////////////////////////////////////
     133Notifier DBNotifier(Text dbName,
     134                    Text model,
     135                    Text session)
     136////////////////////////////////////////////////////////////////////////////
     137{
     138  //Creates the data base notifier of current status
     139  BysMcmc::Notifier.DB dbNotifier =
     140  [[
     141    Text _.dbName = dbName;
     142    Text _.model  = model;
     143    Text _.session  = session
     144  ]]
     145};
     146
Note: See TracChangeset for help on using the changeset viewer.