Variables documentation

class Browsable a

Things that are addressed by URI and browsed as a tree of named children. Both Resource and Variable are browsable: a resource is browsed through the resources it consists of, a variable through its own child structure.

fromUri :: Browsable a => String -> <ReadGraph> a (Simantics/DB)

Returns the value at the given absolute URI. Fails if there is nothing at that URI.

uriOf :: Browsable a => a -> <ReadGraph> String (Simantics/DB)

Returns the URI of the given value.

possibleUriOf :: Browsable a => a -> <ReadGraph> Maybe String (Simantics/DB)

Returns the URI of the given value if it exists or Nothing.

nameOf :: Browsable a => a -> <ReadGraph> String (Simantics/DB)

Reads the name of the value.

possibleNameOf :: Browsable a => a -> <ReadGraph> Maybe String (Simantics/DB)

Reads the name of the value or Nothing if it has no name.

valueOf :: Browsable a => Serializable b => a -> <ReadGraph> b (Simantics/DB)

Reads the value the given entity holds, deserialized with the binding of the expected type. Fails if the entity holds no value.

genericRelatedValue :: Browsable a => a -> Resource -> <ReadGraph> b (Simantics/DB)

Reads the value related to the given entity with the given relation. For a resource this is the value of the object of that relation, for a variable the value of the property named after the relation. Fails if there is no such value.

genericPossibleRelatedValue :: Browsable a => a -> Resource -> <ReadGraph> Maybe b (Simantics/DB)

As genericRelatedValue but returns Nothing when there is no such value.

variantValueOf :: Browsable a => a -> <ReadGraph> Variant (Simantics/DB)

Reads the value the given entity holds as a Variant, packaged together with its data type.

children :: Browsable a => a -> <ReadGraph> [a] (Simantics/DB)

Returns the children of the given entity. For a resource these are the resources it consists of.

parent :: Browsable a => a -> <ReadGraph> a (Simantics/DB)

Returns the parent of the given entity. Fails if there is no unique parent.

possibleParent :: Browsable a => a -> <ReadGraph> Maybe a (Simantics/DB)

As parent but returns Nothing when there is no unique parent.

child :: Browsable a => a -> String -> <ReadGraph> a (Simantics/DB)

child entity name returns the child of entity with the given name. Fails if there is no such child.

possibleChild :: Browsable a => a -> String -> <ReadGraph> Maybe a (Simantics/DB)

As child but returns Nothing when there is no child with the given name.

ResourceX :: Resource -> VariableOrResource
VariableX :: Variable -> VariableOrResource
browse :: Variable -> String -> <ReadGraph> Variable

Returns the variable reached from the given variable by the given relative path. The path may mix child steps and property steps, for example Diagram/PO01#PO11_PRESSURE.

browsePossible :: Variable -> String -> <ReadGraph> Maybe Variable

Like browse, but returns Nothing if the path does not resolve.

children_ :: Variable -> <ReadGraph> Collection Variable

Returns all children of the given variable as a Java collection. children returns the same as a list.

createValueAccessor :: (Variable -> <ReadGraph> a) -> (Variable -> Binding b -> <ReadGraph> b) -> (Variable -> c -> <WriteGraph> ()) -> (Variable -> d -> Binding d -> <WriteGraph> ()) -> (Variable -> <ReadGraph> Datatype) -> ValueAccessor

Creates a value accessor from the five functions that implement reading and writing the value of a variable: reading with the default binding, reading with an explicit binding, writing with the default binding, writing with an explicit binding, and resolving the datatype of the value.

createVariableMap :: [Resource] -> VariableMap

Creates a variable map whose children are the given resources, each becoming a child variable named by its L0.HasName. Use it to define a custom variable space from SCL.

datatype :: Variable -> <ReadGraph> Datatype

Returns the datatype of the value of the given variable.

getIndexRoot :: Variable -> <ReadGraph> Resource

Returns the index root, typically the model or the ontology, that the given variable belongs to.

getPossiblePredicateResource :: Variable -> <ReadGraph> Maybe Resource

Like getPredicateResource, but returns Nothing when there is no predicate resource.

getPossibleType :: Variable -> <ReadGraph> Maybe Resource

Like getType, but returns Nothing if the type of the variable cannot be determined.

getPossibleTypeWithBaseType :: Variable -> Resource -> <ReadGraph> Maybe Resource

Returns the type of the given variable that inherits from the given base type, or Nothing if the variable has no such type.

getPredicateResource :: Variable -> <ReadGraph> Resource

