X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fscl%2FSimantics%2FDistrict.scl;fp=org.simantics.district.network%2Fscl%2FSimantics%2FDistrict.scl;h=b99442e6b0177c9e5e3c032c0ff42eadb029a1cf;hb=00803fe68b14b5dce310a5a88b9c2a55bd1c85e6;hp=6318d7550b5a7bfcf7a15c0a245bdce85c83aef9;hpb=b654d9f368d601565303bcf646fc4fbdfbc37090;p=simantics%2Fdistrict.git diff --git a/org.simantics.district.network/scl/Simantics/District.scl b/org.simantics.district.network/scl/Simantics/District.scl index 6318d755..b99442e6 100644 --- a/org.simantics.district.network/scl/Simantics/District.scl +++ b/org.simantics.district.network/scl/Simantics/District.scl @@ -1,5 +1,7 @@ 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 @@ -83,3 +85,36 @@ importJava "org.simantics.district.network.DistrictNetworkUtil" where createVertex :: Resource -> Vector Double -> Resource -> Resource createEdge :: Resource -> Resource -> 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 -> 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 -> Maybe Double +possibleMappedComponentPropertyValue propName r = match possibleMappedComponentVariable r with + Nothing -> Nothing + Just mv -> possiblePropertyValue mv propName + +""" +""" +mappedComponentPropertyValue :: Double -> String -> Resource -> Double +mappedComponentPropertyValue def propName r = match possibleMappedComponentVariable r with + Nothing -> def + Just mv -> match possiblePropertyValue mv propName with + Nothing -> def + Just v -> v