Commit 77c6279d authored by Mart Lubbers's avatar Mart Lubbers

Simplify monitor

parent abb4ab29
Pipeline #23025 passed with stage
in 3 minutes and 5 seconds
......@@ -10,27 +10,33 @@ import iTasks
import TTY, iTasksTTY
Start w = startEngine manage w
manage = parallel
[(Embedded, \stl->tune (Title "New device") $ forever $
accWorld getTTYDevices
>>= \ds->enterChoice "Choose path" [] ["Other":ds]
>>= \path->updateInformation "TTY Settings" [] {zero & devicePath=path}
>>! \ts->appendTask Embedded (\_->tune (Title ts.devicePath) $ monitor ts @! ()) stl @! ())
]
[]
Start w = flip doTasks w $
parallel [] [OnAction (Action "+") $ always (Embedded, addDevice)]
<<@ ArrangeWithTabs True
>>* [OnAction (Action "Shutdown") (always (shutDown 0))]
monitor ts = catchAll (
>>* [OnAction (Action "Shutdown") $ always (shutDown 0)]
addDevice :: (SharedTaskList ()) -> Task ()
addDevice stl = tune (Title "New device") $
accWorld getTTYDevices
>>= \ds-> enterChoice "Choose path" [] ["-- Other --":ds]
>>= \path->updateInformation "TTY Settings" [] {zero & devicePath=path}
>>! \ts-> appendTask Embedded (\_->monitor ts) stl
@! ()
monitor :: TTYSettings -> Task ()
monitor ts = tune (Title ts.devicePath) $
catchAll (
withShared ([], [], False) \channels->
syncSerialChannel {tv_sec=0,tv_nsec=100*1000000} ts id (\s->(Right [s], "")) channels
syncSerialChannel
{tv_sec=0,tv_nsec=100*1000000} //poll interval
ts //tty settings
id //encode
(\s->(Right (if (s == "") [] [s]), "")) //decode
channels //channels
||- viewSharedInformation "Incoming messages" [ViewAs (take 20 o fst3)] channels
||- forever (
enterInformation "Send line of text" []
>>= \line->upd (\(r,w,s)->(r,w++[line+++"\n"],s)) channels
) @? const NoValue
) (\e->viewInformation "Exception occured" [] e)
>>* [OnAction (Action "Close") (always (treturn ""))]
>>* [OnAction (Action "Close") $ always (treturn ())]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment