-Subproject commit 27239bb503b5bd185a37e2bbf165b7192985efa2
+Subproject commit 1b51061da5972a0cca502403496c12d731093960
sendToDevice :: String (Main (ByteCode () Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
sendToDevice wta mTask (device, timeout) =
- traceValue "starting to send"
- >>| get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask)
- >>= \(msgs, st1)->traceValue "messages generated"
- >>| set st1 bcStateStore
- >>| traceValue "bcstate store updated"
+ get bcStateStore @ toMessages timeout o toRealByteCode (unMain mTask)
+ >>= \(msgs, st1)->set st1 bcStateStore
>>| toSDSRecords st1
- >>= \sdss->traceValue "Shares created"
- >>| set sdss sdsStore//MTaskShareaddToSDSShare
- >>| traceValue "Shares store updated"
+ >>= \sdss->set sdss sdsStore//MTaskShareaddToSDSShare
>>| sendMessages msgs device
- >>| traceValue "Messages sent"
>>| makeTask wta -1
- >>= \t->traceValue "Task made"
- >>| withDevices device (addTask t)
- >>| traceValue "Tasks share updated"
+ >>= withDevices device o addTask
@! ()
where
sharename i = device.deviceChannels +++ "-" +++ toString i
derive class iTask MTaskShareType, MTaskShare
manageShares :: [MTaskShare] -> Task ()
-manageShares shares = forever $ viewInformation "" [] "" @! ()
-// viewSharesGrid shares @! ()
+manageShares shares = withShared Nothing $ \cs->forever $
+ viewSharesGrid cs shares /*||- (viewSharedInformation "" [] cs*/ @! ()//)//||- editCurrentShare cs
// >&^ \st->whileUnchanged st $ \msh->case msh of
// Nothing = viewShares shares
// >>= sendMessages [MTUpd identifier $ toString $ toByteCode a]
// >>| treturn sh
-viewSharesGrid :: [MTaskShare] -> Task [BCValue]
-viewSharesGrid sh = allTasks [watch (getSDSShare m)\\m<-sh]
+viewSharesGrid :: (Shared (Maybe MTaskShare)) [MTaskShare] -> Task [BCValue]
+viewSharesGrid _ [] = viewInformation "No shares yet" [] []
+viewSharesGrid cs sh = (allTasks [watch (getSDSShare m)\\m<-sh] <<@ NoUserInterface)
>&^ \st->whileUnchanged st $ \mshs->enterChoice "" [ChooseFromGrid id]
[{MTaskShare|ss&value=s}\\s<-fromJust mshs & ss<-sh]
+ >>* [OnValue (withValue $ \s->Just (set (Just s) cs))]
@! fromJust mshs
-// /*enterChoice "" [ChooseFromGrid id]*/viewInformation "" [] o fromJust
viewShare :: MTaskShare -> Task BCValue
viewShare m = viewSharedInformation "" [] (getSDSShare m)
countAndLed :: Main (ByteCode () Stmt)
blink :: UserLED -> Main (ByteCode () Stmt)
+count :: Main (ByteCode () Stmt)
blinkShare :: Main (ByteCode () Stmt)
ledtOn :: UserLED -> Main (ByteCode () Stmt)
ledtOff :: UserLED -> Main (ByteCode () Stmt)
import Devices.mTaskDevice
import iTasks._Framework.Serialization
+count :: Main (ByteCode () Stmt)
+count = sds \x=0 In {main = x =. x +. lit 1 :. pub x :. noOp}
+
countAndLed :: Main (ByteCode () Stmt)
countAndLed = sds \x=1 In sds \pinnetje=1 In {main =
IF (digitalRead D3) (
,("readDPin", pinSelection @ readDPin)
,("blink", ledSelection @ blink)
,("blinkShare", treturn blinkShare)
+ ,("count", treturn count)
]
//Read task bytecode
for(i = 0; i<tasks[ct].tlen; i++){
tasks[ct].bc[i] = read_byte();
-// debug("t[][%i]: 0x%02x %d", i,
-// tasks[ct].bc[i], tasks[ct].bc[i]);
}
//Return the task number for later removal
debug("Received a task of length %d", tasks[ct].tlen);
import Tasks.Examples
encode :: MTaskMSGSend -> String
-encode (MTTask to data) = "t" +++ tob +++ to16bit (size data) +++ data +++ "\n"
- where
- tob = case to of
- OneShot = to16bit 0
- OnInterval i = to16bit i
- OnInterrupt _ = abort "Interrupts not implemented yet"
+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"
instance fromByteCode MTaskDeviceSpec where
fromByteCode s = let c = toInt s.[0] in
{MTaskDeviceSpec
- |haveLed=c bitand 1 > 0
- ,haveAio=c bitand 2 > 0
- ,haveDio=c bitand 4 > 0
+ |haveLed=(c bitand 1) > 0
+ ,haveAio=(c bitand 2) > 0
+ ,haveDio=(c bitand 4) > 0
,maxTask=from16bit $ s % (1,3)
,maxSDS=from16bit $ s % (3,5)
}