4 import "Apros/Legacy"
\r
6 connect (ma,ca) (mb,cb) = aconnect ma ca mb cb
\r
8 addPolyline :: String -> String -> (Double,Double) -> [(Double,Double)] -> <Proc> ()
\r
9 addPolyline diagram name position xyPoints = ignore $ addRecursively 1 position xyPoints
\r
11 addRecursively n position xyPoints | length xyPoints <= 30 =
\r
12 addSmallPolyline n position xyPoints
\r
13 addRecursively n (x,y) xyPoints = do
\r
14 swPoint = fst (xyPoints!29)
\r
15 brName = name + "_BR" + show n
\r
16 lvName = name + "_LV" + show n
\r
17 swName = name + "_SW" + show n
\r
18 aadd diagram "BranchAnalog" brName (x-20, y+5)
\r
19 aadd diagram "LV_CHECKER" lvName (x, y)
\r
20 amodi lvName "LVC_LIMIT_VALUE" (fst (xyPoints!29))
\r
21 aadd diagram "ANALOG_SWITCH" swName (x+20, y+5)
\r
22 (in1, out1) = addSmallPolyline n (x, y+10) (take 30 xyPoints)
\r
23 (in2, out2) = addRecursively (n+1) (x, y+20) (drop 29 xyPoints)
\r
24 connect (brName, "AMUX_OUTPUT_SIGN(1)") (lvName, "LVC_INPUT_SIGN")
\r
25 connect (brName, "AMUX_OUTPUT_SIGN(2)") in1
\r
26 connect (brName, "AMUX_OUTPUT_SIGN(4)") in2
\r
27 connect (lvName, "LVC_OUTPUT_SIGN_1") (swName, "SWITCH_CONTROL_S")
\r
28 connect out1 (swName, "SWITCH_INP_SIGN_1")
\r
29 connect out2 (swName, "SWITCH_INP_SIGN_2")
\r
30 ((brName, "AMUX_INPUT_SIGN"), (swName, "SWITCH_OUTP_SIGN"))
\r
31 addSmallPolyline n position xyPoints = do
\r
32 fullName = name + "_" + show n
\r
33 aadd diagram "Polyline" fullName position
\r
34 for [1..length xyPoints] $ \i -> do
\r
35 (x,y) = xyPoints!(i-1)
\r
36 amodi fullName "FUNCTION_X_COORDINATE(\(i))" x
\r
37 amodi fullName "FUNCTION_Y_COORDINATE(\(i))" y
\r
38 amodi fullName "FUNCTION_OK(\(i))" True
\r
39 ((fullName, "FUNCTION_INPUT_SIGN"), (fullName, "FUNCTION_OUTPUT_SIGN"))
\r