Index: online/getCommand.py
===================================================================
--- online/getCommand.py	(revision 663d194797b7293fe31907ec29cca5430d0c2b79)
+++ online/getCommand.py	(revision 663d194797b7293fe31907ec29cca5430d0c2b79)
@@ -0,0 +1,51 @@
+from mantid.simpleapi import *
+import jsonArray
+import threading
+import neonIO
+import time
+from Queue import Queue
+import sys
+import numpy as np
+from canvas import *
+import cStringIO
+import configure
+import stateMachine
+from PyQt4 import QtCore
+
+class getCommand(QtCore.QThread):
+    def __init__(self, neonRedis, refreshtime):
+        QtCore.QThread.__init__(self)
+
+        self.neonRedis = neonRedis
+        self.refreshtime = refreshtime
+        self.command = ''
+        self.call = True
+    
+    def getCommand(self):
+        _path="/GPPD/workspace/stateMachine/command"
+        _json=self.neonRedis.get(_path)
+        return _json
+
+    def setCommand(self, command):
+        self.command=command
+
+    def process(self):
+        while True:
+            _be=time.time()
+            _command=self.getCommand()
+            if self.command==_command:
+                self.call=False
+            else:
+                self.call=True
+                self.setCommand(_command)
+                #dataHandling=stateMachine.stateMachine(self.neonRedis, self.command)
+                #dataHandling.fsm()
+            #print "============================="
+            #print self.call, self.command
+            #print time.time()-_be, "seconds"
+            #print "============================="
+            time.sleep(self.refreshtime)
+
+    def run(self):
+        self.process()
+
Index: online/main.py
===================================================================
--- online/main.py	(revision 17397eb7f5452453b8ebbb65d916ab405b41ec49)
+++ online/main.py	(revision 663d194797b7293fe31907ec29cca5430d0c2b79)
@@ -3,5 +3,4 @@
 import threading
 import neonIO
-#import mantidIO
 import time
 from Queue import Queue
@@ -11,7 +10,9 @@
 import cStringIO
 import configure
-
+import getCommand
+#from PyQt4 import QtGui
 
 if __name__ == '__main__':
+    #myapp=QtGui.QApplication(sys.argv)
     # ======Try to connect NEON server
     ip="10.1.53.240"
@@ -19,15 +20,157 @@
     _neon=neonIO.connectNeon(ip, port, 10.0)
     r=_neon.getServer()
+    #set command
+    _path="/GPPD/workspace/stateMachine/command"
+    _command=''
+    r.set(_path, _command)
     