Returns the resource of the relation through which the given property variable was reached. Fails if the variable is not a property or has no predicate resource.

getType :: Variable -> <ReadGraph> Resource

Function getType returns the type of the input variable as resource

Example:

import "Simantics/Variables"
import "Apros/Module"
getType (moduleVariable "PO01")

> #275837

nameOf(getType (moduleVariable "PO01"))

> "POINT_QF"
instanceIndexRoot :: Variable -> <ReadGraph> Resource

Returns the index root, typically the model or the ontology, that the given variable belongs to.

instantiateUnder :: Resource -> Resource -> <WriteGraph> Resource

Creates a new instance of the given type under the given container and returns it. By default the instance is attached to the container with L0.ConsistsOf and given a fresh name derived from the type, but a type can define its own methods#instantiateUnder function to do something else. Requires a write transaction.

modelOfVariable :: Variable -> <ReadGraph> Resource

Function modelOfVariable returns the model, in which the given input variable is located, as Resource

Example:

import "Simantics/Variables"
import "Apros/Module"
my_variable = moduleVariable "PO01"
my_model = modelOfVariable my_variable
my_model

> #376833

// use function nameOf, which works for resources, to print out the name of the model
nameOf(my_model)

> "Model"
modelResourceOfVariable :: Variable -> <ReadGraph> Resource

Returns the model that contains the given variable. Same as modelOfVariable, which returns the same resource typed as Model.

modelVariableOfVariable :: Variable -> <ReadGraph> Variable

Function modelVariableOfVariable returns the model, in which the given input Variable is located, as Variable

Example:

import "Simantics/Variables"
import "Apros/Module"
my_model_variable = modelVariableOfVariable (moduleVariable "PO01")
my_model_variable

> <variable>

name my_model_variable

> "Model"
name :: Variable -> <ReadGraph> String

Function name return the name of the input variable as string

Example:

import "Simantics/Variables"
import "Apros/Module"
name (moduleVariable "PO01")

> "PO01"
possibleActiveVariable :: Variable -> <ReadGraph> Maybe Variable

Returns the counterpart of the given configuration variable in the currently active experiment run of its model. Returns Nothing if the variable has no model, if the model has no active run, or if the run has no variable at the same path.

possibleConfigurationContext :: Resource -> <ReadGraph> Variable

Returns the configuration variable of the model that the given resource belongs to. The resource may be the model itself or any resource under it. Fails if no model or no configuration is found; despite the name it has no Maybe result.

possibleProperty :: Variable -> String -> <ReadGraph> Maybe Variable

Like property, but returns Nothing if the variable has no property with the given name.

possiblePropertyValue :: Serializable a => Typeable a => Variable -> String -> <ReadGraph> Maybe a

Like propertyValue, but returns Nothing if the variable has no such property or the property has no value.

possiblePropertyValue_ :: Variable -> String -> Binding a -> <ReadGraph> Maybe a

Returns the value of the named property decoded with the given binding, or Nothing if there is no such property or it has no value.

possibleRepresents :: Variable -> <ReadGraph> Maybe Resource

Like represents, but returns Nothing if the variable does not correspond to any resource.

possibleResourceVariable :: Resource -> <ReadGraph> Maybe Variable

Returns the variable that corresponds to the given resource, or Nothing if the resource has no place in the variable tree. If the resource itself has no URI, the variable of its owner is looked up and searched for a child that has the resource's name or represents it.

possibleVariable :: String -> <ReadGraph> Maybe Variable

Returns the variable at the given variable URI, or Nothing if there is no such variable.

possibleVariableValue :: Serializable a => Typeable a => Variable -> <ReadGraph> Maybe a

Like value, but returns Nothing if the variable has no value.

possibleVariableValue_ :: Variable -> Binding a -> <ReadGraph> Maybe a

Returns the value of the given variable decoded with the given binding, or Nothing if the variable has no value.

properties :: Variable -> <ReadGraph> [Variable]

Function properties returns a list, which contains of the properties of the input variable as Variable

Example 1: print out all the properties of certain point as they are shown in Variable Debugger.

import "Simantics/Variables"
import "Apros/Module"
point_properties_list = properties (moduleVariable "PO01")
//print out the names of the properties
for point_properties_list (\x -> print(name x) )

> IncludedInSimulation
> PO11_PRESSURE
> IsDesynchronized
> PO11_PROPERTY_CALC
> PO11_EPM_ROU
> PO11_ELEV_FROM_BOT
...

