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

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?

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

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.

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

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)

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

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)

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!