Commit 0f351a7a authored by Mart Lubbers's avatar Mart Lubbers

adapt to new iTasks async

parent 4ec4afbb
Pipeline #18412 passed with stage
in 3 minutes and 30 seconds
definition module iTasksTTY
from iTasks.Internal.Generic.Visualization import generic gText, :: TextFormat
from iTasks.SDS.Definition import :: SDS, :: Shared, :: RWShared
from iTasks.SDS.Definition import :: Shared, class RWShared, class Readable, class Writeable, class Modifiable, class Registrable, class Identifiable
from iTasks.UI.Editor.Generic import generic gEditor, :: Editor
from iTasks.WF.Definition import :: Task
from iTasks.WF.Definition import class iTask
......@@ -29,4 +29,4 @@ derive class iTask TTYSettings
* @result Task that stops when the stop flag is set
* @throws TTYException
*/
syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b
syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared sds ([a],[b],Bool)) -> Task () | iTask a & iTask b & RWShared sds
......@@ -18,7 +18,7 @@ import TTY
derive class iTask TTYSettings, Parity, BaudRate, ByteSize
syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared ([a],[b],Bool)) -> Task () | iTask a & iTask b
syncSerialChannel :: Timespec TTYSettings (b -> String) (String -> (Either String [a], String)) (Shared sds ([a],[b],Bool)) -> Task () | iTask a & iTask b & RWShared sds
syncSerialChannel poll opts enc dec rw = Task eval
where
eval event evalOpts tree=:(TCInit taskId ts) iworld
......@@ -47,18 +47,19 @@ where
[TTYd dp tty]
# (merr, iworld) = readRegister taskId ticker iworld
| isError merr = (ExceptionResult (fromError merr), iworld)
# (merr, iworld=:{resources}) = read rw iworld
//TODO Keep async in mind
# (merr, iworld=:{resources}) = read rw EmptyContext iworld
| isError merr = (ExceptionResult (fromError merr), iworld)
= case fromOk merr of
//We need to stop
(_,_,True) =
ReadingDone (_,_,True) =
(ValueResult
(Value () True)
{TaskEvalInfo|lastEvent=ts,removedTasks=[],attributes=newMap}
rep
(TCDestroy tree)
, {iworld & resources=[TTYd dp tty:resources]})
(r,s,ss)
ReadingDone (r,s,ss)
# tty = foldr TTYwrite tty $ reverse $ map enc s
# (merr, tty) = readWhileAvailable tty
| isError merr = (exc (fromError merr), iworld)
......@@ -67,8 +68,9 @@ where
(Left err, newacc) = (exc ("Error while parsing: " +++ join " " [toString (toInt c)\\c<-:acc+toString (fromOk merr)]), iworld)
(Right msgs, newacc)
# (merr, iworld) = if (msgs =: [] && s =: [])
(Ok (), iworld)
(write (r++msgs, [], False) rw iworld)
(Ok WritingDone, iworld)
//TODO Keep async in mind
(write (r++msgs, [], False) rw EmptyContext iworld)
| isError merr = (ExceptionResult (fromError merr), iworld)
= (ValueResult
NoValue
......
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