From: Mart Lubbers Date: Tue, 21 Mar 2017 09:47:15 +0000 (+0100) Subject: update spec, and shares X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=ee38806680e1706a4aea577d1ed699860f1fb0e8;p=mTask.git update spec, and shares --- diff --git a/CleanSerial b/CleanSerial index 1b51061..948f49f 160000 --- a/CleanSerial +++ b/CleanSerial @@ -1 +1 @@ -Subproject commit 1b51061da5972a0cca502403496c12d731093960 +Subproject commit 948f49f132f17f55b2ac49c2771df13d9aac3b48 diff --git a/Devices/mTaskDevice.icl b/Devices/mTaskDevice.icl index 5c78b48..6f6480a 100644 --- a/Devices/mTaskDevice.icl +++ b/Devices/mTaskDevice.icl @@ -63,7 +63,9 @@ addDevice devices processFun connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task () connectDevice pf d = let ch = channels d in appendTopLevelTask 'DM'.newMap True (pf d ch -||- catchAll (getSynFun d.deviceData ch) errorHandle) - >>= \tid->withDevices d (\d->{d&deviceTask=Just tid,deviceError=Nothing}) @! () + >>= \tid->withDevices d (\d->{d&deviceTask=Just tid,deviceError=Nothing}) + >>| upd (\(r,s,ss)->(r,s++[MTSpec],ss)) ch + @! () where errorHandle e = withDevices d (\d->{d&deviceTask=Nothing,deviceError=Just e}) @@ -93,6 +95,7 @@ deleteDevice :: MTaskDevice -> Task () deleteDevice d = upd (\(r,s,ss)->(r,s,True)) (channels d) >>| maybe (treturn ()) (flip removeTask topLevelTasks) d.deviceTask >>| upd (filter ((<>)d)) deviceStore +// >>| upd (removeShares d) sdsStore @! () sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task () diff --git a/Shares/mTaskShare.dcl b/Shares/mTaskShare.dcl index 9110254..3cfd7a1 100644 --- a/Shares/mTaskShare.dcl +++ b/Shares/mTaskShare.dcl @@ -8,7 +8,7 @@ derive class iTask MTaskShareType, MTaskShare :: MTaskShareType = MTaskWithShare String | MTaskLens String :: MTaskShare = - {withTask :: String + {withTask :: [String] ,identifier :: Int ,realShare :: MTaskShareType ,value :: BCValue diff --git a/Shares/mTaskShare.icl b/Shares/mTaskShare.icl index 4a188c6..8c0ae61 100644 --- a/Shares/mTaskShare.icl +++ b/Shares/mTaskShare.icl @@ -36,13 +36,15 @@ manageShares shares = withShared Nothing $ \cs->forever $ //updateShare sh=:{withTask,identifier} a = getDeviceByName withTask // >>= sendMessages [MTUpd identifier $ toString $ toByteCode a] // >>| treturn sh +// +from StdFunc import flip 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] + >&^ \st->flip (<<@) NoUserInterface $ whileUnchanged st $ \mshs->enterChoice "" [ChooseFromGrid id] [{MTaskShare|ss&value=s}\\s<-fromJust mshs & ss<-sh] - >>* [OnValue (withValue $ \s->Just (set (Just s) cs))] +// >>* [OnValue (withValue $ \s->Just (set (Just s) cs))] @! fromJust mshs viewShare :: MTaskShare -> Task BCValue @@ -55,7 +57,7 @@ getSDSShare s=:{realShare=(MTaskWithShare id),value} = memoryShare id value makeShare :: String Int BCValue -> Task MTaskShare makeShare withTask identifier value = treturn {MTaskShare - |withTask=withTask + |withTask=[withTask] ,identifier=identifier ,value=value ,realShare=MTaskWithShare $ "mTaskSDS-" +++ toString identifier diff --git a/client/interface.c b/client/interface.c index 59e750e..8afac28 100644 --- a/client/interface.c +++ b/client/interface.c @@ -86,23 +86,22 @@ void delay(long ms) void setup(void) { - palSetPadMode(GPIOG, 9, PAL_MODE_ALTERNATE(8)); // USART6 TX - palSetPadMode(GPIOG, 14, PAL_MODE_ALTERNATE(8)); // USART6 RX +// palSetPadMode(GPIOG, 9, PAL_MODE_ALTERNATE(8)); // USART6 TX +// palSetPadMode(GPIOG, 14, PAL_MODE_ALTERNATE(8)); // USART6 RX halInit(); chSysInit(); sdStart(&SD3, NULL); -// sdStart(&SD6, NULL); - -// while(1){ -// sdPut(&SD3, sdGet(&SD6)); -// delay(50); -// } } void debug(char *fmt, ...) { - (void)fmt; + write_byte('m'); + for(unsigned int i = 0; i MTaskMSGRecv @@ -138,7 +139,7 @@ instance fromByteCode UserLED where fromByteCode s = conses{|*|} !! toInt s.[1] instance fromByteCode BCValue where fromByteCode s = parseBCValue s.[0] s instance toByteCode MTaskInterval where - toByteCode OneShot = toByteCode 0 + toByteCode OneShot = toByteCode (OnInterval 0) //Intervals have the first bit 0 and the rest is a 15 bit unsigned int toByteCode (OnInterval i) = {toChar $ i/256 bitand 127, toChar $ i rem 256} //Intervals have the first bit 1 and the rest is a 15 bit unsigned int diff --git a/todo.txt b/todo.txt new file mode 100644 index 0000000..d53dcad --- /dev/null +++ b/todo.txt @@ -0,0 +1,4 @@ +delete tasks when deleting device +make sure shares are assigned to correct task and not propagated +let tasks have a unique name +add field in task that denotes to which device it belongs