Index: drone/configure.xml
===================================================================
--- drone/configure.xml	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/configure.xml	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<configure  name="MR" valid-from="2017-01-29 00:00:00" valid-to="2050-01-29 00:00:00" last-modified="2017-06-29 00:00:00">
+    <type name="Bank1">
+        <component name="module01" moduleNum="1" server="Service_1" num="0" idstart="100001" pixels="1200" />
+	<component name="monitor1" idstart="3110001" pixels="1024" /> 
+   </type>
+    <tofInformation tofstart="0" tofstep="8" tofbin="2500" unit="microsecond" />
+    <command reductionCommand="False" />
+</configure>
Index: drone/module01
===================================================================
--- drone/module01	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/module01	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
@@ -0,0 +1,2 @@
+./module01.py>> /dev/null 2>&1
+#./module01.py &
Index: drone/module01.py
===================================================================
--- drone/module01.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/module01.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+# author: H.L. TIAN 2017
+
+#import Sniper
+import DroNECore
+import DroNECore.PyIncident       as PI
+import CtrlSvc.PushMatrixIncident as PMI
+import CtrlSvc.PushHistIncident   as PHI
+import CtrlSvc.HeartBeatIncident  as HBI
+import CtrlSvc.NeonRPCIncident    as NRI
+import CtrlSvc.NeonRPCTask        as NRT
+import CtrlSvc.NeonUpdateDataTask as NUT
+import NEON
+import json
+import time
+import redis
+import os
+
+class RedisRemoteData:
+    def __init__(self, ip, path):
+        from redis.sentinel import Sentinel
+        sentinel=Sentinel(ip, socket_timeout=10)
+        self.server = sentinel.master_for('neonmaster', socket_timeout=200, password='sanlie;123', db=0)
+        self.path   = path
+
+    def setData(self, data):
+        self.data = data
+
+    def dump(self):
+        self.server.set(self.path, self.data)
+
+    def getData(self):
+        return self.data
+
+    def load(self):
+        self.data = self.server.get(self.path)
+
+def App(in_module='', in_redisip='', in_cron=1):
+    m_modulename = in_module#'module131'
+    m_redisip    = in_redisip#'10.1.33.141'
+    m_cron       = in_cron#15
+
+    #from xml.etree import ElementTree as ET
+    #root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
+    #tof  = root.find('tofInformation')
+    #m_tofstart= int(tof.attrib['tofstart'])*factor
+    #m_tofstep = int(tof.attrib['tofstep'])*factor 
+    #m_tofbins = int(tof.attrib['tofbin'])
+    #factor = 40  # 25ns to 1us
+    factor = 80  # 12.5ns to 1us
+    m_tofstart= 0*factor
+    m_tofstep = 16*factor # indeed 16 
+    m_tofbins = 2500
+    
+    m_moduleinfo={}
+    m_moduleinfo['num']='0'
+    m_moduleinfo['idstart']=100001
+    m_moduleinfo['idsize']=1200
+        
+    path  = '/MR/workspace/detector/'+m_modulename
+
+    m_taskMatrix = RedisRemoteData(m_redisip, path+"/value")
+    m_taskTOF    = RedisRemoteData(m_redisip, path+"/tof")
+    m_taskPID    = RedisRemoteData(m_redisip, path+"/pid")
+    toflist = [m_tofstep+i*m_tofstep for i in xrange(m_tofbins+1)]
+    m_taskTOF.setData(json.dumps(toflist))
+    m_taskTOF.dump()
+
+    idstart = int(m_moduleinfo['idstart'])
+    idsize  = int(m_moduleinfo['idsize'])
+    pidlist = [i+idstart for i in xrange(idsize)]
+    m_taskPID.setData(json.dumps(pidlist))
+    m_taskPID.dump()
+    
+    m_taskheartbeat = RedisRemoteData(m_redisip, \
+                    '/MR/heartbeat/detector/'+m_modulename)
+    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running', \
+                                    hit = 0, event = 0, pulse = 0, idx = os.getpid()))
+    m_taskheartbeat.dump()
+
+    m_configure = {"pidstart":idstart,"pidsize":idsize}
+    task = DroNECore.DroNEOnline("task")
+    task.asTop()
+    task.setLogLevel(2)
+   
+    ## ===========================
+    m_neonRedis = NEON.Neon.NeonRedisSentinel(m_redisip, i_socket_timeout=0.1, \
+                                           master_name='neonmaster', master_timeout = 120, master_password='sanlie;123', \
+                                           idb = 0, isWritable = True) # server mode, set msgs to Redis
+    servpob = NEON.Neon.NeonService.POBox(m_neonRedis, '/MR/process/detector', 'server:'+m_modulename)
+    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox = servpob, recvPOBox = servpob, isServer=True)
+    nr = NRT.NeonRPCTask("NeonRPC", servrpc, remotedata = m_taskheartbeat)
+
+    import CtrlSvc
+    ct = DroNECore.CtrlTask("ctrl")
+    pi = PMI.PushMatrixCronIncident("PushMatrix", cron = m_cron, \
+                                    repeatable = True, remotedata = m_taskMatrix,\
+                                    configure = m_configure)
+    hi = HBI.HeartBeatCronIncident("HeartBeat", cron = 2, repeatable = True, remotedata = m_taskheartbeat)
+    ni = NRI.NeonRPCCronIncident("NeonRPC", cron = 1, repeatable = True)
+    ct.add(hi)
+    ct.add(ni)
+    ct.add(pi)
+ 
+    ## ===========================
+    nu = NUT.NeonUpdateDataTask("UpdateRemoteData", remotedata = m_taskMatrix, configure=m_configure)
+    ## ===========================
+    import DataSvc
+    task.property("svcs").append("MRDataSvc/DataSvc")
+    task.property("svcs").append("CtrlSvc")
+    task.property("svcs").append("He3TRawDataInputSvc/DataInputSvc")
+    task.property("svcs").append("DimRecvSvc/DataProvideSvc")
+
+    iDat = task.find("DataSvc")
+    iSvc = task.find("DataInputSvc")
+    iPvd = task.find("DataProvideSvc")
+
+    dimsrvname = "dimserver/TEST_SWAP_"+m_moduleinfo['num']
+    
+    iPvd.property("DataSize").set(1000000)
+    iPvd.property("DimServerName").set(dimsrvname)
+    iSvc.property("BuffSize").set(1000000)
+
+    iSvc.show()
+    iPvd.show()
+
+    import Algorithms
+    task.property("algs").append("MRHe3TRecAlg")
+    task.property("algs").append("MRHe3TMapAlg")
+    task.property("algs").append("RunningInfAlg")
+    #task.property("algs").append("DumpAlg")
+
+    iRun = task.find("RunningInfAlg")
+    iRun.property("TofStart").set(m_tofstart)
+    iRun.property("TofBins").set(m_tofbins)
+    iRun.property("TofStep").set(m_tofstep)
+
+    iMap = task.find("MRHe3TMapAlg")
+    #iMap.property("ConfigFileName").set("configure.xml")
+    iMap.show()
+
+    task.setEvtMax(-1)
+    task.initialize()
+    task.run()
+
+if __name__ == "__main__":
+    App(in_module='module01', in_redisip=[('10.1.31.116', 9001)], in_cron=10)
Index: drone/monitor1
===================================================================
--- drone/monitor1	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/monitor1	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
@@ -0,0 +1,2 @@
+./monitor1.py >>/dev/null 2>&1
+#./monitor1.py &
Index: drone/monitor1.py
===================================================================
--- drone/monitor1.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/monitor1.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+# -*- coding:utf-8 -*-
+# author: H.L. TIAN 2017
+import DroNECore
+import DroNECore.PyIncident       as PI
+import CtrlSvc.PushMatrixIncident as PMI
+import CtrlSvc.PushHistIncident   as PHI
+import CtrlSvc.HeartBeatIncident  as HBI
+import CtrlSvc.NeonRPCIncident    as NRI
+import CtrlSvc.NeonRPCTask        as NRT
+import CtrlSvc.NeonUpdateDataTask as NUT
+import NEON
+import json
+import uuid
+import time
+import redis
+import os
+
+class RedisRemoteData:
+    def __init__(self, ip, path):
+        from redis.sentinel import Sentinel
+        sentinel=Sentinel(ip, socket_timeout=10)
+        self.server = sentinel.master_for('neonmaster', socket_timeout=200, password='sanlie;123', db=0)
+        self.path   = path
+
+    def setData(self, data):
+        self.data = data
+
+    def dump(self):
+        self.server.set(self.path, self.data)
+
+    def getData(self):
+        return self.data
+
+    def load(self):
+        self.data = self.server.get(self.path)
+
+def App(in_module='', in_redisip='', in_cron=1):
+    m_modulename = in_module
+    m_redisip    = in_redisip
+    m_cron       = in_cron#15
+
+    #from xml.etree import ElementTree as ET
+    #root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
+    #tof  = root.find('tofInformation')
+    #m_tofstart= int(tof.attrib['tofstart'])*factor
+    #m_tofstep = int(tof.attrib['tofstep'])*factor 
+    #m_tofbins = int(tof.attrib['tofbin'])
+    factor = 1  # 1us to 1us
+    m_tofstart= 0*factor
+    m_tofstep = 16*factor
+    m_tofbins = 2500
+
+    path  = '/MR/workspace/'+m_modulename
+
+    m_taskMatrix = RedisRemoteData(m_redisip, path+"/value")
+    m_taskTOF    = RedisRemoteData(m_redisip, path+"/tof")
+    m_taskPID    = RedisRemoteData(m_redisip, path+"/pid")
+    
+    toflist = [m_tofstep+i*m_tofstep for i in xrange(m_tofbins+1)]
+    m_taskTOF.setData(json.dumps(toflist))
+    m_taskTOF.dump()
+
+    import socket, os
+    m_taskheartbeat = RedisRemoteData(m_redisip, \
+                    '/MR/heartbeat/detector/'+m_modulename)
+
+    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running', \
+                                    hit = 0, event = 0, pulse = 0, idx = os.getpid()))
+    m_taskheartbeat.dump()
+
+    idstart = 3110001
+    idsize  = 1024
+    pidlist = [i+idstart for i in xrange(idsize)]
+
+    #print pidlist
+    m_taskPID.setData(json.dumps(pidlist))
+    m_taskPID.dump()
+
+    m_configure = {"pidstart":idstart,"pidsize":idsize}
+    task = DroNECore.DroNEOnline("task")
+    task.asTop()
+    task.setLogLevel(2)
+
+    ## ===========================
+    m_neonRedis = NEON.Neon.NeonRedisSentinel(m_redisip, i_socket_timeout=0.1, \
+                                           master_name='neonmaster', master_timeout = 120, master_password='sanlie;123', \
+                                           idb = 0, isWritable = True) # server mode, set msgs to Redis
+    servpob = NEON.Neon.NeonService.POBox(m_neonRedis, '/MR/process/detector', 'server:'+m_modulename)
+    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox = servpob, recvPOBox = servpob, isServer=True)
+    nr = NRT.NeonRPCTask("NeonRPC", servrpc, remotedata = m_taskheartbeat)
+
+    import CtrlSvc
+    ct = DroNECore.CtrlTask("ctrl")
+    pi = PMI.PushMatrixCronIncident("PushMatrix", cron = m_cron, \
+                                    repeatable = True, remotedata = m_taskMatrix,\
+                                    configure = m_configure)
+    hi = HBI.HeartBeatCronIncident("HeartBeat", cron = 2, repeatable = True, remotedata = m_taskheartbeat)
+    ni = NRI.NeonRPCCronIncident("NeonRPC", cron = 1, repeatable = True)
+    ct.add(hi)
+    ct.add(ni)
+    ct.add(pi)
+    ## ===========================
+    nu = NUT.NeonUpdateDataTask("UpdateRemoteData", remotedata = m_taskMatrix, configure=m_configure)
+    ## ===========================
+    
+    import DataSvc
+    task.property("svcs").append("MRDataSvc/DataSvc")
+    task.property("svcs").append("CtrlSvc")
+    task.property("svcs").append("EpicsInputSvc/DataInputSvc")
+    iSvc = task.find("DataInputSvc")
+    iSvc.property("Channel").set("rm:"+m_modulename)
+
+    import Algorithms
+    task.property("algs").append("RunningInfAlg")
+    #task.property("algs").append("DumpAlg")
+    iRun = task.find("RunningInfAlg")
+    iRun.property("TofStart").set(m_tofstart)
+    iRun.property("TofBins").set(m_tofbins)
+    iRun.property("TofStep").set(m_tofstep)
+
+    iSvc.show()
+
+    task.setEvtMax(-1)
+    task.initialize()
+    task.run()
+
+if __name__ == "__main__":
+    App(in_module='monitor1', in_redisip=[('10.1.31.116', 9001)], in_cron=10)
