Index: version-MWPC/RMmantid
===================================================================
--- version-MWPC/RMmantid	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
+++ version-MWPC/RMmantid	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -0,0 +1,1 @@
+nohup ./RMmantid.py>log & 
Index: version-MWPC/RMmantid.py
===================================================================
--- version-MWPC/RMmantid.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/RMmantid.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -1,4 +1,4 @@
 #!/usr/bin/python
-
+import sys
 import neonIO
 #import roi
@@ -39,4 +39,5 @@
         import logging
         from logging.handlers import RotatingFileHandler
+        #logging.basicConfig(level=logging.WARNING,
         logging.basicConfig(level=logging.DEBUG,
                 format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
@@ -82,7 +83,6 @@
     init=1
     r_write.set("/MR/stateMachine/status",init)
-
     myThread=[]
-    myThread.append(neonIO.neonIO(r_write, r_read,0.1,myDict,logger))
+    myThread.append(neonIO.neonIO(r_write, r_read,10,myDict,logger))
     myThread.append(getCommand.getCommand(r_write,r_read,1, myDict, logger))
     myThread.append(heartBeat.neonHeartBeat(r_write,r_read, 1, mypid))
Index: version-MWPC/com.py
===================================================================
--- version-MWPC/com.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/com.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -10,6 +10,6 @@
     #sentinel=Sentinel([('10.1.53.240', 9001),('10.1.53,240', 9011),('10.1.53.240', 9021)], socket_timeout=0.1)
     r=sentinel.master_for('neonmaster', socket_timeout=20, password='sanlie;123')
-    _path="/MR/control/command/mantid1"
-    #_path="/MR/control/command/pilot"
+    #_path="/MR/control/command/mantid1"
+    _path="/MR/control/command/pilot1"
     #_path="/MR/control/test"
     r.set(_path, sys.argv[1])
Index: version-MWPC/getCommand.py
===================================================================
--- version-MWPC/getCommand.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/getCommand.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -19,6 +19,6 @@
 
     def getCommand(self):
+        #_path="/MR/control/command/mantid"
         _path="/MR/control/command/mantid"
-        #_path="/MR/control/command/mantid"
         try:
             _json=self.neonRedis_read.get(_path)
@@ -46,12 +46,14 @@
         path='/MR/workspace/MantidData/neutroncounts'
         clearList.append(path)
-        path='/MR/workspace/MantidData/neutroncounts1'
-        clearList.append(path)
-        path='/MR/workspace/MantidData/neutroncounts2'
-        clearList.append(path)
-        path='/MR/workspace/MantidData/neutroncounts3'
-        clearList.append(path)
-        path='/MR/workspace/MantidData/neutroncounts4'
-        clearList.append(path)
+        path='/MR/workspace/MantidData/neutroncounts_roi'
+        clearList.append(path)
+        #path='/MR/workspace/MantidData/neutroncounts1'
+        #clearList.append(path)
+        #path='/MR/workspace/MantidData/neutroncounts2'
+        #clearList.append(path)
+        #path='/MR/workspace/MantidData/neutroncounts3'
+        #clearList.append(path)
+        #path='/MR/workspace/MantidData/neutroncounts4'
+        #clearList.append(path)
         path='/MR/workspace/MantidData/monitor/neutroncounts'
         clearList.append(path)
@@ -106,15 +108,10 @@
         clearList.append(path)
         
-        for i in range(4):
-            path = '/MR/workspace/MantidData/detector/xy_image/tube' + str(i + 1) + '/pos'
-            clearList.append(path)
-            path = '/MR/workspace/MantidData/detector/xy_image/tube' + str(i + 1) + '/counts'
-            clearList.append(path)
-            path = '/MR/workspace/MantidData/detector/xy_image/tube' + str(i + 1) + '/x'
-            clearList.append(path)
-            path = '/MR/workspace/MantidData/detector/xy_image/tube' + str(i + 1) + '/y'
-            clearList.append(path)
-            path = '/MR/workspace/MantidData/detector/xy_image/tube' + str(i + 1) + '/z'
-            clearList.append(path)
+        path='/MR/workspace/MantidData/detector/xy_image/x'
+        clearList.append(path)
+        path='/MR/workspace/MantidData/detector/xy_image/y'
+        clearList.append(path)
+        path='/MR/workspace/MantidData/detector/xy_image/value'
+        clearList.append(path)
 
         path = '/MR/workspace/MantidData/monitor1/xy_image/x'
@@ -134,8 +131,8 @@
                              
         for p in clearList:
-            try:
-                self.neonRedis_write.delete(p)
-            except:
-                pass
+            #try:
+            self.neonRedis_write.delete(p)
+            #except:
+            #    pass
 
     def stateMachine(self, command, status, commandList, statusList,myDict):
@@ -143,4 +140,5 @@
         if command == 0:
             if status == 1:
+                self.clearData()
                 myDict["configure"]= True
                 status = 3
@@ -157,5 +155,5 @@
         elif command == 2:
             if status == 3:
-                self.clearData()
+                #self.clearData()
                 myDict["running"]=True
                 status = 4
@@ -210,10 +208,10 @@
             else:
                 self.setCommand(_command)
-                print "new command: ", self.command
+                self.logger.warning("new command: "+str(self.command))
                 status=self.getStatus()
-                print "before statemachine: ", status
+                self.logger.warning("before statemachine: "+str(status))
                 tmp=self.stateMachine(self.command, status, self.commandList, self.statusList, self.myDict)
                 self.setStatus(tmp)
-                print "after statemachine: ",tmp
+                self.logger.warning("after statemachine: "+str(tmp))
             time.sleep(self.refreshtime)
 
Index: version-MWPC/instrument/detector_mwpc.xml
===================================================================
--- version-MWPC/instrument/detector_mwpc.xml	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/instrument/detector_mwpc.xml	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -23,18 +23,18 @@
     <type name="Bank01">
         <component type="panel" idfillbyfirst="x" idstart="100001" idstepbyrow="100">
-            <location name="module01" x="0.099" y="-0.099" z="2.07934">
+            <location name="module01" x="0.099" y="-0.099" z="2.095">
                 <rot val="180" axis-x="0.0" axis-y="1.0" axis-z="0.0" />
             </location>
         </component>
     </type>
-    <type is="rectangular_detector" name="panel" type="pixel" xpixels="100" xstep="0.002" xstart="0.0" ypixels="100" ystep="0.002" ystart="0.0">
+    <type is="rectangular_detector" name="panel" type="pixel" xpixels="92" xstep="0.0022" xstart="0.0" ypixels="50" ystep="0.004" ystart="0.0">
         <properties />
     </type>
     <type is="detector" name="pixel">
         <cuboid id="pixel-shape">
-            <left-front-bottom-point x="-0.001" y="-0.001" z="0.0" />
-            <left-front-top-point x="-0.001" y="0.001" z="0.0" />
-            <left-back-bottom-point x="-0.001" y="-0.001" z="-0.0001" />
-            <right-front-bottom-point x="0.001" y="-0.001" z="0.0" />
+            <left-front-bottom-point x="-0.0011" y="-0.002" z="0.0" />
+            <left-front-top-point x="-0.0011" y="0.002" z="0.0" />
+            <left-back-bottom-point x="-0.0011" y="-0.002" z="-0.0001" />
+            <right-front-bottom-point x="0.0011" y="-0.002" z="0.0" />
         </cuboid>
         <algebra val="pixel-shape" />
Index: version-MWPC/instrument/monitor01.xml
===================================================================
--- version-MWPC/instrument/monitor01.xml	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
+++ version-MWPC/instrument/monitor01.xml	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -0,0 +1,55 @@
+<instrument name="MR" valid-from   ="2012-04-29 00:00:00"
+                       valid-to     ="2050-01-01 00:00:00"
+               last-modified="2017-03-06 00:00:00">
+  <!--Created by DU-->
+  <!--DEFAULTS-->
+  <defaults>
+    <length unit="metre"/>
+    <angle unit="degree"/>
+    <reference-frame>
+    <!-- The z-axis is set parallel to and in the direction of the beam. the 
+           y-axis points up and the coordinate system is right handed. -->
+      <along-beam axis="z"/>
+      <pointing-up axis="y"/>
+      <handedness val="right"/>
+    </reference-frame>
+  </defaults>
+  <!--SOURCE-->
+  <component type="moderator">
+    <location z="-20.552"/>
+  </component>
+  <type is="Source" name="moderator"/>
+  <!--SAMPLE-->
+  <component type="sample-position">
+    <location x="0.0" y="0.0" z="0.0"/>
+  </component>
+  <type is="SamplePos" name="sample-position"/>
+  <!-- MONITOR-->
+  <component type="monitor1" >
+    <location/>
+  </component>
+
+  <type name="monitor1">
+    <component type="panel" idstart="2001" idfillbyfirst="x" idstepbyrow="32">
+        <location name="monitor1" x="0.0775" y="-0.0775" z="-0.6052" >
+            <rot val="180" axis-x="0.0" axis-y="1.0" axis-z="0.0" />
+        </location>
+    </component>
+  </type>
+
+  <!-- Rectangular Detector Panel (100x124)-->
+  <type is="rectangular_detector" name="panel" type="pixel" xpixels="32" xstart="0" xstep="0.005" ypixels="32" ystart="0" ystep="0.005">
+    <properties/>
+  </type>
+
+  <!-- Pixel for Detectors (100x124)-->
+  <type is="monitor" name="pixel">
+    <cuboid id="pixel-shape">
+      <left-front-bottom-point x="-0.0025" y="-0.0025" z="0.0"  />
+      <left-front-top-point  x="-0.0025" y="0.0025" z="0.0"  />
+      <left-back-bottom-point  x="-0.0025" y="-0.0025" z="-0.0001"  />
+      <right-front-bottom-point  x="0.0025" y="-0.0025" z="0.0"  />
+    </cuboid>
+    <algebra val="pixel-shape"/>
+  </type>
+</instrument>
Index: version-MWPC/neonIO.py
===================================================================
--- version-MWPC/neonIO.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
+++ version-MWPC/neonIO.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -12,4 +12,5 @@
 import math
 import path
+import subprocess
 #class moduleIO(multiprocessing.Process):
 class neonIO(threading.Thread):
@@ -24,4 +25,10 @@
         #self.detValue=[]
         #self.monValue=[]
+        self.tof=[]
+        self.detPid=[]
+        for i in range(4600):
+            self.detPid.append(100001+i)
+        for i in range(501):
+            self.tof.append(8000+i*64)        
 
     def getConf(self):
@@ -30,8 +37,23 @@
         _json=self.neonRedis_read.get(path)
         _conf=json.loads(_json)
+
+
         return _conf
 
+    def getSendOnline(self):
+        path="/MR/workspace/MantidData/SendOnline"
+        _json=self.neonRedis_read.get(path)
+        if _json is None:
+            return 0
+        else:
+            _tmp=jsonArray.jsonDecoder(_json)
+            return _tmp
+
+    def sendSendOnline(self):
+        path="/MR/workspace/MantidData/SendOnline"
+        self.neonRedis_write.set(path, json.dumps(0)) 
+
     def getROIcommand(self):
-        path="/MR/workspace/MantidData/roi"
+        path="/MR/workspace/MantidData/roi_mwpc"
         _json=self.neonRedis_read.get(path)
         if _json is None:
@@ -86,5 +108,18 @@
             #RotateInstrumentComponent(Workspace="sample_1", ComponentName="Bank01", X=0, Y=0, Z=1, Angle=90, RelativeRotation=False)
             #MoveInstrumentComponent(Workspace="sample_1", ComponentName="Bank01", X=0.017, Y=0, Z=0, RelativeRotation=False)
-            SaveNexus(InputWorkspace='sample_1', Filename='./detector.nxs')
+            judge=self.getSendOnline()
+            if judge==0:
+                pass
+            else:
+                SaveNexus(InputWorkspace='sample_1', Filename='./sample.nxs')
+                print 'save nexus!'
+                try:
+                    _cmd = 'scp sample.nxs root@10.1.26.157:/userData/BL02/'
+                    subprocess.check_call(_cmd, shell=True)
+                    self.logger.debug('send online data to cloud!') 
+                except:
+                    self.logger.debug('error in scp!')
+                self.sendSendOnline()                            
+
             if self.angle== 0:
                 pass
@@ -94,7 +129,7 @@
             pass
         if self.monJudge:
-            LoadCSNSRaw(OutputWorkspace="monitor", PixelID_bank=[0,1], TimeOfFlight_bank=[8,16], Counts_bank=[1,1], PixelID_monitor=self.monPid, TimeOfFlight_monitor=self.tof, Counts_monitor=self.monValue)
+            LoadCSNSRaw(OutputWorkspace="monitor", PixelID_bank=[0,1], TimeOfFlight_bank=[8,16], Counts_bank=[1,1], PixelID_monitor=self.monPid, TimeOfFlight_monitor=self.monTof, Counts_monitor=self.monValue)
             LoadInstrument(Workspace="monitor_2", Filename='./instrument/monitor01.xml', RewriteSpectraMap='True')
-            #SaveNexus(InputWorkspace='sample_2', Filename='./monitor1.nxs')
+            SaveNexus(InputWorkspace='monitor_2', Filename='./monitor1.nxs')
             #get I-tof I-wave
             #ConvertUnits(InputWorkspace='monitor_2',OutputWorkspace='__tmpD2',Target='dSpacing',AlignBins=True)
@@ -108,10 +143,15 @@
         if self.detJudge:
             #get I-wave I-tof
+            SumSpectra(InputWorkspace=wsname, OutputWorkspace="tofCounts", IncludeMonitors=False)
+            name=mtd['tofCounts']
+            a=sum(name.readY(0))
+            self.neonRedis_write.set('/MR/workspace/MantidData/neutroncounts_roi', json.dumps(a)) 
             ConvertUnits(InputWorkspace=wsname,OutputWorkspace='__tmp',Target='Wavelength',AlignBins=True)
-            Rebin(InputWorkspace="__tmp",OutputWorkspace="sample_wave_rebin", Params='1.8,0.001,6.8')
+            #Rebin(InputWorkspace="__tmp",OutputWorkspace="sample_wave_rebin", Params='1.8,0.001,6.8')
+            Rebin(InputWorkspace="__tmp",OutputWorkspace="sample_wave_rebin", Params='0.5,0.002,14.0')
             Qxy(InputWorkspace='sample_wave_rebin', OutputWorkspace='sample_Qxy', MaxQxy=0.25, DeltaQ=0.01, SolidAngleWeighting=False)
             ReplaceSpecialValues(InputWorkspace='sample_Qxy', OutputWorkspace='sample_Qxy',NaNValue=0, InfinityValue=0)
-            SumSpectra(InputWorkspace='__tmp', OutputWorkspace="waveCounts", IncludeMonitors=False)
-            ConvertUnits(InputWorkspace='waveCounts',OutputWorkspace='tofCounts',Target='TOF',AlignBins=True)
+            SumSpectra(InputWorkspace='sample_wave_rebin', OutputWorkspace="waveCounts", IncludeMonitors=False)
+            #ConvertUnits(InputWorkspace='waveCounts',OutputWorkspace='tofCounts',Target='TOF',AlignBins=True)
             
             #LoadInstrument(Workspace="tofCounts", Filename='./instrument/onePid.xml', RewriteSpectraMap='True')
@@ -258,4 +298,5 @@
         yaxis=[]
         name=mtd[wsname]
+        v=[[] for i in range(name.getNumberHistograms())]
         for j in range(name.getNumberHistograms()):
             counts.append(sum(name.readY(j)))
@@ -265,11 +306,11 @@
             xaxis.append(_pos.X())
             yaxis.append(_pos.Y())
-        #print "num: ", j
+            v[j].append((_pos.X())*100)
+            v[j].append((_pos.Y())*100)
+            v[j].append(sum(name.readY(j)))
         xaxis=list(set(xaxis))
         yaxis=list(set(yaxis))
-        #print yaxis
         xaxis.sort()
         yaxis.sort()
-        #print yaxis
         for i in range(len(xaxis)):
             xaxis[i]=xaxis[i]*1000
@@ -282,12 +323,9 @@
                 vaxis[p].append(counts[num])
                 num=num+1
-        yaxis.append(yaxis[-1]+(yaxis[-1]-yaxis[-2]))
-        xaxis.append(xaxis[-1]+(xaxis[-1]-xaxis[-2]))
-        #print len(xaxis), len(yaxis)
         self.neonRedis_write.set(prepath+"/xy_image/x", jsonArray.jsonEncoder(xaxis))
         self.neonRedis_write.set(prepath+"/xy_image/y", jsonArray.jsonEncoder(yaxis))
         self.neonRedis_write.set(prepath+"/xy_image/value", jsonArray.jsonEncoder(vaxis))
+        self.neonRedis_write.set(prepath+"/xy_image/wechat", jsonArray.jsonEncoder(v))
         self.logger.debug("finish set XY data for monitor or detector")
-
 
     def roiProcess(self, pos):
@@ -302,6 +340,4 @@
             XYdata[1].append(name.getDetector(j).getRelativePos().Y()*1000)
         index=[]
-        #pos[3]=pos[3]+50
-        #pos[2]=pos[2]+25
         if pos[1]>pos[3]:
             ymax=pos[1]
@@ -323,9 +359,10 @@
             else:
                 pass
-        print "ROI: ",index
+        self.logger.debug( "ROI: "+str(index))
         ExtractSpectra(InputWorkspace='sample_1', OutputWorkspace='roiWS', WorkspaceIndexList=index)
 
     def dataSet(self):
         if self.confRoi['roi']:
+            self.logger.debug("set roi data!!!")
             self.set1DdataToNeon("tofCounts", "/MR/workspace/MantidData/ROI/raw/Itof/tof","/MR/workspace/MantidData/ROI/raw/Itof/counts")
             self.set1DdataToNeon("waveCounts", "/MR/workspace/MantidData/ROI/raw/Iwave/wavelength","/MR/workspace/MantidData/ROI/raw/Iwave/counts")
@@ -334,11 +371,14 @@
             tmp=self.setItheta("roiWS", 7, 0.1, 50, "/MR/workspace/MantidData/ROI/")
         else:
-            if self.detJudge:
-                self.set1DdataToNeon("tofCounts", "/MR/workspace/MantidData/raw/Itof/tof","/MR/workspace/MantidData/raw/Itof/counts")
-                #self.setIQdataToNeon("qCounts_M", "/MR/workspace/MantidData/reduction/monitor/IQ/q","/MR/workspace/MantidData/reduction/monitor/IQ/counts")
-                self.setIQdataToNeon("qCounts_P", "/MR/workspace/MantidData/reduction/PC/IQ/q","/MR/workspace/MantidData/reduction/PC/IQ/counts")
-                self.set1DdataToNeon("waveCounts", "/MR/workspace/MantidData/raw/Iwave/wavelength","/MR/workspace/MantidData/raw/Iwave/counts")
-            else:
-                pass
+            pass
+        self.logger.debug("set whole data!!!")
+        if self.detJudge:
+            self.set1DdataToNeon("tofCounts", "/MR/workspace/MantidData/raw/Itof/tof","/MR/workspace/MantidData/raw/Itof/counts")
+            #self.setIQdataToNeon("qCounts_M", "/MR/workspace/MantidData/reduction/monitor/IQ/q","/MR/workspace/MantidData/reduction/monitor/IQ/counts")
+            self.setIQdataToNeon("qCounts_P", "/MR/workspace/MantidData/reduction/PC/IQ/q","/MR/workspace/MantidData/reduction/PC/IQ/counts")
+            self.set1DdataToNeon("waveCounts", "/MR/workspace/MantidData/raw/Iwave/wavelength","/MR/workspace/MantidData/raw/Iwave/counts")
+            print 'set IQ and Iwave to neon!'
+        else:
+            pass
         if self.monJudge:
             self.set1DdataToNeon("MtofCounts", "/MR/workspace/MantidData/monitor1/tof","/MR/workspace/MantidData/monitor1/counts")
@@ -346,5 +386,5 @@
             self.set1DdataToNeon("MwaveCounts", "/MR/workspace/MantidData/monitor1/wave","/MR/workspace/MantidData/monitor1/wcounts")
             self.logger.warning("finish set monitor1 wave counts")
-            #self.setXYData("monitor_2", "/MR/workspace/MantidData/monitor1")
+            self.setXYData("monitor_2", "/MR/workspace/MantidData/monitor1")
 
         else:
@@ -352,12 +392,25 @@
         # For Tab1 and Tab4 2D data: detector XY hot, monitor XY hot
         if self.detJudge:
-            self.setXYData("sample_1", "/MR/workspace/MantidData/detector")
-            self.setIQxy()
-            # For Tab2 and Tab3 1D and 2D data: tube pos-counts and XY hot
-            # set Tab1 pid counts
-            self.setPidCounts()
+            try:
+                self.setXYData("sample_1", "/MR/workspace/MantidData/detector")
+            except:
+                self.logger.warning("error in set XY data")
+            try:
+                self.setIQxy()
+            except:
+                self.logger.warning("error in set IQxy data")
+                # For Tab2 and Tab3 1D and 2D data: tube pos-counts and XY hot
+                # set Tab1 pid counts
+            try:
+                self.setPidCounts()
+            except:
+                self.logger.warning("error in set pid counts data")
             # set Tab1 Itheta
-            theta=[]
-            theta=self.setItheta("sample_1", 7, 0.1, 50, "/MR/workspace/MantidData/")
+            try:
+                theta=[]
+                theta=self.setItheta("sample_1", 7, 0.1, 50, "/MR/workspace/MantidData/")
+            except:
+                self.logger.warning("error in set Itheta data")
+            
             # set Tab6 IQxyz(error:float division by zero)
             #self.setIQxyz(theta)
@@ -368,10 +421,23 @@
         if self.myDict['configure']:
             if self.confJudge:
+                try:
+                    self.conf=self.getConf()
+                except:
+                    pass
+                try:
+                    self.delay=int(self.conf["detectorDelay"])
+                    self.angle=float(self.conf["detectorAngle"])
+                except:
+                    self.delay = 0
+                    self.angle = 0
+                self.logger.warning("angle = "+str(self.angle)+"|| delay = "+ str(self.delay))
+                '''
                 self.tof=[]
                 self.detPid=[]
-                self.monPid=[]
                 try:
                     self.detPid=self.get1Ddata("/MR/workspace/detector/module01/pid")
-                    self.tof=self.get1Ddata("/MR/workspace/detector/module01/tof")
+                    tmp=self.get1Ddata("/MR/workspace/detector/module01/tof")
+                    for ix in tmp:
+                        self.tof.append(ix+self.delay)
                     print detPid, self.tof
                     self.detJudge=True
@@ -379,17 +445,14 @@
                     self.logger.warning("no data in get pid and tof for detector")
                     self.detJudge=False
+                '''
+                self.monPid=[]
+                self.monTof=[]
                 try:
                     self.monPid=self.get1Ddata("/MR/workspace/monitor1/pid")
-                    #self.tof=self.get1Ddata("/MR/workspace/monitor1/tof")
+                    self.monTof=self.get1Ddata("/MR/workspace/monitor1/tof")
                     self.monJudge=True
                 except:
                     self.logger.warning("no data in get pid and tof for monitor")
                     self.monJudge=False
-                try:
-                    self.conf=self.getConf()
-                    self.angle=float(self.conf["detectorAngle"])
-                except:
-                    self.angle = 0
-                self.logger.warning("angle="+str(self.angle))
                 path.clearRedis(self.neonRedis_write)
                 self.logger.debug("finish new configuring")
@@ -430,5 +493,6 @@
                     pass
                 if self.monJudge:
-                    if(len(self.monValue)!=(len(self.tof)-1)*len(self.monPid)):
+                    if(len(self.monValue)!=(len(self.monTof)-1)*len(self.monPid)):
+                        print len(self.monValue), len(monTof), len(self.monPid) 
                         self.logger.warning("data size doesn't match for monitor")
                         self.monJudge=False
@@ -453,4 +517,10 @@
                             print "position of ROI: ",self.confRoi['pos']
                             self.roiProcess(self.confRoi['pos'])
+                            '''
+                            SumSpectra(InputWorkspace='roiWS', OutputWorkspace="tCounts", IncludeMonitors=False)
+                            name=mtd['tCounts']
+                            a=sum(name.readY(0))
+                            self.neonRedis_write.set('/MR/workspace/MantidData/neutroncounts', json.dumps(a)) 
+                            '''
                             self.wsProcess('roiWS')
                         else:
@@ -463,9 +533,8 @@
                         self.dataSet()
                         print time.time()-be1, 'seconds in dataSet!'
-                        try:
-                            shutil.move("./detector.nxs","./tmp/detetor.nxs" )
-                        except:
-                            self.logger.warning("no detector nexus file!!!")
                         #try:
+                        #    shutil.move("./detector.nxs","./tmp/detetor.nxs" )
+                        #except:
+                        #    self.logger.warning("no detector nexus file!!!")
                         #    shutil.move("./monitor1.nxs","./tmp/monitor1.nxs" )
                         #except:
@@ -473,5 +542,5 @@
 
                         #DeleteWorkspace(Workspace='sample')
-                        self.logger.debug("time is "+str(time.time()-be)+" seconds!!!")
+                        self.logger.debug("finish time is "+str(time.time()-be)+" seconds!!!")
                     '''
                     except:
@@ -490,6 +559,9 @@
         while True:
             self.detJudge=True
-            self.monJudge=False
-            self.process()
-            time.sleep(5)
-
+            self.monJudge=True
+            try:
+                self.process()
+                time.sleep(0.5)
+            except:
+                pass
+
Index: version-MWPC/res.dat
===================================================================
--- version-MWPC/res.dat	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
+++ version-MWPC/res.dat	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -0,0 +1,421 @@
+0;2.976g
+0;2.837g
+0;2.933g
+0;3.097g
+0;2.839g
+0;3.079g
+0;2.976g
+0;2.858g
+0;2.981g
+0;2.839g
+0;3.048g
+0;2.979g
+0;2.980g
+0;2.840g
+0;2.842g
+0;2.984g
+0;2.841g
+0;2.933g
+0;2.840g
+0;2.841g
+0;3.042g
+0;2.981g
+0;2.936g
+0;2.841g
+0;2.980g
+0;2.842g
+0;2.925g
+0;2.981g
+0;2.968g
+0;2.842g
+0;2.964g
+0;2.841g
+0;2.841g
+0;2.982g
+0;2.842g
+0;3.084g
+0;2.982g
+0;2.973g
+0;2.842g
+0;2.982g
+0;2.843g
+0;2.983g
+0;2.844g
+0;3.029g
+0;2.983g
+0;3.029g
+0;2.844g
+0;2.984g
+0;2.844g
+0;3.030g
+0;2.984g
+0;2.936g
+0;2.844g
+0;2.984g
+0;2.844g
+0;2.920g
+0;2.983g
+0;2.845g
+0;2.939g
+0;2.984g
+0;2.963g
+0;2.845g
+0;2.985g
+0;2.845g
+0;3.077g
+0;2.984g
+0;2.938g
+0;2.844g
+0;2.983g
+0;2.843g
+0;3.024g
+0;2.984g
+0;2.938g
+0;2.844g
+0;2.985g
+0;2.844g
+0;2.945g
+0;2.984g
+0;2.845g
+0;2.938g
+0;2.844g
+0;2.979g
+0;2.845g
+0;2.843g
+0;2.985g
+0;2.844g
+0;3.065g
+0;2.985g
+0;2.938g
+0;2.845g
+0;2.985g
+0;2.845g
+0;2.936g
+0;2.983g
+0;2.938g
+0;2.845g
+0;2.985g
+0;2.845g
+0;2.915g
+0;2.985g
+0;2.846g
+0;2.974g
+0;2.845g
+0;2.986g
+0;2.846g
+0;2.848g
+0;2.988g
+0;2.847g
+0;2.938g
+0;2.894g
+0;2.970g
+0;2.846g
+0;2.846g
+0;2.986g
+0;2.845g
+0;3.042g
+0;2.986g
+0;2.939g
+0;2.847g
+0;2.986g
+0;2.846g
+0;2.846g
+0;2.988g
+0;2.848g
+0;2.939g
+0;2.987g
+0;2.980g
+0;2.848g
+0;2.986g
+0;2.846g
+0;3.000g
+0;2.987g
+0;2.939g
+0;2.845g
+0;2.988g
+0;2.847g
+0;2.856g
+0;3.022g
+0;2.846g
+0;2.941g
+0;2.848g
+0;2.986g
+0;2.847g
+0;2.846g
+0;2.988g
+0;2.848g
+0;2.913g
+0;2.990g
+0;2.846g
+0;2.942g
+0;2.849g
+0;2.972g
+0;2.845g
+0;2.848g
+0;2.987g
+0;2.848g
+0;3.095g
+0;2.985g
+0;2.984g
+0;2.849g
+0;2.986g
+0;2.848g
+0;3.006g
+0;2.988g
+0;2.941g
+0;2.849g
+0;2.989g
+0;2.850g
+0;2.894g
+0;2.988g
+0;2.849g
+0;2.942g
+0;2.848g
+0;2.972g
+0;2.847g
+0;2.849g
+0;2.989g
+0;2.850g
+0;3.036g
+0;2.987g
+0;3.034g
+0;2.851g
+0;2.849g
+0;2.988g
+0;2.848g
+0;2.927g
+0;2.990g
+0;2.941g
+0;2.847g
+0;2.989g
+0;2.851g
+0;3.004g
+0;2.989g
+0;2.942g
+0;2.849g
+0;2.989g
+0;2.848g
+0;2.857g
+0;2.991g
+0;2.850g
+0;3.097g
+0;2.990g
+0;2.961g
+0;2.850g
+0;2.849g
+0;2.990g
+0;2.849g
+0;2.942g
+0;2.988g
+0;2.943g
+0;2.850g
+0;2.989g
+0;2.850g
+0;2.850g
+0;2.990g
+0;2.851g
+0;2.856g
+0;2.989g
+0;2.954g
+0;2.848g
+0;2.848g
+0;2.990g
+0;2.848g
+0;3.019g
+0;2.989g
+0;2.980g
+0;2.852g
+0;2.980g
+0;2.849g
+0;2.849g
+0;2.988g
+0;2.850g
+0;3.047g
+0;2.989g
+0;2.943g
+0;2.849g
+0;2.989g
+0;2.850g
+0;2.927g
+0;2.989g
+0;2.849g
+0;2.943g
+0;2.848g
+0;2.948g
+0;2.850g
+0;2.989g
+0;2.850g
+0;3.065g
+0;2.991g
+0;2.982g
+0;2.850g
+0;2.989g
+0;2.850g
+0;2.993g
+0;2.988g
+0;2.941g
+0;2.849g
+0;2.990g
+0;2.849g
+0;2.848g
+0;2.991g
+0;2.850g
+0;3.029g
+0;2.850g
+0;2.949g
+0;2.850g
+0;2.991g
+0;2.850g
+0;3.033g
+0;2.990g
+0;2.986g
+0;2.849g
+0;2.988g
+0;2.851g
+0;2.973g
+0;2.989g
+0;2.943g
+0;2.851g
+0;2.979g
+0;2.850g
+0;2.849g
+0;2.988g
+0;2.849g
+0;3.062g
+0;2.989g
+0;2.986g
+0;2.850g
+0;2.991g
+0;2.849g
+0;2.933g
+0;2.990g
+0;2.850g
+0;2.945g
+0;2.850g
+0;3.009g
+0;2.850g
+0;2.851g
+0;2.990g
+0;2.850g
+0;2.942g
+0;2.990g
+0;2.946g
+0;2.851g
+0;2.990g
+0;2.850g
+0;2.956g
+0;2.989g
+0;2.982g
+0;2.850g
+0;2.991g
+0;2.851g
+0;2.899g
+0;2.992g
+0;2.850g
+0;2.944g
+0;2.851g
+0;2.990g
+0;2.852g
+0;2.851g
+0;3.030g
+0;2.851g
+0;2.943g
+0;2.991g
+0;3.039g
+0;2.849g
+0;2.990g
+0;2.851g
+0;3.002g
+0;2.989g
+0;2.944g
+0;2.850g
+0;2.988g
+0;2.850g
+0;2.852g
+0;2.993g
+0;2.851g
+0;2.944g
+0;2.852g
+0;2.989g
+0;2.851g
+0;2.850g
+0;2.991g
+0;2.851g
+0;3.054g
+0;2.991g
+0;2.945g
+0;2.854g
+0;2.992g
+0;2.853g
+0;3.030g
+0;2.991g
+0;2.990g
+0;2.850g
+0;2.991g
+0;2.851g
+0;3.013g
+0;2.991g
+0;2.946g
+0;2.850g
+0;2.990g
+0;2.851g
+0;2.971g
+0;2.992g
+0;2.945g
+0;2.852g
+0;2.991g
+0;2.851g
+0;2.944g
+0;2.991g
+0;2.852g
+0;2.944g
+0;2.852g
+0;2.991g
+0;2.851g
+0;2.862g
+0;2.990g
+0;2.852g
+0;2.945g
+0;2.852g
+0;2.992g
+0;2.852g
+0;2.863g
+0;2.991g
+0;2.853g
+0;2.945g
+0;2.991g
+0;2.978g
+0;2.850g
+0;2.851g
+0;2.991g
+0;2.853g
+0;3.069g
+0;2.991g
+0;2.990g
+0;2.852g
+0;2.991g
+0;2.853g
+0;3.053g
+0;2.994g
+0;2.946g
+0;2.852g
+0;2.992g
+0;2.852g
+0;2.973g
+0;2.991g
+0;2.945g
+0;2.852g
+0;2.992g
+0;2.853g
+0;2.942g
+0;2.991g
+0;2.985g
+0;2.852g
+0;2.993g
+0;2.852g
+0;2.875g
+0;2.992g
+0;2.852g
+0;2.945g
+0;2.852g
+0;2.992g
Index: version-MWPC/test.py
===================================================================
--- version-MWPC/test.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
+++ version-MWPC/test.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -0,0 +1,5 @@
+import subprocess
+
+_cmd = 'scp *.nxs pilot@10.1.31.184:~/Desktop/'
+subprocess.check_call(_cmd, shell=True)
+print 'ok'
Index: version-MWPC/test/hb_com.py
===================================================================
--- version-MWPC/test/hb_com.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/test/hb_com.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -19,4 +19,5 @@
 
     path='/MR/control/command/mantid' 
+    path="/MR/workspace/MantidData/roi_mwpc" 
     path2='/MR/heartbeat/mantid'
     path3='/MR/heartbeat/pilot' 
@@ -24,5 +25,5 @@
     y=r_read.get(path2)
     z=r_read.get(path3)
-   
+  
     print x, y
     print x, z
Index: version-MWPC/test/mantidData.py
===================================================================
--- version-MWPC/test/mantidData.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/test/mantidData.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -20,15 +20,19 @@
     r_read = r.getRedisRead()
 
+    #name='raw/Iwave'
+    name='/reduction/PC/IQ'
     #name=sys.argv[1]
     #path='/MR/workspace/MantidData/'+name+'/tof' 
     #path2='/MR/workspace/MantidData/'+name+'/counts' 
-    #path='/MR/workspace/MantidData/'+name+'/q' 
-    #path2='/MR/workspace/MantidData/'+name+'/intensity' 
-    #path='/MR/workspace/MantidData/'+name+'/wave' 
-    #path2='/MR/workspace/MantidData/'+name+'/intensity' 
+    path1='/MR/workspace/MantidData/'+name+'/q' 
+    path2='/MR/workspace/MantidData/'+name+'/intensity' 
+    path1='/MR/workspace/MantidData/raw/Itof/tof'
+    path2='/MR/workspace/MantidData/raw/Itof/counts'
+    #path1='/MR/workspace/MantidData/'+name+'/wavelength' 
+    #path2='/MR/workspace/MantidData/'+name+'/counts' 
     #path='/MR/workspace/MantidData/'+name+'/xy_image/x' 
-    path1='/MR/workspace/MantidData/detector/xy_image/x' 
-    path2='/MR/workspace/MantidData/detector/xy_image/y' 
-    path3='/MR/workspace/MantidData/detector/xy_image/value' 
+    #path1='/MR/workspace/MantidData/detector/xy_image/x' 
+    #path2='/MR/workspace/MantidData/detector/xy_image/y' 
+    #path3='/MR/workspace/MantidData/detector/xy_image/value' 
     #path1="/MR/workspace/MantidData/detector/xy_image/tube2/x"
     #path2="/MR/workspace/MantidData/detector/xy_image/tube2/y"
@@ -40,9 +44,9 @@
     #path1="/MR/workspace/MantidData/reduction/PC/IQ/q"
     #path2="/MR/workspace/MantidData/reduction/PC/IQ/counts"
-    #path="/MR/workspace/MantidData/monitor1/tof"
+    #path1="/MR/workspace/MantidData/monitor1/tof"
     #path2="/MR/workspace/MantidData/monitor1/counts"
-    path1='/MR/workspace/MantidData/IQxy/x'
-    path2='/MR/workspace/MantidData/IQxy/y'
-    path3='/MR/workspace/MantidData/IQxy/counts'
+    #path1='/MR/workspace/MantidData/IQxy/x'
+    #path2='/MR/workspace/MantidData/IQxy/y'
+    #path3='/MR/workspace/MantidData/IQxy/counts'
     x=r_read.get(path1)
     #x1=r_read.get(path1)
@@ -50,9 +54,11 @@
     y=r_read.get(path2)
     y=jsonArray.jsonDecoder(y)
-    v=r_read.get(path3)
-    v=jsonArray.jsonDecoder(v)
-    print len(x),len(y)
-    print len(v),len(v[0])
-    #print x,y,v
+    #v=r_read.get(path3)
+    #v=jsonArray.jsonDecoder(v)
+    print x,y,sum(y)
+    sys.exit()
+    #print len(x),len(y)
+    #print len(v),len(v[0])
+    #print x#,y#,v
     #print len(x), len(v)
-
+    print sum(y)
Index: version-MWPC/test/neutronC.py
===================================================================
--- version-MWPC/test/neutronC.py	(revision 4b69a653ed6fc929b38a7e32006898a747528069)
+++ version-MWPC/test/neutronC.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -17,4 +17,5 @@
 
     path="/MR/workspace/MantidData/neutroncounts"
+    #path="/MR/workspace/MantidData/monitor/neutroncounts"
     tmp=r_read.get(path)
     tmp=json.loads(tmp)
Index: version-MWPC/test/rawData.py
===================================================================
--- version-MWPC/test/rawData.py	(revision cb8510a3aec6557879e6f268e9d35ad8c99310ef)
+++ version-MWPC/test/rawData.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -21,19 +21,20 @@
     r_read = r.getRedisRead()
     #path2='/MR/workspace/MantidData/monitor/neutroncounts'
-    #path2='/MR/workspace/monitor1/pid' 
+    #path='/MR/workspace/monitor1/pid' 
+    #path1='/MR/workspace/monitor1/tof' 
     path1='/MR/workspace/detector/module01/pid' 
     path2='/MR/workspace/detector/module01/tof' 
     path3='/MR/workspace/detector/module01/value' 
-    #path1='/MR/workspace/monitor1/value'
-    #x1=r_read.get(path1)
-    #x2=r_read.get(path2)
+    #path2='/MR/workspace/monitor1/value'
+    x1=r_read.get(path1)
+    x2=r_read.get(path2)
     y=r_read.get(path3)
-    #print x2
+    #print x1,x2
     y=jsonArray.jsonDecoder(y)
-    #x1=jsonArray.jsonDecoder(x1)
-    #x2=jsonArray.jsonDecoder(x2)
-    #print x1#, x2
+    x1=jsonArray.jsonDecoder(x1)
+    x2=jsonArray.jsonDecoder(x2)
+    #print x1, x2
     #print len(x1), len(x2), len(y), len(y[0])
-    
+    print len(x2) 
     #print x1 
     #print mod
Index: version-MWPC/test/sendOnline.py
===================================================================
--- version-MWPC/test/sendOnline.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
+++ version-MWPC/test/sendOnline.py	(revision 72971aeec286236fbf8e40f546ae64a4cb838446)
@@ -0,0 +1,51 @@
+import jsonArray
+import time
+import json
+import connect
+import sys
+import numpy
+
+if __name__ == '__main__':
+    # ======Try to connect NEON server
+  
+
+    ip_port =  [('10.1.31.116', 9001), ('10.1.31.116',9001)]
+    passwd = 'sanlie;123'
+
+    r= connect.connectNeon(ip_port, passwd, 10)
+    r_read = r.getRedisRead()
+    path1='/MR/workspace/detector/module01/pid' 
+    path2='/MR/workspace/detector/module01/tof' 
+    path3='/MR/workspace/detector/module01/value' 
+    pids=r_read.get(path1)
+    tof=r_read.get(path2)
+    v=r_read.get(path3)
+    pids=jsonArray.jsonDecoder(pids)
+    tof=jsonArray.jsonDecoder(tof)
+    v=jsonArray.jsonDecoder(v)
+    value=[]
+    for ix in v:
+        for iy in ix:
+            value.append(iy)
+    LoadCSNSRaw(OutputWorkspace="sample", PixelID_bank=self.detPid, TimeOfFlight_bank=self.tof, Counts_bank=self.detValue, PixelID_monitor=[0,1], TimeOfFlight_monitor=[8,16], Counts_monitor=[1,1])
+    #print x1#, x2
+    #print len(x1), len(x2), len(y), len(y[0])
+    
+    #print x1 
+    #print mod
+    #print "dim of monitor: ",numpy.array(mon).shape
+    #a=0
+    b=0
+    for ix in y:
+        b+=sum(ix)
+    print "counts: ",b
+    #'''
+    '''
+    tube=1
+    num=0
+    for iy in mod:
+        if(num>=300*(tube-1) and num<300+300*(tube-1)):
+            b+=sum(iy)
+            print num, ",  counts:",sum(iy)
+        num=num+1
+    '''
