Commit b990b14d authored by Job Cuppen's avatar Job Cuppen

east and west railwayswitches are now functional

parent 1b930d39
......@@ -14,6 +14,7 @@ strw = 6.0
full = 100.0
half = full/2.0
quarter = half/2.0
zero = px 0.0
activecol = "goldenrod"
......@@ -31,8 +32,8 @@ createTiles s = map createTile (myCoolTiles s)
createTile :: (Tile,Int) -> Image State
//createTile (t,i) = overlay [(AtMiddleX,AtMiddleY),(AtMiddleX,AtMiddleY)] offs imgs NoHost where
createTile (t,i) = overlay all offs imgs NoHost where
all = [(AtLeft,AtTop): fst4 (unzip4 (filteredSwitchList (t, i)))]
offs = [(px 0.0, px 0.0): snd4 (unzip4 (filteredSwitchList (t, i)))]
all = [(AtLeft,AtTop): fst4 (unzip4 (filteredSwitchList (t, i)))]
offs = [(zero, zero): snd4 (unzip4 (filteredSwitchList (t, i)))]
imgs = [createTracksOfTile (t,i): thd4 (unzip4 (filteredSwitchList (t, i)))]
// welp
......@@ -49,35 +50,26 @@ filteredSwitchList (t,i) = filter (\(_,_,_,active). active) (switchList (t,i))
switchList :: (Tile,Int) -> [(XYAlign,ImageOffset,Image State, Bool)]
switchList (t,i) = [
((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine False), drawSouth t && drawL t.south ),
((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine True), drawSouth t && drawR t.south),
((AtMiddleX,AtBottom),(px (0.0), px (0.0)), switchIndicatorLine2 False , drawSouth t && drawM t.south),
((AtLeft,AtBottom), (px quarter, zero), switchIndicatorLine False, drawSouth t && drawL t.south),
((AtRight,AtBottom), (px (0.0-quarter),zero), switchIndicatorLine True, drawSouth t && drawR t.south),
((AtMiddleX,AtBottom), (zero, zero), switchIndicatorLine2 False, drawSouth t && drawM t.south),
((AtRight,AtTop),(px (0.0-(half/2.0)), px (0.0)),(switchIndicatorLine False), drawNorth t && drawL t.north ),
((AtLeft,AtTop),(px ((half/2.0)),px (0.0)), (switchIndicatorLine True), drawNorth t && drawR t.north),
((AtMiddleX,AtTop),(px (0.0), px (0.0)),(switchIndicatorLine2 False), drawNorth t && drawM t.north),
((AtRight,AtTop), (px (0.0-quarter), zero), switchIndicatorLine False, drawNorth t && drawL t.north),
((AtLeft,AtTop), (px quarter, zero), switchIndicatorLine True, drawNorth t && drawR t.north),
((AtMiddleX,AtTop), (zero, zero), switchIndicatorLine2 False, drawNorth t && drawM t.north),
((AtRight,AtBottom), (zero, px (0.0-quarter)), switchIndicatorLine True, drawEast t && drawL t.east),
((AtRight,AtTop), (zero, px quarter), switchIndicatorLine False, drawEast t && drawR t.east),
((AtRight,AtMiddleY), (zero, zero), switchIndicatorLine2 True, drawEast t && drawM t.east),
((AtLeft,AtTop), (zero, px quarter), switchIndicatorLine True, drawWest t && drawL t.west),
((AtLeft,AtBottom), (zero, px (0.0-quarter)), switchIndicatorLine False, drawWest t && drawR t.west),
((AtLeft,AtMiddleY), (zero, zero), switchIndicatorLine2 True, drawWest t && drawM t.west),
//((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine (-45.0)), drawSouth t && drawL t.south ),
//((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine 45.0), drawSouth t && drawR t.south),
//((AtMiddleX,AtBottom),(px (0.0), px (0.0)),(switchIndicatorLine 0.0), (drawSouth t && drawM t.south)),
//((AtLeft,AtBottom),(px (half/2.0), px (0.0)),(switchIndicatorLine (-45.0)), drawSouth t && drawL t.south ),
//((AtRight,AtBottom),(px (0.0-(half/2.0)),px (0.0)), (switchIndicatorLine 45.0), drawSouth t && drawR t.south),
//((AtMiddleX,AtBottom),(px (0.0), px (0.0)),(switchIndicatorLine 0.0), (drawSouth t && drawM t.south)),
//((AtLeft,AtBottom),(px (half), px (0.0)),(line (px (0.0)) (px (half/2.0))
// <@< { stroke = toSVGColor "cyan"}
// <@< { strokewidth = (px (strw/2.0))}), drawSouth t ),
//((px 0.0, px (half - strw)), (south t i), drawEast t )
((AtMiddleX,AtTop),(px 0.0, px (0.0)), (north t i), drawNorth t ),
((AtRight,AtMiddleY),(px 0.0, px (0.0)), (east t i), drawEast t ),
((AtMiddleX,AtBottom),(px 0.0, px (0.0 )), (south t i), drawSouth t ),
((AtLeft,AtMiddleY),(px 0.0, px (0.0)), (west t i), drawWest t )//,
((AtMiddleX,AtTop), (zero, zero), north t i, drawNorth t),
((AtRight,AtMiddleY), (zero, zero), east t i, drawEast t),
((AtMiddleX,AtBottom), (zero, zero), south t i, drawSouth t),
((AtLeft,AtMiddleY), (zero, zero), west t i, drawWest t)//,
// ((AtLeft, AtTop), (px 0.0, px 0.0), empty (px full) (px full) , True)
//((px 0.0, px (half - strw)), (south t i), drawWest t )
]
......@@ -92,99 +84,80 @@ drawR dir = case dir of
Right -> True
_ -> False
switchIndicatorLine2 hor = if hor ln2 ln where
ln = line (px (0.0)) (px (sqrt ( ((half/2.0)^2.0)*2.0) ) )
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}
ln2 = line (px (sqrt ( ((half/2.0)^2.0)*2.0) ) ) (px (0.0))
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}
cyanStroke = { stroke = toSVGColor "cyan"}
switchStrokeWidth = { strokewidth = px (strw/2.0)}
switchIndicatorLine2 hor = if hor ln2 ln where
ln = line zero lnWidth
<@< cyanStroke
<@< switchStrokeWidth
ln2 = line lnWidth zero
<@< cyanStroke
<@< switchStrokeWidth
lnWidth = px (sqrt ((quarter^2.0)*2.0))
switchIndicatorLine flp = if flp (flipx ln) ln where
ln = line (px (half/2.0)) (px (half/2.0))
<@< { stroke = toSVGColor "cyan"}
<@< { strokewidth = (px (strw/2.0))}
ln = line lnWidth lnWidth
<@< cyanStroke
<@< switchStrokeWidth
lnWidth = px quarter
createTracksOfTile :: (Tile,Int) -> Image State
createTracksOfTile (t,i) = overlay [] offs imgs NoHost where
offs = [(px 0.0, px 0.0): fst3 (unzip3 (filteredTrackList (t, i)))]
offs = [(zero, zero): fst3 (unzip3 (filteredTrackList (t, i)))]
imgs = [backgroundSquare: snd3 (unzip3 (filteredTrackList (t, i)))]
filteredTrackList (t,i) = filter (\(_,_,active). active) (trackList (t,i))
trackList :: (Tile,Int) -> [(ImageOffset,Image State, Bool)]
trackList (t,i) = [
( (px half, px 0.0) , (ns t i), t.ns ),
( (zero, px half), (ew t i), t.ew),
( (px half, px 0.0), (ne t i), t.ne),
( (px 0.0, px 0.0), (nw t i), t.nw),
((px 0.0, px half),(sw t i), t.sw ),
((px half, px half), (se t i),t.se)
( (px half, zero), ns t i, t.ns),
( (zero, px half), ew t i, t.ew),
( (px half, zero), ne t i, t.ne),
( (zero, zero), nw t i, t.nw),
( (zero, px half), sw t i, t.sw),
( (px half, px half), se t i, t.se)
]
ne tile i = line (px (half)) (px (half))
ne tile i = line (px half) (px half)
<@< { stroke = toSVGColor (if tile.ne activecol inactivecol)}
<@< { strokewidth = (px (strw))}
<@< { strokewidth = (px strw)}
nw tile i = line (px (half)) (px (0.0-half))
nw tile i = line (px half) (px (0.0-half))
<@< { stroke = toSVGColor (if tile.nw activecol inactivecol)}
<@< { strokewidth = (px (strw))}
<@< { strokewidth = (px strw)}
sw tile i = line (px (half)) (px (half))
<@< { strokewidth = (px (strw))}
sw tile i = line (px half) (px half)
<@< { strokewidth = (px strw)}
<@< { stroke = toSVGColor (if tile.sw activecol inactivecol)}
se tile i = line (px half) (px (0.0 - half))
<@< { stroke = toSVGColor (if tile.se activecol inactivecol)}
<@< { strokewidth = (px (toReal (strw)))}
<@< { strokewidth = (px (toReal strw))}
ns tile i = line (px 0.0) (px full)
ns tile i = line zero (px full)
<@< { stroke = toSVGColor (if tile.ns activecol inactivecol)}
<@< { strokewidth = (px (strw))}
<@< { strokewidth = (px strw)}
ew tile i = line (px full) (px 0.0)
ew tile i = line (px full) zero
<@< { stroke = toSVGColor (if tile.ew activecol inactivecol)}
<@< { strokewidth = (px (strw))}
south tile i = overlay [] [] [
<@< { strokewidth = (px strw)}
//line (px (half)) (px (half))
// <@< { stroke = toSVGColor (if tile.ne activecol inactivecol)}
// <@< { strokewidth = (px (strw))},
circle (px (strw * 2.0))
south tile i = circle (px (strw * 2.0))
// <@< { onclick = \span s.{s & tiles = (trace "f" updateAt i {tile & south = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & south = nextDirS tile} s.tiles ) } , local = False}
<@< { opacity = if (drawSouth tile) (1.0) (0.0) }
<@< { strokewidth = if (drawSouth tile) (px 1.0) (px 0.0) }
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & south = nextDirS tile} s.tiles )} , local = False}
<@< { opacity = if (drawSouth tile) 1.0 0.0 }
<@< { strokewidth = if (drawSouth tile) (px 1.0) zero }
<@< { fill = case tile.south of
Blocked -> toSVGColor "red"
_ -> toSVGColor "yellow" }
] NoHost
north tile i = circle (px (strw * 2.0))
// <@< { onclick = \span s.{s & tiles = (trace "f" updateAt i {tile & south = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & north = nextDirN tile} s.tiles ) } , local = False}
<@< { opacity = if (drawNorth tile) (1.0) (0.0) }
<@< { strokewidth = if (drawNorth tile) (px 1.0) (px 0.0) }
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & north = nextDirN tile} s.tiles )} , local = False}
<@< { opacity = if (drawNorth tile) 1.0 0.0 }
<@< { strokewidth = if (drawNorth tile) (px 1.0) zero }
<@< { fill = case tile.north of
Blocked -> toSVGColor "red"
_ -> toSVGColor "yellow" }
......@@ -192,18 +165,18 @@ north tile i = circle (px (strw * 2.0))
east tile i = circle (px (strw * 2.0))
// <@< { onclick = \span s.{s & tiles = (trace "f" updateAt i {tile & south = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & east = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & east = nextDirE tile} s.tiles )} , local = False}
<@< { opacity = if (drawEast tile) (1.0) (0.0) }
<@< { strokewidth = if (drawEast tile) (px 1.0) (px 0.0) }
<@< { strokewidth = if (drawEast tile) (px 1.0) zero }
<@< { fill = case tile.east of
Blocked -> toSVGColor "red"
_ -> toSVGColor "yellow" }
west tile i = circle (px (strw * 2.0))
// <@< { onclick = \span s.{s & tiles = (trace "f" updateAt i {tile & south = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & west = Middle} s.tiles ) } , local = False}
<@< { onclick = \span s.{s & tiles = (updateAt i {tile & west = nextDirW tile} s.tiles )} , local = False}
<@< { opacity = if (drawWest tile) (1.0) (0.0) }
<@< { strokewidth = if (drawWest tile) (px 1.0) (px 0.0) }
<@< { strokewidth = if (drawWest tile) (px 1.0) zero }
<@< { fill = case tile.west of
Blocked -> toSVGColor "red"
_ -> toSVGColor "yellow" }
......@@ -220,6 +193,18 @@ nextDirN tile = case tile.north of
Middle = if tile.nw Right Blocked
Right = Blocked
nextDirW tile = case tile.west of
Blocked = if tile.nw Left (if tile.ew Middle (if tile.sw Right Blocked))
Left = if tile.ew Middle (if tile.sw Right Blocked)
Middle = if tile.sw Right Blocked
Right = Blocked
nextDirE tile = case tile.east of
Blocked = if tile.se Left (if tile.ew Middle (if tile.ne Right Blocked))
Left = if tile.ew Middle (if tile.ne Right Blocked)
Middle = if tile.ne Right Blocked
Right = Blocked
//nextDir old = case old of
// Blocked = Left
// Left = Middle
......@@ -232,7 +217,6 @@ drawSouth t = (length (filter id [t.ns,t.se,t.sw])) >= 2
drawNorth :: Tile -> Bool
drawNorth t = (length (filter id [t.ns,t.ne,t.nw])) >= 2
drawEast :: Tile -> Bool
drawEast t = (length (filter id [t.ne,t.se,t.ew])) >= 2
......@@ -243,12 +227,9 @@ drawWest t = (length (filter id [t.nw,t.sw,t.ew])) >= 2
// _ -> toSVGColor "yellow" }
backgroundSquare = square (px full)
<@< { strokewidth = (px (strw /4.0))}
<@< { strokewidth = (px (strw/4.0))}
<@< { stroke = toSVGColor "dimgray"}
<@< { fill = toSVGColor "forestgreen"}
font = normalFontDef "Ariel" height
height = 40.0
......@@ -35,9 +35,9 @@ tl = {ne = False, nw = False, se = False, sw = False, ew = False, ns = False, no
:: LCSMUser = {name :: String, roles :: [String] }
lcsm_users :: [LCSMUser]
lcsm_users = [{LCSMUser|name="drvr", roles=["driver"]}
,{LCSMUser|name="job", roles=["designer","controller","driver"]}
,{LCSMUser|name="reg", roles=["designer","controller","driver"]}
lcsm_users = [{LCSMUser|name="drvr", roles=["driver"]}
,{LCSMUser|name="job", roles=["designer","controller","driver"]}
,{LCSMUser|name="reg", roles=["designer","controller","driver"]}
,{LCSMUser|name="dsgnr", roles=["designer"]}
,{LCSMUser|name="ctrlr", roles=["controller"]}
]
......@@ -93,9 +93,9 @@ designTask =
lcsm_Workflows =
[restrictedWorkflow "Track Management" "This task manages how the tracks look like and how they are connected" ["designer"] designTask
,restrictedWorkflow "Signal Control" "This task manages which signals are red and which are green" ["controller"] controlTask
,restrictedWorkflow "Train Driving" "This task manages how to train(s) drive" ["driver"] driverTask
[restrictedWorkflow "Track Management" "This task manages how the tracks look like and how they are connected" ["designer"] designTask
,restrictedWorkflow "Signal Control" "This task manages which signals are red and which are green" ["controller"] controlTask
,restrictedWorkflow "Train Driving" "This task manages how to train(s) drive" ["driver"] driverTask
]
Start :: *World -> *World
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment