forgot to commit
authorMart Lubbers <mart@martlubbers.net>
Sun, 19 Mar 2017 19:33:12 +0000 (20:33 +0100)
committerMart Lubbers <mart@martlubbers.net>
Sun, 19 Mar 2017 19:33:12 +0000 (20:33 +0100)
Devices/mTaskDevice.dcl
Devices/mTaskDevice.icl
Devices/mTaskTCP.icl
client/main.c
client/spec.c
mTaskInterpret.dcl
mTaskInterpret.icl
miTask.icl

index 17acd10..ce6e608 100644 (file)
@@ -10,7 +10,7 @@ import mTaskInterpret
 import Generics.gCons
 import iTasksTTY
 
 import Generics.gCons
 import iTasksTTY
 
-derive class iTask MTaskDevice, MTaskDeviceSpec, MTaskResource, MTaskMSGRecv, MTaskMSGSend, BCShare
+derive class iTask MTaskDevice, MTaskResource, MTaskMSGRecv, MTaskMSGSend, BCShare
 derive conses MTaskResource, TCPSettings
 derive consName MTaskResource, TCPSettings
 
 derive conses MTaskResource, TCPSettings
 derive consName MTaskResource, TCPSettings
 
index 537a3b9..9b26455 100644 (file)
@@ -18,7 +18,7 @@ import iTasks.UI.Definition, iTasks.UI.Editor, iTasks.UI.Editor.Builtin, iTasks.
 
 from Data.Func import $
 
 
 from Data.Func import $
 
-derive class iTask MTaskDevice, MTaskResource, MTaskDeviceSpec, MTaskMSGRecv, MTaskMSGSend, BCShare
+derive class iTask MTaskDevice, MTaskResource, MTaskMSGRecv, MTaskMSGSend, BCShare
 derive conses MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 derive consName MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 
 derive conses MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 derive consName MTaskResource, TTYSettings, BaudRate, Parity, ByteSize, TCPSettings
 
@@ -143,4 +143,4 @@ deviceTaskDeleteAcked d i = withDevices d $ deleteTask
        where deleteTask d = {d & deviceTasks=[s\\s<-d.deviceTasks | i <> s.ident]}
 
 deviceAddSpec :: MTaskDevice MTaskDeviceSpec -> Task ()
        where deleteTask d = {d & deviceTasks=[s\\s<-d.deviceTasks | i <> s.ident]}
 
 deviceAddSpec :: MTaskDevice MTaskDeviceSpec -> Task ()
-deviceAddSpec d s = withDevices d $ \r->{r&deviceSpec=Just s}
+deviceAddSpec d s = withDevices d $ \r->{MTaskDevice | r & deviceSpec=Just s}
index 52832d6..4ebc1ac 100644 (file)
@@ -23,7 +23,7 @@ instance MTaskDuplex TCPSettings where
                                onDisconnect=onDisconnect} @! ()
                where
                        onConnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
                                onDisconnect=onDisconnect} @! ()
                where
                        onConnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
-                       onConnect acc (msgs,send,sendStopped) = (Ok acc, Just (msgs,[],sendStopped), map encode send, False)
+                       onConnect acc (msgs,send,sendStopped) = (Ok "", Just (msgs,[],sendStopped), map encode send, False)
 
                        whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
                        //We stop
 
                        whileConnected :: (Maybe String) String ([MTaskMSGRecv], [MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool), [String], Bool)
                        //We stop
@@ -37,9 +37,11 @@ instance MTaskDuplex TCPSettings where
                        = (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
 
                        process :: String -> (String, [String])
                        = (Ok acc, Just (msgs++map decode nd,[],sendStopped), map encode send, False)
 
                        process :: String -> (String, [String])
-                       process s = case indexOf "\n" s of
+                       process s
+                       | not (trace_tn ("process: " +++ toString (toJSON s))) = undef
+                       = case indexOf "\n" s of
                                -1 = (s, [])
                                -1 = (s, [])
-                               i = appSnd (\ss->[s % (0,i):ss]) (process (s % (i+1, size s)))
+                               i = appSnd (\ss->[s % (0,i-1):ss]) (process (s % (i+1, size s)))
                        
                        onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
                        onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)
                        
                        onDisconnect :: String ([MTaskMSGRecv],[MTaskMSGSend],Bool) -> (MaybeErrorString String, Maybe ([MTaskMSGRecv],[MTaskMSGSend],Bool))
                        onDisconnect _ (msgs,send,sendStopped) = (Ok "", Nothing)
index 9de18bc..012e062 100644 (file)
@@ -50,6 +50,7 @@ void read_message(void)
                        task_register();
                        break;
                case '\0':
                        task_register();
                        break;
                case '\0':
