Ejemplo n.º 1
0
void MainWindow::initSettings()
{
    AppSettings settings;
    this->setGeometry(settings.geometry());
    if (settings.isMaximized())
        this->setWindowState(this->windowState() | Qt::WindowMaximized);
}
Ejemplo n.º 2
0
void CalculateVelocityHandler::GetEventSVelRange(float &start, float &end, float &step)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();
    start = setting.s_start();
    end = setting.s_end();
    step = setting.s_step();
}
Ejemplo n.º 3
0
void VelParaSetupHandler::GetAreaParaSetupUiData(AreaPara &para)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    para.mine_area = setting.mine_area();
    para.search_area = setting.search_area();
    para.grid_step = setting.cell_step();
}
Ejemplo n.º 4
0
void AppSettingsTest::hostSaving()
{
    AppSettings appSettings;
    QFETCH(QString, input);
    QFETCH(QString, output);

    appSettings.setHost(input);
    QString res = appSettings.host();
    QVERIFY(res == output);
}
Ejemplo n.º 5
0
void SettingsDialog::LoadSettings(AppSettings &s /* = settings */)
{
	showConsoleCheck->SetValue(s.GetShowConsole());
	autoCloseConsoleCheck->SetValue(s.GetAutoCloseConsole());

	autoUpdateCheck->SetValue(s.GetAutoUpdate());

	instDirTextBox->SetValue(s.GetInstDir().GetFullPath());

	minMemorySpin->SetValue(s.GetMinMemAlloc());
	maxMemorySpin->SetValue(s.GetMaxMemAlloc());

	javaPathTextBox->SetValue(s.GetJavaPath());
	jvmArgsTextBox->SetValue(s.GetJvmArgs());
	
	switch (s.GetGUIMode())
	{
	case GUI_Simple:
		guiStyleDropDown->SetValue(guiModeSimple);
		break;
		
	case GUI_Default:
		guiStyleDropDown->SetValue(guiModeDefault);
		break;
	}
}
void LoginSettingWidget::showEvent(QShowEvent *event)
{
    AppSettings settings;
    settings.beginGroup(QString(APP_PARAM_GROUP_TARGET));
    dest_addr_edit->setText(settings.value(QString(APP_PARAM_ADDR), QString(DEFAULT_TARGET_ADDR)).toString());
    dest_port_edit->setText(settings.value(QString(APP_PARAM_PORT), QString(DEFAULT_TARGET_PORT)).toString());
    settings.endGroup();

    ok_button->setFocus();
    QWidget::showEvent(event);
}
PythonEditorPreferencesPage::PythonEditorPreferencesPage(wxWindow *parent,
                                                         AppSettings& appSettings)
    : EditorPreferencesBase(parent, appSettings, EditorId::PythonEditorId,
        appSettings.editorSettings().pythonSettings()),
    m_newSettings(appSettings.editorSettings().pythonSettings())
{
    wxSizer* fontInfoSizer = PreferencesDialogUtilities::createFontSettingsSizer(m_overrideThemeCheckBox,
        m_fontFaceName, m_fontSize, m_fontButton);

    wxSizer* topSizer = GetSizer();
    topSizer->Add(fontInfoSizer, 0, wxEXPAND | wxALL, 10);
}
Ejemplo n.º 8
0
void HotKeyManager::Init()//HWND hWndTarget)
{
	PrgAPI* pAPI = PRGAPI();
	AppSettings* appSettings = pAPI->GetAppSettings();
	INT value = 0;
	m_hWnd = NULL;//hWndTarget;

	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyPlay, value, 0);
	SetHotKey(HK_Play, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyStop, value, 0);
	SetHotKey(HK_Stop, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyPrev, value, 0);
	SetHotKey(HK_Prev, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyNext, value, 0);
	SetHotKey(HK_Next, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyMiniPlayer, value, 0);
	SetHotKey(HK_ToggleMiniPlayer, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyTooltip, value, 0);
	SetHotKey(HK_Tooltip, HIWORD(value), LOWORD(value));
	appSettings->Read(HotKeyManagerSettingsCategory, cHotkeyQuickSearch, value, 0);
	SetHotKey(HK_QuickSearch, HIWORD(value), LOWORD(value));


	EnableMultimediaHotKeys(pAPI->GetOption(OPT_GEN_MultimediaKeysActive) == 1);

}
void LoginSettingWidget::onOkButtonClicked()
{
    QString ip_addr = dest_addr_edit->text();
    QString port = dest_port_edit->text();

    if(ip_addr.isEmpty() || port.isEmpty()) {
        emit showMsg(Util::EmptyTargetAddrOrPortMsg);
    } else {
        AppSettings settings;
        settings.beginGroup(QString(APP_PARAM_GROUP_TARGET));
        settings.setValue(QString(APP_PARAM_ADDR), ip_addr);
        settings.setValue(QString(APP_PARAM_PORT), port);
        settings.endGroup();
        emit showLogin();
    }
}
Ejemplo n.º 10
0
bool CalculateVelocityHandler::GetChannelSVelRange(float &start, float &end, float &step)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    float p_vel;
    float s_vel;

    if (!GetEventAdjustVel(p_vel, s_vel))
    {
        return false;
    }
    start = s_vel * (100 + setting.minus_per()) / 100;
    end = s_vel * (100 + setting.plus_per()) / 100;
    step = setting.s_step();

    return true;
}
Ejemplo n.º 11
0
bool CalculateVelocityHandler::StationAdjust()
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();
    switch (setting.mode())
    {
    case 0:
        return StationAdjustModeP(selected_event_);
    case 1:
        return StationAdjustModeS(selected_event_);
    case 2:
        return StationAdjustModePS(selected_event_);
    default:
        return false;
    }

    return true;
}
//!
//! @param settings - Object to load settings from
//!
void AdvancedPanel::loadSettings(const AppSettings &settings) {

   print("AdvancedPanel::loadSettings()\n");

//   Init();

   bdmOptions.powerOffDuration         = settings.getValue(powerOffDurationKey,        bdmOptions.powerOffDuration);
   bdmOptions.powerOnRecoveryInterval  = settings.getValue(powerOnRecoveryIntervalKey, bdmOptions.powerOnRecoveryInterval);
   bdmOptions.resetDuration            = settings.getValue(resetDurationKey,           bdmOptions.resetDuration);
   bdmOptions.resetReleaseInterval     = settings.getValue(resetReleaseIntervalKey,    bdmOptions.resetReleaseInterval);
   bdmOptions.resetRecoveryInterval    = settings.getValue(resetRecoveryIntervalKey,   bdmOptions.resetRecoveryInterval);

#if (TARGET==CFV1) || (TARGET==ARM) || (TARGET==ARM_SWD)
   int eepromSize = settings.getValue(eeepromSizeKey,             0);
   eeepromSizeChoice = findEeepromSizeIndex(eepromSize);
   if (eeepromSizeChoice == 0) {
      flexNvmPartitionIndex = 0;
   }
   else {
      int partitionSize = settings.getValue(flexNvmPartitionSizeKey,        0);
      flexNvmPartitionIndex = findPartitionControlIndex(partitionSize);
   }
#endif
   TransferDataToWindow();
}
Ejemplo n.º 13
0
void MainWindow::closeEvent(QCloseEvent* closeEvent)
{
    if (m_scene && !this->saveChanges()) {
        closeEvent->ignore();
        return;
    }

    LOG(INFO) << "Saving settings while closing MainWindow.";

    AppSettings settings;

    if (!this->isMaximized())
        settings.setGeometry(this->geometry());

    settings.setIsMaximized(this->isMaximized());

    closeEvent->accept();
}
Ejemplo n.º 14
0
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif

    QApplication app(argc, argv);

    // Call this to force settings initialization before the application
    // fully launches.
    //
    AppSettings* appSettings = AppSettings::getInstance();

    // Translate application based on locale.
    QTranslator translator;
    bool ok = translator.load
    (
        QString("ghostwriter_") + appSettings->getLocale(),
        appSettings->getTranslationsPath()
    );

    if (!ok)
    {
        translator.load
        (
            "ghostwriter_en",
            appSettings->getTranslationsPath()
        );
    }

    app.installTranslator(&translator);

    QString filePath = QString();

    if (argc > 1)
    {
        filePath = app.arguments().at(1);
    }

    MainWindow window(filePath);

    window.show();
    return app.exec();
}
Ejemplo n.º 15
0
bool MUiDataAdapter::GetMagFilterBlast(EventInfoList &list)
{
    if (!GetNoFilterBlast(list))
    {
        return false;
    }

    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    for (int i = list.count() - 1 ; i >=0; i--)
    {
        if (list.at(i)->magnitude < setting.filter_all_event_magnitude())
        {
            list.removeAt(i);
        }
    }

    return true;
}
Ejemplo n.º 16
0
bool MUiDataAdapter::GetLargeEventInfo(EventInfoList &list)
{
    if (!MDataConfig::GetInstance()->data_exist())
    {
        return false;
    }

    bool ret = false;
    switch (MDataConfig::GetInstance()->event_type())
    {
    case EVENT_TYPE_SEIS:
        ret = GetNoFilterSeis(list);
        break;
    case EVENT_TYPE_BLAST:
        ret = GetNoFilterBlast(list);
        break;
    default:
        break;
    }

    if (!ret)
    {
        return false;
    }

    BubbleSort(list);

    AppSettings settting = ConfigManager::GetInstance()->AppSetting();
    float reference_magnitude = settting.filter_relative_large_event_magnitude();


    for (int i = list.count() - 1; i >= 0; i--)
    {
        if (list.at(i)->magnitude < reference_magnitude)
        {
            list.removeAt(i);
        }
    }

    list = list.mid(0, settting.filter_relative_large_event_display_num());

    return true;
}
Ejemplo n.º 17
0
/**
 *	@brief	キーマップ定義を読み込みます。initInstance の処理で呼ばれます。
 */
