def startup(sensors_groups, host='localhost', port=65000): """ """ server = [] client = [] samples_per_channel = 100 devices = extract_devices(sensors_groups) channels = extract_channels(sensors_groups) DaqPkgRingBuffer.configure(samples_per_channel, 0.0) DaqDictRingBuffer.configure(samples_per_channel * 10, 0) # server daq configurations for name in channels: DaqPkgRingBuffer.bind(name, channels[name]) for name in devices: server.append(DaqRegister(devices[name])) server.append(DaqServer(host, port)) # client analyzer configurations for name in channels: DaqDictRingBuffer.bind(name, channels[name]) client.append( DaqAnalyzer('localhost', 65000, channels['ceramic'], name)) client.append(DaqPlotter(samples_per_channel=samples_per_channel * 10)) asyncore.loop()
def read(self): if DaqAsyncTurn.is_my_turn(self.name): DaqMultiPlotter.send_data(self.data) # Wait for new data on Ring Buffer DaqDictRingBuffer.status(status=False) DaqAsyncTurn.next_turn()
def handle_read(self): if DaqAsyncTurn.is_my_turn(self.name): data = DaqDictRingBuffer.extract(chunk=self.samples_per_channel) DaqMultiPlotter.send_data(data) # Wait for new data on Ring Buffer DaqDictRingBuffer.status(status=False) DaqAsyncTurn.next_turn()
def start(devices): channels = extract_channels(devices) samples_per_channel = 100 DaqDictRingBuffer.configure(samples_per_channel, 0.) groups = ['ceramic', 'polymer'] for name in groups: DaqDictRingBuffer.bind(name, channels[name]) plotter = DaqPlotter(samples_per_channel=samples_per_channel) asyncore.loop()
def start(sensors_groups): channels = extract_channels(sensors_groups) DaqDictRingBuffer.configure(100000, 0.) for name in ['ceramic']: DaqDictRingBuffer.bind(name, channels[name]) ceramic = DaqClient('localhost', 65000, channels['ceramic'], 'ceramic') #polymer = DaqClient('localhost', 65000, devices['polymer']) #plotter = DaqPlotter() asyncore.loop()
def start(devices): channels = extract_channels(devices) samples_per_channel = 100 DaqDictRingBuffer.configure(samples_per_channel, 0.) groups = ['ceramic', 'polymer'] for name in groups: DaqDictRingBuffer.bind(name, channels[name]) DaqAsyncTurn.configure(groups + ['plotter']) ceramic = DaqClient('localhost', 65000, channels['ceramic'], 'ceramic') polymer = DaqClient('localhost', 65000, channels['polymer'], 'polymer') plotter = DaqPlotter(samples_per_channel=samples_per_channel) asyncore.loop()
def handle_read(self): if DaqAsyncTurn.is_my_turn(self.name): self.cache += self.recv(1024) if '\n' in self.cache: i = self.cache.index('\n') z = len('\n') + i data = eval(self.cache[:i]) self.cache = self.cache[z:] print('%s > %s samples per channel received.' % (self.name, len(data[data.keys()[0]]))) self.buffer = self.name DaqDictRingBuffer.append(self.name, data) DaqAsyncTurn.next_turn()
def handle_read(self): self.cache += self.recv(1024) if '\n' in self.cache: i = self.cache.index('\n') z = len('\n') + i print('Received %s bytes.' % len(self.cache[:i])) data = eval(self.cache[:i]) self.cache = self.cache[z:] #print('%s > %s rows received.' % (self.internal_id, len(data[0]))) DaqDictRingBuffer.append(self.name, data) DaqDictRingBuffer.status = True self.buffer += '.'
def handle_read(self): if DaqAsyncTurn.is_my_turn(self.name): self.cache += self.recv(1024) if '\n' in self.cache: i = self.cache.index('\n') z = len('\n') + i data = eval(self.cache[:i]) self.cache = self.cache[z:] print('%s > %s samples per channel received.' % ( self.name, len(data[data.keys()[0]])) ) self.buffer = self.name DaqDictRingBuffer.append(self.name, data) DaqAsyncTurn.next_turn()
def read(self): if DaqAsyncTurn.is_my_turn(self.name): data = self.server.next() DaqDictRingBuffer.append(self.name, data) DaqAsyncTurn.next_turn()
def startup(sensors_groups): """ """ server = [] client = [] # total samples per channel samples_per_channel = 15000 # samples per channel per each read access samples_per_channel_read = 1000 # quantity of package of data to be buffered packages_per_channel = 1 devices = extract_devices(sensors_groups) channels = extract_channels(sensors_groups) tree_channels = defaultdict(dict) DaqPkgRingBuffer.configure(packages_per_channel, 0.0) DaqDictRingBuffer.configure(max_samples_per_channel=samples_per_channel * 2, nothing_value=0, overwritten_exception=False) # server daq configurations for name in channels: DaqPkgRingBuffer.bind(name, channels[name]) for name in devices: server.append(DaqRegister(devices[name], samples_per_channel_read)) # client analyzer configurations for name in channels: tree_channels[name] = dict([(ch, None) for ch in channels[name]]) DaqDictRingBuffer.bind(name, channels[name]) client.append( DaqAnalyzer(channels=channels[name], daq_name=name, server=DaqServer.listening(channels[name], name))) """ # View all signals ring buffer chart = DaqPlotter(samples_per_channel=samples_per_channel*2) client.append(chart) """ # View only segmented signals chart = DaqAsyncPlotter(samples_per_channel=samples_per_channel, tree_channels=tree_channels) client.append(chart) def callback_process(data): # call the weigh method weight = Weigh.calculate(data) # call the save method # # call chart method chart.send(data) # Segmentation Module for name in channels: client.append( SegmentedByTrigger(buffer_name=name, channels=channels[name], trigger=sensors_groups[name]['trigger'], chunk=samples_per_channel, ring_buffer=DaqDictRingBuffer, callback=callback_process)) loop(routines=server + client, wait=0.00000001)