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 (filter ((<>)d)) deviceStore
@! ()
sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
[{t & ident=i}:ts] [t:ackFirst ts]
deviceTaskDelete :: MTaskDevice MTaskTask -> Task ()
-deviceTaskDelete dev task = sendMessages [MTTaskDel task.ident] dev
- >>| upd (\ds->filter ((<>) dev) ds) deviceStore @! ()
+deviceTaskDelete dev task = sendMessages [MTTaskDel task.ident] dev @! ()
deviceTaskDeleteAcked :: MTaskDevice Int -> Task ()
deviceTaskDeleteAcked d i = withDevices d $ deleteTask
import Devices.mTaskDevice
import iTasks
from Data.Tuple import appSnd
+from Data.Maybe import fromMaybe
from Text import class Text(indexOf), instance Text String
derive class iTask TCPSettings
whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
//We stop
whileConnected _ _ (_,_,True) = (Ok "", Nothing, [], True)
-
//No new data and nothing to send
whileConnected Nothing acc (_,[],_) = (Ok acc, Nothing, [], False)
-
//New data and possibly something to send
- whileConnected (Just newdata) acc (msgs,send,sendStopped)
- # (acc, nd) = process (acc +++ newdata)
+ whileConnected newdata acc (msgs,send,sendStopped)
+ # (acc, nd) = process (acc +++ fromMaybe "" newdata)
| isEmpty nd && isEmpty send = (Ok acc, Nothing, [], False)
= (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
process :: String -> (String, [String])
process s = case indexOf "\n" s of
-1 = (s, [])
- i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i, size s)))
+ i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i+1, size s)))
onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)