diff --git a/cd_utils/cdutils_core.cpp b/cd_utils/cdutils_core.cpp index 24bc582..01e0f61 100644 --- a/cd_utils/cdutils_core.cpp +++ b/cd_utils/cdutils_core.cpp @@ -181,8 +181,13 @@ void CDCore::init(const PIString & configuration, bool pult) { } +void CDCore::stop() { + connection.stop(); +} + + void CDCore::startX(double freq) { - piCout << "start x" << x_timer.isRunning() << freq; + //piCout << "start x" << x_timer.isRunning() << freq; if (!x_timer.isRunning()) x_timer.start(1000. / piMaxd(freq, 0.01)); } @@ -194,7 +199,7 @@ void CDCore::stopX() { void CDCore::sendCommand(const CDType & c) { - piCoutObj << "C_sendCommand" << c; + //piCoutObj << "C_sendCommand" << c; PIByteArray sba = makeHeader(CD_Command, 0); sba << c.path(); sendDirect(sba); @@ -204,7 +209,7 @@ void CDCore::sendCommand(const CDType & c) { void CDCore::registerCHandler(const CDType & c, PIObject * o, Handler h) { PIString sp = pathToString(c.path()); if (sp.isEmpty() || !h) return; - piCout << "register" << sp; + //piCout << "register" << sp; c_handlers[sp] = OHPair(o, h); } @@ -432,14 +437,14 @@ void CDCore::procReceivedPacket(PIByteArray & ba) { } break; case CD_XValues: { if (!x_pult_side) break; - x_mutex.lock(); PIVector > x_vals; ba >> x_vals; + x_mutex.lock(); piForeachC (PIDeque & p, x_vals) { x_[p].readX(ba); } - X_ReceivedX(x_vals); /// WARNING! under mutex x_mutex.unlock(); + X_ReceivedX(x_vals); } break; case CD_CQuery: C_Send(); diff --git a/cd_utils/cdutils_core.h b/cd_utils/cdutils_core.h index e9c952e..4a6cccd 100644 --- a/cd_utils/cdutils_core.h +++ b/cd_utils/cdutils_core.h @@ -64,6 +64,7 @@ public: void initApp(); void initPult(); void init(const PIString & configuration, bool pult = false); + void stop(); void startX(double freq = 20.); void stopX(); void sendCommand(const CDType & c); diff --git a/qad/widgets/qcodeedit.cpp b/qad/widgets/qcodeedit.cpp index b77a6fc..39f8f2d 100644 --- a/qad/widgets/qcodeedit.cpp +++ b/qad/widgets/qcodeedit.cpp @@ -295,6 +295,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { int tcpos = 0; switch (e->type()) { case QEvent::MouseButtonPress: + if (!isEnabled()) break; tc = ui->textCode->cursorForPosition(((QMouseEvent*)e)->pos()); tc.movePosition(QTextCursor::EndOfLine); pos_el_press = tc.anchor(); @@ -305,6 +306,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { ui->textCode->setTextCursor(tc); return true; case QEvent::MouseMove: + if (!isEnabled()) break; tc = ui->textCode->cursorForPosition(((QMouseEvent*)e)->pos()); tc.movePosition(QTextCursor::StartOfLine); if (pos_press == tc.anchor()) { @@ -323,6 +325,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) { ui->textCode->setTextCursor(tc); return true; case QEvent::Wheel: + if (!isEnabled()) break; QApplication::sendEvent(ui->textCode->viewport(), e); return true; default: break; diff --git a/qcd_utils/pult/CMakeLists.txt b/qcd_utils/pult/CMakeLists.txt index 69df148..230c5a0 100644 --- a/qcd_utils/pult/CMakeLists.txt +++ b/qcd_utils/pult/CMakeLists.txt @@ -3,7 +3,7 @@ find_qt(${QtVersions} Core Gui OpenGL) qt_sources(SRC) qt_wrap(${SRC} HDRS out_HDR CPPS out_CPP QMS out_QM) qt_add_executable(${PROJECT_NAME} WIN32 out_CPP) -qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qcd_utils qad_application) +qt_target_link_libraries(${PROJECT_NAME} qad_utils qad_widgets qad_graphic qad_application qcd_utils piqt_utils) message(STATUS "Building ${PROJECT_NAME}") if(LIB) if(WIN32) diff --git a/qcd_utils/pult/cdpultwindow.cpp b/qcd_utils/pult/cdpultwindow.cpp index baa0a9e..3c93be2 100644 --- a/qcd_utils/pult/cdpultwindow.cpp +++ b/qcd_utils/pult/cdpultwindow.cpp @@ -9,14 +9,20 @@ #include "qcd_modedialog.h" #include "chunkstream.h" #include "qvariantedit.h" +#include "piqt.h" +#include "piqt_highlighter.h" +#include "qcodeedit.h" #include #include +using namespace CDUtils; + CDPultWindow::CDPultWindow(QWidget *parent) : EMainWindow(parent), Ui::CDPultWindow() { setupUi(this); centralWidget()->hide(); - CDUtils::CDCore::instance()->initPult(); + CDCore::instance()->initPult(); + new ConfigHighlighter(codeConfig->document()); widgetK->setType(CDUtils::CDType::cdK); widgetX->setType(CDUtils::CDType::cdX); widgetC->setType(CDUtils::CDType::cdC); @@ -51,6 +57,34 @@ void CDPultWindow::loadFile(const QString & fp) { } +void CDPultWindow::apply(bool sessions) { + CDCore::instance()->stop(); + widgetK->setFile(editFileK->value().value().file); + widgetX->setFile(editFileX->value().value().file); + widgetC->setFile(editFileC->value().value().file); + if (checkDefaultConfig->isChecked()) + CDCore::instance()->initPult(); + else + CDCore::instance()->init(Q2PIString(codeConfig->text()), true); + widgetX->view->startX(); + if (sessions) { + widgetGraphics->load(session_gr); + if (!session_mw.isEmpty()) + restoreState(session_mw); + X.lock(); + PIVector > x_list = X.enabledList(); + X.unlock(); + piForeachC (PIDeque & p, x_list) + X.enable(X[p]); + ((CDItemModel*)widgetX->view->model())->updateModel(); + widgetX->view->expandAll(); + } + dockCDKView->setVisible(checkHasK->isChecked()); + dockCDXView->setVisible(checkHasX->isChecked()); + dockCDCView->setVisible(checkHasC->isChecked()); +} + + void CDPultWindow::closeEvent(QCloseEvent *e) { EMainWindow::closeEvent(e); if (!e->isAccepted()) @@ -80,15 +114,20 @@ bool CDPultWindow::load(const QString & path) { checkHasK->setChecked(conf.getValue("has_k")); checkHasX->setChecked(conf.getValue("has_x")); checkHasC->setChecked(conf.getValue("has_c")); + checkDefaultConfig->setChecked(conf.getValue("default_config")); + codeConfig->setText(QByteArray2QString(conf.getValue("config", QByteArray()))); session_gr = conf.getValue("session_gr", QByteArray()); + session_mw = conf.getValue("session_mw", QByteArray()); setChanged(false); file_name = path; + apply(true); return true; } bool CDPultWindow::save(const QString & path) { session_gr = widgetGraphics->save(); + session_mw = saveState(); QPIConfig conf(path, QIODevice::ReadWrite); conf.clear(); conf.setValue("file_k", editFileK->value().value().file); @@ -99,7 +138,11 @@ bool CDPultWindow::save(const QString & path) { conf.setValue("has_k", checkHasK->isChecked()); conf.setValue("has_x", checkHasX->isChecked()); conf.setValue("has_c", checkHasC->isChecked()); + conf.setValue("has_c", checkHasC->isChecked()); + conf.setValue("default_config", checkDefaultConfig->isChecked()); + conf.setValue("config", QString2QByteArray(codeConfig->text())); conf.setValue("session_gr", session_gr); + conf.setValue("session_mw", session_mw); file_name = path; return true; @@ -160,22 +203,7 @@ void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) { void CDPultWindow::on_buttonSessionApply_clicked() { - // with session or not - widgetK->setFile(editFileK->value().value().file); - widgetX->setFile(editFileX->value().value().file); - widgetC->setFile(editFileC->value().value().file); - dockCDKView->setVisible(checkHasK->isChecked()); - dockCDXView->setVisible(checkHasX->isChecked()); - dockCDCView->setVisible(checkHasC->isChecked()); - widgetX->view->startX(); - widgetGraphics->load(session_gr); - X.lock(); - PIVector > x_list = X.enabledList(); - X.unlock(); - piForeachC (PIDeque & p, x_list) - X.enable(X[p]); - ((CDItemModel*)widgetX->view->model())->updateModel(); - widgetX->view->expandAll(); + apply(false); } diff --git a/qcd_utils/pult/cdpultwindow.h b/qcd_utils/pult/cdpultwindow.h index 2345f06..f63ad39 100644 --- a/qcd_utils/pult/cdpultwindow.h +++ b/qcd_utils/pult/cdpultwindow.h @@ -17,6 +17,7 @@ public: explicit CDPultWindow(QWidget *parent = 0); ~CDPultWindow(); void loadFile(const QString & fp); + void apply(bool sessions); private: @@ -31,7 +32,7 @@ private: Ribbon * ribbon; QMap log_icons; - QByteArray session_gr; + QByteArray session_gr, session_mw; private slots: void addToLog(CDViewWidget::LogIcon icon, const QString & msg); diff --git a/qcd_utils/pult/cdpultwindow.ui b/qcd_utils/pult/cdpultwindow.ui index 4eca223..5e9f885 100644 --- a/qcd_utils/pult/cdpultwindow.ui +++ b/qcd_utils/pult/cdpultwindow.ui @@ -278,20 +278,37 @@ + + + + Default config + + + - - - Qt::Vertical + + + + 0 + 0 + - - - 20 - 1 - + + include = ip.conf +[connection] +device.cd = eth://udp:${ip.pult}:27002:${ip.app}:27001 #s +[] + - + + + DejaVu Sans Mono + 9 + + + @@ -445,6 +462,8 @@ + + @@ -458,6 +477,11 @@ QLineEdit
clineedit.h
+ + QCodeEdit + QWidget +
qcodeedit.h
+
QVariantEdit QWidget @@ -618,5 +642,21 @@ + + checkDefaultConfig + toggled(bool) + codeConfig + setDisabled(bool) + + + 579 + 280 + + + 581 + 304 + + +