X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.icl;h=ef75b9a1bf7c3c58e599d1c01e441099d5371dcf;hb=88ecd686ff62986cde139abb65ab52b9e93d3035;hp=aeceb925b39336180882bb8905111a6d90c79aeb;hpb=feacd1b50fca9624284f8b8c22c26d7a8071515d;p=mTask.git diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index aeceb92..ef75b9a 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -43,8 +43,9 @@ import Tasks.Examples encode :: MTaskMSGSend -> String encode (MTTask to data) = "t" +++ toByteCode to +++ to16bit (size data) +++ data +++ "\n" encode (MTTaskDel i) = "d" +++ to16bit i +++ "\n" -encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n" -encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n" +encode (MTSds i v) = "s" +++ to16bit i +++ toByteCode v +++ "\n" +encode (MTUpd i v) = "u" +++ to16bit i +++ toByteCode v +++ "\n" +encode (MTSpec) = "c\n" import StdDebug decode :: String -> MTaskMSGRecv @@ -138,7 +139,7 @@ instance fromByteCode UserLED where fromByteCode s = conses{|*|} !! toInt s.[1] instance fromByteCode BCValue where fromByteCode s = parseBCValue s.[0] s instance toByteCode MTaskInterval where - toByteCode OneShot = toByteCode 0 + toByteCode OneShot = toByteCode (OnInterval 0) //Intervals have the first bit 0 and the rest is a 15 bit unsigned int toByteCode (OnInterval i) = {toChar $ i/256 bitand 127, toChar $ i rem 256} //Intervals have the first bit 1 and the rest is a 15 bit unsigned int @@ -328,13 +329,19 @@ toReadableByteCode x s where (ex, newls) = splitAt (bclength b - 1) ls -toMessages :: MTaskInterval (String, BCState) -> ([MTaskMSGSend], BCState) -toMessages interval (bytes, st=:{sdss}) = ( - [MTSds sdsi $ toByteCode e\\{sdsi,sdsval=(BCValue e)}<-sdss] ++ - [MTTask interval bytes], st) +derive gPrint BCShare -toSDSUpdate :: Int Int -> [MTaskMSGSend] -toSDSUpdate i v = [MTUpd i (to16bit v)] +toMessages :: MTaskInterval (Main (ByteCode a b)) BCState -> ([MTaskMSGSend], BCState) +toMessages interval x s +# (bc, newstate) = toRealByteCode (unMain x) s +# newsdss = 'DL'.difference newstate.sdss s.sdss +| not (trace_tn $ printToString s.sdss) = undef +| not (trace_tn $ printToString newstate.sdss) = undef +| not (trace_tn $ printToString newsdss) = undef += ([MTSds sdsi e\\{sdsi,sdsval=e}<-newsdss] ++ + [MTTask interval bc], newstate) + +instance == BCShare where (==) a b = a.sdsi == b.sdsi //Start = toMessages (OnInterval 500) $ toRealByteCode (unMain bc) zero Start = fst $ toReadableByteCode (unMain $ countAndLed) zero