Ejemplo n.º 1
0
def main():
    # Setup logging
    FORMAT = "%(asctime)-15s:%(levelname)s %(message)s"
    logging.basicConfig(level=logging.DEBUG,format=FORMAT)

    # Load configuration
    config = ConfigParser.ConfigParser()
    config.read(['config/client/SenStore.cfg'])
    
    #
    # Connect to server and get manager proxy
    #
    client = SenStoreClient(sys.argv, 'Narada Sensor Data Saver Python client')
    mngr = client.getManager()
    logging.info('Connected to SenStore')

    # Load the defined Narada units and channels
    daqUnits = daqlib.loadConfigUnits('narada.cfg')
    
    # Get the signals
    signalPrxTable = daqlib.getChannelDataProxies(mngr, daqUnits.keys())

    # Create time axis
    t0 = time.time()
    dt = 0.01   # Sampled data interval
    n = 5*60*100 # Number of samples per run
    ts = 6*3600   # Interval between runs
    N = 3     # Number of runs
    t = numpy.zeros(n)
    for k in range(-N,0):
        for i in range(-len(t),0):
            t[i] = t0 + i*dt + k*ts

        # Insert dummy data for each signal (channel)
        for key, signalPrx in signalPrxTable.iteritems():
            data = numpy.random.random_integers(0,2**16-1,n)
            signalPrx.appendToSignal(t.tolist(), data.tolist())
            logging.info('Stored random data in Narada channel signal %s:%d' % key)

    # All done
    client.close()
Ejemplo n.º 2
0
def main():
    # Setup logging
    FORMAT = "%(asctime)-15s:%(levelname)s %(message)s"
    logging.basicConfig(level=logging.DEBUG,format=FORMAT)

    # Load configuration
    config = ConfigParser.ConfigParser()
    config.read(['config/client/SenStore.cfg'])
    
    #
    # Connect to server and get manager proxy
    #
    client = SenStoreClient(sys.argv, 'Narada Query Python client')
    mngr = client.getManager()
    logging.info('Connected to SenStore')

    # Load the defined Narada units and channels
    daqUnits = daqlib.loadConfigUnits('narada.cfg')
    
    # Get the signals
    signalPrxTable = daqlib.getChannelDataProxies(mngr, daqUnits.keys())
    nSum = 0
    print 'Applied time zone is: %s' % time.strftime("%Z", time.localtime())
    for key, signalPrx in signalPrxTable.iteritems():
        # Get time range of available signal data
        timeInfo = signalPrx.getTimeAxisInfo([])
        if len(timeInfo.t) > 0:
            t0 = timeInfo.t[0]
            t1 = timeInfo.t[-1]
            print 'Narada unit %s channel %d info:' % key
            s0 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t0))
            s1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(t1))
            print '  time: %s to %s' % (s0, s1)
            print '  sample index: %d to %d' % (timeInfo.idx[0], timeInfo.idx[-1])
            dimInfo = signalPrx.getSignalSize()
            print "  size: %s" % 'x'.join(['%d' % dim for dim in dimInfo])
            nSum += timeInfo.idx[-1] - timeInfo.idx[0] + 1
    print 'Total number of samples: %d (%dk, %dM)' % (nSum, nSum/1000, nSum/1000000)

    # All done
    client.close()