-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSfcHXT.hs
53 lines (42 loc) · 2.63 KB
/
SfcHXT.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module SfcHXT where
data TypeBodyElem = StepT | ActionBlock | TransitionT | SelectionConvergence | SelectionDivergence deriving (Eq, Show)
-- BodyElem (ID, (Type, ( [Reference(ConnIN)], (Qualifier, Text) ) ) )
newtype BodyElem = BodyElem { unBodyElem :: (Int, ( String, (TypeBodyElem, ([Int], (String, String) ) ) ) ) } deriving (Eq, Show)
-- VarP (type,(name, ([value], Category) ))
newtype VarP = VarP { unVarP :: (String,(String, ([String], String) )) } deriving (Eq, Show)
data SFCP = SFCP {
nameP :: String,
varsP :: [VarP],
stepsP :: [BodyElem],
actionsP :: [BodyElem],
initStepP :: BodyElem,
transitionsP :: [BodyElem],
annotationsP :: [String],
histP :: Bool
} deriving (Show, Eq)
findBodyElem :: Int -> [BodyElem] -> [BodyElem]
findBodyElem x [] = []
findBodyElem x (y:ys) = let idElemList = (fst . unBodyElem) y
in if x == idElemList then [y] else findBodyElem x ys
typeBodyElem :: BodyElem -> TypeBodyElem
typeBodyElem = fst . snd . snd . unBodyElem
findOriginTransition :: BodyElem -> [BodyElem] -> [BodyElem]
findOriginTransition x [] = []
findOriginTransition x l = let idReference = (head . fst . snd . snd . snd . unBodyElem) x
elemFound = (head (findBodyElem idReference l))
in case typeBodyElem elemFound of
StepT -> [elemFound]
otherwise -> findOriginTransition elemFound l
findDestinationTransition :: BodyElem -> [BodyElem] -> [BodyElem]
findDestinationTransition x [] = []
findDestinationTransition x (y:ys) = let idX = (fst . unBodyElem) x
idReferences = (fst . snd . snd . snd . unBodyElem) y
in if idX `elem` idReferences then
if typeBodyElem y == StepT then [y]
else findDestinationTransition y ys
else
findDestinationTransition x (ys ++ [y])
findActionsStep :: BodyElem -> [BodyElem] -> BodyElem
findActionsStep x (y:ys) = let stepRef = (head . fst . snd . snd . snd . unBodyElem) x
actualStepID = (fst . unBodyElem) y
in if stepRef == actualStepID then y else findActionsStep x ys