connectDevice :: (MTaskDevice (Shared Channels) -> Task ()) MTaskDevice -> Task ()
manageDevices :: (MTaskDevice (Shared Channels) -> Task ()) [MTaskDevice] -> Task ()
sendMessages :: [MTaskMSGSend] -> (MTaskDevice -> Task Channels)
+getDevice :: String -> Task MTaskDevice
withDevices :: MTaskDevice (MTaskDevice -> MTaskDevice) -> Task ()
import iTasksTTY
import TTY
import qualified Data.Map as DM
+import qualified Data.List as DL
import Utils.SDS
import Utils.Devices
ackFirst [t:ts] = if (t.ident == -1)
[{t & ident=i}:ts] [t:ackFirst ts]
+getDevice :: String -> Task MTaskDevice
+getDevice n = get deviceStore @ fromJust o 'DL'.find (\s->s.deviceName == n)
+
deviceTaskDelete :: MTaskDevice MTaskTask -> Task ()
deviceTaskDelete dev task = sendMessages [MTTaskDel task.ident] dev @! ()
:: MTaskShareType = MTaskWithShare String | MTaskLens String
:: MTaskShare =
{withTask :: [String]
- ,withDevice :: [MTaskDevice]
+ ,withDevice :: [String]
,identifier :: Int
,realShare :: MTaskShareType
,value :: BCValue
manageShares :: [MTaskShare] -> Task ()
-///makeShare :: String Int Dynamic -> Task MTaskShare
-makeShare :: String MTaskDevice Int BCValue -> Task MTaskShare
+makeShare :: String String Int BCValue -> Task MTaskShare
updateShare :: Int BCValue -> Task ()
import mTask
import Data.List
from Data.Func import $
+from StdFunc import flip
derive class iTask MTaskShareType, MTaskShare
viewSharedInformation "Current value" [] (getSDSShare sh)
||- (
updateSharedInformation "New value" [] (getSDSShare sh)
- >>= \nv->allTasks (map (sendMessages [MTUpd sh.identifier nv]) sh.withDevice)
+ >>= \nv->allTasks (map getDevice sh.withDevice)
+ >>= \devs->allTasks (map (sendMessages [MTUpd sh.identifier nv]) devs)
>>| treturn nv
)
<<@ ArrangeHorizontal
-// >&^ \st->whileUnchanged st $ \msh->case msh of
-// Nothing = viewShares shares
-// Just sh = forever (
-// viewSharedInformation "View value" [] (getSDSShare sh) >>| treturn sh
-// >>* [OnAction (Action "Update") (withValue (Just o updateInformation "New value" []))]
-// >>= updateShare sh
-// )
-//
-// ) @! ()
-
-
-//viewShares :: [MTaskShare] -> Task BCValue
-//viewShares shares = anyTask (map viewShare shares)
-//
-//viewAndDelete :: [MTaskShare] -> Task ()
-//viewAndDelete shares
-// = enterChoice "Choose share to update" [ChooseFromGrid id] shares @! ()
-
-//updateShare :: MTaskShare a -> Task MTaskShare | toByteCode, iTask a
-//updateShare sh=:{withTask,identifier} a = getDeviceByName withTask
-// >>= sendMessages [MTUpd identifier $ toString $ toByteCode a]
-// >>| treturn sh
-//
-from StdFunc import flip
-
viewSharesGrid :: (Shared (Maybe MTaskShare)) [MTaskShare] -> Task [BCValue]
viewSharesGrid _ [] = viewInformation "No shares yet" [] []
viewSharesGrid cs sh = (allTasks [watch (getSDSShare m)\\m<-sh] <<@ NoUserInterface)
getSDSShare :: MTaskShare -> Shared BCValue
getSDSShare s=:{realShare=(MTaskWithShare id),value} = memoryShare id value
-makeShare :: String MTaskDevice Int BCValue -> Task MTaskShare
+makeShare :: String String Int BCValue -> Task MTaskShare
makeShare withTask withDevice identifier value = treturn
{MTaskShare
|withTask=[withTask]
toSDSRecords :: [MTaskMSGSend] BCState MTaskDevice -> Task [MTaskShare]
toSDSRecords s st device = sequence ""
- [makeShare wta device sdsi sdsval
+ [makeShare wta device.deviceName sdsi sdsval
\\{sdsi,sdspub,sdsval}<-st.sdss
, (MTSds sdsi` _)<-s
| sdsi == sdsi`]