class DTSrc: def __init__ (self, cacheSize, archMode, archSize, serverAddrs, clientName): # create source self.src = Source (cacheSize, archMode, archSize) self.src.OpenRBNBConnection (serverAddrs, clientName) print self.src def createChannels (self, chNames, chInfos, chMIMEs): #create channel map self.chMap = ChannelMap () # add channels # Define channels by name, via ChannelMap.Add(java.lang.String). for chIndex in range(len(chNames)): self.chMap.Add(chNames[chIndex]) assignedIndex = self.chMap.GetIndex (chNames[chIndex]) # add user info such as units self.chMap.PutUserInfo(assignedIndex, chInfos[chIndex]) # put the MIME type self.chMap.PutMime (assignedIndex, chMIMEs[chIndex]) # Register the channelMap self.src.Register (self.chMap) def insertData (self, timeStamp, dataVals): # create a loop here # Set a TimeStamp, # using ChannelMap.PutTime(double,double) or # ChannelMap.PutTimeAuto(java.lang.String). print 'We are inserting the data ' + str (timeStamp) startTime = timeStamp durationTime = 0 self.chMap.PutTime (startTime, durationTime) # Add data for each channel, through the various PutChannel methods, # such as ChannelMap.PutData(int,byte[],int). chIndex = 0 for dataVal in dataVals: if dataVal != 'NAN': if dataVal == '-INF': dataVal = -99999 dataVal = float(dataVal) dVal = array([dataVal], 'd') self.chMap.PutDataAsFloat64 (chIndex, dVal) chIndex = chIndex +1 # print self.chMap # Flush(ChannelMap) data to RBNB server. self.src.Flush (self.chMap)
class DTSrc: def __init__(self, cacheSize, archMode, archSize, serverAddrs, clientName): # create source self.src = Source(cacheSize, archMode, archSize) self.src.OpenRBNBConnection(serverAddrs, clientName) print self.src def createChannels(self, chNames, chInfos, chMIMEs): #create channel map self.chMap = ChannelMap() # add channels # Define channels by name, via ChannelMap.Add(java.lang.String). for chIndex in range(len(chNames)): self.chMap.Add(chNames[chIndex]) assignedIndex = self.chMap.GetIndex(chNames[chIndex]) # add user info such as units self.chMap.PutUserInfo(assignedIndex, chInfos[chIndex]) # put the MIME type self.chMap.PutMime(assignedIndex, chMIMEs[chIndex]) # Register the channelMap self.src.Register(self.chMap) def insertData(self, chID, img): # create a loop here # Set a TimeStamp, # using ChannelMap.PutTime(double,double) or # ChannelMap.PutTimeAuto(java.lang.String). print 'We are inserting the image' self.chMap.PutTimeAuto("server") self.chMap.PutDataAsByteArray(chID, img) self.chMap.PutMime(chID, 'image/jpeg') # Flush(ChannelMap) data to RBNB server. self.src.Flush(self.chMap)
def __init__(self, cacheSize, archMode, archSize, serverAddrs, clientName): # create source self.src = Source(cacheSize, archMode, archSize) self.src.OpenRBNBConnection(serverAddrs, clientName) print self.src
import sched, time from jarray import array from jreload import makeLoadSet makeLoadSet('DTunit', ["/Applications/RBNB/bin/rbnb.jar"]) from DTunit.com.rbnb.sapi import Source from DTunit.com.rbnb.sapi import ChannelMap from DTunit.com.rbnb.sapi import Client from org.python.core import PyFile DTSrc = Source(100, 'create', 88888) DTSrc.OpenRBNBConnection('localhost:3333', 'FakeDAQ') chMap = ChannelMap() ################# # create channels ################# # add channel chMap.Add('ch0') assignedIndex = chMap.GetIndex('ch0') chMap.PutUserInfo(assignedIndex, 'units = test') chMap.PutMime(assignedIndex, 'application/octet-stream') chMap.Add('ch1') assignedIndex = chMap.GetIndex('ch1') chMap.PutMime(assignedIndex, 'application/octet-stream')