1 (edited by plc-user 2024-03-30 15:50:33)

Topic: Suggestion: Use Terminal-Names in schematic-file

Hello everyone!

For some time now, it is possible to assign a name to terminals in the element files. A unique UUID is automatically added in the background. If such a component is then inserted into a schematic and provided with connections, the UUIDs of the terminals are already used in the qet file to identify the connection.

At some point in the future, when the developers have (a lot of) time for the project again, the "UUID" and "Name" information will be used to automatically generate cable plans and wiring instructions.

As a "programming exercise", I looked in the source code for a way to include the names of the terminals in the connection line in the schematic file and actually found what I was looking for!

However, there is one "difficulty":
What name may automatically be used if the creator of the element has not assigned any names?
I made it easy for myself here and also saved the UUID of the connection for the name.

Here is the resulting diff file:

diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp
diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp
index dc9d23595..df0e9fdc6 100644
--- a/sources/qetgraphicsitem/conductor.cpp
+++ b/sources/qetgraphicsitem/conductor.cpp
@@ -1048,6 +1048,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
        } else {
                dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
                dom_element.setAttribute("terminal1", terminal1->uuid().toString());
+               dom_element.setAttribute("terminalname1", terminal1->name());
        }

        if (terminal2->uuid().isNull()) {
@@ -1056,6 +1057,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
        } else {
                dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
                dom_element.setAttribute("terminal2", terminal2->uuid().toString());
+               dom_element.setAttribute("terminalname2", terminal2->name());
        }
        dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");

diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp
index 54f9ece5f..951d67aa0 100644
--- a/sources/qetgraphicsitem/terminal.cpp
+++ b/sources/qetgraphicsitem/terminal.cpp
@@ -744,6 +744,16 @@ QUuid Terminal::uuid() const
        return d->m_uuid;
 }

