Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_LogProtocolStatControl.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_LogProtocolStatControl.hpp"
00026 
00027 
00028 C_LogProtocolStatControl::C_LogProtocolStatControl(C_ProtocolStatsFrame *P_stats):C_TaskControl(){
00029   m_sem = NULL ;
00030   m_stat = P_stats ;
00031 }
00032 
00033 C_LogProtocolStatControl::~C_LogProtocolStatControl(){
00034   DELETE_VAR (m_sem) ;
00035   m_stat = NULL ;
00036 }
00037 
00038 void  C_LogProtocolStatControl::init(unsigned long P_period, string_t& P_fileName) {
00039   GEN_DEBUG(0, "C_LogProtocolStatControl::init() start");
00040 
00041   m_stat -> set_file_name ((char*)P_fileName.c_str());
00042   NEW_VAR(m_sem, C_SemaphoreTimed(P_period));
00043   m_sem -> P();
00044   C_TaskControl::init() ;
00045   GEN_DEBUG(0, "C_LogProtocolStatControl::init() end");
00046 }
00047 
00048 
00049 T_GeneratorError C_LogProtocolStatControl::InitProcedure() {
00050   GEN_DEBUG(0, "C_LogProtocolStatControl::doInit() start");
00051   m_stat->init();
00052   m_stat->make_first_log();
00053   GEN_DEBUG(0, "C_LogProtocolStatControl::doInit() end");
00054   return (E_GEN_NO_ERROR);
00055 }
00056 
00057 T_GeneratorError C_LogProtocolStatControl::TaskProcedure() {
00058   GEN_DEBUG(0, "C_LogProtocolStatControl::doTask() start");
00059   m_stat->make_log ();
00060 //    m_stat->executeStatAction(C_GeneratorStats::E_RESET_PL_COUNTERS);
00061   sched_yield () ;
00062   m_sem -> P() ;
00063   GEN_DEBUG(0, "C_LogProtocolStatControl::doTask() end");
00064   return (E_GEN_NO_ERROR);
00065 }
00066 
00067 T_GeneratorError C_LogProtocolStatControl::EndProcedure() {
00068   m_stat->make_log ();
00069   return (E_GEN_NO_ERROR);
00070 }
00071 
00072 T_GeneratorError C_LogProtocolStatControl::StoppingProcedure() {
00073   M_state = C_TaskControl::E_STATE_STOPPED ;
00074   return (E_GEN_NO_ERROR);
00075 }
00076 
00077 T_GeneratorError C_LogProtocolStatControl::ForcedStoppingProcedure() {
00078   return (E_GEN_NO_ERROR);
00079 }
00080 
00081 void C_LogProtocolStatControl::reset_cumul_counters() {
00082   m_stat->reset_cumul_counters();
00083 }
00084 
00085 
00086 
00087 // end of file
00088 

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