SI_SymbolPin::SI_SymbolPin(SI_Symbol& symbol, const Uuid& pinUuid) : SI_Base(), mCircuit(symbol.getSchematic().getProject().getCircuit()), mSymbol(symbol), mSymbolPin(nullptr), mComponentSignal(nullptr), mPinSignalMapItem(nullptr), mComponentSignalInstance(nullptr), mAddedToSchematic(false), mRegisteredNetPoint(nullptr), mGraphicsItem(nullptr) { // read attributes mSymbolPin = mSymbol.getLibSymbol().getPinByUuid(pinUuid); if (!mSymbolPin) { throw RuntimeError(__FILE__, __LINE__, pinUuid.toStr(), QString(tr("Invalid symbol pin UUID: \"%1\"")).arg(pinUuid.toStr())); } mPinSignalMapItem = mSymbol.getCompSymbVarItem().getPinSignalMapItemOfPin(pinUuid); if (!mPinSignalMapItem) { throw RuntimeError(__FILE__, __LINE__, QString(), QString(tr("Pin \"%1\" not found in pin-signal-map of symbol instance \"%2\".")) .arg(pinUuid.toStr(), symbol.getUuid().toStr())); } Uuid cmpSignalUuid = mPinSignalMapItem->getSignalUuid(); mComponentSignalInstance = mSymbol.getComponentInstance().getSignalInstance(cmpSignalUuid); mComponentSignal = mSymbol.getComponentInstance().getLibComponent().getSignalByUuid(cmpSignalUuid); mGraphicsItem = new SGI_SymbolPin(*this); updatePosition(); // create ERC messages mErcMsgUnconnectedRequiredPin.reset(new ErcMsg(mCircuit.getProject(), *this, QString("%1/%2").arg(mSymbol.getUuid().toStr()).arg(mSymbolPin->getUuid().toStr()), "UnconnectedRequiredPin", ErcMsg::ErcMsgType_t::SchematicError)); updateErcMessages(); }
ComponentSignalInstance::ComponentSignalInstance(Circuit& circuit, ComponentInstance& cmpInstance, const XmlDomElement& domElement) throw (Exception) : QObject(nullptr), mCircuit(circuit), mComponentInstance(cmpInstance), mComponentSignal(nullptr), mNetSignal(nullptr), mAddedToCircuit(false) { // read attributes Uuid compSignalUuid = domElement.getAttribute<Uuid>("comp_signal", true); mComponentSignal = mComponentInstance.getLibComponent().getSignalByUuid(compSignalUuid); if(!mComponentSignal) { throw RuntimeError(__FILE__, __LINE__, compSignalUuid.toStr(), QString( tr("Invalid component signal UUID: \"%1\"")).arg(compSignalUuid.toStr())); } Uuid netsignalUuid = domElement.getAttribute<Uuid>("netsignal", false, Uuid()); if (!netsignalUuid.isNull()) { mNetSignal = mCircuit.getNetSignalByUuid(netsignalUuid); if(!mNetSignal) { throw RuntimeError(__FILE__, __LINE__, netsignalUuid.toStr(), QString(tr("Invalid netsignal UUID: \"%1\"")).arg(netsignalUuid.toStr())); } } init(); }
QSet<Uuid> Library::getDevicesOfComponent(const Uuid& component) const throw (Exception) { QSqlQuery query = prepareQuery( "SELECT uuid, filepath FROM devices WHERE component_uuid = :uuid"); query.bindValue(":uuid", component.toStr()); execQuery(query, false); QSet<Uuid> elements; while (query.next()) { QString uuidStr = query.value(0).toString(); Uuid uuid(uuidStr); if (!uuid.isNull()) elements.insert(uuid); else qWarning() << "Invalid element in library: devices::" << uuid; } return elements; }
Uuid ConverterDb::getOrCreateUuid(const QString& cat, const QString& key1, const QString& key2) { QString allowedChars( "_-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); QString settingsKey = mLibFilePath.getFilename() % '_' % key1 % '_' % key2; settingsKey.replace("{", ""); settingsKey.replace("}", ""); settingsKey.replace(" ", "_"); for (int i = 0; i < settingsKey.length(); i++) { if (!allowedChars.contains(settingsKey[i])) settingsKey.replace( i, 1, QString("__U%1__").arg( QString::number(settingsKey[i].unicode(), 16).toUpper())); } settingsKey.prepend(cat % '/'); Uuid uuid = Uuid::createRandom(); QString value = mIniFile.value(settingsKey).toString(); if (!value.isEmpty()) uuid = Uuid::fromString(value); // can throw mIniFile.setValue(settingsKey, uuid.toStr()); return uuid; }
void XmlDomElement::setAttribute(const QString& name, const Uuid& value) noexcept { setAttribute<QString>(name, value.isNull() ? "" : value.toStr()); }
void XmlDomElement::setText<Uuid>(const Uuid& value) noexcept { setText(value.toStr()); }
Uuid ConverterDb::getSymbolVariantItemUuid(const Uuid& componentUuid, const QString& gateName) { return getOrCreateUuid("symbolgates_to_symbvaritems", componentUuid.toStr(), gateName); }
Uuid ConverterDb::getSymbolVariantUuid(const Uuid& componentUuid) { return getOrCreateUuid("component_symbolvariants", componentUuid.toStr()); }
Uuid ConverterDb::getComponentSignalUuid(const Uuid& componentUuid, const QString& gateName, const QString& pinName) { return getOrCreateUuid("gatepins_to_componentsignals", componentUuid.toStr(), gateName % pinName); }
Uuid ConverterDb::getPackagePadUuid(const Uuid& footprintUuid, const QString& padName) { return getOrCreateUuid("package_pads", footprintUuid.toStr(), padName); }
Uuid ConverterDb::getSymbolPinUuid(const Uuid& symbolUuid, const QString& pinName) { return getOrCreateUuid("symbol_pins", symbolUuid.toStr(), pinName); }
void LibraryListEditorWidget::addItem(const Uuid& library) noexcept { QString name = mLibNames.value(library, library.toStr()); QListWidgetItem* item = new QListWidgetItem(name, mUi->listWidget); item->setData(Qt::UserRole, library.toStr()); }