Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_LogStatControl.cpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #include <cstdlib>
00021 #include <pthread.h> // for sched_yield definition
00022 
00023 #include "Utils.hpp"
00024 #include "GeneratorTrace.hpp"
00025 #include "C_LogStatControl.hpp"
00026 
00027 
00028 C_LogStatControl::C_LogStatControl():C_TaskControl(){
00029   m_sem = NULL ;
00030   m_stat = NULL ;
00031 }
00032 
00033 C_LogStatControl::~C_LogStatControl(){
00034   DELETE_VAR (m_sem) ;
00035   m_stat = NULL ;
00036 }
00037 
00038 void  C_LogStatControl::init(unsigned long P_period, string_t& P_fileName) {
00039   GEN_DEBUG(0, "C_LogStatControl::init() start");
00040   m_stat = C_GeneratorStats::instance() ;
00041   m_stat -> setFileName ((char*)P_fileName.c_str());
00042 
00043   NEW_VAR(m_sem, C_SemaphoreTimed(P_period));
00044   m_sem -> P();
00045   C_TaskControl::init() ;
00046   GEN_DEBUG(0, "C_LogStatControl::init() end");
00047 }
00048 
00049 
00050 T_GeneratorError C_LogStatControl::InitProcedure() {
00051   GEN_DEBUG(0, "C_LogStatControl::doInit() start");
00052   m_stat->init();
00053   m_stat->makeFirstLog();
00054   GEN_DEBUG(0, "C_LogStatControl::doInit() end");
00055   return (E_GEN_NO_ERROR);
00056 }
00057 
00058 T_GeneratorError C_LogStatControl::TaskProcedure() {
00059   GEN_DEBUG(0, "C_LogStatControl::doTask() start");
00060   m_stat->makeLog ();
00061   m_stat->executeStatAction(C_GeneratorStats::E_RESET_PL_COUNTERS);
00062   sched_yield () ;
00063   m_sem -> P() ;
00064   GEN_DEBUG(0, "C_LogStatControl::doTask() end");
00065   return (E_GEN_NO_ERROR);
00066 }
00067 
00068 T_GeneratorError C_LogStatControl::EndProcedure() {
00069   m_stat->makeLog ();
00070   return (E_GEN_NO_ERROR);
00071 }
00072 
00073 T_GeneratorError C_LogStatControl::StoppingProcedure() {
00074   M_state = C_TaskControl::E_STATE_STOPPED ;
00075   m_sem->V();
00076 
00077   return (E_GEN_NO_ERROR);
00078 }
00079 
00080 T_GeneratorError C_LogStatControl::ForcedStoppingProcedure() {
00081   return (E_GEN_NO_ERROR);
00082 }
00083 
00084 void C_LogStatControl::reset_cumul_counters() {
00085   m_stat->reset_cumul_counters();
00086 }
00087 
00088 
00089 void C_LogStatControl::activate_percent_traffic() {
00090   m_stat->activate_percent_traffic();
00091 }
00092 
00093 
00094 
00095 
00096 // end of file
00097 

Generated on Wed Mar 7 14:44:50 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002