00001 /*************************************************************************** 00002 ** 00003 ** This file is part of dascubed. 00004 ** 00005 ** This file may be distributed and/or modified under the terms of the 00006 ** GNU General Public License version 2 or 3 as published by the Free 00007 ** Software Foundation and appearing in the file LICENSE.GPL included 00008 ** in the packaging of this file. 00009 ** 00010 ** This file is distributed in the hope that it will be useful, but WITHOUT 00011 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 ** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 ** more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 ** 00018 ** See http://www.geopsy.org for more information. 00019 ** 00020 ** Created: 2011-03-23 00021 ** Authors: 00022 ** Marc Wathelet (LGIT, Grenoble, France) 00023 ** 00024 ***************************************************************************/ 00025 00026 #ifndef CUBEDEVICE_H 00027 #define CUBEDEVICE_H 00028 00029 #include <GpCoreTools.h> 00030 #include <WaranCore.h> 00031 00032 #include "CubeSerial.h" 00033 #include "CubeBuffer.h" 00034 00035 class CubeTcpServer; 00036 00037 class CubeDevice: public PThread 00038 { 00039 public: 00040 CubeDevice(const std::string& stationName, 00041 const std::string& devicePath, 00042 CubeTcpServer * server); 00043 ~CubeDevice(); 00044 00045 const std::string stationName() const {return _stationName;} 00046 00047 void setAutoStart(bool as) {_serial->setAutoStart(as);} 00048 bool autoStart() const {return _serial->autoStart();} 00049 00050 inline bool write(const char * buf, ssize_t byteCount); 00051 bool mutexWrite(const char * buf, ssize_t byteCount); 00052 00053 bool isRunning() const {return _buffer->isRunning();} 00054 unsigned long int runningTime() const {return _buffer->runningTime();} 00055 bool isConnected() const {return _serial->isConnected();} 00056 00057 unsigned int frequency() const {return _buffer->frequency();} 00058 unsigned int hardwareGain() const {return _buffer->hardwareGain();} 00059 unsigned int softwareGain() const {return _buffer->softwareGain();} 00060 unsigned int timeMode() const {return _buffer->timeMode();} 00061 private: 00062 void startCube(); 00063 virtual void run(); 00064 00065 std::string _stationName; 00066 CubeBuffer * _buffer; 00067 CubeSerial * _serial; 00068 CubeTcpServer * _server; 00069 }; 00070 00071 inline bool CubeDevice::write(const char * buf, ssize_t byteCount) 00072 { 00073 return _serial->write(buf, byteCount); 00074 } 00075 00076 #endif // CUBEDEVICE_H