+                       die("Server closed connection");
                        break;
                case '\n':
                        break;
                        break;
                case '\n':
                        break;
index 8098a77..825e894 100644 (file)
@@ -4,9 +4,11 @@
 
 void spec_send(void)
 {
 
 void spec_send(void)
 {
+       debug("Writing spec");
        write_byte('c');
        write_byte(0 | (HAVELED << 0) | (HAVEAIO << 1) | (HAVEDIO << 2));
        write16(MAXTASKS);
        write16(MAXSDSS);
        write_byte('\n');
        write_byte('c');
        write_byte(0 | (HAVELED << 0) | (HAVEAIO << 1) | (HAVEDIO << 2));
        write16(MAXTASKS);
        write16(MAXSDSS);
        write_byte('\n');
+       debug("Done writing spec");
 }
 }
index f64cf62..f0795e1 100644 (file)
@@ -100,7 +100,7 @@ derive conses BCValue
 derive consNum BCValue
 
 derive class gCons Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin
 derive consNum BCValue
 
 derive class gCons Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin
-derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode
+derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode, MTaskDeviceSpec
 derive gEditor BCValue
 derive gText BCValue
 derive JSONEncode BCValue
 derive gEditor BCValue
 derive gText BCValue
 derive JSONEncode BCValue
index 716fc18..c986ec5 100644 (file)
@@ -51,8 +51,10 @@ 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"
 
 encode (MTSds i v) = "s" +++ to16bit i +++ v +++ "\n"
 encode (MTUpd i v) = "u" +++ to16bit i +++ v +++ "\n"
 
+import StdDebug
 decode :: String -> MTaskMSGRecv
 decode x
 decode :: String -> MTaskMSGRecv
 decode x
+| not (trace_tn ("decoding: " +++ toString (toJSON x))) = undef
 | size x == 0 = MTEmpty
 = case x.[0] of
        't' = MTTaskAck $ fromByteCode x
 | size x == 0 = MTEmpty
 = case x.[0] of
        't' = MTTaskAck $ fromByteCode x
@@ -193,7 +195,7 @@ gDefault{|BCValue|} = BCValue 0
 gEq{|BCValue|} (BCValue e) (BCValue f) = toByteCode e == toByteCode f
 
 derive class gCons Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin
 gEq{|BCValue|} (BCValue e) (BCValue f) = toByteCode e == toByteCode f
 
 derive class gCons Long, UserLED, Button, AnalogPin, DigitalPin, PinMode, Pin
-derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode
+derive class iTask UserLED, Long, Pin, Button, AnalogPin, DigitalPin, PinMode, MTaskDeviceSpec
 
 op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr
 op2 (BC x) (BC y) bc = BC $ x >>| y >>| tell [bc]
 
 op2 :: (ByteCode a p1) (ByteCode a p2) BC -> ByteCode b Expr
 op2 (BC x) (BC y) bc = BC $ x >>| y >>| tell [bc]
index 45ee7dd..fda80c8 100644 (file)
@@ -24,9 +24,35 @@ import iTasks._Framework.Serialization
 
 import TTY, iTasksTTY
 
 
 import TTY, iTasksTTY
 
+//derive class iTask ByteSize, Parity, BaudRate, TTYSettings, TCPSettings
+//derive class iTask MTaskDeviceSpec, MTaskResource, MTaskTask, MTaskDevice
+
 Start :: *World -> *World
 Start :: *World -> *World
-Start world = startEngine (mTaskManager
-       >>* [OnAction (Action "Shutdown") (always $ shutDown)]) world
+Start world = startEngine (viewInformation "" [] md) world
+       where
+               md = 
+                       { deviceTask = Just $ TaskId 0 0
+                       , deviceError = Just ""
+                       , deviceChannels = "abc"
+                       , deviceName = "hoi"
+                       , deviceTasks = []
+                       , deviceData = TCPDevice {TCPSettings
+                               |host="localhost",
+                               port=8888
+                               }
+                       , deviceSpec = Just {MTaskDeviceSpec
+                               |haveLed = True
+                               ,haveAio = True
+                               ,haveDio = True
+                               ,maxTask = 42
+                               ,maxSDS = 5
+                               }
+                       }
+                       
+                       
+
+//Start world = startEngine (mTaskManager
+//     >>* [OnAction (Action "Shutdown") (always $ shutDown)]) world
 
 mTaskManager :: Task ()
 mTaskManager = startupDevices >>| anyTask 
 
 mTaskManager :: Task ()
 mTaskManager = startupDevices >>| anyTask