void WinCoveredCalcApp::loadKeyMappingsOnInit()
{
	Path keymapFile;
	AppSettings* appSettings = GetAppSettings();
	keymapFile = appSettings->GetKeymapFilePath();
	if (keymapFile.IsEmpty())
	{
		// 設定になければデフォルト

		// FIXME: ユーザに尋ねる?
		
		// トリック:
		// 1.8.x まではカスタマイズがなくて日本語 JIS キーボードしかなかった。
		// デフォルト設定としては US QWERTY(標準的な 101/104 拡張キーボード)がよいが、
		// 言語が日本語の場合は以前のまま日本語 JIS キーボードの方が好ましい。
		// それ以外の場合に US QWERTY キーボードにする。
		MBCString langCode;
		GetCurrentLanguageCode(langCode);
		if (0 == langCode.Compare(LANG_CODE_JAJP))
		{
			keymapFile.AssignFromSlashSeparated(ALITERAL("${") VPATH_APP_KEYMAPS ALITERAL("}/JapaneseJIS.cckxw"));
		}
		else
		{
			keymapFile.AssignFromSlashSeparated(ALITERAL("${") VPATH_APP_KEYMAPS ALITERAL("}/UsQWERTY.cckxw"));
		}
		appSettings->SetKeymapFilePath(keymapFile);
	}
	
	Path absolutePath = ExpandVirtualPath(keymapFile);
	try
	{
		LoadKeyMappings(absolutePath);
	}
	catch (Exception* ex)
	{
		// キーマッピング定義が読み込めませんでした。
		ExceptionMessageUtils::DoExceptionMessageBoxWithText(this, ex, NSID_EMSG_LOAD_KEYMAPPINGS,
									MessageBoxProvider::ButtonType_OK, MessageBoxProvider::AlertType_Warning);
		ex->Delete();
	}	
}
Ejemplo n.º 18
0
LRESULT CSetPgApps::OnEditChanged(HWND hDlg, WORD nCtrlId)
{
	int iCur = mb_SkipSelChange ? -1 : (int)SendDlgItemMessage(hDlg, lbAppDistinct, LB_GETCURSEL, 0,0);
	AppSettings* pApp = (iCur < 0) ? NULL : gpSet->GetAppSettingsPtr(iCur);
	_ASSERTE((iCur<0) || (pApp && pApp->AppNames));

	if (pApp)
	{
		switch (nCtrlId)
		{
		case tAppDistinctName:
			if (!mb_SkipEditChange)
			{
				_ASSERTE(pApp && pApp->AppNames);
				wchar_t* pszApps = NULL;
				if (GetString(hDlg, nCtrlId, &pszApps))
				{
					pApp->SetNames(pszApps);
					MSetter lockSelChange(&mb_SkipSelChange);
					SetListAppName(pApp, iCur+1, iCur);
				}
				SafeFree(pszApps);
			} // tAppDistinctName
			break;

		case tCursorFixedSize:
		case tInactiveCursorFixedSize:
		case tCursorMinSize:
		case tInactiveCursorMinSize:
			if (pApp)
			{
				mb_Redraw = CSetPgCursor::OnEditChangedCursor(mh_Child, nCtrlId, pApp);
			} //case tCursorFixedSize, tInactiveCursorFixedSize, tCursorMinSize, tInactiveCursorMinSize:
			break;

		}
	}

	return 0;
}
Ejemplo n.º 19
0
void CTeenSpiritDlg::LoadSettings()
{
	AppSettings* params = PRGAPI()->GetAppSettings();

	WINDOWPLACEMENT pl;
	GetWindowPlacement(&pl);
	int showCmd;
	params->Read(SettingsCategory, _T("CMDSHOW"), showCmd, SW_SHOWNORMAL);
	params->Read(SettingsCategory, _T("LEFT"), (int&) pl.rcNormalPosition.left, 40);
	params->Read(SettingsCategory, _T("TOP"), (int&) pl.rcNormalPosition.top, 25);
	params->Read(SettingsCategory, _T("RIGHT"), (int&) pl.rcNormalPosition.right, 900);
	params->Read(SettingsCategory, _T("BOTTOM"), (int&) pl.rcNormalPosition.bottom, 650);
	//pl.showCmd = SW_SHOWMINIMIZED;
	pl.showCmd = showCmd;
	ModifyStyle(WS_VISIBLE, 0);
	if (showCmd == SW_SHOWMINIMIZED)
	{
		ModifyStyle(WS_VISIBLE, 0);
		SetWindowPlacement(&pl);
		PostMessage(WM_SYSCOMMAND, SC_MINIMIZE);
	}
	else if (showCmd == SW_SHOWMAXIMIZED)
	{
		SetWindowPlacement(&pl);
		ModifyStyle(WS_CAPTION | WS_THICKFRAME, 0);
		MaximizeWindow(pl.rcNormalPosition);

	}
	else
		SetWindowPlacement(&pl);
}
Ejemplo n.º 20
0
bool MUiDataAdapter::GetPeriodEventInfo(QDate &start, QDate &end, EventInfoList &list)
{
    MDataBase *db = MDataBase::GetInstance();

    if (!db->GetPeriodEventInfo(start, end, list, true, true))
    {
        return false;
    }

    AppSettings setting = ConfigManager::GetInstance()->AppSetting();
    for (int i = list.count() - 1 ; i >=0; i--)
    {
        if ((list.at(i)->type == 0)||
                (list.at(i)->type == 2)||
                (list.at(i)->magnitude < setting.filter_all_event_magnitude()))
        {
            list.removeAt(i);
        }
    }

    return true;
}
Ejemplo n.º 21
0
void 
Settings::Save(BFile* file)
{
	BMessage message;
	// store application settings
	for (int i = 0; i < AppSettingsCount(); i++) {
		AppSettings* app = AppSettingsAt(i);
		message.AddString("message", app->GetMimeType());
		message.AddString("p", app->GetPrinter());
	}
	// store printer settings
	for (int i = 0; i < PrinterSettingsCount(); i++) {
		PrinterSettings* p = PrinterSettingsAt(i);
		message.AddString("P", p->GetPrinter());
		message.AddMessage("S", p->GetPageSettings());
		message.AddMessage("J", p->GetJobSettings());
	}
	
	message.AddBool("UseConfigWindow", fUseConfigWindow);
	message.AddRect("ConfigWindowFrame", fConfigWindowFrame);
	message.AddString("DefaultPrinter", fDefaultPrinter);
	message.Flatten(file);
}
Ejemplo n.º 22
0
bool CalculateVelocityHandler::GetLocParPara(LocParPara &para)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    para.grid.origin_x = setting.search_area().min_x;
    para.grid.origin_y = setting.search_area().min_y;
    para.grid.origin_z = setting.search_area().min_z;

    if (setting.cell_step() == 0)
    {
        return false;
    }

    para.grid.step_x = setting.cell_step();
    para.grid.step_y = setting.cell_step();
    para.grid.step_z = setting.cell_step();

    para.grid.grid_num_x = (setting.search_area().max_x - setting.search_area().min_x) / para.grid.step_x;
    para.grid.grid_num_y = (setting.search_area().max_y - setting.search_area().min_y) / para.grid.step_y;
    para.grid.grid_num_z = (setting.search_area().max_z - setting.search_area().min_z) / para.grid.step_z;

    return true;
}
Ejemplo n.º 23
0
void VelParaSetupHandler::GetModeSetupUiData(ModeSetupPara &info)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    info.calculate_method = setting.calculation_method();
    info.mode = setting.mode();
    info.channel_filter = setting.channel_filter();
    info.accuracy = setting.accuracy();
    info.z_join_calculate = setting.z_join_calculate();
}
Ejemplo n.º 24
0
void HotKeyManager::SaveSettings()
{
	TRACEST(_T("HotKeyManager::SaveSettings."));
	PrgAPI* pAPI = PRGAPI();
	AppSettings* appSettings = pAPI->GetAppSettings();
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyPlay, (INT) m_HotKeys[HK_Play - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyStop, (INT) m_HotKeys[HK_Stop - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyPrev, (INT) m_HotKeys[HK_Prev - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyNext, (INT) m_HotKeys[HK_Next - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyMiniPlayer, (INT) m_HotKeys[HK_ToggleMiniPlayer - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyTooltip, (INT) m_HotKeys[HK_Tooltip - HK_First - 1]);
	appSettings->Write(HotKeyManagerSettingsCategory, cHotkeyQuickSearch, (INT) m_HotKeys[HK_QuickSearch - HK_First - 1]);

}
Ejemplo n.º 25
0
void CTeenSpiritDlg::SaveSettings()
{
	PrgAPI* pAPI = PRGAPI();
	AppSettings* params = pAPI->GetAppSettings();
	WINDOWPLACEMENT pl;
	GetWindowPlacement(&pl);
	params->Write(SettingsCategory, _T("CMDSHOW"), (int&) pl.showCmd);
	params->Write(SettingsCategory, _T("LEFT"), (int&) pl.rcNormalPosition.left);
	params->Write(SettingsCategory, _T("TOP"), (int&) pl.rcNormalPosition.top);
	params->Write(SettingsCategory, _T("RIGHT"), (int&) pl.rcNormalPosition.right);
	params->Write(SettingsCategory, _T("BOTTOM"), (int&) pl.rcNormalPosition.bottom);
	m_PaneController.SaveSettings();
	BOOL bIsPlayerVisible = FALSE;
	CMiniPlayerDlg* pMPDlg = pAPI->GetMiniPlayerDlg(FALSE);
	if (pMPDlg != NULL)
		bIsPlayerVisible = pMPDlg->IsWindowVisible();
	pAPI->SetOption(OPT_MINIPLR_ShowAtStartup, bIsPlayerVisible);

}
//! Save setting file
//!
//! @param settings      - Object to save settings to
//!
void AdvancedPanel::saveSettings(AppSettings &settings) {

   print("AdvancedPanel::saveSettings()\n");

   settings.addValue(powerOffDurationKey,          bdmOptions.powerOffDuration);
   settings.addValue(powerOnRecoveryIntervalKey,   bdmOptions.powerOnRecoveryInterval);
   settings.addValue(resetDurationKey,             bdmOptions.resetDuration);
   settings.addValue(resetReleaseIntervalKey,      bdmOptions.resetReleaseInterval);
   settings.addValue(resetRecoveryIntervalKey,     bdmOptions.resetRecoveryInterval);

#if (TARGET==CFV1) || (TARGET==ARM) || (TARGET==ARM_SWD)
   FlexNVMInfoPtr flexNVMInfo = currentDevice->getflexNVMInfo();
   if (flexNVMInfo == NULL) {
      return;
   }
   vector<FlexNVMInfo::EeepromSizeValue>      &eeepromSizeValues(flexNVMInfo->getEeepromSizeValues());
   vector<FlexNVMInfo::FlexNvmPartitionValue> &flexNvmPartitionValues(flexNVMInfo->getFlexNvmPartitionValues());
   settings.addValue(eeepromSizeKey,               eeepromSizeValues[eeepromSizeChoice].size);
   if (eeepromSizeChoice>0) {
      settings.addValue(flexNvmPartitionSizeKey,   flexNvmPartitionValues[flexNvmPartitionIndex].backingStore);
   }
#endif
}
Ejemplo n.º 27
0
int main(int argc, char* argv[])
{
#if QT_VERSION >= 0x050600
    QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif

    QApplication app(argc, argv);

    // Call this to force settings initialization before the application
    // fully launches.
    //
    AppSettings* appSettings = AppSettings::getInstance();
    QLocale::setDefault(appSettings->getLocale());

    QTranslator qtTranslator;
    bool ok = qtTranslator.load("qt_" + appSettings->getLocale(),
        QLibraryInfo::location(QLibraryInfo::TranslationsPath));

    if (!ok)
    {
        qtTranslator.load("qt_" + appSettings->getLocale(),
            appSettings->getTranslationsPath());
    }

    app.installTranslator(&qtTranslator);

    QTranslator qtBaseTranslator;
    ok = qtBaseTranslator.load("qtbase_" + appSettings->getLocale(),
        QLibraryInfo::location(QLibraryInfo::TranslationsPath));

    if (!ok)
    {
        qtBaseTranslator.load("qtbase_" + appSettings->getLocale(),
            appSettings->getTranslationsPath());
    }

    app.installTranslator(&qtBaseTranslator);

    QTranslator appTranslator;
    ok = appTranslator.load
    (
        QString("ghostwriter_") + appSettings->getLocale(),
        appSettings->getTranslationsPath()
    );

    if (!ok)
    {
        appTranslator.load
        (
            "ghostwriter_en",
            appSettings->getTranslationsPath()
        );
    }

    app.installTranslator(&appTranslator);

    QString filePath = QString();

    if (argc > 1)
    {
        filePath = app.arguments().at(1);
    }

    MainWindow window(filePath);

    window.show();
    return app.exec();
}
Ejemplo n.º 28
0
bool CalculateVelocityHandler::GetTimeGridPara(TimeGridPara &para, int channel_id)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    para.grid.origin_x = setting.mine_area().min_x;
    para.grid.origin_y = setting.mine_area().min_y;
    para.grid.origin_z = setting.mine_area().min_z;

    if (setting.cell_step() == 0)
    {
        return false;
    }

    para.grid.step_x = setting.cell_step();
    para.grid.step_y = setting.cell_step();
    para.grid.step_z = setting.cell_step();

    para.grid.grid_num_x = (setting.mine_area().max_x - setting.mine_area().min_x) / para.grid.step_x;
    para.grid.grid_num_y = (setting.mine_area().max_y - setting.mine_area().min_y) / para.grid.step_y;
    para.grid.grid_num_z = (setting.mine_area().max_z - setting.mine_area().min_z) / para.grid.step_z;

    para.layer_list = setting.layer_info();

    QList<ChannelInfo> list = channel_map_.values();

    for (int i = 0; i < list.count(); i++)
    {
        ChannelInfo info = list.at(i);

        if (channel_id != 0)
        {
            if (info.id != channel_id)
            {
                continue;
            }
        }

        ChannelInfo cinfo;

        if (!GetChannelInfo(info.id, cinfo))
        {
            return false;
        }

        StationInfo sinfo;

        if (!GetStationInfo(cinfo.station_id, sinfo))
        {
            return false;
        }

        SCInfo scinfo;
        scinfo.name = sinfo.name + "_" + QString().sprintf("%d", cinfo.component);
        scinfo.channel_id = cinfo.id;
        scinfo.east = sinfo.point.east;
        scinfo.north = sinfo.point.north;
        scinfo.deep = sinfo.point.deep;

        para.scinfo_list.append(scinfo);
    }

    return true;
}
Ejemplo n.º 29
0
int main() {
    std::ios_base::sync_with_stdio(false);

    string confPath = std::getenv("HOME");
    if(!confPath.empty()) {
        confPath += "/.config/ctudc/";
    }
    AppSettings appSettings;
    try {
        appSettings.load(confPath + "CtudcServer.conf");
    } catch(const std::exception& e) {
        fatal(StringBuilder() << "Failed parse CtudcServer.conf: " << e.what());
    }

    ChannelsConfigParser channelParser;
    try {
        channelParser.load(confPath + "channels.conf");
    } catch(std::exception& e) {
        fatal(StringBuilder() << "Failed parse channels.conf: " << e.what());
    }

    auto caentdc = make_shared<CaenV2718>(0xEE00);
    auto emisstdc = make_shared<EmissTdc>();
    auto ftd = make_shared<ftdi::Module>(0x28);
    auto vlt = make_shared<Amplifier>();
    vlt->setTimeout(5000);
    try {
        ftd->open("C232HM-EDHSL-0");
        ftd->initialize({ftdi::I2C_CLOCK_STANDARD_MODE, 1, 0});
    } catch(std::exception& e) {
        std::cerr << "FTD: " << e.what() << std::endl;
    }

    auto tdcController  = make_shared<Caen2718Contr>("tdc", caentdc);
    auto emissController= make_shared<EmissContr>("emiss", emisstdc);
    auto vltController  = make_shared<VoltageContr>("vlt", vlt, ftd, appSettings.voltConfig);
    auto expoController = make_shared<ExpoContr>("expo", emisstdc, appSettings.expoConfig, channelParser.getConfig());
    expoController->onNewRun() = [&](unsigned nRun) {
        appSettings.expoConfig.nRun = nRun;
        appSettings.save(confPath + "CtudcServer.conf");
    };
    

    trek::net::Server server({emissController, expoController, vltController}, appSettings.ip, appSettings.port);
    server.onStart() = [](const auto&) {
        std::cout << system_clock::now() << " Server start" << endl;
    };
    server.onStop() = [](const auto&) {
        std::cout << system_clock::now() << " Server stop" << endl;
    };
    server.onSessionStart() = [](const trek::net::Session & session) {
        std::cout << system_clock::now() << " Connected: " << session.remoteAddress() << endl;
    };
    server.onSessionClose() = [](const trek::net::Session & session) {
        std::cout << system_clock::now() << " Disconnected: " << session.remoteAddress() << endl;
    };
    server.onRecv() = [](const auto & session, const auto & message) {
        std::cout << system_clock::now() << " Recv " << session.remoteAddress() << ": " << message << endl;
    };
    server.onSend() = [](const auto & session, const auto & message) {
        std::cout << system_clock::now() << " Send " << session.remoteAddress() << ": " << message << endl;
    };

    std::atomic_bool runnig(true);
    auto future = std::async(std::launch::async, [&] {
        while(runnig.load()) {
            try {
                server.run();
            } catch(exception& e) {
                std::cout << system_clock::now() << " Server failed: " << e.what() << std::endl;
                server.stop();
            }
        }
    });
    string command;
    while(true) {
        std::getline(cin, command);
        if(command == "exit") {
            if(future.valid()) {
                runnig.store(false);
                server.stop();
                future.get();
            }
            break;
        }
    }
    return 0;
}
Ejemplo n.º 30
0
void VelParaSetupHandler::GetPSVelSetupUiData(PSVelSetupPara &para)
{
    AppSettings setting = ConfigManager::GetInstance()->AppSetting();

    para.p_start = setting.p_start();
    para.p_end = setting.p_end();
    para.s_start = setting.s_start();
    para.s_end = setting.s_end();
    para.plus_per = setting.plus_per();
    para.minus_per = setting.minus_per();
    para.layer_info = setting.layer_info();
    para.p_step = setting.p_step();
    para.s_step = setting.s_step();
    para.p_divide_by_s = setting.p_divide_by_s();
}