/*********************************************************************************
 **
 ** SmartSampler main task.  Just kick off and log any exceptions.
 **
 *********************************************************************************/
#include "SmartSampler.hh"

#include "System.h"
#include "Syslog.h"

int main(int argc, char *argv[]) {
  int i;
  SmartSampler *tmp,*ssp = NULL;

  if( System::setTaskPriority(BackgroundPriority-2)==-1 ) {
    Syslog::write("SmartSampler - unable to fix my task priority.");
    return 1;
  }
  
  try {
    ssp = new SmartSampler(SMARTSAMPLER_PERIOD/SMARTSAMPLER_CLOCKDIV);

    Syslog::write("SmartSampler - starting the task.");
    ssp->run();

    Syslog::write("SmartSampler - end of task.");
    tmp = ssp;
    ssp = NULL;
    delete tmp;

    return 0;
  } 
  catch(Exception e) {
    Syslog::write("SmartSampler - caught exception: %s", e.msg);
  } catch(...) {
    Syslog::write("SmartSampler - caught exception!");
  }
  if( NULL!=ssp )
    delete ssp;
  return 2;
} // main
