Browse Source

Clear the SCCD controller

Yentl Van Tendeloo 4 years ago
parent
commit
9084b05884
3 changed files with 10 additions and 10 deletions
  1. 1 4
      wrappers/http_client.py
  2. 0 3
      wrappers/http_client.xml
  3. 9 3
      wrappers/modelverse.py

+ 1 - 4
wrappers/http_client.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Thu Aug 24 10:20:41 2017
+Date:   Fri Aug 25 15:48:04 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   HTTP client
@@ -263,7 +263,6 @@ class HTTPClient(RuntimeClassBase):
         timeout = parameters[1]
         self.address = address
         self.timeout = timeout
-        print("Connecting")
     
     def _connecting_connecting_1_exec(self, parameters):
         socket = parameters[0]
@@ -330,14 +329,12 @@ class HTTPClient(RuntimeClassBase):
     def _connected_parsing_wait_for_payload_0_exec(self, parameters):
         data = self.received_data[:self.length]
         self.received_data = self.received_data[self.length:]
-        print("Send out data with ID: " + str(data))
         self.big_step.outputEvent(Event("HTTP_output", "request_out", [data, self.IDs.pop(0)]))
     
     def _connected_parsing_wait_for_payload_0_guard(self, parameters):
         return len(self.received_data) >= self.length and self.IDs[0] is not None
     
     def _connected_parsing_wait_for_payload_1_exec(self, parameters):
-        print("Ignore data: " + str(self.received_data[:self.length]))
         # Drop data
         self.received_data = self.received_data[self.length:]
         self.IDs.pop(0)

+ 0 - 3
wrappers/http_client.xml

@@ -57,7 +57,6 @@
                     <script>
                         self.address = address
                         self.timeout = timeout
-                        print("Connecting")
                     </script>
                 </transition>
             </state>
@@ -171,7 +170,6 @@
                             <script>
                                 data = self.received_data[:self.length]
                                 self.received_data = self.received_data[self.length:]
-                                print("Send out data with ID: " + str(data))
                             </script>
                             <raise event="HTTP_output" scope="output" port="request_out">
                                 <parameter expr="data"/>
@@ -181,7 +179,6 @@
 
                         <transition cond="len(self.received_data) >= self.length and self.IDs[0] is None" target="../wait_for_header">
                             <script>
-                                print("Ignore data: " + str(self.received_data[:self.length]))
                                 # Drop data
                                 self.received_data = self.received_data[self.length:]
                                 self.IDs.pop(0)

+ 9 - 3
wrappers/modelverse.py

@@ -305,6 +305,12 @@ def init(address_param="127.0.0.1:8001", timeout=20.0):
     import http_client
     global ctrl_input
     global ctrl_output
+
+    if ctrl_input is not None:
+        ctrl_input.stop()
+    if ctrl_output is not None:
+        ctrl_output.stop()
+
     ctrl_input = http_client.Controller()
     ctrl_output = http_client.Controller()
     controllers = [ctrl_input, ctrl_output]
@@ -318,7 +324,6 @@ def init(address_param="127.0.0.1:8001", timeout=20.0):
         thrd = threading.Thread(target=ctrl.start)
         thrd.daemon = True
         thrd.start()
-        time.sleep(0.1)
 
         evt = listener.fetch(-1)
         if evt.name != "http_client_initialized":
@@ -327,6 +332,9 @@ def init(address_param="127.0.0.1:8001", timeout=20.0):
         ctrl.addInput(Event("connect", "request_in", [(addr, port), timeout]))
 
         evt = listener.fetch(-1)
+
+        if evt.name == "http_client_timeout":
+            raise Exception("HTTP client timeout")
         if evt.name != "http_client_ready":
             raise Exception("HTTP client did not behave as expected during connect: " + str(evt.name))
 
@@ -354,9 +362,7 @@ def login(username, password):
     global mode
     _goto_mode(MODE_UNAUTHORIZED)
 
-    print("Wait for output")
     _output("Log on as which user?")
-    print("Got that output")
     _input(username)
     if _output() == "Password for existing user?":
         _input(password)