repositories
/
mTask.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
demo
[mTask.git]
/
miTask.icl
diff --git
a/miTask.icl
b/miTask.icl
index
92fbff2
..
2757450
100644
(file)
--- a/
miTask.icl
+++ b/
miTask.icl
@@
-21,7
+21,7
@@
import iTasks._Framework.Store
import TTY
derive class iTask Queue, TTYSettings, Parity, BaudRate, ByteSize
import TTY
derive class iTask Queue, TTYSettings, Parity, BaudRate, ByteSize
-derive class iTask MTaskMSGRecv, MTaskMSGSend, SerTCP
+derive class iTask MTaskMSGRecv, MTaskMSGSend, SerTCP
, UserLED
:: SerTCP = Serial | TCP
:: *Resource | TTYd !*TTY
:: SerTCP = Serial | TCP
:: *Resource | TTYd !*TTY
@@
-32,28
+32,29
@@
Start world = startEngine mTaskTask world
bc :: Main (ByteCode () Stmt)
bc = sds \x=1 In sds \pinnetje=1 In {main =
bc :: Main (ByteCode () Stmt)
bc = sds \x=1 In sds \pinnetje=1 In {main =
- IF (digitalRead D3
==. lit True
) (
+ IF (digitalRead D3) (
x =. x +. lit 1 :.
pub x
) (
noOp
) :.
IF (pinnetje ==. lit 1) (
x =. x +. lit 1 :.
pub x
) (
noOp
) :.
IF (pinnetje ==. lit 1) (
- digitalWrite D0 (lit True) :.
- digitalWrite D1 (lit False) :.
- digitalWrite D2 (lit False)
+ ledOn LED1
) (
IF (pinnetje ==. lit 2) (
) (
IF (pinnetje ==. lit 2) (
- digitalWrite D0 (lit False) :.
- digitalWrite D1 (lit True) :.
- digitalWrite D2 (lit False)
+ ledOn LED2
) (
) (
- digitalWrite D0 (lit False) :.
- digitalWrite D1 (lit False) :.
- digitalWrite D2 (lit True)
+ ledOn LED3
)
)}
)
)}
+bc2 :: UserLED -> Main (ByteCode () Stmt)
+bc2 d = {main = ledOn d}
+
+bc3 :: UserLED -> Main (ByteCode () Stmt)
+bc3 d = {main = ledOff d}
+
+
withDevice :: ((Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task a) -> Task a | iTask a
withDevice t = withShared ([], [], False) \ch->
enterInformation "Type" []
withDevice :: ((Shared ([MTaskMSGRecv],[MTaskMSGSend],Bool)) -> Task a) -> Task a | iTask a
withDevice t = withShared ([], [], False) \ch->
enterInformation "Type" []
@@
-74,14
+75,17
@@
withDevice t = withShared ([], [], False) \ch->
mTaskTask :: Task ()
mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in
mTaskTask :: Task ()
mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in
- withDevice
(
\ch->
+ withDevice \ch->
sendMsg msgs ch
||- processMessages ch messageShare sdsShares
sendMsg msgs ch
||- processMessages ch messageShare sdsShares
+ ||- forever (enterChoice "Choose led to enable" [] [LED1, LED2, LED3]
+ >>= \p->sendMsg (fst (makeMsgs 0 (bc2 p))) ch)
+ ||- forever (enterChoice "Choose led to disable" [] [LED1, LED2, LED3]
+ >>= \p->sendMsg (fst (makeMsgs 0 (bc3 p))) ch)
||- viewSharedInformation "channels" [ViewWith lens] ch
||- viewSharedInformation "messages" [] messageShare
||- viewSh sdsShares ch
>>* [OnAction ActionFinish (always shutDown)]
||- viewSharedInformation "channels" [ViewWith lens] ch
||- viewSharedInformation "messages" [] messageShare
||- viewSh sdsShares ch
>>* [OnAction ActionFinish (always shutDown)]
- )
where
messageShare :: Shared [String]
messageShare = sharedStore "mTaskMessagesRecv" []
where
messageShare :: Shared [String]
messageShare = sharedStore "mTaskMessagesRecv" []
@@
-103,11
+107,13
@@
mTaskTask = let (msgs, sdsShares) = makeMsgs 1000 bc in
dd [x,y] = toInt x*265 + toInt y
updateSDSs :: [(Int, Shared Int)] (Shared [String]) MTaskMSGRecv -> Task ()
dd [x,y] = toInt x*265 + toInt y
updateSDSs :: [(Int, Shared Int)] (Shared [String]) MTaskMSGRecv -> Task ()
- updateSDSs _ m (MTMessage s) = upd (\l->take 20 [s:l]) m @! ()
updateSDSs [(id, sh):xs] m n=:(MTPub i d)
| id == i = set ((toInt d.[0])*265 + toInt d.[1]) sh @! ()
= updateSDSs xs m n
updateSDSs [(id, sh):xs] m n=:(MTPub i d)
| id == i = set ((toInt d.[0])*265 + toInt d.[1]) sh @! ()
= updateSDSs xs m n
- updateSDSs _ _ _ = return ()
+ updateSDSs _ m mtm = case mtm of
+ MTMessage s = upd (\l->take 5 [s:l]) m @! ()
+ mta=:(MTTaskAdded _) = upd (\l->take 5 [toString mta:l]) m @! ()
+ _ = return ()
lens :: ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> ([String], [String])
lens (r,s,_) = (map toString r, map toString s)
lens :: ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> ([String], [String])
lens (r,s,_) = (map toString r, map toString s)