, deviceError :: Maybe String
, deviceChannels :: String
, deviceName :: String
+ , deviceState :: BCState
, deviceTasks :: [MTaskTask]
, deviceData :: MTaskResource
, deviceSpec :: Maybe MTaskDeviceSpec
}
import GenPrint, StdMisc, StdDebug, TTY
+
+gPrint{|BCState|} x st = gPrint{|*|} "BCState..." st
+
derive gPrint MTaskDevice, MTaskShare, Maybe, MTaskResource, MTaskTask, TaskId, TTYSettings, TCPSettings, DateTime
derive gPrint Parity, BaudRate, ByteSize
@ \dt->{MTaskTask | name=name,ident=ident,dateAdded=dt}
sendTaskToDevice :: String (Main (ByteCode a Stmt)) (MTaskDevice, MTaskInterval) -> Task ()
-sendTaskToDevice wta mTask (device, timeout) =
- get bcStateStore @ toMessages timeout mTask
- >>= \(msgs, st1)->set st1 bcStateStore
- >>| toSDSRecords msgs st1 device
+sendTaskToDevice wta mTask (device, timeout)
+# (msgs, newState) = toMessages timeout mTask device.deviceState
+= toSDSRecords msgs newState device
>>= \sdss->updateShares device ((++) sdss)
>>| sendMessages msgs device
>>| makeTask wta -1
- >>= withDevices device o addTask
+ >>= withDevices device o addTaskUpState newState
@! ()
where
sharename i = device.deviceChannels +++ "-" +++ toString i
[makeShare wta sdsi sdsval
\\{sdsi,sdsval}<-st.sdss, (MTSds sdsi` _)<-s | sdsi == sdsi`]
- addTask :: MTaskTask MTaskDevice -> MTaskDevice
- addTask task device = {device & deviceTasks=[task:device.deviceTasks]}
+ addTaskUpState :: BCState MTaskTask MTaskDevice -> MTaskDevice
+ addTaskUpState st task device =
+ { MTaskDevice
+ | device
+ & deviceState=st
+ , deviceTasks=[task:device.deviceTasks]}