⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serverplug.cpp

📁 软件无线电的平台
💻 CPP
字号:
/***************************************************************************                 ServerPlug.cpp  -  Interfaces to the server                            -------------------    begin                :  2003    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 03/01/20 - ineiti - begin **************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#include <qapplication.h>#include <qdir.h>#include "serverplug.h"#include <iostream>using namespace std;#define DBG_LVL 0ServerPlug::ServerPlug( QString path ) : QWidget() {  QDir act( path );  f_cmd = new QFile( act.absFilePath( "cmd" ) );  f_result = new QFile( act.absFilePath( "result" ) );    if ( !f_cmd->exists() || !f_result->exists() ){    cout << "You must point to a dir with a cmd and result file" << endl;    qApp->quit();  }  f_cmd->open( IO_Raw | IO_WriteOnly );  cout << "opened cmd" << endl;  f_result->open( IO_Raw | IO_ReadOnly );  cout << "openend result\n";  cmd = new QTextStream( f_cmd );  result = new QTextStream( f_result );}ServerPlug::~ServerPlug(){}// Reads the number of channelsint ServerPlug::getNbrChannels(){  int ret;  QStringList res = sendCmd( "STATS" );  ret = res[0].toInt();#if DBG_LVL >= 4  cout << "nbrChannels: " << ret << endl;#endif  return ret;}// Reads the maximal length of the filterint ServerPlug::getMaxFilterLength(){  int ret;  QStringList res = sendCmd( "STATS" );  ret = res[1].toInt();#if DBG_LVL >= 4  cout << "maxFilter: " << ret << endl;#endif  return ret;}// Sets the filter for a given channelvoid ServerPlug::setChannel( int index, QValueList<double> *h ){  unsigned int i;    *cmd << "CHANNEL " << index << " " << h->count() << " ";  for ( i=0; i<h->count(); i++ ){    *cmd << *h->at(i) << " ";  }  flush();}void ServerPlug::flush(){  f_cmd->close();  f_cmd->open( IO_Raw | IO_WriteOnly );  cmd = new QTextStream( f_cmd );}QStringList ServerPlug::sendCmd( QString send ){#if DBG_LVL >= 4  cout << "writing: " << send << "\n";#endif  *cmd << send << endl;  flush();  QString res;  res = result->readLine();#if DBG_LVL >= 4  cout << "returned: " << res << endl;#endif  return QStringList::split( " ", res );}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -