GetConstraint - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


SysMLConnector

  

GetConstraint

  

extract constraint relation(s) from Constraint Block(s)

  

PutConstraint

  

replace constraint relation(s) in Constraint Block

 

Calling Sequence

Parameters

Returns

Options

Description

Examples

Calling Sequence

GetConstraint(t, options)

GetConstraint(u, options)

GetConstraint(q, options)

PutConstraint(t, v, cs)

PutConstraint(u, v, cs)

PutConstraint(q, v, cs)

Parameters

t

-

table in JSON format; previously downloaded SysML model element

u

-

UUID string, or table where u["@id"] is a UUID string

q

-

string; qualified name with :: as separator(s)

options

-

(optional) equation(s) of the form keyword=value, where keyword is either 'output', 'fullname', or 'postprocess'

v

-

relation or list of relations : new value for the constraint relation(s)

cs

-

(optional) change set; default: the internally cached change set

Returns

• 

GetConstraint:

– 

If t is a Constraint Block, an equation of the form string=list(relation) is returned, unless 'output'='compact' is specified, in which case just the sequence of relations is returned.

– 

If t is a Package, the return value is a list. By default, each list entry is of the form [w, e], where w is a UUID string and e is an equation of the form string=list(relation) as above. If 'output=compact' is specified, then each list entry is just a relation.

– 

Otherwise, the return value is NULL.

– 

The format of the names in the relation(s) is determined by the fullname option.

• 

PutConstraint returns NULL and updates the change set.

Options

• 

'output'='compact' : if specified, only relation(s) are returned, without UUIDs and without Constraint Block names. The default behaviour, when this option is not specified, is described in the Returns section.

• 

'fullname'=f : determines the form of the Constraint Parameters in the output.

– 

If f=true, then fully qualified names are used, starting from the root element, and separated by the two characters ::.

– 

If f=false (the default), then only the Constraint Parameters' names are used in the relation(s).

– 

If f=short, then names of the form a::b are returned, where b is the name of a Constraint Parameter and a is the name of its owner, the Constraint Block.

• 

'postprocess'=p : set(name); if specified, some postprocessing is applied to subexpressions whose 0th operand is in p, typically, in order to transform them into valid Maple syntax. Currently, only postprocess=`<`&comma;<= is supported, and it will rewrite any inequalities in terms of Heaviside functions. The default behaviour is to not perform any postprocessing.

Description

• 

For a Constraint Block t, the GetConstraint(t) calling sequence converts the constraint relation(s) corresponding to t to Maple relations, and by default returns them in the form string=list(relation), where the left-hand side is the name of the Constraint Block, unless the 'output'='compact' option is specified, in which case just the sequence of relations is returned.

• 

A relation is either an equation =, a strict <,> or non-strict , inequality, or an inequation  (negated equation).

• 

The relations are taken from the strings in the body of the specification (Opaque Expression) of the first ownedRule (Constraint) of t and converted to Maple relations. The format of the Constraint Parameters occurring in the resulting relations is determined by the fullname option.

• 

If one of the strings from the body cannot be converted to a Maple relation, e.g., because it has a syntax error, then it will be left as a string.

• 

If t is a Package, then relations as above are computed for all Constraint Blocks owned by the Package in bulk. This is more efficient than calling GetConstraint individually on each block in a loop. By default, for each block both its UUID, name, and the corresponding relation(s) are returned.

• 

Otherwise, if t is neither a Constraint Block nor a Package, GetConstraint returns NULL.

• 

The PutConstraint(t,v,cs) calling sequence records the new value (constraint relation(s)) v for the Constraint Block t, more precisely the body of the specification of the first ownedRule of t, in the change set cs. The change set can subsequently be commited to the SysML model using Commit.

• 

If cs already contains a change entry for t, it will be overwritten with v.

• 

The following model elements must already exist for both commands to work: the Constraint Block t itself, the Constraint referred to by its first ownedRule, and the Opaque Expression referred to by the specification feature of the Constraint.

• 

Both commands raise an error if t is a Constraint Block that does not have an ownedRule, and PutConstraint also raises an error if t is not a Constraint Block.

• 

The GetConstraint(u) and PutConstraint(u,v,cs) calling sequences first download the SysML model element specified by the UUID in u, and then proceed as above. If a model element with the given UUID cannot be found on the server, an error is raised.

• 

The GetConstraint(q) and PutConstraint(q,v,cs) calling sequences first look up, download and cache the SysML model element specified by the qualified name q (see QueryModel), and then proceed as above. If a model element with the given qualified name cannot be found on the server, an error is raised.

• 

If the first argument is a table in JSON format without an "@id" field, then it is assumed to be a valid model element, corresponding to the t calling sequence. If the first argument is a string that is not a syntactically valid UUID, then it is assumed to be a qualified name, corresponding to the q calling sequence.

