]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.scl.tutorial/scl/Tutorial/2.04 (Exercise) Polyline.md b/bundles/org.simantics.scl.tutorial/scl/Tutorial/2.04 (Exercise) Polyline.md
new file mode 100644 (file)
index 0000000..f78059c
--- /dev/null
@@ -0,0 +1,67 @@
+## Polyline exercise\r
+\r
+### Step 1\r
+\r
+Implement a function\r
+\r
+    addPolyline :: String -> String -> (Double,Double) -> [(Double,Double)] -> <Proc> ()\r
+\r
+that is called as\r
+\r
+    addPolyline diagramName name location polylineData\r
+\r
+It creates a polyline `name` to the diagram `diagramName` at `location`.\r
+The polyline should interpolate the points `polylineData`\r
+(assumed in this step to contain at most 30 points).\r
+\r
+You need the following functions:\r
+\r
+::value[Apros/Legacy/aadd,Apros/Legacy/amodi]\r
+\r
+And the following symbol and attributes\r
+\r
+    Polyline\r
+        FUNCTION_X_COORDINATE(i)\r
+        FUNCTION_Y_COORDINATE(i)\r
+        FUNCTION_OK(i)\r
+\r
+Test that your function produces a functional model configuration.\r
+\r
+### Step 2\r
+\r
+Extend your function so that it supports also `polylineList` with more\r
+than 30 points. For example\r
+\r
+    addPolyline "Diagram" "PL" (100,100) [(x,sin x) | i <- [0..100], x = 0.1*fromInteger i]\r
+\r
+might produce the following model configuration:\r
+\r
+![](http://www.simantics.org/~niemisto/SCL20150513/Polyline.png)\r
+\r
+You may implement the polyline using the following symbols and attributes\r
+\r
+    Polyline\r
+        FUNCTION_X_COORDINATE(i)\r
+        FUNCTION_Y_COORDINATE(i)\r
+        FUNCTION_OK(i)\r
+        FUNCTION_INPUT_SIGN\r
+        FUNCTION_OUTPUT_SIGN\r
+    BranchAnalog\r
+        AMUX_INPUT_SIGN\r
+        AMUX_OUTPUT_SIGN(i)\r
+    LV_CHECKER\r
+        LVC_INPUT_SIGN\r
+        LVC_LIMIT_VALUE\r
+        LVC_OUTPUT_SIGN_1\r
+    ANALOG_SWITCH\r
+        SWITCH_CONTROL_S\r
+        SWITCH_INP_SIGN_1\r
+        SWITCH_INP_SIGN_2\r
+        SWITCH_OUTP_SIGN\r
+\r
+\r
+You need in addition to `aadd` and `amodi` the function\r
+\r
+::value[Apros/Legacy/aconnect]\r
+\r
+Test that your function produces a functional model configuration.
\ No newline at end of file