GetValue - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.

Online Help

All Products    Maple    MapleSim


SysMLConnector

  

GetValue

  

extract values from Properties or Slots

  

PutValue

  

replace value in Property or Slot

 

Calling Sequence

Parameters

Returns

Options

Description

Examples

Calling Sequence

GetValue(t, options)

GetValue(u, options)

GetValue(q, options)

PutValue(t, v, cs)

PutValue(u, v, cs)

PutValue(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 'types'

v

-

new value for the Property or Slot, with or without units

cs

-

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

Returns

GetValue:

• 

If t is a Property, or a Slot whose defining feature is a Property, an equation of the form x=y is returned, where x is the name of the Property as a string, and y is either a single object (or, if t is a Slot with more than one value, a sequence of objects) of the form

– 

list [c,d] for a Value Property, where c is a numeric value and d is a Maple unit,

– 

[string,list(string),table], as returned by QueryModel, for a reference property,

– 

string for any other property.

  

If 'output=compact' is specified, then the left hand side x in the equation above is the Property's name as a symbol. In addition, for a Value Property, the right hand side is c*d instead of the list [c,d] (or a sequence of such products in case of multiple Slot values).

• 

If t is a Block, or an Instance Specification whose classifier is a Block, the return value is a list. By default, each list entry is of the form [w, x=y], where w is a UUID string, and x, y are as described above.

  

If 'output=compact' is specified, then each list entry is just an equation of the form x=y, with Property's names as symbols on the left-hand sides. In addition, for each Value Property, the right hand side is c*d instead of the list [c,d] (or a sequence of such products in case of multiple Slot values).

• 

Otherwise, the return value is NULL.

• 

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

PutValue returns NULL and updates the change set.

Options

• 

'output'='compact' : if specified, only equation(s) are returned, without UUIDs, each with a symbol on the left-hand side and, for a Value Property, a product of numeric value and unit on the right-hand side. (Note that the unit vanishes if the numeric value is 0.) The default behavior, when this option is not specified, is described in the Returns section.

• 

'fullname'=f : determines the form of the variable names x in the output.

– 

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

– 

If f=false (the default), then only the Value Properties' names are used in the equation(s).

– 

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

• 

'types'=T : set of strings; only consider properties whose type (either UML type or at least one of the stereotypes) is contained in T. If t is an Instance Specification, then only return Slots for which the UML type or at least one of the stereotypes of their defining feature is in T. The default value is types={"ValueProperty"}.

Description

• 

For a Property t, or a Slot t whose defining feature is a Property, the GetValue(t) calling sequence retrieves its value, i.e., the default value or all Slot values, respectively, including unit(s), and returns it as a Maple equation, whose left-hand side is the name of the Property.

• 

The value is taken from the Value Specification(s) referred to by the default value or the Slot value(s), respectively.

• 

The exact form of the equation is determined by the output option. By default, the left-hand side is the name x of the Property as a string, and the right-hand side is the value or sequence of values as described in the Returns section.

• 

The format of the name x is determined by the fullname option.

• 

If t is a Block, or an Instance Specification whose classifier is a Block, then values are retrieved for all Properties owned by the Block, or all Slots owned by the Instance Specification whose defining feature is a Property, in bulk. This is more efficient than calling GetValue individually on each Property or Slot in a loop. By default, for each Property or Slot both its UUID and the corresponding equation are returned, unless the option 'output=compact' is given.

• 

By default, only Value Properties and Slots whose defining feature is a Value Property are considered, unless the option types is specified.

• 

Otherwise, if t is neither a Property, nor a Slot whose defining feature is a Property, nor a Block, nor an Instance Specification whose classifier is a Block, then GetValue returns NULL.

• 

The PutValue(t,v,cs) calling sequence records the new value v for the Value Property or Slot t, more precisely the Value Specification(s) vs referred to by the default value of a Property or the value(s) of a Slot, respectively, in the change set cs.  The change set can subsequently be committed to the SysML model using Commit.

• 

v can either be a numeric value, a numeric value with a unit, or a string, or a list of such values. The last case is only possible if t is a Slot, and then the number of values in v must match the number of existing Slot values, which are overridden by the values from v.

• 

If t is a Value Property or a Slot whose defining feature is a Value Property and v is a numeric value without unit, or if the Value Property or Slot does not have a unit attached, then the new value is just v. If the Value Property or Slot already has a unit attached and v has a unit as well, then the numeric value of v will be converted to the expected unit from the Value Property / Slot first and then recorded in the change set. In case of incompatible units an error is raised. In case of multiple Slot values, this will be done for each such value.

• 

If t is a reference property, or a Slot whose defining feature is a reference property, then v must be a UUID string (or a list of such strings in case of multiple Slot values) referring to existing model elements.

• 

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

• 

The following model elements must already exist for both commands to work: the Property or Slot t itself, and the Value Specification(s) vs.  

• 

Both commands raise an error if t is a Property that does not have a default value, or a Slot whose defining feature is not a Property, or a Slot without a value, and PutValue also raises an error if t is not a Property or a Slot.

• 

The GetValue(u) and PutValue(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 GetValue(q) and PutValue(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,Commit,Connect,GetBinding,GetChildren,GetConstraint,GetInstances,GetSlots,GetValue,Login,Logout,PrintChangeSet,PrintElement,PutConstraint,PutValue,QualifiedNameOf,QueryModel,Warnlevel

(1)

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

ConnectJMPTWCSysML:

Download the Analysis Block.

Analysis_BlockQueryModelModel-Turbofan::System Breakdown::System Structure::Analysis Block

Analysis_Block01984647-e938-4b84-8484-c5d5a1f47bec,uml:Class,Block,Analysis Block

(2)

UUIDs and equations for all Value Properties in the Analysis Block, using only simple parameter names.

lGetValueAnalysis_Block3:

numelemsl

29

(3)

maplprint,l1..3:

["d478980a-4ab8-4693-b4af-c1d136b33423", "PR_fan" = [1.5, 1]]
["0551c1c3-8afc-4655-9fb9-b787261d0657", "nozzle_area" = [.168, Units:-Unit(m^2)]]
["e6767b34-5e29-4b91-9db0-cf10e5f37cdf", "Bvc" = [0., 1]]

Get the equation only for the 1st Value Property but with a qualified name. (This also demonstrates the UUID calling sequence.)

GetValued478980a-4ab8-4693-b4af-c1d136b33423,fullname=true

Model-Turbofan::System Breakdown::System Structure::Analysis Block::PR_fan=1.5,1

(4)

Using the qualified name calling sequence, get equations for all Value Properties in the Analysis Block, without UUIDs and in compact form, and using shorter names of the form a::b for the Value Properties.

lGetValueModel-Turbofan::System Breakdown::System Structure::Analysis Block,output=compact,fullname=short:

mapprint,l1..3:

Analysis Block::PR_fan=1.5

Analysis Block::nozzle_area=0.168m2

Analysis Block::Bvc=0.

(5)

Change the value of PR_fan, using the internal change set.

PutValued478980a-4ab8-4693-b4af-c1d136b33423,1.2

PrintChangeSet

c5bf0b87-1c3f-42db-8862-ab4155b05e5d (PR_fan): value = "1.2" ("1.5")

Note the UUID printed is the one of the Value Specification from the default value.

Change the value of nozzle_area, with a different unit, and using the qualified name calling sequence.

PutValueModel-Turbofan::System Breakdown::System Structure::Analysis Block::nozzle_area,1500.Units:-Unitcm2

PrintChangeSet

d013db8e-f9e3-428e-8960-7200dffcf7f2 (nozzle_area): value = ".1500000000" ("0.168")

c5bf0b87-1c3f-42db-8862-ab4155b05e5d (PR_fan): value = "1.2" ("1.5")

Note how the numeric value has been converted from cm2 to the target unit m2.

An error is raised if the given unit is incompatible with the target unit.

PutValueModel-Turbofan::System Breakdown::System Structure::Analysis Block::nozzle_area,1500.Units:-Unitcm

Error, (in SysMLConnector:-PutValue) incompatible units: given Units:-Unit(cm), expected unit Units:-Unit(m^2)

If we do not specify a unit then PutValue assumes that the numeric value given already has the right unit (in this example, this would probably be a user mistake).

PutValueModel-Turbofan::System Breakdown::System Structure::Analysis Block::nozzle_area,1500.

PrintChangeSet

d013db8e-f9e3-428e-8960-7200dffcf7f2 (nozzle_area): value = "1500." ("0.168")

c5bf0b87-1c3f-42db-8862-ab4155b05e5d (PR_fan): value = "1.2" ("1.5")

Note that the most recent change to nozzle_area has clobbered the previous one.

Note also that the cached model elements were not changed.

PrintElementc5bf0b87-1c3f-42db-8862-ab4155b05e5d:

"ID" = "_19_0_3_8970276_1591124300179_21362_34809"
"name" = ""
"owner" = [1 = {"@id" = "d478980a-4ab8-4693-b4af-c1d136b33423"}]
"owningProperty" = {"@id" = "d478980a-4ab8-4693-b4af-c1d136b33423"}
"value" = "1.5"
"visibility__from_PackageableElement" = "public"

Logout

See Also

Commit

Connect

GetBinding

GetChildren

GetConstraint

JSON

QueryModel

SysMLConnector