import redis
import jsonArray
import time
import numpy as np
from numpy import *
import random
from redis.sentinel import Sentinel

if __name__ == '__main__':
    # ======Try to connect NEON server
    #ip="10.1.33.141"
    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')
    moduleList=['module131', 'module132', 'module133', 'module231', 'module232', 'module233', 'module322', 'module331', 'module332', 'module333', 'module341', 'module342', 'module343', 'module422', 'module431', 'module432', 'module433', 'module441', 'module442', 'module443', 'module521', 'module522', 'module523', 'module531', 'module532', 'module533', 'module541', 'module542', 'module543', 'module621', 'module622', 'module623', 'module631', 'module632', 'module633', 'module641', 'module642', 'module643']
    monitorList=['monitor1','monitor2','monitor3']
 
    path="/GPPD/workspace/detector/"
    monitorList=['monitor1','monitor2','monitor3']
    npid=5328
    ntof=2500
    v=[[] for k in range(npid)]
    for i in range(npid):
        for j in range(ntof):
            v[i].append(random.randint(0,100))
    v1=jsonArray.jsonEncoder(v)
    for name in monitorList:
        path3=path+str(name)+"/value"
        r.set(path3,v1)
    print "finish set test data!"


