Homepage
Demos
Overview
Downloads
Tutorials
Reference
Credits

NetworkStatusControl.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_NetworkStatusControl_h_
00003 #define INCLUDED_NetworkStatusControl_h_
00004 
00005 #include "ControlBase.h"
00006 #include "Motion/MMAccessor.h"
00007 #include "Motion/LedMC.h"
00008 #include "NullControl.h"
00009 #include "Events/EventRouter.h"
00010 #include "Wireless/Wireless.h"
00011 #include <ERA201D1.h>
00012 
00013 //! will display current network status such as wireless signal strength
00014 class NetworkStatusControl : public ControlBase, public EventListener {
00015 public:
00016   //! constructor
00017   NetworkStatusControl() : ControlBase("Network Status","Displays current network status such as wireless signal strength"), EventListener() {}
00018   
00019   //! constructor, pass custom name
00020   NetworkStatusControl(const std::string& nm) : ControlBase(nm,"Displays current network status such as wireless signal strength"), EventListener() {}
00021   
00022   //! stops listening for power events and sets display to invalid
00023   virtual void pause() {
00024     erouter->removeListener(this);
00025     ControlBase::pause();
00026   }
00027   //! calls report()
00028   virtual void refresh() {
00029     erouter->addTimer(this,0,1000,true);
00030     EtherDriverGetWLANStatisticsMsg msg;
00031     EtherStatus status = ERA201D1_GetWLANStatistics(&msg);
00032     clearSlots();
00033     const unsigned int TMP_SIZE=255;
00034     char tmp[TMP_SIZE];
00035     if (status == ETHER_OK) {
00036       snprintf(tmp,TMP_SIZE,"link: %d",msg.statistics.link);
00037       pushSlot(new NullControl(tmp));
00038       snprintf(tmp,TMP_SIZE,"signal: %d",msg.statistics.signal);
00039       pushSlot(new NullControl(tmp));
00040       snprintf(tmp,TMP_SIZE,"noise: %d",msg.statistics.noise);
00041       pushSlot(new NullControl(tmp));
00042       snprintf(tmp,TMP_SIZE,"invalidIDCount: %d",msg.statistics.invalidIDCount);
00043       pushSlot(new NullControl(tmp));
00044       snprintf(tmp,TMP_SIZE,"invalidEncCount: %d",msg.statistics.invalidEncCount);
00045       pushSlot(new NullControl(tmp));
00046       snprintf(tmp,TMP_SIZE,"invalidMiscCount: %d",msg.statistics.invalidMiscCount);
00047       pushSlot(new NullControl(tmp));
00048       MMAccessor<LedMC> leds_acc(display_id);
00049       leds_acc->displayPercent(msg.statistics.signal/100.0,LedEngine::major,LedEngine::major);
00050     } else {
00051       snprintf(tmp,TMP_SIZE,"ERA201D1_GetWLANSettings() FAILED %d", status);
00052       pushSlot(new NullControl("Error Accessing wireless statistics",tmp));
00053       serr->printf("%s",tmp);
00054     }
00055 
00056     ControlBase::refresh();
00057   }
00058   //! stops listening for power events and sets display to invalid
00059   virtual void deactivate() {
00060     erouter->removeListener(this);
00061     ControlBase::deactivate();
00062   }
00063   virtual void processEvent(const EventBase& /*event*/) {
00064     refresh();
00065   }
00066   
00067 };
00068 
00069 /*! @file
00070  * @brief Defines NetworkStatusControl, which will display current network status such as wireless signal strength
00071  * @author Sony OPEN-R Sample Code
00072  * @author klibby and lkirtane (original port)
00073  * @author ejt (UI repackaging)
00074  *
00075  * $Author: ejt $
00076  * $Name: tekkotsu-2_3 $
00077  * $Revision: 1.1 $
00078  * $State: Exp $
00079  * $Date: 2005/01/12 22:37:26 $
00080  */
00081 
00082 #endif

Tekkotsu v2.3
Generated Sat Jan 29 02:25:23 2005 by Doxygen 1.4.0