addDevice :: (Shared [MTaskDevice]) -> Task String
//addDevice :: (Shared [MTaskDevice]) -> Task MTaskResource
//addDevice :: (Shared [MTaskDevice]) -> Task ()
+
+viewDevices :: [MTaskDevice] -> Task ()
import iTasksTTY
import TTY
import qualified Data.Map as DM
-import Utils
+import Utils.SDS
import GenBimap
import Devices.mTaskSerial
deviceSettings "SerialDevice" = getmTaskSerialDevice
deviceSettings "TCPDevice" = getmTaskTCPDevice
-deviceTypes :: [MTaskResource]
-deviceTypes = conses{|*|}
+ deviceTypes :: [MTaskResource]
+ deviceTypes = conses{|*|}
+
+viewDevices :: [MTaskDevice] -> Task ()
+viewDevices ds = anyTask [
+ addDevice deviceStore <<@ Title "Add new device" @! ():
+ [viewDevice d <<@ Title d.deviceName\\d<-ds]]
+ <<@ ArrangeWithTabs @! ()
+
+viewDevice :: MTaskDevice -> Task ()
+viewDevice d = (viewInformation "Device settings" [] d
+ ||- viewSharedInformation "Channels" [ViewAs dropEmpty] (channels d) @! ()
+ ) <<@ ArrangeHorizontal
+ where
+ dropEmpty (r,s,ss) = (filter ((=!=)MTEmpty) r,s,ss)
--- /dev/null
+definition module Shares.mTaskShare
+
+:: MTaskShare = {
+ initValue :: Int,
+ withTask :: String,
+ identifier :: Int,
+ realShare :: String
+ }
--- /dev/null
+implementation module Shares.mTaskShare
+
+++ /dev/null
-definition module Utils
-
-import iTasks
-
-memoryShare :: String a -> Shared a | iTask a
+++ /dev/null
-implementation module Utils
-
-import iTasks
-import iTasks._Framework.Store
-from Data.Func import $
-
-memoryShare :: String a -> Shared a | iTask a
-memoryShare s d = sdsFocus s $ memoryStore "" $ Just d
--- /dev/null
+definition module Utils.SDS
+
+import Shares.mTaskShare
+import Devices.mTaskDevice
+import iTasks
+
+derive class iTask MTaskShare
+
+memoryShare :: String a -> Shared a | iTask a
+
+deviceStore :: Shared [MTaskDevice]
+sdsStore :: Shared [MTaskShare]
+bcStateStore :: Shared BCState
+mTaskTaskStore :: Shared [String]
--- /dev/null
+implementation module Utils.SDS
+
+import iTasks
+import iTasks._Framework.Store
+import Devices.mTaskDevice
+import Shares.mTaskShare
+from Data.Func import $
+
+derive class iTask MTaskShare, BCState
+
+memoryShare :: String a -> Shared a | iTask a
+memoryShare s d = sdsFocus s $ memoryStore "" $ Just d
+
+deviceStore :: Shared [MTaskDevice]
+deviceStore = sharedStore "mTaskDevices" []
+
+sdsStore :: Shared [MTaskShare]
+sdsStore = memoryShare "mTaskShares" []
+
+bcStateStore :: Shared BCState
+bcStateStore = memoryShare "mTaskBCState" zero
+
+mTaskTaskStore :: Shared [String]
+mTaskTaskStore = memoryShare "mTaskTasks" ["count", "ledon", "ledoff"]
import iTasks
import mTask
import Devices.mTaskDevice
+import Shares.mTaskShare
+import Utils.SDS
from Text import class Text(startsWith,concat,split,join), instance Text String
derive class iTask UserLED
-:: MTaskShare = {
- initValue :: Int,
- withTask :: String,
- identifier :: Int,
- realShare :: String
- }
-
Start :: *World -> *World
Start world = startEngine (mTaskManager
>>* [OnAction (Action "Shutdown") (always $ shutDown)]) world
-memoryShare :: String a -> Shared a | iTask a
-memoryShare s d = sdsFocus s $ memoryStore "" $ Just d
-
-deviceStore :: Shared [MTaskDevice]
-deviceStore = sharedStore "mTaskDevices" []
-
-sdsStore :: Shared [MTaskShare]
-sdsStore = memoryShare "mTaskShares" []
-
-bcStateStore :: Shared BCState
-bcStateStore = memoryShare "mTaskBCState" zero
-
-mTaskTaskStore :: Shared [String]
-mTaskTaskStore = memoryShare "mTaskTasks" ["count", "ledon", "ledoff"]
-
mTaskMap :: Map String (Main (ByteCode () Stmt))
mTaskMap = 'DM'.fromList [("count", bc), ("ledon", bc2 LED1), ("ledoff", bc3 LED3)]
bc3 d = {main = ledOff d}
:: MTaskDeviceStatus = {connected :: Bool, name :: String, tasks :: [String]}
-derive class iTask MTaskDeviceStatus, MTaskShare, BCState
+derive class iTask MTaskDeviceStatus, BCState
mTaskManager :: Task ()
mTaskManager = anyTask
// ||- updateInformation "Value" [] v)
- viewDevices :: [MTaskDevice] -> Task ()
- viewDevices ds = anyTask [
- addDevice deviceStore <<@ Title "Add new device" @! ():
- [viewDevice d <<@ Title d.deviceName\\d<-ds]]
- <<@ ArrangeWithTabs @! ()
-
- viewDevice :: MTaskDevice -> Task ()
- viewDevice d = (viewInformation "Device settings" [] d
- ||- viewSharedInformation "Channels" [ViewAs dropEmpty] (channels d) @! ()
- ) <<@ ArrangeHorizontal
- where
- dropEmpty (r,s,ss) = (filter ((=!=)MTEmpty) r,s,ss)
-
-
// addDevice :: (Shared [MTaskDevice]) -> Task SerTCP
// addDevice devices = enterInformation "Device type" []
// >&^ \sh->whileUnchanged sh $ \mty->case mty of