How to programmatically distinguish the port's domain for a simscape block? Like a connection belonging to foundation​.electrica​l.electric​al or physical signal?

10 visualizzazioni (ultimi 30 giorni)
How to programmatically distinguish the port's domain for a simscape block? Like a connection belonging to foundation.electrical.electrical or physical signal?
I am trying to automate connections between simscape custom blocks, the custom library is old and hard to change now. So for explaining the situation, consider the below example, a simple voltage sensor and code
LConn1 => + (node and bidirectional)
RConn1 => V (Physical Signal, unidirectional)
RConn2 => - (node and bidirectional)
So to automate the connections, add_line, RConn and LConn properties are used:
SourceConn = PortDetails.RConn(x)
add_line(Model_Name, SourceConn,... are the commands used.
But to automate, the distinction between RConn1 and RConn2 is needed, so a if-block can be used in code, that can allow add_line command to connect nodes to nodes only and wont try to
  1. Connect a physical signal port (V) to a node and stop execution.
  2. Connect a physical signal port (V) to another physical signal port (which could be on other block's input side ... I tried "try-catch-end" but failed due to this scenario).
So kindly let me know if there are anyways/commands/or a work around way to extract information about Simscape ports by which such automation is possible.
Thankyou.

Risposte (1)

Yifeng Tang
Yifeng Tang circa un'ora fa
ports = simscape.connectionPortProperties(gcb)
gcb here is pointing to a Pipe (TL) block, and I get
ports =
1×3 ConnectionPortProperties array with properties:
Name
Label
Type
and I can query into ports as
>> ports(1)
ans =
ConnectionPortProperties with properties:
Name: "A"
Label: "A"
Type: Domain (foundation.thermal_liquid.thermal_liquid)
The last line of output sounds like what you are looking for :)

Categorie

Scopri di più su Simscape in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by