From: Mart Lubbers Date: Mon, 20 Mar 2017 15:00:20 +0000 (+0100) Subject: update X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=feacd1b50fca9624284f8b8c22c26d7a8071515d;p=mTask.git update --- diff --git a/CleanSerial b/CleanSerial index 27239bb..1b51061 160000 --- a/CleanSerial +++ b/CleanSerial @@ -1 +1 @@ -Subproject commit 27239bb503b5bd185a37e2bbf165b7192985efa2 +Subproject commit 1b51061da5972a0cca502403496c12d731093960 diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index 9b26455..5c78b48 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -97,21 +97,13 @@ deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d) sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task () sendToDevice wta mTask (device, timeout) = - traceValue "starting to send" - >>| get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask) - >>= \(msgs, st1)->traceValue "messages generated" - >>| set st1 bcStateStore - >>| traceValue "bcstate store updated" + get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask) + >>= \(msgs, st1)->set st1 bcStateStore >>| toSDSRecords st1 - >>= \sdss->traceValue "Shares created" - >>| set sdss sdsStore//MTaskShareaddToSDSShare - >>| traceValue "Shares store updated" + >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare >>| sendMessages msgs device - >>| traceValue "Messages sent" >>| makeTask wta -1 - >>= \t->traceValue "Task made" - >>| withDevices device (addTask t) - >>| traceValue "Tasks share updated" + >>= withDevices device o addTask @! () where sharename i = device.deviceChannels +++ "-" +++ toString i diff --git a/Shares/mTaskShare.icl b/Shares/mTaskShare.icl index 27c9544..4a188c6 100644 --- a/Shares/mTaskShare.icl +++ b/Shares/mTaskShare.icl @@ -11,8 +11,8 @@ from Data.Func import $ derive class iTask MTaskShareType, MTaskShare manageShares :: [MTaskShare] -> Task () -manageShares shares = forever $ viewInformation "" [] "" @! () -// viewSharesGrid shares @! () +manageShares shares = withShared Nothing $ \cs->forever $ + viewSharesGrid cs shares /*||- (viewSharedInformation "" [] cs*/ @! ()//)//||- editCurrentShare cs // >&^ \st->whileUnchanged st $ \msh->case msh of // Nothing = viewShares shares @@ -37,12 +37,13 @@ manageShares shares = forever $ viewInformation "" [] "" @! () // >>= sendMessages [MTUpd identifier $ toString $ toByteCode a] // >>| treturn sh -viewSharesGrid :: [MTaskShare] -> Task [BCValue] -viewSharesGrid sh = allTasks [watch (getSDSShare m)\\m<-sh] +viewSharesGrid :: (Shared (Maybe MTaskShare)) [MTaskShare] -> Task [BCValue] +viewSharesGrid _ [] = viewInformation "No shares yet" [] [] +viewSharesGrid cs sh = (allTasks [watch (getSDSShare m)\\m<-sh] <<@ NoUserInterface) >&^ \st->whileUnchanged st $ \mshs->enterChoice "" [ChooseFromGrid id] [{MTaskShare|ss&value=s}\\s<-fromJust mshs & ss<-sh] + >>* [OnValue (withValue $ \s->Just (set (Just s) cs))] @! fromJust mshs -// /*enterChoice "" [ChooseFromGrid id]*/viewInformation "" [] o fromJust viewShare :: MTaskShare -> Task BCValue viewShare m = viewSharedInformation "" [] (getSDSShare m) diff --git a/Tasks/Examples.dcl b/Tasks/Examples.dcl index 414fd68..bf962cd 100644 --- a/Tasks/Examples.dcl +++ b/Tasks/Examples.dcl @@ -5,6 +5,7 @@ import mTask countAndLed :: Main (ByteCode () Stmt) blink :: UserLED -> Main (ByteCode () Stmt) +count :: Main (ByteCode () Stmt) blinkShare :: Main (ByteCode () Stmt) ledtOn :: UserLED -> Main (ByteCode () Stmt) ledtOff :: UserLED -> Main (ByteCode () Stmt) diff --git a/Tasks/Examples.icl b/Tasks/Examples.icl index 9404274..103862c 100644 --- a/Tasks/Examples.icl +++ b/Tasks/Examples.icl @@ -6,6 +6,9 @@ import mTask import Devices.mTaskDevice import iTasks._Framework.Serialization +count :: Main (ByteCode () Stmt) +count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp} + countAndLed :: Main (ByteCode () Stmt) countAndLed = sds \x=1 In sds \pinnetje=1 In {main = IF (digitalRead D3) ( @@ -63,4 +66,5 @@ allmTasks = 'DM'.fromList ,("readDPin", pinSelection @ readDPin) ,("blink", ledSelection @ blink) ,("blinkShare", treturn blinkShare) + ,("count", treturn count) ] diff --git a/client/task.c b/client/task.c index 0d9b125..198aee3 100644 --- a/client/task.c +++ b/client/task.c @@ -42,8 +42,6 @@ void task_register(void) //Read task bytecode for(i = 0; i String -encode (MTTask to data) = "t" +++ tob +++ to16bit (size data) +++ data +++ "\n" - where - tob = case to of - OneShot = to16bit 0 - OnInterval i = to16bit i - OnInterrupt _ = abort "Interrupts not implemented yet" +encode (MTTask to data) = "t" +++ toByteCode to +++ to16bit (size data) +++ data +++ "\n" encode (MTTaskDel i) = "d" +++ to16bit i +++ "\n" encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n" encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n" @@ -159,9 +154,9 @@ instance fromByteCode MTaskInterval instance fromByteCode MTaskDeviceSpec where fromByteCode s = let c = toInt s.[0] in {MTaskDeviceSpec - |haveLed=c bitand 1 > 0 - ,haveAio=c bitand 2 > 0 - ,haveDio=c bitand 4 > 0 + |haveLed=(c bitand 1) > 0 + ,haveAio=(c bitand 2) > 0 + ,haveDio=(c bitand 4) > 0 ,maxTask=from16bit $ s % (1,3) ,maxSDS=from16bit $ s % (3,5) }