modularize more
[mTask.git] / miTask.icl
index 6c80f05..47778b2 100644 (file)
@@ -6,6 +6,8 @@ from StdFunc import flip
 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
 
@@ -22,32 +24,10 @@ import TTY, iTasksTTY
 
 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)]
 
@@ -76,7 +56,7 @@ bc3 :: UserLED -> Main (ByteCode () Stmt)
 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 
@@ -147,20 +127,6 @@ 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