X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskSimulation.icl;h=3a94811a26865afa3c51f9e55d2579843be66744;hb=34dfa724f02cd36ff31057ab71ba53ad57fabcb5;hp=180d7e1b8ba799bd5cb0a159af180a9afbfaaac0;hpb=e25fda18ca554ec3fe937152403872b916367ddb;p=mTask.git diff --git a/mTaskSimulation.icl b/mTaskSimulation.icl index 180d7e1..3a94811 100644 --- a/mTaskSimulation.icl +++ b/mTaskSimulation.icl @@ -5,7 +5,7 @@ import gdynamic, gCons, GenEq, StdMisc, StdArray import mTask eval :: (Main (Eval t p)) -> [String] | toString t -eval {main=(E f)} = [toString (fst (f Rd state0))] +eval {main=(E f)} = [toString (fst (f Rd zero))] :: State = { tasks :: [(Int, State->State)] @@ -16,8 +16,8 @@ eval {main=(E f)} = [toString (fst (f Rd state0))] , millis:: Int } -state0 :: State -state0 = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []} +instance zero State where + zero = {store = [], tasks = [], serial = [], millis = 0, dpins = [] , apins = []} //:: TaskSim :== (Int, State->State) :: Eval t p = E ((ReadWrite t) State -> (t, State)) @@ -153,7 +153,7 @@ instance writePinD AnalogPin where derive class iTask DigitalPin, AnalogPin, Dyn, StateInterface, DisplayVar, Pin simulate :: (Main (Eval a p)) -> Task () -simulate {main=(E f)} = setup state0 where +simulate {main=(E f)} = setup zero where setup s = updateInformation "State" [] (toView s) >>* [ OnAction ActionFinish (always shutDown) @@ -164,7 +164,7 @@ simulate {main=(E f)} = setup state0 where updateInformation "State" [] (toView s) >>* [ OnAction ActionFinish (always shutDown) , OnAction (Action "clear serial" []) (always (simloop {s & serial = []})) - , OnAction ActionNew (always (setup state0)) + , OnAction ActionNew (always (setup zero)) : if (isEmpty s.tasks) [] [OnAction (Action "loop" []) (hasValue