X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.district.network%2Fscl%2FSimantics%2FDistrict.scl;h=5eaa05760560d31a385aadfa7a0bd1bce16dae22;hb=adaf5cd394f4a08ea8e692377d24d2611c28f954;hp=b99442e6b0177c9e5e3c032c0ff42eadb029a1cf;hpb=2cf7ae447c79df6240b67fd3ca4f0338bdae8c00;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 b99442e6..5eaa0576 100644 --- a/org.simantics.district.network/scl/Simantics/District.scl +++ b/org.simantics.district.network/scl/Simantics/District.scl @@ -8,6 +8,7 @@ import "MSet" as MSet importJava "org.simantics.district.network.DistrictNetworkUtil" where calculateDistance :: Resource -> Resource -> Double + nearbyVertices :: Resource -> Double -> [Resource] importJava "org.simantics.district.network.ModelledCRS" where xToLongitude :: Double -> Double @@ -82,8 +83,17 @@ translateElement elem = do () importJava "org.simantics.district.network.DistrictNetworkUtil" where - createVertex :: Resource -> Vector Double -> Resource -> Resource - createEdge :: Resource -> Resource -> Resource + createVertex :: Resource -> Vector Double -> Double -> Resource -> Resource + createEdge :: Resource -> Resource -> Vector Double -> Resource + +""" +Tries to look for the Resource representing the configuration component +mapped to the specified district network diagram element. +""" +possibleMappedComponent :: Resource -> Maybe Resource +possibleMappedComponent r = match possibleObject r DN.MappedComponent with + Nothing -> Nothing + Just me -> possibleObject me MOD.ElementToComponent """ Tries to look for the Variable representing the configuration component @@ -93,28 +103,57 @@ 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 +possibleMappedComponentVariable r = match possibleMappedComponent r 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 + Just mc -> do + mcv = resourceVariable mc + match possibleActiveVariable mcv with + Nothing -> Just mcv + a -> a """ """ -possibleMappedComponentPropertyValue :: String -> Resource -> Maybe Double +possibleMappedComponentPropertyValue :: Serializable a => Typeable a => String -> Resource -> Maybe a possibleMappedComponentPropertyValue propName r = match possibleMappedComponentVariable r with Nothing -> Nothing Just mv -> possiblePropertyValue mv propName """ """ -mappedComponentPropertyValue :: Double -> String -> Resource -> Double +mappedComponentPropertyValue :: Serializable a => Typeable a => a -> String -> Resource -> a mappedComponentPropertyValue def propName r = match possibleMappedComponentVariable r with Nothing -> def Just mv -> match possiblePropertyValue mv propName with Nothing -> def Just v -> v + +""" +Returns possible district network element that is mapped to the +specified model configuration component. The DN element is found +using the following relation path: + + domain model configuration component ---[MOD.ComponentToElement]---> domain model diagram element + ----[DN.MappedFromElement]----> district network diagram element +""" +possibleDNElementMappedToComponent :: Resource -> Maybe Resource +possibleDNElementMappedToComponent mappedComponent = match possibleObject mappedComponent MOD.ComponentToElement with + Nothing -> Nothing + Just element -> possibleObject element DN.MappedFromElement + +""" +Returns all district network elements that are found to be mapped the +specified mapped model configuration components by +[possibleDNElementMappedToComponent](possibleDNElementMappedToComponent). + +The result list can be smaller than the input resource list, even empty. +""" +dnElementsMappedToComponents :: [Resource] -> [Resource] +dnElementsMappedToComponents mappedComponents = mapMaybe possibleDNElementMappedToComponent mappedComponents + + +importJava "org.simantics.district.network.DistrictNetworkUtil" where + createNetworkDiagram :: Resource -> Resource -> String -> Resource -> Resource -> Resource -> Resource -> Resource -> Resource + changeMappingType :: Resource -> [Resource] -> () + findDNElementById :: Resource -> String -> Maybe Resource + findDNElementByXYCoordinates :: Resource -> Double -> Double -> Double -> [Resource] +