X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=mTaskInterpret.icl;h=c986ec5607b45425c45997d1d1a69545247b9b97;hb=be3f747f775c05facb8a34cf0baba523401b88fb;hp=b6ab92922c0215f0d7d0b3dd371f6aa36f7bf0d2;hpb=32ff545d18253da21f25c69c6d99b96f90668773;p=mTask.git diff --git a/mTaskInterpret.icl b/mTaskInterpret.icl index b6ab929..c986ec5 100644 --- a/mTaskInterpret.icl +++ b/mTaskInterpret.icl @@ -51,8 +51,10 @@ 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" +import StdDebug decode :: String -> MTaskMSGRecv decode x +| not (trace_tn ("decoding: " +++ toString (toJSON x))) = undef | size x == 0 = MTEmpty = case x.[0] of 't' = MTTaskAck $ fromByteCode x @@ -89,6 +91,7 @@ instance toString MTaskMSGRecv where toString (MTSDSDelAck i) = "SDS deleted with id: " +++ toString i toString (MTPub i v) = "Publish id: " +++ toString i +++ " value " +++ safePrint v + toString (MTDevSpec mt) = "Specification: " +++ printToString mt toString (MTMessage m) = m toString MTEmpty = "Empty message" @@ -159,8 +162,8 @@ instance fromByteCode MTaskDeviceSpec where |haveLed=c bitand 1 > 0 ,haveAio=c bitand 2 > 0 ,haveDio=c bitand 4 > 0 - ,maxTask=toInt s.[1] - ,maxSDS =toInt s.[2] + ,maxTask=from16bit $ s % (1,3) + ,maxSDS=from16bit $ s % (3,5) } derive gPrint Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin, BC, MTaskDeviceSpec @@ -192,7 +195,7 @@ gDefault{|BCValue|} = BCValue 0 gEq{|BCValue|} (BCValue e) (BCValue f) = toByteCode e == toByteCode f derive class gCons Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin -derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode +derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode, MTaskDeviceSpec op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr op2 (BC x) (BC y) bc = BC $ x >>| y >>| tell [bc]