import "Simantics/DB" import "Simantics/Variables" import "Simantics/Entity" import "Simantics/Model" import "http://www.simantics.org/Modeling-1.2" as MOD type Subscription = Resource type SubscriptionFolder = Resource importJava "org.simantics.modeling.subscription.SCLSubscription" where @JavaName addSubscriptionItems """ Creates new Subscription with the given Variable under the given SubscriptionFolder. **Input 1:** Subscription folder in which subscription is wanbted to be created as **Resource** **Input 2:** 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 module PO01 attribute PO11_PRESSURE to the latter folder. import "Apros/Model" import "Apros/Module" import "Simantics/Diagram" import "Apros/Variables" import "Simantics/Subscription" my_model = model "Model" my_diagram = diagram my_model ["NewGenericDiagram"] my_component = getComponent my_model "PO01" my_variable_uri = stateVariableUri my_model my_diagram my_component "PO11_PRESSURE" my_variable = getStateVariable my_variable_uri 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 """ addSubscriptionInFolder :: SubscriptionFolder -> Variable -> Subscription @JavaName newSubscriptionItem """ Creates new Subscription with advanced options for user to define non-default parameters. **Input 1:** Wanted subscription folder as **Resource** **Input 2:** Wanted variable from which the subscription is done as **Variable** **Input 3:** Sampling interval as **Double** **Input 4:** Deadband as **Double** **Input 5:** Gain as **Double** **Input 6:** Bias as **Double** **Input 7:** Unit as **String** **Input 8:** 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 "Apros/Model" import "Apros/Module" import "Simantics/Diagram" import "Apros/Variables" import "Simantics/Subscription" my_model = model "Model" my_diagram = diagram my_model ["NewGenericDiagram"] my_component = getComponent my_model "PO01" my_variable_uri = stateVariableUri my_model my_diagram my_component "PO11_PRESSURE" my_variable = getStateVariable my_variable_uri my_subscription_folder = defaultSubscriptionFolder my_model newSubscription my_subscription_folder my_variable 5 0 10 0 "Bar" "Pressure at point PO01" #430173 """ newSubscription :: SubscriptionFolder -> Variable -> Double -> Double -> Double -> Double -> String -> String -> Subscription @JavaName addSubscriptionFolder """ Creates new SubscriptionFolder under the given Model. Parameter String defines the name of the folder. **Input 1:** Model in which new subscription folder is wanted to be created as **Model** **Input 2:** Wanted name for the new subscription folder as **String** **Output:** The newly created subscription folder as **Resource** Example: import "Apros/Model" import "Simantics/Subscription" my_model = model "Model" addSubscriptionFolder my_model "Pressure subscriptions of the model" #430186 """ addSubscriptionFolder :: Model -> String -> SubscriptionFolder @JavaName defaultSubscriptionFolder """ Browses the given Model for its default SubscriptionFolder with name "Default" and then returns it. If folder is not found, returns a random SubscriptionFolder **Input 1:** Model which default subscription folder is wanted to be obtained as **Model** **Output:** The default subscription folder as **Resource** Example: import "Apros/Model" import "Simantics/Subscription" my_model = model "Model" defaultSubscriptionFolder my_model #386608 """ defaultSubscriptionFolder :: Model -> SubscriptionFolder @JavaName getLabel getSubscriptionLabel :: Subscription -> String """ Creates new Subscription with the given Variable to the Variables models default SubscriptionFolder. **Input 1:** Wanted module attribute from which subscription is to be created as **Variable** **Output:** The newly created subscription as **Resource** Example: create a subscription of module PO01 attribute PO11_PRESSURE to the default subscription folder with default options. import "Apros/Model" import "Apros/Module" import "Simantics/Diagram" import "Apros/Variables" import "Simantics/Subscription" my_model = model "Model" my_diagram = diagram my_model ["NewGenericDiagram"] my_component = getComponent my_model "PO01" my_variable_uri = stateVariableUri my_model my_diagram my_component "PO11_PRESSURE" my_variable = getStateVariable my_variable_uri addSubscription my_variable #430121 """ addSubscription :: Variable -> Subscription addSubscription variable = do model = modelOfVariable variable default = defaultSubscriptionFolder model addSubscriptionInFolder default variable """ Browses the given Model for its SubscriptionFolders and then returns them in a list. **Input 1:** Model which subscription folders are wanted as **Model** **Output:** List which elements are subscription folder **Resources** Example: Model contains two subscription folders called **Default** and **Pressure subscriptions of the model**. Let's fetch them and print out their names. import "Apros/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 """ subscriptionFoldersOf :: Model -> [SubscriptionFolder] subscriptionFoldersOf model = recurse (toResource model) where recurse r = do cs = resourceChildrenOf r folders = map fromResource $ filter isSubscriptionFolder cs folders isSubscriptionFolder r = isInstanceOf r MOD.Subscription