- (\t->upd (appFst3 (const [])) ch >>| process (fst3 t)))])
- where
- process :: [MTaskMSGRecv] -> Task ()
- process [] = treturn ()
- process [m:ms] = (case m of
- MTTaskAck i = traceValue (toString m) @! ()
- MTTaskDelAck i = traceValue (toString m) @! ()
- MTSDSAck i = traceValue (toString m) @! ()
- MTSDSDelAck i = traceValue (toString m) @! ()
- MTPub i val = getSDSRecord i >>= set (toInt val.[0]*256 + toInt val.[1]) o getSDSStore @! ()
- MTMessage val = traceValue (toString m) @! ()
- MTEmpty = treturn ()
- ) >>| process ms
-
- deviceviewer :: [MTaskDevice] -> [MTaskDeviceStatus]
- deviceviewer ds = [{MTaskDeviceStatus | name = d.deviceName,
- connected = if (isNothing d.deviceTask) False True,
- tasks = [s +++ toString i\\(s, i)<-d.deviceTasks]}\\d<-ds]
-
- mapPar :: (a -> Task a) [a] -> Task ()
- mapPar f l = foldr1 (\x y->f x ||- y) l <<@ ArrangeWithTabs @! ()
- allAtOnce t = foldr1 (||-) t @! ()
- //allAtOnce = (flip (@!) ()) o foldr1 (||-)
-
-sendMsg :: [MTaskMSGSend] (Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task ()
-sendMsg m ch = upd (\(r,s,ss)->(r,s ++ m,True)) ch @! ()
-
-syncNetworkChannel :: String Int (Shared ([MTaskMSGRecv], [MTaskMSGSend], Bool)) -> Task ()
-syncNetworkChannel server port channel = catchAll
- (tcpconnect server port channel {ConnectionHandlers|onConnect=onConnect,whileConnected=whileConnected,onDisconnect=onDisconnect} @! ())
- (\v->traceValue v @! ())
- where
- onConnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
- onConnect _ (msgs,send,sendStopped)
- = (Ok "", Just (msgs,[],sendStopped), map encode send, False)
-
- whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
-
- //whileConnected Nothing acc (msgs,send,sendStopped)
- //= (Ok acc, Just (msgs,[],sendStopped), map encode send, False)
- whileConnected mnewData acc (msgs,send,sendStopped)
- = (Ok acc, Just (msgs ++ map decode (maybeToList mnewData),[],sendStopped), map encode send, False)
- //| sendStopped = (Ok acc, Just (msgs ++ [decode newData],[],False), map encode send, False)
-// = (Ok acc, Just (msgs ++ [decode newData],[],False), [], False)
-
- onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
- onDisconnect l (msgs,send,sendStopped) = (Ok l, Nothing)