-    # ======Initilize the configuration
-    conf=configure.getConfigure()
-    bList=conf.bankGroup
-    mList=conf.monitorGroup
-    neonpathDetPid, neonpathDetTof, neonpathDetValue=conf.getBankInputPath() 
-    neonpathMonPid, neonpathMonTof, neonpathMonValue=conf.getMonitorInputPath()
-    print "finish configuration!"
-    # ===Get data from NEON
-    myGetThread=neonIO.dataGet(r, 1, bList, mList,neonpathDetPid, neonpathDetTof, neonpathDetValue,neonpathMonPid, neonpathMonTof, neonpathMonValue)
-    myGetThread.start()
-    print "   INOF: myGetThread Started"
-    time.sleep(0.1)
+    print 'waiting . . .' 
+    status='waiting'
+    command=None
+    myCommandThread=getCommand.getCommand(r,0.1)
+    myCommandThread.start()
+    started=True
+    myGetThread=None 
+    #write statemachine
+    command=myCommandThread.command
+    while True:
+        if command==myCommandThread.command:
+            started=True
+        elif started:
+            command = myCommandThread.command
+            if status == 'waiting':
+                print 'waiting status cannot reveive any command'
+                status='unconfigured'
+ 
+            if command == 'configure':
+                if status == 'unconfigured':
+                    status = 'configuring'
+                    print "status change to configuring"
+                    myGetThread=neonIO.dataGet(r, 1)
+                    status = 'ready'
+                    print "status change to ready"
+                elif status == 'configuring':
+                    print "configuring status cannot receive configure command"
+                elif status == 'ready':
+                    print "ready status cannot receive configure command"
+                elif status == 'running':
+                    print "running status cannot receive configure command"
+                elif _status == 'paused':
+                    print "paused status cannot receive configure command" 
+                elif _status == 'stopped':
+                    print "stopped status cannot receive configure command" 
+                started=False
+
+            elif command == 'unconfigure':
+                if status == 'unconfigured':
+                    print "unconfigured status cannot receive unconfigure command"
+                elif status == 'configuring':
+                    print "configuring status cannot receive unconfigure command"
+                elif status == 'ready':
+                    status = 'unconfigured'
+                    print "status change to unconfigured"
+                elif status == 'running':
+                    print "running status cannot receive unconfigure command"
+                elif status == 'paused':
+                    print "paused status cannot receive unconfigure command"
+                elif status == 'stopped':
+                    print "stopped status cannot receive unconfigure command"
+                started=False
+
+            elif command == 'start':
+                if status == 'unconfigured':
+                    print "unconfigured status cannot receive start command"
+                elif status == 'configuring':
+                    print "configuring status cannot receive start command"
+                elif status == 'ready':
+                    print "begin to run!!!"
+                    myGetThread.start()
+                    status = 'running'
+                    print "status change to running"
+                elif status == 'running':
+                    print "running status cannot receive start command"
+                elif status == 'paused':
+                    print "paused status cannot receive start command"
+                elif status == 'stopped':
+                    print "stopped status cannot receive start command"
+                started=False
+
+            elif command == 'pause':
+                if status == 'unconfigured':
+                    print "unconfigured status cannot receive pause command"
+                elif status == 'configuring':
+                    print "configuring status cannot receive pause command"
+                elif status == 'ready':
+                    print "ready status cannot receive pause command"
+                elif status == 'running':
+                    myGetThread.pause()
+                    status = 'paused'
+                    print "status change to paused"
+                elif status == 'paused':
+                    print "paused status cannot receive pause command"
+                elif status == 'stopped':
+                    print "stopped status cannot receive pause command"
+                started=False
+                
+            elif command == 'resume':
+                if status == 'unconfigured':
+                    print "unconfigured status cannot receive resume command"
+                elif status == 'configuring':
+                    print "configuring status cannot receive resume command"
+                elif status == 'ready':
+                    print "ready status cannot receive resume command"
+                elif status == 'running':
+                    print "running status cannot receive resume command"
+                elif status == 'paused':
+                    myGetThread.resume()
+                    status = 'running'
+                    print "status change to runninig"
+                elif status == 'stopped':
+                    myGetThread.resume()
+                    status = 'running'
+                    print "status change to runninig"
+                started=False
+            
+            elif command == 'stop':
+                if status == 'unconfigured':
+                    print "unconfigured status cannot receive stop command"
+                elif status == 'configuring':
+                    print "configuring status cannot receive stop command"
+                elif status == 'ready':
+                    print "ready status cannot receive stop command"
+                elif status == 'running':
+                    myGetThread.stop()
+                    status = 'stopped'
+                    print "status change to stopped"
+                elif status == 'paused':
+                    print "paused status cannot receive stop command"
+                elif status == 'stopped':
+                    print "stopped status cannot receive stop command"
+                started=False
+
+            elif command == 'abort':
+                if status == 'unconfigured':
+                     print "unconfigured status cannot receive stop command"
+                elif status == 'configuring':
+                    status = 'unconfigured'
+                    print "status change to unconfigured"
+                elif status == 'ready':
+                    print "ready status cannot receive stop command"
+                elif status == 'running':
+                    myGetThread.terminate()
+                    status = 'ready'
+                elif status == 'paused':
+                    print "paused status cannot receive abort command"
+                elif status == 'stopped':
+                    print "stopped status cannot receive abort command"
+                started = False
+
+            print "status: ", status
+        #else:
+            #continue
+    #myGetThread=neonIO.dataGet(r, 1)
+    #myGetThread.start()
+    #time.sleep(1)
+    #print "   INOF: myGetThread Started"
+    #print myCommandThread.call, myCommandThread.command 
+    #sys.exit(myapp.exec_())
Index: online/neonIO.py
===================================================================
--- online/neonIO.py	(revision 535307e30751e99fc7fcd55d4f33b76d91e8f02d)
+++ online/neonIO.py	(revision 663d194797b7293fe31907ec29cca5430d0c2b79)
@@ -27,24 +27,28 @@
 import matplotlib.pyplot as plt
 import setDataToNeon
