-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.py
90 lines (72 loc) · 2.2 KB
/
robot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
import os
APP_NAME = 'TestRobot'
APP_VERSION = '1.2'
OS_NAME = os.name
import sys
APP_PATH = os.path.abspath(os.path.dirname(__file__))
sys.path.append(APP_PATH)
import pygtk
import gtk
pygtk.require('2.0')
from ui.SessionView import SessionView
from core.SessionManager import SessionManager
from core.Monitor import Monitor
from core.SessionStatus import SessionStatus
import thread
import ConfigParser
import time
from common import *
class TestRobot(Monitor):
def __init__(self, manager):
self.autorun = 0
self.manager = manager
self.type = Monitor.CONTROL_SESSION
def updateView(self, sessionStatus):
self.autoTestAction(sessionStatus)
def autoTestAction(self, status):
id = status.getId()
sessionStatus = status.getStatus()
if sessionStatus == SessionStatus.NETWORKERROR:
self.manager.setup([id])
if sessionStatus == SessionStatus.STOPPED:
self.manager.setup([id]);
if sessionStatus == SessionStatus.SETUP:
self.manager.play([id])
if sessionStatus == SessionStatus.RUNNING:
pass
def destory(widget, event, data = None):
gtk.main_quit()
sys.exit(0)
return False
def startRun():
manager.setup()
manager.play()
Pressure = 5
if __name__ == "__main__":
manager = SessionManager()
view = SessionView(manager)
mainViewUI = view.createView()
gtk.gdk.threads_init()
robot = TestRobot(manager)
if len(sys.argv) < 2:
configFile = "./config.cfg"
else:
configFile = sys.argv[1]
config = readConfigFromFile(configFile)
if config == None:
print "please specify the configure file"
sys.exit(-1)
createSession(config.protocol, config.address,
config.param,
config.number, manager,
view, TestRobot, Pressure)
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.connect("delete_event", destory)
window.add(mainViewUI)
window.set_size_request(720,630)
window.show_all()
thread.start_new_thread(startRun, ())
gtk.gdk.threads_enter()
gtk.main()
gtk.gdk.threads_level()