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

Online Help

All Products    Maple    MapleSim


Connecting to Teamwork Cloud from Maple

 

Description

Examples

Description

The SysML Connector toolbox offers functionality to access a SysML model stored on a server:

• 

Login and Logout.

• 

Query individual model elements by UUID or fully qualified name.

• 

Bulk download all child elements of a given model element, possibly filtered by Classifier or Stereotype.

• 

Extract numerical values and units from SysML Value Properties, Blocks, Slots, and Instance Specifications, and convert them to Maple objects, either individually or in bulk.

• 

Extract mathematical equations from SysML Blocks, BindingConnectors, Packages and ConstraintBlocks, and convert them to Maple objects, either individually or in bulk.

• 

Change numerical values or equations in Maple and add them to a change set.

• 

Commit a set of changes back to the server.

This worksheet demonstrates the package functionality for a Teamwork Cloud (TWC) server.

Examples

withSysMLConnector

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

(1)

Log into TWC server.

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

Error, (in URL:-Get) connection timed out after 50002 milliseconds

List all available projects.

Connect

Error, (in SysMLConnector:-Connect) call Login first

Connect to Turbofan Jet Engine SysML model.

modelConnectJMPTWCSysML

Error, (in SysMLConnector:-Connect) call Login first

Query the Analysis Block by fully qualified name. This returns a list of 3 elements:

– 

UUID of the model element on the server

– 

Classifier and Stereotype(s) of the model element

– 

a Maple table, of which only the name is printed, storing the (many) data fields of the model element

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

Error, (in SysMLConnector:-QueryModel) call Connect first

Query a Value Property by name, relative to the Analysis Block.

Velocity_inQueryModelVelocity_in,Analysis_Block3

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-QueryModel; first unused argument is Analysis_Block[3]

Inspect all the nontrivial / nonempty fields of the model element. This Value Property has two children.

PrintElementVelocity_in3

Error, invalid input: SysMLConnector:-PrintElement expects its 1st argument, tt, to be of type Or(string,list,table), but received Velocity_in[3]

Find the qualified name of the type of the model element.

QualifiedNameOfVelocity_in3type

Error, invalid input: SysMLConnector:-QualifiedNameOf expects its 1st argument, element, to be of type Or(table,string), but received Velocity_in[3]["type"]

Query the first child (the default value) by UUID.

Velocity_in3ownedElement1

Velocity_in3ownedElement1

(2)

QueryModel

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-QueryModel; first unused argument is Velocity_in[3]["ownedElement"][1]

The numerical value is stored in the value feature of this Value Specification.

PrintElementvs3

Error, invalid input: SysMLConnector:-PrintElement expects its 1st argument, tt, to be of type Or(string,list,table), but received vs[3]

Instead of using this low-level functionality to manually navigate through the model structure, we can directly extract both the numerical value and the unit of this Value Property and convert them to Maple objects.

GetValueVelocity_in3

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetValue; first unused argument is Velocity_in[3]

This can also be done in bulk for all Value Properties in the Analysis Block.

valuesGetValueAnalysis_Block3,fullname=short,output=compact:

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetValue; first unused argument is Analysis_Block[3]

The warnings indicate some Value Properties that do not have a default value, as well as some non-standard unit specifications, which however the code accepts. Here are all the values.

Vectorvalues

Error, (in Vector) dimension parameter is required for this form of initializer

Equations from BindingConnectors and ConstraintBlocks can also be extracted from the model, either individually or in bulk.

If they are stored in the model as Maple syntax strings, they will be converted to Maple object; otherwise, they will remain as strings.

ConstraintsQueryModelModel-Turbofan::Constraints

Error, (in SysMLConnector:-QueryModel) call Connect first

GetConstraintConstraints3ownedElement1&comma;postprocess=`<`&comma;`<=`

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetConstraint; first unused argument is Constraints[3]["ownedElement"][1]

VectorGetConstraintConstraints3&comma;output=compact&comma;postprocess=`<`&comma;`<=`

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetConstraint; first unused argument is Constraints[3]

VectorGetBindingAnalysis_Block3&comma;fullname=short&comma;output=compact

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetBinding; first unused argument is Analysis_Block[3]

Now let's change the numerical values of some model elements.

GetValueVelocity_in3

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-GetValue; first unused argument is Velocity_in[3]

h_aircraftQueryModelh_aircraft&comma;Analysis_Block3

Error, invalid input: too many and/or wrong type of arguments passed to SysMLConnector:-QueryModel; first unused argument is Analysis_Block[3]

PutValueVelocity_in3&comma;0.250Units:-Unitkms

Error, invalid input: SysMLConnector:-PutValue expects its 1st argument, element, to be of type {string, table}, but received Velocity_in[3]

PutValueh_aircraft3&comma;39000.0

Error, invalid input: SysMLConnector:-PutValue expects its 1st argument, element, to be of type {string, table}, but received h_aircraft[3]

All changes are accumulated in a change set so they can be committed all at once.

The target unit is the one stored in the model. (It is not yet possible to change the target unit.)

However, if a different unit than the target unit is specified, Maple will automatically convert the value to the target unit (see Velocity_in).

If no unit is specified, then the numerical value will be stored without any conversion, assuming it is in the target unit already.

PrintChangeSet

Maple will detect inconsistent units at this stage.

PutValueVelocity_in3&comma;0.250Units:-Unitkm

Error, invalid input: SysMLConnector:-PutValue expects its 1st argument, element, to be of type {string, table}, but received Velocity_in[3]

The final step will write the two changed values from the above change set back to the model on the TWC server.

CommitUpdated Velocity_in and h_aircraft

Logout

Error, (in SysMLConnector:-Logout) not currently logged in