import "Simantics/DB"
import "Simantics/Ontologies"
+import "Simantics/Variables"
+import "http://www.simantics.org/DistrictNetwork-1.0" as DN
import "Map" as Map
import "MSet" as MSet
()
else ()
()
+
+importJava "org.simantics.district.network.DistrictNetworkUtil" where
+ createVertex :: Resource -> Vector Double -> Resource -> <WriteGraph, Proc> Resource
+ createEdge :: Resource -> Resource -> <WriteGraph, Proc> Resource
+
+"""
+Tries to look for the Variable representing the configuration component
+mapped to the specified district network diagram element.
+
+The variable returned is by default the active experiment context variable
+but if that is not available then a configuration context variable is returned.
+"""
+possibleMappedComponentVariable :: Resource -> <ReadGraph> Maybe Variable
+possibleMappedComponentVariable r = match possibleObject r DN.MappedComponent with
+ Nothing -> Nothing
+ Just me -> match possibleObject me MOD.ElementToComponent with
+ Nothing -> Nothing
+ Just mc -> do
+ mcv = resourceVariable mc
+ match possibleActiveVariable mcv with
+ Nothing -> Just mcv
+ a -> a
+
+"""
+"""
+possibleMappedComponentPropertyValue :: String -> Resource -> <ReadGraph> Maybe Double
+possibleMappedComponentPropertyValue propName r = match possibleMappedComponentVariable r with
+ Nothing -> Nothing
+ Just mv -> possiblePropertyValue mv propName
+
+"""
+"""
+mappedComponentPropertyValue :: Double -> String -> Resource -> <ReadGraph> Double
+mappedComponentPropertyValue def propName r = match possibleMappedComponentVariable r with
+ Nothing -> def
+ Just mv -> match possiblePropertyValue mv propName with
+ Nothing -> def
+ Just v -> v