void LevelOneDec::choosePrintCharts()
{
    QMessageBox *pmbx = new QMessageBox(QMessageBox::Information,
                                        tr("Print"),
                                        tr("What is the chart you want to print?"),
                                        QMessageBox::Yes | QMessageBox::No | QMessageBox::Close);

    pmbx->button(QMessageBox::Yes)->setText(tr("Phase Coordinates"));
    pmbx->button(QMessageBox::No)->setText(tr("Available Deviations"));

    int n = pmbx->exec();
    delete pmbx;

    if (n == QMessageBox::Yes)
    {
        levelOneChart->printLevelOnePlot();
        return;
    }
    else if (n == QMessageBox::No)
    {
        levelOneMuChart->printLevelOnePlot();
        return;
    }
    else if (n == QMessageBox::Close)
    {
        return;
    }
}
Exemple #2
0
int main(int argc, char *argv[])
{
#if _DEBUG || (__GNUC__ && !NDEBUG)
#ifdef _WIN32
  const char *logfilepath = "./resultsviewer.log";
#else
  const char *logfilepath = "/var/log/resultsviewer.log";
#endif
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
  openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
  fileLog.setLogLevel(Debug);
#else
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif

  bool cont = true;
  while(cont) {
    cont = false;

    // Make the run path the default plugin search location
    QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory()));

    QApplication qApplication(argc,argv);
    openstudio::Application::instance().setApplication(&qApplication);

    try {
      resultsviewer::MainWindow w;
      w.show();

      return qApplication.exec();

    } catch (const std::exception &e) {
      LOG_FREE(Fatal, "ResultsViewer", "An unhandled exception has occurred: " << e.what());
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unhandled Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unhandled exception has occurred.");
      msgBox.setInformativeText(e.what());
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    } catch (...) {
      LOG_FREE(Fatal, "ResultsViewer", "An unknown exception has occurred.");
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unknown Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unknown exception has occurred.");
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    }
  }
}
bool alele::AccountHolder::showAuthenticationPopup(string const& _title, string const& _text)
{
	QMessageBox userInput;
	userInput.setText(QString::fromStdString(_title));
	userInput.setInformativeText(QString::fromStdString(_text));
	userInput.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
	userInput.button(QMessageBox::Ok)->setText("Allow");
	userInput.button(QMessageBox::Cancel)->setText("Reject");
	userInput.setDefaultButton(QMessageBox::Cancel);
	return userInput.exec() == QMessageBox::Ok;
}
Exemple #4
0
int main(int argc, char *argv[])
{
  openstudio::Logger::instance().standardOutLogger().disable();

  openstudio::FileLogSink logFile(openstudio::toPath(logfilepath));
  logFile.setLogLevel(Warn);

  bool cont = true;
  while(cont) {
    cont = false;

    QApplication qApplication(argc,argv);
    openstudio::Application::instance().setApplication(&qApplication);

    try {
      resultsviewer::MainWindow w;
      w.show();

      return qApplication.exec();

    } catch (const std::exception &e) {
      LOG_FREE(Fatal, "ResultsViewer", "An unhandled exception has occurred: " << e.what());
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unhandled Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unhandled exception has occurred.");
      msgBox.setInformativeText(e.what());
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    } catch (...) {
      LOG_FREE(Fatal, "ResultsViewer", "An unknown exception has occurred.");
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unknown Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unknown exception has occurred.");
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    }
  }
}
void
WorkoutWindow::ergFileSelected(ErgFile*f)
{
    if (active) return;

    if (workout->isDirty()) {
        QMessageBox msgBox;
        msgBox.setText(tr("You have unsaved changes to a workout."));
        msgBox.setInformativeText(tr("Do you want to save them?"));
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::Cancel);
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.exec();

        // save first, otherwise changes lost
        if(msgBox.clickedButton() == msgBox.button(QMessageBox::Yes)) {
            active = true;
            saveFile();
            active = false;
        }
    }

    // just get on with it.
    ergFile = f;
    workout->ergFileSelected(f);

    // almost certainly hides it on load
    setScroller(QPointF(workout->minVX(), workout->maxVX()));
}
void FontSettingsPage::confirmDeleteColorScheme()
{
    const int index = d_ptr->m_ui->schemeComboBox->currentIndex();
    if (index == -1)
        return;

    const ColorSchemeEntry &entry = d_ptr->m_schemeListModel->colorSchemeAt(index);
    if (entry.readOnly)
        return;

    QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
                                              tr("Delete Color Scheme"),
                                              tr("Are you sure you want to delete this color scheme permanently?"),
                                              QMessageBox::Discard | QMessageBox::Cancel,
                                              d_ptr->m_ui->deleteButton->window());

    // Change the text and role of the discard button
    auto deleteButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
    deleteButton->setText(tr("Delete"));
    messageBox->addButton(deleteButton, QMessageBox::AcceptRole);
    messageBox->setDefaultButton(deleteButton);

    connect(deleteButton, &QAbstractButton::clicked, messageBox, &QDialog::accept);
    connect(messageBox, &QDialog::accepted, this, &FontSettingsPage::deleteColorScheme);
    messageBox->setAttribute(Qt::WA_DeleteOnClose);
    messageBox->open();
}
void FontSettingsPage::maybeSaveColorScheme()
{
    if (d_ptr->m_value.colorScheme() == d_ptr->m_ui->schemeEdit->colorScheme())
        return;

    QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
                                              tr("Color Scheme Changed"),
                                              tr("The color scheme \"%1\" was modified, do you want to save the changes?")
                                                  .arg(d_ptr->m_ui->schemeEdit->colorScheme().displayName()),
                                              QMessageBox::Discard | QMessageBox::Save,
                                              d_ptr->m_ui->schemeComboBox->window());

    // Change the text of the discard button
    QPushButton *discardButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
    discardButton->setText(tr("Discard"));
    messageBox->addButton(discardButton, QMessageBox::DestructiveRole);
    messageBox->setDefaultButton(QMessageBox::Save);

    if (messageBox->exec() == QMessageBox::Save) {
        const ColorScheme &scheme = d_ptr->m_ui->schemeEdit->colorScheme();
        scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::mainWindow());
    }
}
void ThemeSettingsWidget::maybeSaveTheme()
{
    if (!d->m_ui->editor->model()->hasChanges())
        return;

    QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
                                              tr("Theme Changed"),
                                              tr("The theme \"%1\" was modified, do you want to save the changes?")
                                                  .arg(d->m_currentTheme.displayName()),
                                              QMessageBox::Discard | QMessageBox::Save,
                                              d->m_ui->themeComboBox->window());

    // Change the text of the discard button
    QPushButton *discardButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
    discardButton->setText(tr("Discard"));
    messageBox->addButton(discardButton, QMessageBox::DestructiveRole);
    messageBox->setDefaultButton(QMessageBox::Save);

    if (messageBox->exec() == QMessageBox::Save) {
        Theme newTheme(d->m_currentTheme.name());
        d->m_ui->editor->model()->toTheme(&newTheme);
        newTheme.writeSettings(d->m_currentTheme.filePath());
    }
}
void measurepulse::on_pushButton_7_clicked()
{
	publiccaution.addevent("摩擦系数测试页面","完成测试并退出","用户完成测试并退出",1);

	//校验上次的测试
	QRegExp rx("^\\d+\\.?\\d*$");
	if ( rx.indexIn(lineEdit[2]->text()) == -1)
	{
		QMessageBox msgBox;
		msgBox.setText("输入格式不对,请重新输入");
		msgBox.setWindowTitle("输入错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		return;
	}
	bool ok;

	if (lineEdit[2]->text().toDouble(&ok) == 0)
	{
		QMessageBox msgBox;
		msgBox.setText("输入数据为0,请重新输入");
		msgBox.setWindowTitle("输入错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();
		return;
	}

	double count = 0;
	ksmc->GetEncoderCount(count);

	//新值小于小于旧值,说明可能翻转了
	if (count < encoder[2])
	{
		//真正翻转,而不是编码器回退,回退脉冲不可能超过3000000000
		if (count < 1000000000 && encoder[2] > 4000000000)
		{
			encoder[2] = 4294967295 - encoder[2] + count;
		} 
		else
		{
			encoder[2] = count - encoder[2];
		}
	}
	else
	{
		encoder[2] = count - encoder[2];
	}


	//校验编码计数
	if (encoder[2] == 0)
	{
		QMessageBox msgBox;
		msgBox.setText("编码器计数没有变化,请重新测试");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();

		ui.pushButton->setEnabled(false);
		ui.pushButton_2->setEnabled(false);
		ui.pushButton_3->setEnabled(false);
		ui.pushButton_4->setEnabled(false);
		ui.pushButton_5->setEnabled(true);
		ui.pushButton_6->setEnabled(false);
		ui.pushButton_7->setEnabled(false);
		lineEdit[0]->setEnabled(false);
		lineEdit[1]->setEnabled(false);
		lineEdit[2]->setEnabled(false);
		lineEdit[2]->clear();

		//返回
		return;
	}

	
	//3次的摩擦系数校验
	//一致性标识
	bool validcheck = true;
	meaure[0] = lineEdit[0]->text().toDouble(&ok);
	meaure[1] = lineEdit[1]->text().toDouble(&ok);
	meaure[2] = lineEdit[2]->text().toDouble(&ok);



	double frications[3];

	for (int i = 0;i < 3; ++i)
	{
		if (meaure[i] != 0)
		{
			frications[i] = encoder[i] / meaure[i];
			std::cout << "encoder,measure,frication:" <<  encoder[i] << "," << meaure[i] << "," << frications[i];
		} 
		else
		{
			frications[i] = 0;

		}
	}

	if((frications[0] - frications[1]) > 0)
	{
		if (((frications[0] - frications[1]) /frications[0]) > 0.005 )
		{
			validcheck = false;
		}
	}
	else
	{
		if (((frications[1] - frications[0]) /frications[0]) > 0.005 )
		{
			validcheck = false;

		}
	}

	if((frications[0] - frications[2]) > 0)
	{
		if (((frications[0] - frications[2]) /frications[0]) > 0.005 )
		{
			validcheck = false;
		}
	}
	else
	{
		if (((frications[2] - frications[0]) /frications[0]) > 0.005 )
		{
			validcheck = false;

		}
	}


	if((frications[2] - frications[1]) > 0)
	{
		if (((frications[2] - frications[1]) /frications[2]) > 0.005 )
		{
			validcheck = false;
		}
	}
	else
	{
		if (((frications[1] - frications[2]) /frications[2]) > 0.005 )
		{
			validcheck = false;
		}
	}

	if (validcheck == false)
	{
		QMessageBox msgBox;
		msgBox.setText("数据一致性不行,请重新测试");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();

		ui.pushButton->setEnabled(true);
		ui.pushButton_2->setEnabled(false);
		ui.pushButton_3->setEnabled(false);
		ui.pushButton_4->setEnabled(false);
		ui.pushButton_5->setEnabled(false);
		ui.pushButton_6->setEnabled(false);
		ui.pushButton_7->setEnabled(false);
		lineEdit[0]->setEnabled(false);
		lineEdit[1]->setEnabled(false);
		lineEdit[2]->setEnabled(false);
		lineEdit[0]->clear();
		lineEdit[1]->clear();
		lineEdit[2]->clear();
		return;

	}

    long frication = (long)(((frications[0] + frications[1] + frications[2])/3 ) * 1000)  ; 

	//摩擦系数范围检查
	QDomNode paranode = GetParaByName("tune", "摩擦系数");
	float minval,maxval;

	minval = paranode.firstChildElement("rangemin").text().toFloat(&ok);
	maxval = paranode.firstChildElement("rangemax").text().toFloat(&ok);

	//校验数据是否超标
	if (frication > maxval
		|| frication < minval)
	{
		QMessageBox msgBox;
		msgBox.setText("摩擦系数数据超出范围请重新测试!");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();

		ui.pushButton->setEnabled(true);
		ui.pushButton_2->setEnabled(false);
		ui.pushButton_3->setEnabled(false);
		ui.pushButton_4->setEnabled(false);
		ui.pushButton_5->setEnabled(false);
		ui.pushButton_6->setEnabled(false);
		ui.pushButton_7->setEnabled(false);
		lineEdit[0]->setEnabled(false);
		lineEdit[1]->setEnabled(false);
		lineEdit[2]->setEnabled(false);
		lineEdit[0]->clear();
		lineEdit[1]->clear();
		lineEdit[2]->clear();

		return;
	}


	//保存和应用
	paranode.firstChildElement("value").firstChild().setNodeValue(
		QString::number(frication));
	ksmc->SetPulserPerMeter(frication);

	//刷新到界面
	FricationNodeItem->setText(QString::number(frication));

	//保存XML文件
	QFile file(QApplication::applicationDirPath() + QString("/aaa.xml"));
	if (!file.open(QFile::WriteOnly))
	{
		QMessageBox msgBox;
		msgBox.setText("打开文件aaa.xml失败");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();
		return;
	}

	QTextStream out(&file);
	doc->save(out, 4);

	//返回
	this->accept();
}
void measurepulse::on_pushButton_5_clicked()
{
	publiccaution.addevent("摩擦系数测试页面","第三次开始","用户第三次开始",1);

	//校验上次的测试
	QRegExp rx("^\\d+\\.?\\d*$");
	if ( rx.indexIn(lineEdit[1]->text()) == -1)
	{
		QMessageBox msgBox;
		msgBox.setText("输入格式不对,请重新输入");
		msgBox.setWindowTitle("输入错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		return;
	}
	bool ok;

	if (lineEdit[1]->text().toDouble(&ok) == 0)
	{
		QMessageBox msgBox;
		msgBox.setText("输入数据为0,请重新输入");
		msgBox.setWindowTitle("输入错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();
		return;
	}

	//记录脉冲数
	double count = 0;
	ksmc->GetEncoderCount(count);

	//新值小于小于旧值,说明可能翻转了
	if (count < encoder[1])
	{
		//真正翻转,而不是编码器回退,回退脉冲不可能超过3000000000
		if (count < 1000000000 && encoder[1] > 4000000000)
		{
			encoder[1] = 4294967295 - encoder[1] + count;
		} 
		else
		{
			encoder[1] = count - encoder[1];
		}
	}
	else
	{
		encoder[1] = count - encoder[1];
	}

	//校验编码计数
	if (encoder[1] == 0)
	{
		QMessageBox msgBox;
		msgBox.setText("编码器计数没有变化,请重新测试");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();

		ui.pushButton->setEnabled(false);
		ui.pushButton_2->setEnabled(true);
		ui.pushButton_3->setEnabled(true);
		ui.pushButton_4->setEnabled(true);
		ui.pushButton_5->setEnabled(false);
		ui.pushButton_6->setEnabled(true);
		ui.pushButton_7->setEnabled(false);
		lineEdit[0]->setEnabled(false);
		lineEdit[1]->setEnabled(false);
		lineEdit[2]->setEnabled(false);
		lineEdit[1]->clear();

		//返回
		return;
	}
	//记录脉冲数目
	count = 0;
	ksmc->GetEncoderCount(count);
	encoder[2] = count;

	step = 3;

	interfaceevent* ptempevent = new interfaceevent();
	ptempevent->cmd = 0x0a;//橡毯开始运动
	ptempevent->status = 0x00;//命令状态

	//发送一个事件给后台线程
	QCoreApplication::postEvent(backendobject, ptempevent);

	//启动
	ui.pushButton_5->setEnabled(false);
	lineEdit[1]->setEnabled(false);
	ui.pushButton_8->setEnabled(false);

}
int MUH_HESAP_EKLEME_FISI::CHECK_DELETE_LINE ( int fis_id, int row_number )
{
    Q_UNUSED(fis_id);
    m_hesabin_parentini_aktar  = false;

    int alt_hesap_sayisi       = 0;
    int parent_id              = 0;
    int hesap_id               = m_ui->tablewidget_alt_hesaplar->item ( row_number, ROW_ID_COLUMN )->text().toInt();

    QMessageBox * mesaj        = new QMessageBox ( this );
    mesaj->setButtonText ( QMessageBox::Ok, tr ("Devam") );
    QPushButton * buton_cancel = mesaj->addButton ( QMessageBox::Cancel );
    mesaj->setButtonText ( QMessageBox::Cancel, tr ( "Vazgeç" ) );

    SQL_QUERY sql_query  ( DB );

    sql_query.PREPARE_SELECT("muh_hesaplar" , "tam_hesap_kodu , hesap_ismi" , "hesap_id = :hesap_id");
    sql_query.SET_VALUE      ( ":hesap_id", hesap_id );

    if ( sql_query.SELECT() NE 0 ) {
        sql_query.NEXT();

        mesaj->setWindowTitle ( tr ( "DİKKAT" ) );
        mesaj->setText ( tr ( "'%1 %2'` hesabı silinecek." ).arg ( sql_query.VALUE(0).toString()).arg ( sql_query.VALUE(1).toString() ) );
        mesaj->setInformativeText ( "Emin misiniz?" );
        mesaj->exec();

        if (mesaj->clickedButton() EQ buton_cancel ) {
            return ADAK_FAIL;
        }
    }

    sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_id" , "parent_id = :parent_id");
    sql_query.SET_VALUE      ( ":parent_id", hesap_id );

    alt_hesap_sayisi = sql_query.SELECT();

    if ( alt_hesap_sayisi > 0 ) {
        mesaj->setText ( tr ( "Hesabı silmek için,önce alt hesaplarını silmelisiniz!.." ) );
        mesaj->removeButton ( mesaj->button ( QMessageBox::Cancel ) );
        mesaj->setInformativeText ( "" );
        mesaj->setButtonText ( QMessageBox::Ok, tr ( "Tamam" ) );
        mesaj->exec();
        return ADAK_FAIL;
    }


    //Hesabin tek bir alt hesabi varsa,alt hesap ile ana hesap yer degistirecek

    sql_query.PREPARE_SELECT("muh_hesaplar" , "parent_id" , "hesap_id = :hesap_id");
    sql_query.SET_VALUE      ( ":hesap_id", hesap_id );

    if ( sql_query.SELECT() NE 0 ) {

        sql_query.NEXT();
        parent_id = sql_query.VALUE(0).toInt();
    }

    sql_query.PREPARE_SELECT("muh_hesaplar" , "hesap_id" , "parent_id = :parent_id");

    sql_query.SET_VALUE      ( ":parent_id", parent_id );

    if ( sql_query.SELECT() NE 0 ) {

        int hesap_sayisi = sql_query.NUM_OF_ROWS();


        if ( hesap_sayisi EQ 1 ) {
            m_hesabin_parentini_aktar = true;
            return ADAK_OK;
        }
        sql_query.PREPARE_SELECT("muh_fis_satirlari" , "fis_id" , "hesap_id = :hesap_id");

        sql_query.SET_VALUE(":hesap_id" , hesap_id);
        if ( sql_query.SELECT() NE 0 ) {
            DB->CANCEL_TRANSACTION();
            mesaj = new QMessageBox();
            mesaj->setIcon ( QMessageBox::Critical );
            mesaj->setWindowTitle ( tr ( "HATA" ) );
            mesaj->addButton ( QMessageBox::Ok );
            mesaj->setText ( tr ( "Hesap işlem görmüş,silinemez!.." ) );
            mesaj->exec();
            return ADAK_FAIL;
        }
    }

    return ADAK_OK;
}
Exemple #12
0
int main(int argc, char *argv[])
{

  ruby_sysinit(&argc, &argv);
  {
    RUBY_INIT_STACK;
    ruby_init();
  }

#if _DEBUG || (__GNUC__ && !NDEBUG)
#ifdef _WIN32
  const char *logfilepath = "./openstudio_pat.log";
#else
  const char *logfilepath = "/var/log/openstudio_pat.log";
#endif
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
  openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
  fileLog.setLogLevel(Debug);
#else
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif

  // list of Ruby modules we want to load into the interpreter
  std::vector<std::string> modules;
  modules.push_back("openstudioutilitiescore");
  modules.push_back("openstudioutilitiesbcl");
  modules.push_back("openstudioutilitiesidd");
  modules.push_back("openstudioutilitiesidf");
  modules.push_back("openstudioutilities");
  modules.push_back("openstudiomodel");
  modules.push_back("openstudiomodelcore");
  modules.push_back("openstudiomodelsimulation");
  modules.push_back("openstudiomodelresources");
  modules.push_back("openstudiomodelgeometry");
  modules.push_back("openstudiomodelhvac");
  modules.push_back("openstudiomodelrefrigeration");
  modules.push_back("openstudioenergyplus");
  modules.push_back("openstudioruleset");

  bool cont = true;
  while(cont) {
    cont = false;

    // Initialize the embedded Ruby interpreter
    std::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter(
        new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(),
          openstudio::getOpenStudioRubyScriptsPath(),
          modules));

    // Initialize the argument getter
    QSharedPointer<openstudio::ruleset::RubyUserScriptInfoGetter> infoGetter(
        new openstudio::ruleset::EmbeddedRubyUserScriptInfoGetter<openstudio::detail::RubyInterpreter>(rubyInterpreter));


    // Make the run path the default plugin search location
    QCoreApplication::addLibraryPath(openstudio::toQString(openstudio::getApplicationRunDirectory()));

    openstudio::pat::PatApp app(argc, argv, infoGetter);
    openstudio::Application::instance().setApplication(&app);

    try {
      return app.exec();
    } catch (const std::exception &e) {
      LOG_FREE(Fatal, "PatApp", "An unhandled exception has occurred: " << e.what());
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unhandled Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unhandled exception has occurred.");
      msgBox.setInformativeText(e.what());
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    } catch (...) {
      LOG_FREE(Fatal, "PatApp", "An unknown exception has occurred.");
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unknown Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unknown exception has occurred.");
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    }
  }
}
Exemple #13
0
//打开串口设备
bool Open(struct serialif* pserialif)
{

	pserialif->devmutex.lock();

	//设置并打开端口
	pserialif->hCom = CreateFileA(pserialif->Name.toAscii(), GENERIC_READ
		| GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);

	if (pserialif->hCom == (HANDLE) - 1)
	{
		QMessageBox msgBox;
		msgBox.setText("没有检测到加密狗!");
		msgBox.setWindowTitle("错误");
		msgBox.setStandardButtons(QMessageBox::Yes );
		QAbstractButton* tb = msgBox.button(QMessageBox::Yes);
		tb->setText("确定");
		msgBox.exec();
	}
	else
	{

		DCB wdcb;
		GetCommState(pserialif->hCom, &wdcb);

		wdcb.BaudRate = pserialif->BaudRate.toUInt();

		wdcb.ByteSize = pserialif->ByteSize.toUInt();

		if (pserialif->Parity == QString("EVEN"))
		{
			wdcb.Parity = EVENPARITY;
		}
		else if(pserialif->Parity == QString("ODD"))
		{
			wdcb.Parity = ODDPARITY;
		}
		else
		{
			wdcb.Parity = NOPARITY;
		}

		if (pserialif->StopBits == QString("2"))
		{
			wdcb.StopBits =TWOSTOPBITS;
		}
		else
		{
			wdcb.StopBits =ONESTOPBIT;
		}

		if (pserialif->fRtsControl == QString("disable"))
		{
			wdcb.fRtsControl = RTS_CONTROL_DISABLE;
		}
		else if(pserialif->fRtsControl == QString("handshake"))
		{
			wdcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
		}
		else if(pserialif->fRtsControl == QString("toggle"))
		{
			wdcb.fRtsControl = RTS_CONTROL_TOGGLE;
		}
		else
		{
			wdcb.fRtsControl = RTS_CONTROL_ENABLE;
		}

		SetCommState(pserialif->hCom, &wdcb);
		PurgeComm(pserialif->hCom, PURGE_TXCLEAR|PURGE_RXCLEAR);


		//异步要设置超时时间
		COMMTIMEOUTS m_timeout;
		m_timeout.ReadIntervalTimeout = 1000;
		m_timeout.ReadTotalTimeoutConstant = 1000;
		m_timeout.ReadTotalTimeoutMultiplier = 1000;
		m_timeout.WriteTotalTimeoutConstant = 1000;
		m_timeout.WriteTotalTimeoutMultiplier =1000;
		SetCommTimeouts(pserialif->hCom,&m_timeout);

		pserialif->deviceopen = true;
	}

	pserialif->devmutex.unlock();
	return true;
}
Exemple #14
0
int main(int argc, char *argv[])
{

#if RUBY_API_VERSION_MAJOR && RUBY_API_VERSION_MAJOR==2
  ruby_sysinit(&argc, &argv);
  {
    RUBY_INIT_STACK;
    ruby_init();
  }
#endif

#if _DEBUG || (__GNUC__ && !NDEBUG)
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Debug);
  openstudio::FileLogSink fileLog(openstudio::toPath(logfilepath));
  fileLog.setLogLevel(Debug);
#else
  openstudio::Logger::instance().standardOutLogger().setLogLevel(Warn);
#endif

  bool cont = true;
  while(cont) {
    cont = false;



    std::vector<std::string> modules;
    modules.push_back("openstudioutilitiescore");
    modules.push_back("openstudioutilitiesbcl");
    modules.push_back("openstudioutilitiesidd");
    modules.push_back("openstudioutilitiesidf");
    modules.push_back("openstudioutilities");
    modules.push_back("openstudiomodel");
    modules.push_back("openstudiomodelcore");
    modules.push_back("openstudiomodelsimulation");
    modules.push_back("openstudiomodelresources");
    modules.push_back("openstudiomodelgeometry");
    modules.push_back("openstudiomodelhvac");
    modules.push_back("openstudioenergyplus");
    modules.push_back("openstudioruleset");

    //try {
    // Initialize the embedded Ruby interpreter
    boost::shared_ptr<openstudio::detail::RubyInterpreter> rubyInterpreter(
        new openstudio::detail::RubyInterpreter(openstudio::getOpenStudioRubyPath(),
          openstudio::getOpenStudioRubyScriptsPath(),
          modules));

    // Initialize the argument getter
    QSharedPointer<openstudio::ruleset::RubyUserScriptArgumentGetter> argumentGetter(
        new openstudio::ruleset::detail::RubyUserScriptArgumentGetter_Impl<openstudio::detail::RubyInterpreter>(rubyInterpreter));



    openstudio::OpenStudioApp app(argc, argv, argumentGetter);
    openstudio::Application::instance().setApplication(&app);

    try {
      return app.exec();
    } catch (const std::exception &e) {
      LOG_FREE(Fatal, "OpenStudio", "An unhandled exception has occurred: " << e.what());
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unhandled Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unhandled exception has occurred.");
      msgBox.setInformativeText(e.what());
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    } catch (...) {
      LOG_FREE(Fatal, "OpenStudio", "An unknown exception has occurred.");
      cont = true;
      QMessageBox msgBox;
      msgBox.setWindowTitle("Unknown Exception");
      msgBox.setIcon(QMessageBox::Critical);
      msgBox.setText("An unknown exception has occurred.");
      msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Close);
      msgBox.button(QMessageBox::Retry)->setText("Relaunch");
      if (msgBox.exec() == QMessageBox::Close) {
        cont = false;
      }
    }
  }
}
Exemple #15
0
void WebView::onFeaturePermissionRequest(const QUrl &securityOrigin, QWebEnginePage::Feature feature)
{

    if(Preferences::getInstance()->isPermissionGranted(feature))
    {
        page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
        return;
    }

    if(Preferences::getInstance()->isPermissionDenied(feature))
    {
        page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionDeniedByUser);
        return;
    }

    auto permissionString = [](QWebEnginePage::Feature feature) {
        switch(feature)
        {
            case QWebEnginePage::Geolocation:
                return tr("current location");
            case QWebEnginePage::MediaAudioVideoCapture:
                return tr("camera and microphone");
            case QWebEnginePage::MediaAudioCapture:
                return tr("microphone");
            case QWebEnginePage::MediaVideoCapture:
                return tr("camera");
            default:
                return tr("unknown");
        }
    };

    qDebug() << Q_FUNC_INFO;
    qDebug() << securityOrigin << " " << feature;

    QMessageBox *box = new QMessageBox(QMessageBox::Question,
                                       tr("Permission Request"),
                                       tr("VRSteam wants to access your %1, do you want to allow that?").arg(permissionString(feature)),
                                       QMessageBox::Yes | QMessageBox::No,
                                       this);

    QCheckBox *checkBox = new QCheckBox(tr("Remember this decision"), box);
    box->setCheckBox(checkBox);

    box->exec();

    bool accepted = box->clickedButton() == box->button(QMessageBox::Yes);
    if(accepted)
    {
        qDebug() << "Accepted feature request";
        page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionGrantedByUser);
    }
    else
    {
        qDebug() << "Denied feature request";
        page()->setFeaturePermission(securityOrigin, feature, QWebEnginePage::PermissionDeniedByUser);
    }

    if(checkBox->isChecked())
    {
        Preferences::getInstance()->setPermission(feature, accepted);
    }
}
Exemple #16
0
bool checkSystemInstallation(QString& parVboxDefaultMachineFolder)
{
  QString buttonContinueText = QCoreApplication::translate("'Continue-anyway'-Button of a shown warning", "Continue anyway");
  size_t memorySize = getMemorySize( );
  qint64 freeMemoryInMb = memorySize / (1024 * 1024);
  // currently not needed:
  //ILOG("Total Physical RAM size: " + QString::number(freeMemoryInMb) + " MB");
  //qint64 freeSpace = getFreeDiskSpace(parInstallPath);
  //ILOG("Free space on disk containing '" + parInstallPath + "': " + QString::number(freeSpace) + " Bytes");

  int availableRamNeededInMB;
  if (RunningOnWindows())
    availableRamNeededInMB = 1024 * 3;
  else
    availableRamNeededInMB = 1024 * 2;

  if (freeMemoryInMb < availableRamNeededInMB)
  {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    QString message = QCoreApplication::translate("check available resources", "This computer has to low memory(%1 MegaByte) for the PrivacyMachine to work properly (highly recommended: %2 MegaByte).");
    message = message.arg(QString::number(freeMemoryInMb), QString::number(availableRamNeededInMB));
    msgBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore);
    msgBox.button(QMessageBox::Ignore)->setText(buttonContinueText);
    msgBox.setText(message);
    int ret = msgBox.exec();
    if (ret != QMessageBox::Ignore)
      return false;
    else
     ILOG("User pressed Button 'Continue Anyway' while memory check");
  }

  bool hasVirtualization = CpuFeatures::Virtualization();
  if (!hasVirtualization)
  {
    IERR("Hardware Virtualisation Support is not available");
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Critical);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    msgBox.setTextFormat(Qt::RichText);   // this is what makes the links clickable
    QString message = QCoreApplication::translate("check available resources", "The Hardware Virtualization Support for the CPU is not enabled (or does not exist on very old computers). Please reboot to enter your BIOS and enable an option called like Virtualization, VT-x, AMD-V or AMD-SVM");
    message += "<br>";
    message += "<div style=\"text-align:center\">";
    message += "<a href='http://www.howtogeek.com/213795/how-to-enable-intel-vt-x-in-your-computers-bios-or-uefi-firmware/'>Explanation on howtogeek.com</a>";
    message += "</div>";
    msgBox.setText(message);
    msgBox.exec();
    return false;
  }

  bool vboxInstalled;
  QString vboxCommand;
  QString vboxVersion;  
  bool vboxExtensionPackInstalled;
  determineVirtualBoxInstallation(vboxInstalled, vboxCommand, vboxVersion, parVboxDefaultMachineFolder, vboxExtensionPackInstalled);

  if (!vboxInstalled)
  {
    IERR("VirtualBox is not installed");
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Critical);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    msgBox.setTextFormat(Qt::RichText);   // this is what makes the links clickable
    QString message = QCoreApplication::translate("check of software dependencies", "VirtualBox from Oracle is not installed, please download it directly from:");
    message += "<br>";
    message += "<div style=\"text-align:center\">";
    message += "<a href='https://www.virtualbox.org'>https://www.virtualbox.org</a>";
    message += "</div>";
    msgBox.setText(message);
    msgBox.exec();
    return false;
  }

  if (!vboxExtensionPackInstalled)
  {
    IERR("ExtensionPack of VirtualBox is not installed");
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Critical);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    msgBox.setTextFormat(Qt::RichText);   // this is what makes the links clickable
    QString messagePart1 = QCoreApplication::translate("check of software dependencies", "The 'Extension Pack' for VirtualBox is not installed, please download it directly from:");
    messagePart1 += "<br>";
    messagePart1 += "<div style=\"text-align:center\">";
    messagePart1 += "<a href='https://www.virtualbox.org/wiki/Downloads'>https://www.virtualbox.org/wiki/Downloads</a>";
    messagePart1 += "</div>";
    QString messagePart2 = QCoreApplication::translate("check of software dependencies", "Install the downloaded File 'Oracle_VM_VirtualBox_Extension_Pack-[CurrentVersion].vbox-extpack' with a Double-Click (it will be opened by VirtualBox)");
    msgBox.setText(messagePart1 + "<br><br>" + messagePart2);
    msgBox.exec();
    return false;
  }


  // We only support the VirtualBox-Versions supported by Oracle: One main and one legacy version
  // @Debian-Users: Sorry, but VirtualBox is not maintained any more: <https://www.debian.org/security/2016/dsa-3699>
  //
  // from <https://www.virtualbox.org/wiki/Download_Old_Builds>
  // i.e. Actual Version of VirtualBox-Stable : 5.0.28 (<StableMajor>.<StableMinor>.<StableBugfix>)
  // i.e. Actual Version of VirtualBox-Current: 5.1.8  (<CurrentMajor>.<CurrentMinor>.<CurrentBugfix>)
  // -> 5.0.28: ok
  // -> 5.0.29: ok, log warning
  // -> 5.0.1: show warning: too old
  // -> 5.1.8: ok
  // -> 5.1.9: ok, log warning
  // -> 5.1.1: show warning: too old
  // -> 5.2.1: show warning: unsupported
  int  StableMajor = 5; int  StableMinor = 0; int  StableBugfix = 28;
  int CurrentMajor = 5; int CurrentMinor = 1; int CurrentBugfix = 8;

  // Supported Versions to show User i.e. "5.0.* + 5.1.*"
  QString supportedVersions;
  supportedVersions += QString::number(StableMajor);
  supportedVersions += ".";
  supportedVersions += QString::number(StableMinor);
  supportedVersions += ".* ";
  supportedVersions += QString::number(CurrentMajor);
  supportedVersions += ".";
  supportedVersions += QString::number(CurrentMinor);


  // the current version contains the subversion revision i.e.: 5.0.28r111378
  ILOG("installed VirtualBox version: " + vboxVersion);
  QRegularExpression regExpVboxVersion("^(\\d+)\\.(\\d+)\\.(\\d+).*$", QRegularExpression::MultilineOption);
  QRegularExpressionMatch match;

  bool showVersionUnsupported = false;
  bool showVersionToOld = false;
  bool showVersionToNew = false;
  QString vboxVersionStripped = vboxVersion;
  match = regExpVboxVersion.match(vboxVersion);
  if (match.lastCapturedIndex() == 3)
  {
    vboxVersionStripped = match.captured(1) + "." + match.captured(2) + "." + match.captured(3);
    if (match.captured(1).toInt() == StableMajor && match.captured(2).toInt() == StableMinor )
    {
      // VirtualBox-Stable detected
      if (match.captured(3).toInt() < StableBugfix)
      {
        showVersionToOld = true;
      }
      if (match.captured(3).toInt() > StableBugfix)
      {
        IWARN("Currently installed Bugfix-Version of VirtualBox-Stable is newer than the Verion tested by the PrivacyMachine-Team");
      }
    }
    else if (match.captured(1).toInt() == CurrentMajor && match.captured(2).toInt() == CurrentMinor )
    {
      // VirtualBox-Current detected
      if (match.captured(3).toInt() < CurrentBugfix)
      {
        showVersionToOld = true;
      }
      if (match.captured(3).toInt() > CurrentBugfix)
      {
        IWARN("Currently installed Bugfix-Version of VirtualBox-Current is newer than the Verion tested by the PrivacyMachine-Team");
      }
    }
    else if (match.captured(1).toInt() == CurrentMajor && match.captured(2).toInt() > CurrentMinor )
    {
      // Minor(API?) version is newer
      IWARN("Currently installed Version of VirtualBox-Current is newer than the Verion tested by the PrivacyMachine-Team");
      showVersionToNew = true;
    }
    else
    {
      IWARN("Unknown version format of virtualbox");
      showVersionUnsupported = true;
    }
  }
  else
  {
    IWARN("Unknown version format of virtualbox");
    showVersionUnsupported = true;
  }

  if (showVersionUnsupported)
  {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    QString messageLine1 = QCoreApplication::translate("check of software dependencies", "The currently installed VirtualBox version '%1' is unsupported.");
    messageLine1 = messageLine1.arg(vboxVersionStripped);
    QString messageLine2 = QCoreApplication::translate("check of software dependencies", "Currently supported versions are: %1");
    messageLine2 = messageLine2.arg(supportedVersions);
    QString message = messageLine1 + "<br>" + messageLine2;
    msgBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore);
    msgBox.button(QMessageBox::Ignore)->setText(buttonContinueText);
    msgBox.setText(message);
    int ret = msgBox.exec();
    if (ret != QMessageBox::Ignore)
      return false;
    else
     IWARN("User pressed Button 'Continue Anyway' while virtualbox version check");
  }

  if (showVersionToNew)
  {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    QString messageLine1 = QCoreApplication::translate("check of software dependencies", "The currently installed VirtualBox version '%1' is newer than the Verion tested by the PrivacyMachine-Team.");
    messageLine1 = messageLine1.arg(vboxVersionStripped);
    QString messageLine2 = QCoreApplication::translate("check of software dependencies", "Currently tested versions are: %1");
    messageLine2 = messageLine2.arg(supportedVersions);
    QString message = messageLine1 + "<br>" + messageLine2;
    msgBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore);
    msgBox.button(QMessageBox::Ignore)->setText(buttonContinueText);
    msgBox.setText(message);
    int ret = msgBox.exec();
    if (ret != QMessageBox::Ignore)
      return false;
    else
     IWARN("User pressed Button 'Continue Anyway' while virtualbox version check");
  }

  if (showVersionToOld)
  {
    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Warning);
    msgBox.setWindowTitle(QApplication::applicationName()+" "+QApplication::applicationVersion());
    QString messageLine1 = QCoreApplication::translate("check of software dependencies", "The currently installed VirtualBox version '%1' is too old. Please update VirtualBox to the current version and start the PrivacyMachine again.");
    messageLine1 = messageLine1.arg(vboxVersionStripped);
    QString messageLine2;
    if (RunningOnWindows())
    {
      messageLine2 = "<br><br>" + QCoreApplication::translate("check of software dependencies", "To update VirtualBox: Start it manually from the windows start menu and navigate to the menu inside VirtualBox: File -> Check for Updates");
    }
    QString message = messageLine1 + messageLine2;
    msgBox.setStandardButtons(QMessageBox::Abort | QMessageBox::Ignore);
    msgBox.button(QMessageBox::Ignore)->setText(buttonContinueText);
    msgBox.setText(message);
    int ret = msgBox.exec();
    if (ret != QMessageBox::Ignore)
      return false;
    else
     IWARN("User pressed Button 'Continue Anyway' while virtualbox version check");
  }

  return true;
}