]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.tutorial/scl/Tutorial/2.04 (Exercise) Polyline.md
Import org.simantics.scl.tutorial from incubator SVN repo
[simantics/platform.git] / bundles / org.simantics.scl.tutorial / scl / Tutorial / 2.04 (Exercise) Polyline.md
1 ## Polyline exercise\r
2 \r
3 ### Step 1\r
4 \r
5 Implement a function\r
6 \r
7     addPolyline :: String -> String -> (Double,Double) -> [(Double,Double)] -> <Proc> ()\r
8 \r
9 that is called as\r
10 \r
11     addPolyline diagramName name location polylineData\r
12 \r
13 It creates a polyline `name` to the diagram `diagramName` at `location`.\r
14 The polyline should interpolate the points `polylineData`\r
15 (assumed in this step to contain at most 30 points).\r
16 \r
17 You need the following functions:\r
18 \r
19 ::value[Apros/Legacy/aadd,Apros/Legacy/amodi]\r
20 \r
21 And the following symbol and attributes\r
22 \r
23     Polyline\r
24         FUNCTION_X_COORDINATE(i)\r
25         FUNCTION_Y_COORDINATE(i)\r
26         FUNCTION_OK(i)\r
27 \r
28 Test that your function produces a functional model configuration.\r
29 \r
30 ### Step 2\r
31 \r
32 Extend your function so that it supports also `polylineList` with more\r
33 than 30 points. For example\r
34 \r
35     addPolyline "Diagram" "PL" (100,100) [(x,sin x) | i <- [0..100], x = 0.1*fromInteger i]\r
36 \r
37 might produce the following model configuration:\r
38 \r
39 ![](http://www.simantics.org/~niemisto/SCL20150513/Polyline.png)\r
40 \r
41 You may implement the polyline using the following symbols and attributes\r
42 \r
43     Polyline\r
44         FUNCTION_X_COORDINATE(i)\r
45         FUNCTION_Y_COORDINATE(i)\r
46         FUNCTION_OK(i)\r
47         FUNCTION_INPUT_SIGN\r
48         FUNCTION_OUTPUT_SIGN\r
49     BranchAnalog\r
50         AMUX_INPUT_SIGN\r
51         AMUX_OUTPUT_SIGN(i)\r
52     LV_CHECKER\r
53         LVC_INPUT_SIGN\r
54         LVC_LIMIT_VALUE\r
55         LVC_OUTPUT_SIGN_1\r
56     ANALOG_SWITCH\r
57         SWITCH_CONTROL_S\r
58         SWITCH_INP_SIGN_1\r
59         SWITCH_INP_SIGN_2\r
60         SWITCH_OUTP_SIGN\r
61 \r
62 \r
63 You need in addition to `aadd` and `amodi` the function\r
64 \r
65 ::value[Apros/Legacy/aconnect]\r
66 \r
67 Test that your function produces a functional model configuration.