+QString Terminal::name() const
+{
+    if (d->m_name == "")
+    {
+               return ((d->m_uuid).toString());
+       } else {
+               return d->m_name;
+       }
+}
+
 /**
        @brief Conductor::relatedPotentialTerminal
        Return terminal at the same potential from the same
diff --git a/sources/qetgraphicsitem/terminal.h b/sources/qetgraphicsitem/terminal.h
index e014d2a1f..a8d22abc8 100644
--- a/sources/qetgraphicsitem/terminal.h
+++ b/sources/qetgraphicsitem/terminal.h
@@ -74,6 +74,7 @@ class Terminal : public QGraphicsObject
                Diagram  *diagram             () const;
                Element  *parentElement       () const;
                QUuid uuid                    () const;
+               QString   name                () const;

                QList<Conductor *> conductors() const;
                Qet::Orientation orientation() const;

I understand this code fragment explicitly as a basis for discussion:
Please have a look at it and leave comments!

Best regards
  plc-user

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

Hallo plc-user,

Until now, if the "terminal name" property was empty, it didn't seem to bother, so I'll think leave it empty.
What do you think?

Best regards
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

Let me ask to be on the safe side:
Don't insert the Tag?
OR
Insert the Tag with empty value?

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

Insert the Tag "terminalname1" "terminalname2" with empty value, i think if user not added this values in terminal label.
Terminal UUID was always added.


https://download.qelectrotech.org/qet/forum_img_2/terminalname.png

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

What could be very constructive would be to add the conductors wire section, color, cable, element label, terminal name connected to each end in the sqlite database in a new table, a bit like nomeclature aka BOM.

It's justa an idea, this would avoid having to write a plugin like qet_tb_generator in python, which reads the XML to generate the terminal blocks, and then it might be possible to do more with SQL and csv export?

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

When we insert empty tags it makes the number of changed code-lines even smaller!  nomicons/wink

Here's the new diff:

diff --git a/sources/qetgraphicsitem/conductor.cpp b/sources/qetgraphicsitem/conductor.cpp
index dc9d23595..df0e9fdc6 100644
--- a/sources/qetgraphicsitem/conductor.cpp
+++ b/sources/qetgraphicsitem/conductor.cpp
@@ -1048,6 +1048,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
        } else {
                dom_element.setAttribute("element1", terminal1->parentElement()->uuid().toString());
                dom_element.setAttribute("terminal1", terminal1->uuid().toString());
+               dom_element.setAttribute("terminalname1", terminal1->name());
        }
 
        if (terminal2->uuid().isNull()) {
@@ -1056,6 +1057,7 @@ QDomElement Conductor::toXml(QDomDocument &dom_document,
        } else {
                dom_element.setAttribute("element2", terminal2->parentElement()->uuid().toString());
                dom_element.setAttribute("terminal2", terminal2->uuid().toString());
+               dom_element.setAttribute("terminalname2", terminal2->name());
        }
        dom_element.setAttribute("freezeLabel", m_freeze_label? "true" : "false");
 
diff --git a/sources/qetgraphicsitem/terminal.cpp b/sources/qetgraphicsitem/terminal.cpp
index 54f9ece5f..272720382 100644
--- a/sources/qetgraphicsitem/terminal.cpp
+++ b/sources/qetgraphicsitem/terminal.cpp
@@ -744,6 +744,11 @@ QUuid Terminal::uuid() const
        return d->m_uuid;
 }
 
+QString Terminal::name() const
+{
+       return d->m_name;
+}
+
 /**
        @brief Conductor::relatedPotentialTerminal
        Return terminal at the same potential from the same
diff --git a/sources/qetgraphicsitem/terminal.h b/sources/qetgraphicsitem/terminal.h
index e014d2a1f..a8d22abc8 100644
--- a/sources/qetgraphicsitem/terminal.h
+++ b/sources/qetgraphicsitem/terminal.h
@@ -74,6 +74,7 @@ class Terminal : public QGraphicsObject
                Diagram  *diagram             () const;
                Element  *parentElement       () const;
                QUuid uuid                    () const;
+               QString   name                () const;
 
                QList<Conductor *> conductors() const;
                Qet::Orientation orientation() const;

The TerminalNames are only inserted into the connection, when the terminals have UUIDs ... only then!

In the element-collection I found "some" elements which have terminals with names but no UUID. Already working on them... nomicons/smile

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

Salut Laurent,

scorpio810 wrote:

What could be very constructive would be to add the conductors wire section, color, cable, element label, terminal name connected to each end in the sqlite database in a new table, a bit like nomeclature aka BOM.

I would like to understand your comment better, therefore my questions.

How or in what is the internal structure of a folio stored at runtime of QET?
Is it the XML structure as it is in the resulting qet file, or is an sqlite database used internally?
Is there a place where this is documented?
Please don't say: "The source code is the documentation" nomicons/wink

Of course, I would also like the connection information to become an internal QET generation for a cable plan or wiring instructions for the electrician at some point: I don't really like such things with python plugins! This can be quite a hassle on some systems... 
How this can/should be designed for the user is, in my opinion, of secondary importance for the time being: The internal structures need to be understood and extended.

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

Hallo plc-user,

When you start QET and open an project QET read the XML of the project, draw all diagrams, etc, after it create an use a sqlite database in memory, you can export this database now, but you can't imported data yet to the project on the fly running.

Edit: Sqlite database for project was added recently also QET code can run without..

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

Conductor numbering export to csv not use database:
https://github.com/qelectrotech/qelectr … export.cpp

Summary page and BOM use database:
https://github.com/qelectrotech/qelectr … s/dataBase

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

Let me ask more specific:

As a user: If I make a change in the circuit diagram, where is this change saved internally? In the XML structure?
It is clear that this will (at some point) be transferred to a sqlite database in memory.

Or is it so that the sqlite DB in memory is used during editing the diagram and the XML structure is only adapted for saving?

To ask technically: (sqlite XOR XML)?   nomicons/wink

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

For me, sqlite help to create BOM, summary pages, ect, but when you change any things the change it's saved in XML of the project.

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

o.k.  –  Merci, Laurent !

In this case, the learning curve is not quite so steep for me: I "only" have to dive deeper into QT and QET programming!
I've hardly ever had anything to do with sqlite as a programmer.

As I said: For now I just want to understand how QET works "under the hood"... and maybe contribute some things.

"Still learning!" (even at my age nomicons/wink)

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

@plc-user if you don't mind my asking how old are you?
Me : 55 years old..

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

@Laurent: +2

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

@plc-user: age only matters if you're healthy nomicons/wink

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

Re: Suggestion: Use Terminal-Names in schematic-file

Health is the most important thing, besides family and friends!
(a little money might help a bit, too...nomicons/wink)

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: Suggestion: Use Terminal-Names in schematic-file

plc-user wrote:

Health is the most important thing, besides family and friends!
(a little money might help a bit, too...nomicons/wink)

If you wish, I can have Paypal send you some of the money we receive from donations from users who thank us for this project, given the excellent work you do.

It's certainly not a fortune (~ 500€)and I had to contribute out of my own pocket for the Aplle develloper notarization ~99€.

And in June I have to renew the web hosting at a cost of 160€.

I thanks all users who donate and hepling to support this project again, thanks all.

Best regards,
Laurent

"Le jour où tu découvres le Libre, tu sais que tu ne pourras jamais plus revenir en arrière..."

18 (edited by plc-user 2024-04-01 18:29:21)

Re: Suggestion: Use Terminal-Names in schematic-file

Ooops ... No, no, no ... don't get me wrong!
It wasn't meant that way!!! 

I have a good job and earn my money for living and "a bit" more!  nomicons/smile

Please spend the donated money for QET-Project!

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

19 (edited by hairy_kiwi 2024-10-01 13:31:50)

Re: Suggestion: Use Terminal-Names in schematic-file

scorpio810 wrote:

For me, sqlite help to create BOM, summary pages, ect, but when you change any things the change it's saved in XML of the project.

Hello Laurent and plc-user,

I've also taken an interest in the QET codebase recently. Forgive me intruding on your conversation, however unless I mis-read what Laurent says, what he writes is not my observation from the following tests:

If I open a couple of text editors: Brackets and Visual Studio, while in QET I change a wire number for example from "110" to "110A", I do not see that change reflected in either Brackets or Visual Studio, until I Save the project in QET.

Conversely, if I modify the .qet file in Brackets or Visual Studio (both the formula="110x" and num="110x" values for the wire I'm watching) I immediately see the change reflected in the other text editor, but not in QET until after closing and reopening the project.

Hope it helps - and I've not simply misunderstood or got the wrong end of the stick nomicons/smile


Btw Laurent, as far as fundraising for essential annual project expenditure, I'd be very happy to contribute; and I'm sure no doubt many people would, if fundraising efforts were made more public. I know other opensource projects have similar annual fundraising campaigns and believe devs ought not to be spending their personal money on keeping a mature, widely-appreciated project online when they already contribute their free time. I think you only need decide whether to accept donations directly, or via a payment processing intermediary (searching "online donation platforms" turns up a plethora of providers) - and the money will surely follow.

Thank you both and all the devs for your ongoing work nomicons/smile