void SetUp() override { connect(src0a.o, src_merge.a); connect(src0b.o, src_merge.b); connect(src_merge.o, fork.i); connect(src1.o, merge.b); connect(fork.a, q0.i); connect(fork.b, merge.a); connect(merge.o, q1.i); connect(q0.o, join.a); connect(q1.o, sw.i); connect(sw.a, join.b); connect(sw.b, s1.i); connect(join.o, s0.i); attachSwitchingFunction(&sw, {NAMED_ENUM("type", "rsp")}); attachFunction(&join, [](const SymbolicPacket &a, const SymbolicPacket &b) { return b; }); attach(&src0a.o, {NAMED_ENUM("type", "rsp")}); attach(&src0b.o, {NAMED_ENUM("type", "req")}); attach(&src1.o, {NAMED_ENUM("type", "req")}); components = {&s0, &s1, &q0, &q1, &src0a, &src0b, &src1, &src_merge, &fork, &merge, &join, &sw}; auto state = XMASState{}; state.add_queue(&q0, {}); state.add_queue(&q1, {}); reachable_states.insert({"initial state", std::move(state)}); state = XMASState{}; state.add_queue(&q0, {{{NAMED_ENUM("type", "rsp")}}}); state.add_queue(&q1, {{{NAMED_ENUM("type", "rsp")}}}); reachable_states.insert({"rsp in each queue", std::move(state)}); state = XMASState{}; state.add_queue(&q0, {{{NAMED_ENUM("type", "rsp")}}}); state.add_queue(&q1, {}); reachable_states.insert({"rsp in queue 0", std::move(state)}); state = XMASState{}; state.add_queue( &q0, {{{NAMED_ENUM("type", "rsp")}}, {{NAMED_ENUM("type", "rsp")}}}); state.add_queue(&q1, {}); unreachable_states.insert({"two rsp in queue 0", std::move(state)}); }
void VCButton::copyFrom(VCButton* button) { attachFunction(button->m_functionID); m_resizeMode = false; assert(button->keyBind()); if (m_keyBind) { disconnect(m_keyBind); delete m_keyBind; } m_keyBind = new KeyBind(button->keyBind()); connect(m_keyBind, SIGNAL(pressed()), this, SLOT(pressFunction())); connect(m_keyBind, SIGNAL(released()), this, SLOT(releaseFunction())); setToggleButton(true); setCaption(button->caption()); if (button->ownFont()) { setFont(button->font()); } if (button->ownPalette()) { setPaletteForegroundColor(button->paletteForegroundColor()); setPaletteBackgroundColor(button->paletteBackgroundColor()); } if (button->paletteBackgroundPixmap()) { setPaletteBackgroundPixmap(*button->paletteBackgroundPixmap()); } reparent(button->parentWidget(), 0, QPoint(0, 0), true); setGeometry(button->geometry()); move(button->x() + button->width(), button->y()); }
void VCButton::pressFunction() { assert(m_keyBind); if (/*m_keyBind->pressAction() == KeyBind::PressNothing || */ m_functionID == KNoID) { return; } /* else if (m_keyBind->pressAction() == KeyBind::PressStart) { Function* f = _app->doc()->function(m_functionID); if (f) { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } */ else if (m_keyBind->pressAction() == KeyBind::PressToggle && m_isExclusive == false) { Function* f = _app->doc()->function(m_functionID); if (f) { if (isOn()) { f->stop(); //setOn(false); } else { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } else if (m_keyBind->pressAction() == KeyBind::PressToggle && m_isExclusive == true) { QObjectList* l = parentWidget()->queryList("VCButton"); QObjectListIt it(*l); QObject* obj; while ((obj = it.current()) != 0) { ++it; if (((VCButton*)obj)->isOn()) { Function* f = _app->doc()->function(((VCButton*)obj)->functionID()); f->stop(); } } delete l; Function* f = _app->doc()->function(m_functionID); if (f) { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } else if (m_keyBind->pressAction() == KeyBind::PressFlash) { Function* f = _app->doc()->function(m_functionID); if (f) { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } /* else if (m_keyBind->pressAction() == KeyBind::PressStepForward) { // // TODO: Implement a bus for stepping // } else if (m_keyBind->pressAction() == KeyBind::PressStepBackward) { // // TODO: Implement a bus for stepping // } */ }
void VCButton::createContents(QPtrList <QString> &list) { QRect rect(30, 30, 30, 30); for (QString* s = list.next(); s != NULL; s = list.next()) { if (*s == QString("Entry")) { s = list.prev(); break; } else if (*s == QString("Name")) { setCaption(*(list.next())); } else if (*s == QString("Parent")) { VCFrame* parent = _app->virtualConsole()->getFrame(list.next()->toInt()); if (parent != NULL) { reparent((QWidget*)parent, 0, QPoint(0, 0), true); } // each Button should set if (parent->buttonBehaviour() == VCFrame::Exclusive) { setExclusive(true); } else { setExclusive(false); } } else if (*s == QString("X")) { rect.setX(list.next()->toInt()); } else if (*s == QString("Y")) { rect.setY(list.next()->toInt()); } else if (*s == QString("Width")) { rect.setWidth(list.next()->toInt()); } else if (*s == QString("Height")) { rect.setHeight(list.next()->toInt()); } else if (*s == QString("Textcolor")) { QColor qc; qc.setRgb(list.next()->toUInt()); setPaletteForegroundColor(qc); } else if (*s == QString("Backgroundcolor")) { QColor qc; qc.setRgb(list.next()->toUInt()); setPaletteBackgroundColor(qc); } else if (*s == QString("Color")) { // Backwards compatibility for button background color QString t = *(list.next()); int i = t.find(QString(",")); int r = t.left(i).toInt(); int j = t.find(QString(","), i + 1); int g = t.mid(i+1, j-i-1).toInt(); int b = t.mid(j+1).toInt(); QColor qc(r, g, b); setPaletteBackgroundColor(qc); } else if (*s == QString("Pixmap")) { QString t; t = *(list.next()); QPixmap pm(t); if (pm.isNull() == false) { setIconText(t); setPaletteBackgroundPixmap(pm); } } else if (*s == QString("Font")) { QFont f = font(); QString q = *(list.next()); f.fromString(q); setFont(f); } else if (*s == QString("Function")) { attachFunction(list.next()->toInt()); } else if (*s == QString("BindKey")) { assert(m_keyBind); QString t = *(list.next()); m_keyBind->setKey(t.toInt()); } else if (*s == QString("BindMod")) { assert(m_keyBind); QString t = *(list.next()); m_keyBind->setMod(t.toInt()); } else if (*s == QString("BindPress")) { assert(m_keyBind); QString t = *(list.next()); m_keyBind->setPressAction((KeyBind::PressAction) t.toInt()); } else if (*s == QString("BindRelease")) { assert(m_keyBind); QString t = *(list.next()); m_keyBind->setReleaseAction((KeyBind::ReleaseAction) t.toInt()); } else { // Unknown keyword, ignore *list.next(); } } setGeometry(rect); }
void VCButton::pressFunction() { assert(m_keyBind); if (/*m_keyBind->pressAction() == KeyBind::PressNothing || */ m_functionID == KNoID) { return; } /* else if (m_keyBind->pressAction() == KeyBind::PressStart) { Function* f = _app->doc()->function(m_functionID); if (f) { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } */ else //if (m_keyBind->pressAction() == KeyBind::PressToggle) { Function* f = _app->doc()->function(m_functionID); if (f) { if (isOn()) { f->stop(); //setOn(false); } else { if (f->engage(static_cast<QObject*> (this))) { setOn(true); } } } else { qDebug("Function has been deleted!"); attachFunction(KNoID); } } /* else if (m_keyBind->pressAction() == KeyBind::PressStepForward) { // // TODO: Implement a bus for stepping // } else if (m_keyBind->pressAction() == KeyBind::PressStepBackward) { // // TODO: Implement a bus for stepping // } */ }