X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=miTask.icl;h=92fbff2de2f8acd40edfeddccee16556528c2e50;hb=3698f150b0c5e5ebed23b0885ced2711ef16d9f5;hp=56a36f39275d8945580553f9345608fa5c8a7bb4;hpb=6e3b45dd6cef95c1577a91b15a1256fa4b06ca88;p=mTask.git diff --git a/miTask.icl b/miTask.icl index 56a36f3..92fbff2 100644 --- a/miTask.icl +++ b/miTask.icl @@ -54,14 +54,15 @@ bc = sds \x=1 In sds \pinnetje=1 In {main = ) )} -deviceSelector :: (Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task () -deviceSelector ch = enterInformation "Type" [] +withDevice :: ((Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task a) -> Task a | iTask a +withDevice t = withShared ([], [], False) \ch-> + enterInformation "Type" [] >>= \ty->case ty of TCP = (enterInformation "Host" [] -&&- enterInformation "Port" []) - >>= \(port,host)->syncNetworkChannel host port ch + >>= \(port,host)->t ch -|| syncNetworkChannel host port ch Serial = accWorld getDevices >>= \dl->(enterChoice "Device" [] dl -&&- updateInformation "Settings" [] zero) - >>= \(dev,set)->syncSerialChannel dev set ch + >>= \(dev,set)->t ch -|| syncSerialChannel dev set ch where getDevices :: !*World -> *(![String], !*World) getDevices w = case readDirectory "/dev" w of @@ -73,8 +74,8 @@ deviceSelector ch = enterInformation "Type" [] mTaskTask :: Task () mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in - withShared ([], msgs, False) (\ch-> - deviceSelector ch + withDevice (\ch-> + sendMsg msgs ch ||- processMessages ch messageShare sdsShares ||- viewSharedInformation "channels" [ViewWith lens] ch ||- viewSharedInformation "messages" [] messageShare @@ -98,14 +99,15 @@ mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in # (msgs, st) = toMessages timeout (toRealByteCode (unMain bc)) = (msgs, map f st.sdss) where - f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) 0) + f (i,d) = (i, sharedStore ("mTaskSDS-" +++ toString i) (dd d)) + dd [x,y] = toInt x*265 + toInt y updateSDSs :: [(Int, Shared Int)] (Shared [String]) MTaskMSGRecv -> Task () updateSDSs _ m (MTMessage s) = upd (\l->take 20 [s:l]) m @! () - updateSDSs _ _ MTEmpty = return () updateSDSs [(id, sh):xs] m n=:(MTPub i d) | id == i = set ((toInt d.[0])*265 + toInt d.[1]) sh @! () = updateSDSs xs m n + updateSDSs _ _ _ = return () lens :: ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> ([String], [String]) lens (r,s,_) = (map toString r, map toString s) @@ -167,7 +169,6 @@ serialDeviceBackgroundTask rw iworld (False, tty) = ([], tty) (_, tty) # (l, tty) = TTYreadline tty - | not (trace_tn ("recv: '" +++ l +++ "'")) = undef = ([decode l], tty) # iworld = {iworld & resources=Just (TTYd tty)} = case write (r++ml,[],False) rw iworld of