00001 /*************************************************************************** 00002 Counter.h - description 00003 ------------------- 00004 begin : ven mar 26 2004 00005 copyright : (C) 2004 by Daniele Lavatelli 00006 email : ldaniele@interfree.it 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 #ifndef COUNTER_H 00019 00020 #define COUNTER_H 00021 00022 // #define TEST_YES //Compiled in test mode to produce documentation 00023 #define TEST_NO 00024 00025 #include "TimeSpecStruct.h" 00026 00028 00029 typedef struct EventType 00030 { 00031 unsigned Type : 1; 00032 unsigned Count : 7; 00033 } EventType; 00034 00035 #define WHISTLE_EVENT 1 00036 #define NOISE_EVENT 0 00037 00039 00040 class Counter 00041 { 00042 public: 00043 00045 00048 Counter (TimeSpecsType); 00049 00051 ~Counter(); 00052 00054 00067 int Process(int); //Returns Short, Long or Multiple whistle 00068 00069 00071 00073 float GetReliability(); 00074 00075 #ifdef TEST_YES 00076 00077 00078 void PrintStack(); //Provided for test, see documentation 00079 #endif 00080 00081 private: 00082 int mPrevious; 00083 TimeSpecsType mSpecs; 00084 unsigned int mEventStackPointer; 00085 EventType mpEventStack[5]; 00086 unsigned int mNumWhistles; 00087 float mReliability; 00088 float mLastReliability; 00089 }; 00090 00091 #define SHORT_WHISTLE -2 00092 #define LONG_WHISTLE -1 00093 #define NO_WHISTLES 0 00094 00095 #define MAX_CONFIDENCE 1.0 00096 #define MED_CONFIDENCE 0.8 00097 #define LOW_CONFIDENCE 0.4 00098 00099 #endif