beep.h
Go to the documentation of this file.
00001 #ifndef BEEP_H
00002 #define BEEP_H
00003 
00004 void init_beep();
00005 void start_beep(int freq, int length=50);
00006 void stop_beep();
00007 void quit_beep();
00008 
00009 typedef enum {BEEP_INFO_START, BEEP_INFO_FREQ, BEEP_INFO_LENGTH, NUM_BEEP_INFO} beep_info;
00010 
00011 // Beep client to send command to BeeperRTC
00012 #include <rtm/idl/BasicDataTypeSkel.h>
00013 class BeepClient
00014 {
00015  private:
00016   bool is_start_beep, prev_is_start_beep;
00017   int freq, length;
00018  public:
00019   BeepClient () : is_start_beep(false), prev_is_start_beep(false) {};
00020   ~BeepClient () {};
00021   int get_num_beep_info () const { return NUM_BEEP_INFO; };
00022   void startBeep (const int _freq, const int _length = 50)
00023   {
00024     prev_is_start_beep = is_start_beep;
00025     is_start_beep = true;
00026     freq = _freq;
00027     length = _length;
00028   };
00029   void stopBeep ()
00030   {
00031     prev_is_start_beep = is_start_beep;
00032     is_start_beep = false;
00033     freq = 1; // dummy
00034     length = 0; // dummy
00035   };
00036   bool isWritable () const
00037   {
00038     // Write data port to overwrite and pass through between client RTCs.
00039     // If currently "start" or changed to "stop", write data port.
00040     // If keep "stop", do not write data port.
00041     return (is_start_beep || prev_is_start_beep);
00042   };
00043   void setDataPort (RTC::TimedLongSeq& out_data)
00044   {
00045     out_data.data[BEEP_INFO_START] = (is_start_beep?1:0);
00046     out_data.data[BEEP_INFO_FREQ] = freq;
00047     out_data.data[BEEP_INFO_LENGTH] = length;
00048   };
00049 };
00050 #endif // BEEP_H


hrpsys
Author(s): AIST, Fumio Kanehiro
autogenerated on Wed Sep 6 2017 02:35:54