mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-25 23:54:22 +01:00
Change a wire's properties by uuid without building its folios (stage D5)
Scripts get conductorPropertyByUuid() and setConductorPropertyByUuid(), the wire named by its uuid (conductorUuids()) rather than by a symbol's terminal. A change goes to every wire at the wire's potential, as setConductorProperty() does. When those wires are all on folios not built, none is numbered by a formula, and what changes in each is what a .qetz database holds in its own columns (number, function, voltage, colour and section of the wire, cable, bus), it goes through the project database: the store and the conductor rows, undoable by uuid. The potential is followed in the database (projectDataBase::potentialWires(): through wire ends, folio reports and terminal blocks, as Conductor::relatedPotentialConductors() follows it; a terminal block that isolates its terminals answers nothing). Building a wire takes its change (Conductor::fromXml()); a .qetz save writes it in the database, the folio file copied; a folio written from its XML gets it there; a .qet builds. Anything else builds the folio, as before. tst_lazyfolios: every wire's potential from the database = as followed, 1 342 of 1 342 (industrial, eager and from a .qetz); a cable set by uuid on a 14-wire potential builds no folio, reaches every wire, saves as when built, undoes, shows once built (fails when building ignores the change, and when the .qetz writer does). The test's run limit is raised (500 s -> 1 500 s, ctest 1 800 s): under load it ran past 500 s. ctest 96/96 both ways. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -92,7 +92,7 @@ if(Python3_Interpreter_FOUND AND CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
--build ${CMAKE_BINARY_DIR} --binary $<TARGET_FILE:qelectrotech>
|
||||
--source ${CMAKE_CURRENT_SOURCE_DIR}/lazy_folios_probe.cpp
|
||||
--fixture ${CMAKE_CURRENT_SOURCE_DIR}/../../examples/industrial.qet)
|
||||
set_tests_properties(tst_lazyfolios PROPERTIES TIMEOUT 600 RUN_SERIAL TRUE
|
||||
set_tests_properties(tst_lazyfolios PROPERTIES TIMEOUT 1800 RUN_SERIAL TRUE
|
||||
ENVIRONMENT "QT_QPA_PLATFORM=offscreen")
|
||||
# Deleting a cable, undoing the delete twice and then editing anything
|
||||
# has both cable commands tearing down the same cable. Runs under the
|
||||
|
||||
@@ -777,6 +777,28 @@ int main(int argc, char **argv)
|
||||
std::printf(".qetz drawn items through their view: %d lazily, %d when built\n", lazily, built);
|
||||
check(built > 0, "the project has drawn items");
|
||||
check(lazily == built, "the drawn items' view as when built");
|
||||
}
|
||||
//Every wire's potential from the database as QElectroTech
|
||||
//follows it with every folio built
|
||||
{
|
||||
QETProject indexed_potentials(zipped);
|
||||
int same = 0, differ = 0, unknown = 0;
|
||||
for (Diagram *folio : eager.folios())
|
||||
for (Conductor *wire : folio->conductors()) {
|
||||
QSet<QUuid> live{wire->uuid()};
|
||||
for (Conductor *c : wire->relatedPotentialConductors(true)) live.insert(c->uuid());
|
||||
for (QETProject *project : {&eager, &indexed_potentials}) {
|
||||
const auto stored = project->dataBase()->potentialWires(wire->uuid());
|
||||
if (!stored) { ++unknown; continue; }
|
||||
if (*stored == live) { ++same; continue; }
|
||||
if (differ++ < 3)
|
||||
std::printf(" potential of %s: %d wires followed, %d from the database\n",
|
||||
qPrintable(wire->uuid().toString()), int(live.size()), int(stored->size()));
|
||||
}
|
||||
}
|
||||
std::printf("potentials from the database: %d same, %d differ, %d not answered\n", same, differ, unknown);
|
||||
check(differ == 0 && same > 0, "every wire's potential from the database as followed");
|
||||
check(indexed_potentials.unloadedFolioCount() > 0, "potentials read without building");
|
||||
}
|
||||
//The folios' rows as saved, not as reading their headers one
|
||||
//by one numbers them ("1/1" for the first of three, D7)
|
||||
@@ -997,6 +1019,76 @@ int main(int argc, char **argv)
|
||||
revisionEveryFolio(zipped, output, "revised", path);
|
||||
revisionEveryFolio(zipped, output, "relabelled", path, busiest);
|
||||
|
||||
//A script changes a wire's cable by its uuid, on folios not
|
||||
//built, the wire and its potential numbered by hand: through
|
||||
//the project database, no folio built; saved as when built;
|
||||
//undone; the folio built afterwards shows it (D5)
|
||||
{
|
||||
QETProject cabled(zipped);
|
||||
const int unbuilt = cabled.unloadedFolioCount();
|
||||
int folio_index = -1;
|
||||
QString uuid;
|
||||
QSet<QUuid> potential;
|
||||
for (int i = 0 ; i < folios.size() && uuid.isEmpty() ; ++i) {
|
||||
if (cabled.folios().at(i)->isLoaded()) continue;
|
||||
for (Conductor *wire : folios.at(i)->conductors()) {
|
||||
QSet<Conductor *> wires = wire->relatedPotentialConductors(true);
|
||||
wires << wire;
|
||||
bool usable = true;
|
||||
for (Conductor *c : std::as_const(wires))
|
||||
if (!c->properties().m_formula.isEmpty()
|
||||
|| cabled.folios().at(eager.folioIndex(c->diagram()))->isLoaded())
|
||||
usable = false;
|
||||
if (!usable || wires.size() < 2) continue;
|
||||
folio_index = i;
|
||||
uuid = wire->uuid().toString();
|
||||
for (Conductor *c : std::as_const(wires)) potential.insert(c->uuid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
check(!uuid.isEmpty(), "a wire numbered by hand, its potential on folios not built");
|
||||
QetScriptApi api(&cabled);
|
||||
const QString before = api.conductorPropertyByUuid(folio_index, uuid, "cable");
|
||||
const QString value = QStringLiteral("W-42");
|
||||
check(api.setConductorPropertyByUuid(folio_index, uuid, "cable", value), "a script changes a wire not built");
|
||||
check(api.conductorPropertyByUuid(folio_index, uuid, "cable") == value, "the wire's change read back");
|
||||
for (const QUuid &wire : std::as_const(potential))
|
||||
check(cabled.dataBase()->conductorProperties(wire).m_cable == value, "every wire of the potential changed");
|
||||
check(cabled.unloadedFolioCount() == unbuilt, "changing wires not built builds no folio");
|
||||
const QString cabled_path = output + "/cabled.qetz";
|
||||
check(cabled.writeContainerFile(cabled_path, &error), "saved after the wire change");
|
||||
std::printf(".qetz wire on folio %d, potential of %d wires, cable changed by uuid: 0 folios built, %d by saving\n",
|
||||
folio_index + 1, int(potential.size()), unbuilt - cabled.unloadedFolioCount());
|
||||
qputenv("QET_EAGER_FOLIOS", "1");
|
||||
const QString usual_path = output + "/cabled-usual.qetz";
|
||||
{
|
||||
QETProject usual_cabled(zipped);
|
||||
check(QetScriptApi(&usual_cabled).setConductorPropertyByUuid(folio_index, uuid, "cable", value),
|
||||
"the same wire change when built");
|
||||
check(usual_cabled.writeContainerFile(usual_path, &error), "saved after the wire change when built");
|
||||
}
|
||||
QETProject cabled_back(cabled_path), usual_back(usual_path);
|
||||
qunsetenv("QET_EAGER_FOLIOS");
|
||||
auto lines = [&path](QETProject &project) {
|
||||
QStringList list = sortedLines(project.toXml().toString(), path);
|
||||
list.removeIf([](const QString &line) { return line.contains(QLatin1String("name=\"saved")); });
|
||||
return list;
|
||||
};
|
||||
check(lines(cabled_back) == lines(usual_back), "a wire changed through the database saved as when built");
|
||||
cabled.undoStack()->undo();
|
||||
check(api.conductorPropertyByUuid(folio_index, uuid, "cable") == before, "the wire change undone");
|
||||
cabled.undoStack()->redo();
|
||||
Conductor *built_wire = nullptr;
|
||||
for (Conductor *wire : cabled.folios().at(folio_index)->conductors())
|
||||
if (wire->uuid().toString() == uuid) built_wire = wire;
|
||||
check(!built_wire, "the folio not built yet");
|
||||
cabled.buildFolioToShow(cabled.folios().at(folio_index));
|
||||
for (Conductor *wire : cabled.folios().at(folio_index)->conductors())
|
||||
if (wire->uuid().toString() == uuid) built_wire = wire;
|
||||
check(built_wire && built_wire->properties().m_cable == value,
|
||||
"a wire changed before its folio was built shows the change");
|
||||
}
|
||||
|
||||
//The wire numbers and wiring list exports, and the terminal
|
||||
//numbering dialog: as when built, building only the folios
|
||||
//holding a terminal (D5)
|
||||
|
||||
@@ -54,7 +54,7 @@ subprocess.run([ninja, '-C', str(build), '-f', probe_manifest.name, target], che
|
||||
output = build / 'lazy-folios'
|
||||
output.mkdir(exist_ok=True)
|
||||
report = output / 'results.txt'
|
||||
result = subprocess.run([str(probe_binary), str(fixture), str(report), str(output)], timeout=500)
|
||||
result = subprocess.run([str(probe_binary), str(fixture), str(report), str(output)], timeout=1500)
|
||||
if report.exists():
|
||||
print(report.read_text(encoding='utf-8', errors='replace'))
|
||||
sys.exit(result.returncode)
|
||||
|
||||
Reference in New Issue
Block a user