Exemplo n.º 1
0
/*!
 */
void pAcquisitionWindow::setupConnections()
{
  connect(m_transportBar, SIGNAL(start()), this, SLOT(startRun()));    
  connect(m_transportBar, SIGNAL(stop()), this, SLOT(stopRun()));

  connect(m_runController, SIGNAL(runStarted()),
          this, SLOT(disableTabs()));
  connect(m_runController, SIGNAL(runStopped()),
          this, SLOT(enableTabs()));          
  connect(m_runController, SIGNAL(runStopped()), this, SLOT(stop()));
  connect(m_runController, SIGNAL(stationIdSet(int)), m_daqDisplay,
	  SLOT(updateStationId(int)));
  connect(m_runController, SIGNAL(runIdChanged(int)), m_daqDisplay,
	  SLOT(updateRunId(int)));
  connect(m_runController, SIGNAL(statusChanged(QString)), m_daqDisplay,
	  SLOT(updateStatus(QString)));
  connect(m_runController, SIGNAL(numDataBlocksChanged(int)),
	  m_daqDisplay, SLOT(updateNumDataBlocks(int)));
  connect(m_runController, SIGNAL(numEventsChanged(int)),
	  m_daqDisplay, SLOT(updateNumEvents(int)));
  connect(m_runController, SIGNAL(elapsedSecondsChanged(int)),
	  m_daqDisplay, SLOT(updateElapsedSeconds(int)));
  connect(m_runController, SIGNAL(averageEventRateChanged(double)),
	  m_daqDisplay, SLOT(updateAverageDaqRate(double)));
  //connect(m_runController, SIGNAL(instantEventRateChanged(double)),
  //m_daqDisplay, SLOT(updateInstantDaqRate(double)));
  connect(m_runController->xpolFpga(),
	  SIGNAL(vrefRead(unsigned short, double)),
	  this, SLOT(displayReference(unsigned short, double)));
  connect(m_thresholdSettingTab->getRefreshRefButton(), SIGNAL(clicked()),
  	  m_runController->xpolFpga(), SLOT(readVrefDac()));
  connect(m_userPreferencesTab, SIGNAL(visualizetionModeChanged(int)),
	  this, SLOT(changeVisualizationMode(int)));
}
Exemplo n.º 2
0
StabilityBin::StabilityBin(ContextProvider::Service& s):
    isStableProperty(s, "Position.Stable"),
    isShakyProperty(s, "Position.Shaky"),
    accelerometerReader(10),
    cutterFilter(4.0),
    avgVarFilter(60),
    stabilityFilter(&isStableProperty, &isShakyProperty, STABILITY_THRESHOLD, UNSTABILITY_THRESHOLD, STABILITY_HYSTERESIS),
    sessionId(0)
{
    add(&accelerometerReader, "accelerometer");
    add(&normalizerFilter, "normalizerfilter");
    add(&cutterFilter, "cutterfilter");
    add(&avgVarFilter, "avgvarfilter");
    add(&stabilityFilter, "stabilityfilter");

    join("accelerometer", "source", "normalizerfilter", "sink");
    join("normalizerfilter", "source", "cutterfilter", "sink");
    join("cutterfilter", "source", "avgvarfilter", "sink");
    join("avgvarfilter", "source", "stabilityfilter", "sink");

    // Context group
    group.add(isStableProperty);
    group.add(isShakyProperty);
    connect(&group, SIGNAL(firstSubscriberAppeared()), this, SLOT(startRun()));
    connect(&group, SIGNAL(lastSubscriberDisappeared()), this, SLOT(stopRun()));
}
Exemplo n.º 3
0
OrientationBin::OrientationBin(ContextProvider::Service& s):
    topEdgeProperty(s, "Screen.TopEdge"),
    isCoveredProperty(s, "Screen.IsCovered"),
    isFlatProperty(s, "Position.IsFlat"),
    accelerometerReader(10),
    topEdgeReader(10),
    faceReader(10),
    screenInterpreterFilter(&topEdgeProperty, &isCoveredProperty, &isFlatProperty),
    sessionId(0)
{
    add(&topEdgeReader, "topedge");
    add(&faceReader, "face");
    add(&screenInterpreterFilter, "screeninterpreterfilter");

    // Create a branching filter chain
    join("topedge", "source", "screeninterpreterfilter", "sink");
    join("face", "source", "screeninterpreterfilter", "sink");

    // Context group
    group.add(topEdgeProperty);
    group.add(isCoveredProperty);
    group.add(isFlatProperty);
    connect(&group, SIGNAL(firstSubscriberAppeared()), this, SLOT(startRun()));
    connect(&group, SIGNAL(lastSubscriberDisappeared()), this, SLOT(stopRun()));

    // Set default values (if the default isn't Unknown)
    topEdgeProperty.setValue("top");
    isCoveredProperty.setValue(false);
    isFlatProperty.setValue(false);
}
Exemplo n.º 4
0
void CRunGui::newEnv()
{
	stopRun();
	//NewEnvDialog newEnvDialog(Env.MapFilePath, Env.EffFilePath ,Env.BeetlesFilePath, this );
	int result = newEnvDialog->exec();
	if (result ==QDialog::Accepted)
	{
		COneRun oneRun;
		newEnvDialog->getData(&oneRun);
		//QMessageBox::information(NULL,"MyApp",QString::number(oneRun.NumRandBeetles) +" Before cleaning");
		Env.CleanEnv();
		//QMessageBox::information(NULL,"MyApp",QString::number(oneRun.NumRandBeetles));
		Env.SetEnv(&oneRun);
		//1QMessage::information(NULL,"MyApp","Env is cleaned");
		//Env.FillEmptyEnvRandomly(seed,numBeetles,mapFN,effFN,isStepOnFlower);	
		//1QMessage::information(NULL,"MyApp","Env is filled"); //ch1
		//emit envChanged();//uprav tak, aby to nastalo jen if Env was 0
		//Field->setEnvRef(Env);	
		emit envIsEmpty(Env.IsEmpty);
		FlowerGrowingRatioInEnvChanged(GFSlider->value());

		//1QMessage::information(NULL,"MyApp","Message is emited"); //ch1
		
		Env.NextTime();
		renewAllChildren();
		statusBar()->showMessage(tr("New environment made."));
	}
}
Exemplo n.º 5
0
LWDAQ_Client::LWDAQ_Client(QString host, quint16 port, QObject *parent) : QObject(parent),
                                  hostName(host),
                                  portNo(port),
                                  currentState(UNSET),
                                  cmdNo(0),
                                  error(false),
                                  errorText("") {

    tcpSocket = new QTcpSocket(this);

    connect(tcpSocket, SIGNAL(connected()), this, SLOT(gotConnected()));
    connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(gotDisconnected()));
    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readStatus()));
    connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)),
                this, SLOT(displayError(QAbstractSocket::SocketError)));

    connectTimer = new QTimer(this);
    connectTimer->setInterval(RECONNECT_TIME*1000);
    connectTimer->setSingleShot(true);
    connect(connectTimer, SIGNAL(timeout()), this, SLOT(init()));

    statusTimer = new QTimer(this);
    statusTimer->setInterval(SLOW_UPDATE_TIME*1000);
    statusTimer->setSingleShot(false);
    connect(statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));

    runTimer = new QTimer(this);
    runTimer->setInterval(DEFAULT_RUN_TIME*1000);
    runTimer->setSingleShot(true);
    connect(runTimer, SIGNAL(timeout()), this, SLOT(stopRun()));
}
Exemplo n.º 6
0
 void changeDirction(double _dirct_speed, double angle) {
   stopRun();
   data.stri_speed = 0;
   data.dirct_speed = _dirct_speed;
   data.dth_goal = angle * ecl::pi /180;
   kobuki.setBaseControl( data.stri_speed, data.dirct_speed ); // dirct_speed: to control the speed of dirction
   dta.state = TURN;
   return;
 }
