def _sample_data_loop(self, sample_interval): while not self.sampling_gl_quit.wait(timeout=sample_interval): try: if self.agent_plugin: sample = self.agent_plugin.acquire_samples() if sample: #log.info("Sample %s", sample) packet = DataPacketBuilder.build_packet_from_samples(sample, resource_id=self.resource_id, stream_name=self.stream_name) self.stream_pub.publish(packet) except Exception as ex: log.exception("Error in sampling greenlet")
def _sample_data_loop(self, sample_interval): while not self.sampling_gl_quit.wait(timeout=sample_interval): try: if self.agent_plugin: sample = self.agent_plugin.acquire_samples() if sample: #log.info("Sample %s", sample) packet = DataPacketBuilder.build_packet_from_samples( sample, resource_id=self.resource_id, stream_name=self.stream_name) self.stream_pub.publish(packet) except Exception as ex: log.exception("Error in sampling greenlet")
def _get_data_packet(self, index, num_rows=1): """ Return a data packet with number of samples. The index indicates the offset from the starting timestamp, 10 sec per sample.""" base_ts = 1000000000 index_ts = base_ts + 10 * index # Core samples as provided by agent.acquire_samples sample_list = [] for i in xrange(num_rows): ts = index_ts + i * 10 sample = [NTP4Time(ts).to_ntp64(), float(index + i), random.random()*100] sample_list.append(sample) sample_desc = dict(cols=["time", "var1", "random1"], data=sample_list) packet = DataPacketBuilder.build_packet_from_samples(sample_desc, resource_id="ds_id", stream_name="basic_streams") return packet
def _get_data_packet(self, index, num_rows=1): """ Return a data packet with number of samples. The index indicates the offset from the starting timestamp, 10 sec per sample.""" base_ts = 1000000000 index_ts = base_ts + 10 * index # Core samples as provided by agent.acquire_samples sample_list = [] for i in xrange(num_rows): ts = index_ts + i * 10 sample = [ NTP4Time(ts).to_ntp64(), float(index + i), random.random() * 100 ] sample_list.append(sample) sample_desc = dict(cols=["time", "var1", "random1"], data=sample_list) packet = DataPacketBuilder.build_packet_from_samples( sample_desc, resource_id="ds_id", stream_name="basic_streams") return packet