Simantics/Subscription module documentation
Subscription (Item)
A Subscription represents an Item instance in Simantics ontology (http://www.simantics.org/Modeling-1.2/Subscription/Item ).
It describes
addSubscription :: Variable -> <WriteGraph> Resource
Creates a new Subscription item for given Variable to the currently active model's default SubscriptionFolder .
Inputs:
- Wanted module attribute from which subscription is to be created as
Variable
Output: The newly created subscription item as Resource
Example: create a subscription of component COMPONENT property PROPERTY to the default subscription folder with default options.
import "Simantics/Model"
import "Simantics/Diagram"
import "Simantics/Subscription"
my_model = model "Model"
my_diagram = diagram my_model ["NewGenericDiagram"]
my_component = child (variable my_diagram) "COMPONENT"
my_variable = property my_component "PRESSURE"
addSubscription my_variable
#430121
addSubscriptionInFolder :: Resource -> Variable -> <WriteGraph> Resource
Creates new Subscription with the given Variable under the given SubscriptionFolder.
Inputs:
- Subscription folder in which subscription is wanted to be created as
Resource
- Wanted module attribute from which subscription is to be created as
Variable
Output: The newly created subscription as Resource
Example: Model contains two subscription folders called Default and Pressure subscriptions of the model.
Let's fetch them and add one new subscription of component COMPONENT property PRESSURE to the latter folder.
import "Simantics/Variables"
import "Simantics/Diagram"
import "Simantics/Subscription"
my_model = model "Model"
my_diagram = diagram my_model ["NewGenericDiagram"]
my_component = child (variable my_diagram) "COMPONENT"
my_variable = property my_component "PRESSURE"
my_subscription_folder_list = subscriptionFoldersOf my_model
my_subscription_folder_list
> [#430091, #386608]
print (labelOf (my_subscription_folder_list!0))
> Pressure subscriptions of the model
print (labelOf (my_subscription_folder_list!1))
> Default
addSubscriptionInFolder (my_subscription_folder_list!0) my_variable
> #430094
newSubscription :: Resource -> Variable -> Double -> Double -> Double -> Double -> String -> String -> <WriteGraph> Resource
Creates new Subscription with advanced options for user to define non-default parameters.
Inputs:
- Wanted subscription folder as Resource
- Wanted variable from which the subscription is done as Variable
- Sampling interval as Double
- Deadband as Double
- Gain as Double
- Bias as Double
- Unit as String
- Label as String
Output: The newly created subscription as Resource
Example: Let's add a subscription of module PO01 attribute PO11_PRESSURE to the default subscription folder. This point is
located on diagram NewGenericDiagram in a model called Model. We want to have unit to be shown as bars, so lets define gain as 10.
Also lets define sampling interval to be 5 seconds and label as Pressure at point PO01
import "Simantics/Variables"
import "Simantics/Diagram"
import "Simantics/Subscription"
my_model = model "Model"
my_diagram = diagram my_model ["NewGenericDiagram"]
my_component = child (variable my_diagram) "COMPONENT"
my_variable = property my_component "PRESSURE"
my_subscription_folder = defaultSubscriptionFolder my_model
newSubscription my_subscription_folder my_variable 5 0 10 0 "Bar" "Pressure at point PO01"
#430173
getSubscriptionLabel :: Resource -> <ReadGraph> String
Get the label value that is currently visible in Model Browser for a subscription item.
Subscription Folder
A Subscription folder represents a Subscription instance in Simantics ontology (http://www.simantics.org/Modeling-1.2/Subscription ).
Subscription folders are containers for subscription items.
addSubscriptionFolder :: Resource -> String -> <WriteGraph> Resource
Creates new SubscriptionFolder under the given Model. Parameter String defines the name of the folder.
Inputs:
- Model in which the new subscription folder shall be created as
Resource
- Descriptive label for the new subscription folder as
String
Output: The newly created subscription folder as Resource
Example:
import "Simantics/Model"
import "Simantics/Subscription"
my_model = model "Model"
addSubscriptionFolder my_model "Pressure subscriptions of the model"
#430186
defaultSubscriptionFolder :: Resource -> <ReadGraph> Resource
Browses the given Model for its default SubscriptionFolder with name "Default" and then returns it. If folder is not found, returns a random SubscriptionFolder
Inputs:
- Model which default subscription folder is wanted to be obtained as
Resource
Output: The default subscription folder as Resource
Example:
import "Simantics/Model"
import "Simantics/Subscription"
my_model = model "Model"
defaultSubscriptionFolder my_model
#386608
subscriptionFoldersOf :: Resource -> <ReadGraph> [Resource]
Browses the given Model for its SubscriptionFolders and then returns them in a list.
Inputs:
- Model which subscription folders are wanted as
Resource
Output: List which elements are subscription folder Resource s
Example: Model contains two subscription folders called Default and Pressure subscriptions of the model. Let's fetch them and print out their names.
import "Simantics/Model"
import "Simantics/Subscription"
my_model = model "Model"
my_subscription_folder_list = subscriptionFoldersOf my_model
my_subscription_folder_list
[#386608, #430189]
print (labelOf (my_subscription_folder_list!0))
Default
print (labelOf (my_subscription_folder_list!1))
Pressure subscriptions of the model
|