Exemplo n.º 7
0
 void goStright(double _stri_speed, double distance) {
   stopRun();
   data.stri_speed = _stri_speed;
   data.dirct_speed = 0;
   data.dx_goal = distance;
   kobuki.setBaseControl( data.stri_speed, data.dirct_speed ); 
   data.state = RUN;
   return;
 }
Exemplo n.º 8
0
/* 解析代码后,执行代码 */
void frmLog::onRun()
{
	if (isRunning)
	{
		stopRun();
	}
	else
	{
		startRun();
	}
}
Exemplo n.º 9
0
  void update( Kobuki& kobuki ){
    ecl::Pose2D<double> pose_update;
    ecl::linear_algebra::Vector3d pose_update_rates;
    kobuki.updateOdometry(pose_update, pose_update_rates);
    pose *= pose_update;
    dx += pose_update.x();
    dth += pose_update.heading();

    if( state == RUN ){
      if (data.dx >= data.dx_goal) {
        stopRun();
      } else if (data.dx <= -data.dx_goal) {
        stopRun();
      }
    }
    else if( state == TURN ){
      if (data.dth >= data.dth_goal) {
        stopRun();
      } else if (data.dth <= -data.dth_goal) {
        stopRun();
      }
    }
    return;
  }
Exemplo n.º 10
0
StabilityBin::~StabilityBin()
{
    stopRun();
}
Exemplo n.º 11
0
/* 收到串口数据 */
void frmLog::onReadData()
{
	QByteArray data = mSerial.readAll();
	QString str = data, ss, stime, smsg;
	int pos, len;
	static bool new_line = true;

	if ((str == "") || (str == "\n")) return;
	/* 符合熔断条件,向主窗体请求停止所有报文发送 */
	if ((ui.chkStopAll->isChecked()) && (ui.ctlStopPattern->text().trimmed().length() > 0))
	{
		if (str.indexOf(ui.ctlStopPattern->text()) >= 0)
		{
			stopRun();
			emit stopAllActions();
		}
	}
	str.replace("\r\n", "\n");
	str.remove("\r");
	// 出现\n的时候打印时间
find_next_line:
	//qDebug() << "str:" << str << new_line;
	pos = str.indexOf("\n");
	if (pos >= 0)
	{
		ss = str.mid(0, pos+1);
	}
	else 
		ss = str;
	if (new_line)
	{
		qDebug() << "Line:" << sMonitorLine;
		sLastLine = sMonitorLine;
		QDateTime time = QDateTime::currentDateTime();//获取系统现在的时间
		stime = time.toString("hh:mm:ss.zzz"); //设置显示格式
		smsg = "[" + stime + "]    " + ss;
		sMonitorLine = ss;
	}
	else
	{
		smsg += ss;
		sMonitorLine += ss;
	}

	// 如果有监控指定字符串
	if (sMonitorPattern != "")
	{
		if (sMonitorLine.indexOf(sMonitorPattern) >= 0)
			sMonitorResult = true;
	}

	// 读取指定内容开头的行
    if ((sReadLinePattern != "") && (sReadLineResult == false))
	{
		if (sLastLine.indexOf(sReadLinePattern) == 0)
        {
            sReadLine = sLastLine;
			sReadLineResult = true;
        }
	}

	// 检测看有没有版本信息
	checkVersionPattern(sMonitorLine);

	if (pos >= 0)
		new_line = true;
	else
		new_line = false;

	qDebug() << "MSG:" << sMonitorLine;
	//smsg = sMonitorLine;
	smsg.remove("[1;32m");
	smsg.remove("[1;33m");
	smsg.remove("[1;34m");
	smsg.remove("[1;35m");
	smsg.remove("[1;36m");
	smsg.remove("[0;0m");
	smsg.remove("[0m");

	//if (pos>=0)
	{
		ui.txtComInfo->insertPlainText(smsg);
		ui.txtComInfo->moveCursor(QTextCursor::End);
	}
	len = str.length();
	if ((pos >= 0) &&(pos < len - 1)) 
	{
		str = str.mid(pos + 1);
		goto find_next_line;
	}

	// 太多内容了,程序会变慢,保存后清除
	if (ui.txtComInfo->document()->lineCount() > mMaxMonitor)
	{
		saveMonitor();
		ui.txtComInfo->clear();
	}
	ui.ctlMonitorLineNum->setText(QString::number(ui.txtComInfo->document()->lineCount()));
}
Exemplo n.º 12
0
frmLog::~frmLog()
{
	stopRun();
}
Exemplo n.º 13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    _marker_detector.setMinMaxSize(0.0001,0.5);

    ui->cameraResolutionComboBox->addItem("640x480");
    ui->cameraResolutionComboBox->addItem("1920x1080");

    _serial_port = new QSerialPort();
    refreshSerialPortOptions();
    connect(ui->serialConnectButton,SIGNAL(clicked()),SLOT(updateSerialPort()));
    connect(ui->serialDisconnectButton,SIGNAL(clicked()),SLOT(disconnectSerialPort()));
    connect(_serial_port,SIGNAL(readyRead()),SLOT(receiveData()));
    connect(ui->sendSerialDataButton,SIGNAL(clicked()),SLOT(sendTextEditSerialData()));
    connect(ui->sendSerialDataLineEdit,SIGNAL(returnPressed()),SLOT(sendTextEditSerialData()));
    connect(ui->refreshSerialOptionsButton,SIGNAL(clicked()),SLOT(refreshSerialPortOptions()));
    loadDefaultSettings();
    //applySettings();

    //Timer connects to the kcamera object to call grabFrame every 30 milliseconds
    _timer = new QTimer(this);
    connect(_timer,SIGNAL(timeout()),SLOT(update()));
    _timer->start(20);

    //Update video every 20ms
    QTimer* video_timer = new QTimer(this);
    connect(video_timer,SIGNAL(timeout()),SLOT(updateVideo()));
    video_timer->start(20);

    connect(ui->applySettingsButton,SIGNAL(clicked()),SLOT(applySettings()));

    QFileDialog* file_dialog = new QFileDialog();
    connect(file_dialog,SIGNAL(fileSelected(QString)),ui->calibrationFileLineEdit,SLOT(setText(QString)));
    connect(ui->browseCalibrationFileButton,SIGNAL(clicked()),file_dialog,SLOT(open()));

    //Connections for selecting view (image/2D trace)
    connect(ui->viewSelectComboBox,SIGNAL(currentIndexChanged(QString)),SLOT(selectView(QString)));

    connect(ui->saveSentDataButton,SIGNAL(clicked()),SLOT(saveSentData()));
    connect(ui->clearSentDataButton,SIGNAL(clicked()),SLOT(clearSentData()));

    ui->markerTracePlot->addGraph();
    ui->markerTracePlot->graph(0)->addData(1.5,1.5);

    ui->markerTracePlot->graph(0)->addData(1.9,1.9);
    ui->markerTracePlot->graph(0)->addData(1.5,1.9);
    ui->markerTracePlot->graph(0)->setScatterStyle(QCPScatterStyle::ssCross);
    ui->markerTracePlot->replot();

    _running = false;
    _frame_count = 0;
    connect(ui->startRunButton,SIGNAL(clicked()),this,SLOT(startRun()));
    connect(ui->stopRunButton,SIGNAL(clicked()),this,SLOT(stopRun()));

    _received_data_max_length = 1000;
    _sent_data_max_length = 1000;

    //Camera Sliders
    connect(ui->brightnessSlider, SIGNAL(valueChanged(int)), this, SLOT(updateBrightness(int)));
    connect(ui->sharpnessSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSharpness(int)));
    connect(ui->autofocusCheckbox, SIGNAL(toggled(bool)), this, SLOT(updateAutoFocus(bool)));
    connect(ui->focusSlider, SIGNAL(valueChanged(int)), this, SLOT(updateFocus(int)));
}
Exemplo n.º 14
0
OrientationBin::~OrientationBin()
{
    stopRun();
}