+import configure
 #from mantidIO import *
 
 class dataGet(QtCore.QThread):
 
-    def __init__(self, neonRedis, refreshtime, bankGroup, monitorGroup, neonpathDetPid, neonpathDetTof, neonpathDetValue, neonpathMonPid, neonpathMonTof, neonpathMonValue):
+    def __init__(self, neonRedis, refreshtime):
         QtCore.QThread.__init__(self)
 
         self.refreshtime=refreshtime
         self.neonRedis=neonRedis
-
-        self.neonpathDetPid=neonpathDetPid
-        self.neonpathDetTof=neonpathDetTof
-        self.neonpathDetValue=neonpathDetValue
-        self.neonpathMonPid=neonpathMonPid
-        self.neonpathMonTof=neonpathMonTof
-        self.neonpathMonValue=neonpathMonValue
-
-        self.bankGroup=bankGroup
-        self.monitorGroup=monitorGroup
-        
+        # configuration
+        conf=configure.Configure()
+        conf.getConfigure()
+        self.neonpathDetPid=conf.neonpathDetPid
+        self.neonpathDetTof=conf.neonpathDetTof
+        self.neonpathDetValue=conf.neonpathDetValue
+        self.neonpathMonPid=conf.neonpathMonPid
+        self.neonpathMonTof=conf.neonpathMonTof
+        self.neonpathMonValue=conf.neonpathMonValue
+
+        self.bankGroup=conf.bankGroup
+        self.monitorGroup=conf.monitorGroup
+        self.started = True        
+        self.stopped = False        
         self.modulenum_bank=[]
         self.modulenum_mon=[]
@@ -345,20 +349,50 @@
     def process(self):
         _be=time.time()
-        print "   INFO: getDataFromNeon", datetime.datetime.now()
-        self.getDataFromNeon()
-        print "   INFO: createWorkspace", datetime.datetime.now()
-        self.createWorkspace()
-        print "   INFO: reduceData", datetime.datetime.now()
-        self.reduceData()
-        print "   INFO: dataSet", datetime.datetime.now()
-        self.dataSet()
-        print "===================================="
-        print time.time()-_be, "seconds"
-        print "===================================="
+        if not self.stopped:
+            while not self.started:
+                pass
+            print "   INFO: getDataFromNeon", datetime.datetime.now()
+            self.getDataFromNeon()
+            while not self.started:
+                pass
+            if not self.stopped:
+                print "   INFO: createWorkspace", datetime.datetime.now()
+                self.createWorkspace()
+                while not self.started:
+                    pass
+                if not self.stopped:
+                    print "   INFO: reduceData", datetime.datetime.now()
+                    self.reduceData()
+                    while not self.started:
+                        pass
+                    if not self.stopped:
+                        print "   INFO: dataSet", datetime.datetime.now()
+                        self.dataSet()
+                        print "===================================="
+                        print time.time()-_be, "seconds"
+                        print "===================================="
+                    else:
+                        pass
+                else:
+                    pass
+            else:
+                pass
+        else:
+            pass
     
-    def start(self):
+    def run(self):
         while True:
             self.process()
             time.sleep(self.refreshtime)
+
+    def pause(self):
+        self.started=False
+    
+    def resume(self):
+        self.started = True
+        self.stopped = False
+
+    def stop(self):
+        self.stopped=True
 
 class connectNeon():