Example 2: print out only the properties of a point, which name starts as "PO11". Else do nothing.

import "Simantics/Variables"
import "Apros/Module"
point_properties_list = properties (moduleVariable "PO01")
for point_properties_list (\x -> do
    //print out the names of the properties, which name start as "PO11"
    if (take 4 (name x) == "PO11") then do
        print(name x)
        ()
    else do
        ()
)

> PO11_PRESSURE
> PO11_PROPERTY_CALC
> PO11_EPM_ROU
> PO11_ELEV_FROM_BOT
> PO11_NODE_VELOCITY_CALC
...
propertiesClassified :: Variable -> Resource -> <ReadGraph> [Variable]

Returns those properties of the given variable that carry the given classification resource.

propertiesClassified_ :: Variable -> Resource -> <ReadGraph> Collection Variable

Returns those properties of the given variable that carry the given classification resource, as a Java collection. propertiesClassified returns the same as a list.

properties_ :: Variable -> <ReadGraph> Collection Variable

Returns all properties of the given variable as a Java collection. properties returns the same as a list.

property :: Variable -> String -> <ReadGraph> Variable

Function property return the wanted property as Variable

Input 1: Module which property we want to obtain as Variable

Input 2: Name of the property as String

Output: wanted property as Variable

Example

import "Simantics/Variables"
import "Apros/Module"
my_property_variable = property (moduleVariable "PO01") "PO11_PRESSURE"
my_property_variable

> <variable>
propertyInfoOf :: Resource -> <ReadGraph> PropertyInfo

Returns the cached PropertyInfo of the given property relation.

propertyValue :: Serializable a => Typeable a => Variable -> String -> <ReadGraph> a

Function propertyValue finds the value of given property.

Example: Find out the value of point PO01 attribute PO11_PRESSURE

import "Simantics/Variables"
import "Apros/Module"
propertyValue (moduleVariable "PO01") "PO11_PRESSURE" :: Double

> 0.75
propertyValue_ :: Variable -> String -> Binding a -> <ReadGraph> a

Returns the value of the named property of the given variable, decoded with the given binding.

represents :: Variable -> <ReadGraph> Resource

Function represents returns the resource of the given input variable

Input 1: Variable which resource is wanted to be obtainend

Output: Resource of the given input variable.

Example: Find out the resource of given variable

import "Simantics/Variables"
import "Apros/Module"
represents (moduleVariable "PO01")

> #426013
resolvePossible :: RVI -> Variable -> <ReadGraph> Maybe Variable

Follows the given RVI from the given variable and returns the variable it leads to, or Nothing if some step of the path does not resolve.

resourceVariable :: Resource -> <ReadGraph> Variable

Function resourceVariable converts a resource to a corresponding variable.

Example:

import "Simantics/Variables"
import "Apros/Module"
model_id = model "Model"
my_resource = getComponent model_id "PO01"
my_variable = resourceVariable my_resource
my_variable

> <variable>
rviBinding :: <ReadGraph> Binding a

Returns the Binding needed to read RVI type properties.

rviIsEmpty :: RVI -> Boolean

Returns True if the given RVI is empty in which case resolvePossible rvi var would return Just var.

rviOf :: Variable -> <ReadGraph> RVI

Returns the RVI of the given variable, relative to the nearest enclosing context.

sclVariableMap :: (Variable -> <ReadGraph,Proc> [Variable]) -> VariableMap

Creates a variable map whose children of a variable are the variables produced by the given function.

sclVariableMapWithBasis :: VariableMap -> (Variable -> <ReadGraph,Proc> [Variable]) -> VariableMap

Like sclVariableMap, but the variables produced by the function are added on top of those of the given basis map, replacing any that have the same name.

setPropertyValue :: Serializable a => Variable -> String -> a -> <WriteGraph> ()

Function setPropertyValue sets wanted to value to given Variable property.

Input 1: Wanted module as Variable

Input 2: Wanted property name as String

Output: No output, given value is inserted to property

Example:

import "Simantics/Variables"
import "Apros/Module"
setPropertyValue (moduleVariable "PO01") "PO11_PRESSURE" 0.5
setPropertyValue_ :: Variable -> String -> a -> Binding a -> <WriteGraph> ()

Writes the value of the named property of the given variable, encoding it with the given binding. Requires a write transaction and fails if the property is not writable.

setRVIProperty :: Variable -> RVI -> <WriteGraph> ()

