refactoors
[mTask.git] / mTaskSimulation.icl
index 6fed084..3f88aee 100644 (file)
@@ -1,8 +1,12 @@
 implementation module mTaskSimulation
 
+import Generics.gdynamic
+import Generics.gCons
+
 import iTasks
-import gdynamic, gCons, GenEq, StdMisc, StdArray
+import GenEq, StdMisc, StdArray
 import mTask
+derive class iTask Display
 
 eval :: (Main (Eval t p)) -> [String] | toString t
 eval {main=(E f)} = [toString (fst (f Rd zero))]
@@ -150,27 +154,27 @@ instance writePinD AnalogPin where
 
 // ----- Interactive Simulation ----- //
 
-derive class iTask DigitalPin, AnalogPin, Dyn, StateInterface, DisplayVar, Pin
+derive class iTask StateInterface, DisplayVar
 
 simulate :: (Main (Eval a p)) -> Task ()
 simulate {main=(E f)} = setup zero where
   setup s =
-         updateInformation "State" [] (toView s)
-         >>* [ OnAction ActionFinish (always shutDown)
-           , OnAction (Action "setup" []) (hasValue 
-             (\si.simloop (snd (f Rd (mergeView s si)))))
-           ]
+         updateInformation "State" [] (toView s) @! ()
+//       >>* [ OnAction ActionFinish (always shutDown)
+//         , OnAction (Action "setup" []) (hasValue 
+//           (\si.simloop (snd (f Rd (mergeView s si)))))
+//         ]
   simloop s =
-         updateInformation "State" [] (toView s)
-         >>* [ OnAction ActionFinish (always shutDown)
-           , OnAction (Action "clear serial" []) (always (simloop {s & serial = []}))
-           , OnAction ActionNew (always (setup zero))
-           : if (isEmpty s.tasks)
-               []
-               [OnAction (Action "loop" []) (hasValue
-             \si.simloop (step` (mergeView s si)))
-             ]
-           ]
+         updateInformation "State" [] (toView s) @!()
+//       >>* [ OnAction ActionFinish (always shutDown)
+//         , OnAction (Action "clear serial" []) (always (simloop {s & serial = []}))
+//         , OnAction ActionNew (always (setup zero))
+//         : if (isEmpty s.tasks)
+//             []
+//             [OnAction (Action "loop" []) (hasValue
+//           \si.simloop (step` (mergeView s si)))
+//           ]
+//         ]
 
 toView :: State` -> StateInterface
 toView s = 
@@ -250,8 +254,8 @@ instance stringQuotes String where stringQuotes x = c "\"" +.+ x +.+ c "\""
 instance stringQuotes t    where stringQuotes x = x
 
 
-derive   toGenDynamic (), MTask, DigitalPin, AnalogPin, Pin, [], Long//, Servo
-derive fromGenDynamic (), MTask, DigitalPin, AnalogPin, Pin, [], Long//, Servo
+derive   toGenDynamic (), MTask, DigitalPin, AnalogPin, Pin, [], Long, UserLED//, Servo
+derive fromGenDynamic (), MTask, DigitalPin, AnalogPin, Pin, [], Long, UserLED//, Servo
 instance ==   () where (==) _ _ = True