We planned to upgrade GitLab and Mattermost to the latest version this Friday morning. Expect some downtime!

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 ...@@ -10,27 +10,33 @@ import iTasks
import TTY, iTasksTTY import TTY, iTasksTTY
Start w = flip doTasks w $
parallel [] [OnAction (Action "+") $ always (Embedded, addDevice)]
<<@ ArrangeWithTabs True
>>* [OnAction (Action "Shutdown") $ always (shutDown 0)]
Start w = startEngine manage w addDevice :: (SharedTaskList ()) -> Task ()
addDevice stl = tune (Title "New device") $
manage = parallel
[(Embedded, \stl->tune (Title "New device") $ forever $
accWorld getTTYDevices accWorld getTTYDevices
>>= \ds->enterChoice "Choose path" [] ["Other":ds] >>= \ds-> enterChoice "Choose path" [] ["-- Other --":ds]
>>= \path->updateInformation "TTY Settings" [] {zero & devicePath=path} >>= \path->updateInformation "TTY Settings" [] {zero & devicePath=path}
>>! \ts->appendTask Embedded (\_->tune (Title ts.devicePath) $ monitor ts @! ()) stl @! ()) >>! \ts-> appendTask Embedded (\_->monitor ts) stl
] @! ()
[]
<<@ ArrangeWithTabs True
>>* [OnAction (Action "Shutdown") (always (shutDown 0))]
monitor ts = catchAll ( monitor :: TTYSettings -> Task ()
monitor ts = tune (Title ts.devicePath) $
catchAll (
withShared ([], [], False) \channels-> 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 ||- viewSharedInformation "Incoming messages" [ViewAs (take 20 o fst3)] channels
||- forever ( ||- forever (
enterInformation "Send line of text" [] enterInformation "Send line of text" []
>>= \line->upd (\(r,w,s)->(r,w++[line+++"\n"],s)) channels >>= \line->upd (\(r,w,s)->(r,w++[line+++"\n"],s)) channels
) @? const NoValue ) @? const NoValue
) (\e->viewInformation "Exception occured" [] e) ) (\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