Writes the given RVI as the value of the given RVI-valued property variable. The old literal is removed and a new one claimed on the parent resource. Requires a write transaction.

setValue :: Variable -> a -> <WriteGraph> ()

Writes the value of the given variable, using the default binding for the class of the value. Requires a write transaction and fails if the variable is not writable.

standardChildDomainProperties :: VariableMap

The variable map that resolves the properties of a variable that represents an entity. It is the default value of the L0.domainProperties property for entities.

standardGetDatatype :: Variable -> <ReadGraph> Datatype

The default implementation for resolving the datatype of the value of a variable.

standardGetValue1 :: Variable -> <ReadGraph> a

The default implementation for reading the value of a standard graph property variable, using the default binding of the property.

standardGetValue2 :: Variable -> Binding a -> <ReadGraph> a

The default implementation for reading the value of a standard graph property variable with the given binding.

standardGraphPropertyVariable :: Variable -> Maybe VariableNode -> Resource -> PropertyInfo -> Resource -> <ReadGraph> Variable

Creates a standard graph property variable for the property described by the given PropertyInfo on the given parent resource, under the given parent variable. The VariableNode is the external data source node that backs the property, or Nothing when the value lives in the graph, and the last argument is the resource the property variable represents.

standardGraphPropertyVariableParentPredicate :: Variable -> Resource -> <ReadGraph> Variable

Creates a standard graph property variable for the property reached from the given parent variable through the given predicate resource.

standardPropertyDomainProperties :: VariableMap

The variable map that resolves the properties of a variable that is itself a property, such as the Unit in .../PI_X#PI_MASS_FLOW#Unit. It is the default value of the L0.domainProperties property for properties.

standardSetValue2 :: Variable -> a -> <WriteGraph> ()

The default implementation for writing the value of a standard graph property variable, using the default binding for the class of the value. Requires a write transaction.

standardSetValue3 :: Variable -> a -> Binding a -> <WriteGraph> ()

The default implementation for writing the value of a standard graph property variable with the given binding. Requires a write transaction.

switchPossibleContext :: Variable -> Resource -> <ReadGraph> Maybe Variable

Returns the variable at the same relative path as the given variable but under the given context resource, for example the same property in another experiment run. Returns Nothing if the variable has no enclosing context or if the given context has nothing at that path.

uniqueChild :: Resource -> Resource -> String -> <ReadGraph> Variable

Searches the index of the given model for an instance of the given type with the given name and returns it as a variable. Fails if the index has no match; if it has several, the first one is returned.

untypedPossiblePropertyValue :: Variable -> String -> <ReadGraph> Maybe a

Like untypedPropertyValue, but returns Nothing instead of failing when the property or its value is missing.

untypedPossibleVariableValue :: Variable -> <ReadGraph> Maybe a

Like untypedValue, but returns Nothing instead of failing when the variable has no value.

untypedPropertyValue :: Variable -> String -> <ReadGraph> a

Returns the value of the named property without checking that it has the expected SCL type. propertyValue is the type safe version.

untypedValue :: Variable -> <ReadGraph> a

Returns the value of the given variable using the binding of its datatype, without checking that the value has the expected SCL type. value is the type safe version.

uri :: Variable -> <ReadGraph> String

Function uri return the uri of given variable. The uri is fetched from the active Experiment

Input 1: wanted variable which uri is needed as Variable

Output: uri of the variable as String

Example:

import "Simantics/Variables"
import "Apros/Module"
uri (moduleVariable "PO01")

>"http://Projects/Development%20Project/Model/Experiment/8ee6b693-891b-438e-a597-9e15a2634e8b/NewGenericDiagram/PO01"
value :: Serializable a => Typeable a => Variable -> <ReadGraph> a

Returns the value of the given variable, decoded with the default binding of the expected SCL type.

value_ :: Variable -> Binding a -> <ReadGraph> a

Returns the value of the given variable, decoded with the given binding.

variable :: String -> <ReadGraph> Variable

Function variable converts a variable URI to a variable.

Example:

import "Simantics/Variables"
import "Apros/Module"
model_id = model "Model"
my_component = getComponent model_id "PO01"
my_uri = uriOf my_component
my_variable = variable my_uri
my_variable

> <variable>
variableParent :: Variable -> <ReadGraph> Variable

Function variableParent returns the name of the parent variable as Variable

Example:

import "Simantics/Variables"
import "Apros/Module"
my_variable = moduleVariable "PO01"
variableParent my_variable

> <variable>

name (variableParent my_variable)

> "NewGenericDiagram"