repositories
/
mTask.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
better serial integration, moved things outside
[mTask.git]
/
mTaskInterpret.icl
diff --git
a/mTaskInterpret.icl
b/mTaskInterpret.icl
index
1833e62
..
4876e93
100644
(file)
--- a/
mTaskInterpret.icl
+++ b/
mTaskInterpret.icl
@@
-1,7
+1,9
@@
implementation module mTaskInterpret
//import iTasks
implementation module mTaskInterpret
//import iTasks
-import gdynamic, gCons, GenEq, StdMisc, StdArray, GenBimap
+import Generics.gCons
+
+import GenEq, StdMisc, StdArray, GenBimap
import GenPrint
import StdEnum
import mTask
import GenPrint
import StdEnum
import mTask
@@
-23,19
+25,22
@@
import qualified Data.Map as DM
import Text.Encodings.Base64
encode :: MTaskMSGSend -> String
import Text.Encodings.Base64
encode :: MTaskMSGSend -> String
-encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n"
encode (MTTask to data) = "t" +++ to16bit to +++ to16bit (size data) +++ data +++ "\n"
encode (MTTask to data) = "t" +++ to16bit to +++ to16bit (size data) +++ data +++ "\n"
+encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n"
encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n"
decode :: String -> MTaskMSGRecv
decode x
| size x == 0 = MTEmpty
= case x.[0] of
encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n"
decode :: String -> MTaskMSGRecv
decode x
| size x == 0 = MTEmpty
= case x.[0] of
+ 't' = MTTaskAck (from16bit (x % (1,3)))
+ 'd' = MTTaskDelAck (from16bit (x % (1,3)))
+ 'm' = MTMessage x
+ 's' = MTSDSAck (from16bit (x % (1,3)))
+ 'a' = MTSDSDelAck (from16bit (x % (1,3)))
+ 'p' = MTPub (from16bit (x % (1,3))) (x % (3,5))
'\0' = MTEmpty
'\n' = MTEmpty
'\0' = MTEmpty
'\n' = MTEmpty
- 'm' = MTMessage x
- 't' = MTTaskAdded (from16bit (x % (1,3)))
- 'u' = MTPub (from16bit (x % (1,3))) (x % (3,5))
_ = MTMessage x//abort ("Didn't understand message: " +++ join " " [toString (toInt c)\\c<-: x] +++ "\n")
safePrint :== toString o toJSON
_ = MTMessage x//abort ("Didn't understand message: " +++ join " " [toString (toInt c)\\c<-: x] +++ "\n")
safePrint :== toString o toJSON
@@
-49,9
+54,13
@@
instance toString MTaskMSGSend where
+++ " value " +++ safePrint v
instance toString MTaskMSGRecv where
+++ " value " +++ safePrint v
instance toString MTaskMSGRecv where
+ toString (MTTaskAck i) = "Task added with id: " +++ toString i
+ toString (MTTaskDelAck i) = "Task deleted with id: " +++ toString i
+ toString (MTSDSAck i) = "SDS added with id: " +++ toString i
+ toString (MTSDSDelAck i) = "SDS deleted with id: " +++ toString i
toString (MTPub i v) = "Publish id: " +++ toString i
+++ " value " +++ safePrint v
toString (MTPub i v) = "Publish id: " +++ toString i
+++ " value " +++ safePrint v
- toString (MT
TaskAdded i) = "Task added with id: " +++ toString i
+ toString (MT
Message m) = m
toString MTEmpty = "Empty message"
bclength :: BC -> Int
toString MTEmpty = "Empty message"
bclength :: BC -> Int
@@
-220,9
+229,9
@@
instance zero BCState where
zero = {freshl=[1..], freshs=[1..], sdss=[]}
zero = {freshl=[1..], freshs=[1..], sdss=[]}
-toRealByteCode :: (ByteCode a b) -> (String, BCState)
-toRealByteCode x
-# (bc, st) = runBC x
zero
+toRealByteCode :: (ByteCode a b)
BCState
-> (String, BCState)
+toRealByteCode x
s
+# (bc, st) = runBC x
s
# (bc, gtmap) = computeGotos bc 1
= (concat $ map (toString o toByteVal) (map (implGotos gtmap) bc), st)
# (bc, gtmap) = computeGotos bc 1
= (concat $ map (toString o toByteVal) (map (implGotos gtmap) bc), st)
@@
-256,7
+265,7
@@
toMessages interval (bytes, st=:{sdss}) = ([MTSds i (toString b)\\(i,b)<-sdss] +
toSDSUpdate :: Int Int -> [MTaskMSGSend]
toSDSUpdate i v = [MTUpd i (to16bit v)]
toSDSUpdate :: Int Int -> [MTaskMSGSend]
toSDSUpdate i v = [MTUpd i (to16bit v)]
-Start = toMessages 500 $ toRealByteCode (unMain bc)
+Start = toMessages 500 $ toRealByteCode (unMain bc)
zero
where
bc = sds \x=5 In
sds \y=4 In
where
bc = sds \x=5 In
sds \y=4 In