• 

Model elements that have already been downloaded and cached previously are retrieved from the cache instead of re-downloaded from the server.

• 

Use of this command requires an active server connection, using the Connect command.  If such a connection does not exist, an error will be raised.

Examples

withSysMLConnector

ClearChangeSet&comma;Commit&comma;Connect&comma;GetBinding&comma;GetChildren&comma;GetConstraint&comma;GetInstances&comma;GetSlots&comma;GetValue&comma;Login&comma;Logout&comma;PrintChangeSet&comma;PrintElement&comma;PutConstraint&comma;PutValue&comma;QualifiedNameOf&comma;QueryModel&comma;Warnlevel

(1)

Loginhttps://twc.mycompany.com:8111/&comma;user=alice&comma;password=a%5Wr^Xt0p@2

ConnectJMPTWCSysML&colon;

Download the Constraints package.

ConstraintsQueryModelModel-Turbofan::Constraints

Constraintse8170bf0-1f12-4a50-9132-204b85472a84&comma;uml:Package&comma;Constraints

(2)

UUIDs and relations for all Constraint Blocks in the Constraints package, using only simple parameter names.

lGetConstraintConstraints3&colon;

numelemsl

53

(3)

maplprint&comma;l1..3&colon;

["aa16b6cd-0533-42e2-a7b2-c3186f5d6f03", "ExitVelocity_b" = [Vexit_b = `*`(CpR < CpRa,(gamma*R*Te)^.5)]]
["ca320fe0-d1ef-4a01-af71-fca39fcfad17", "ExitVelocity_a" = [Vexit_a = 1.414213562*`*`(CpRa < CpR,(Cpp*(T0i-Te))^.5)]]
["0f21bb2f-dfc6-4278-a195-ea2eb73d6233", "Temperature at exit" = [T0tt = T0t+deltaT]]

Get the relations only for the 1st Constraint Block but with qualified names, as symbols, and convert the inequality to a Heaviside expression. (This also demonstrates the UUID calling sequence.)

GetConstraintaa16b6cd-0533-42e2-a7b2-c3186f5d6f03&comma;fullname=true&comma;postprocess=`<`&comma;`<=`

Model-Turbofan::Constraints::ExitVelocity_b=Model-Turbofan::Constraints::ExitVelocity_b::Vexit_b=HeavisideModel-Turbofan::Constraints::ExitVelocity_b::CpRaModel-Turbofan::Constraints::ExitVelocity_b::CpRModel-Turbofan::Constraints::ExitVelocity_b::gammaModel-Turbofan::Constraints::ExitVelocity_b::RModel-Turbofan::Constraints::ExitVelocity_b::Te

(4)

Using the qualified name calling sequence, get relations for all Constraint Blocks in the Package, without UUIDs and block names, and using shorter names of the form a::b for the Constraint Parameters.

lGetConstraintModel-Turbofan::Constraints&comma;output=compact&comma;fullname=short&comma;postprocess=`<`&comma;`<=`&colon;

mapprint&comma;l1..3&colon;

ExitVelocity_b::Vexit_b=HeavisideExitVelocity_b::CpRaExitVelocity_b::CpRExitVelocity_b::gammaExitVelocity_b::RExitVelocity_b::Te

ExitVelocity_a::Vexit_a=1.414213562ExitVelocity_a::CppExitVelocity_a::T0iExitVelocity_a::TeHeavisideExitVelocity_a::CpRa+ExitVelocity_a::CpR

Temperature at exit::T0tt=Temperature at exit::T0t+Temperature at exit::deltaT

(5)

Replace the relation for "Temperature at exit" by a new one, recording this in the internal change set.

PutConstraint0f21bb2f-dfc6-4278-a195-ea2eb73d6233&comma;T0tt=T0t

PrintChangeSet

502a4da2-d9c3-4585-908e-484772a0051f (Temperature at exit): body = ["T0tt = T0t"] (["T0tt = T0t + deltaT"])

Note the UUID printed is the one of the Opaque Expression.

Note also that the cached model elements were not changed.

PrintElement502a4da2-d9c3-4585-908e-484772a0051f&colon;

"ID" = "_19_0_3_8970276_1591124299670_346644_24803"
"body" = [1 = "T0tt = T0t + deltaT"]
"name" = ""
"owner" = [1 = {"@id" = "ad7c35e5-ed4a-43a3-bb6e-dd40720e8768"}]
"owningConstraint" = {"@id" = "ad7c35e5-ed4a-43a3-bb6e-dd40720e8768"}
"visibility__from_PackageableElement" = "public"

Logout

See Also

Commit

Connect

GetBinding

GetChildren

GetValue

JSON

QueryModel

SysMLConnector