def read_data(self): ''' size = gsocket.bytesAvailable() if size == self.size: self.buffer = gsocket.read(8*self.size) print(len(self.buffer)) print("Start processing readout.") self.process_readout() print("Start analyzing data.") self.analytics() print("Display data.") self.display_data() ''' # Test if buffer can be filled by one line (see code above) # print("Reading...") # wait for enough data and read to self.buffer size = gsocket.bytesAvailable() print(size) if size <= 0: return elif self.offset + size < 8 * self.size: self.buffer[self.offset:self.offset + size] = gsocket.read(size) self.offset += size # if the buffer is not complete, return and wait for more return else: print("Finished Readout.") self.buffer[self.offset:8 * self.size] = gsocket.read(8 * self.size - self.offset) self.offset = 0 # print("\tBuffer size: ", len(self.buffer)) print("Start processing readout.") self.process_readout() print("Start analyzing data.") self.analytics() print("Display data.") self.display_data() if self.flipangleTool.acqCount > 0 and self.flipangleTool.centeringFlag == True: print(time.ctime()) time.sleep(self.flipangleTool.acqTimeout) print(time.ctime()) self.flipangleTool.find_Ceter() elif self.flipangleTool.acqCount > 0 and self.flipangleTool.attenuationFlag == True: print(time.ctime()) time.sleep(self.flipangleTool.acqTimeout) print(time.ctime()) self.flipangleTool.find_At()
def read_data(self): # wait for enough data and read to self.buffer size = gsocket.bytesAvailable() if size <= 0: return elif self.offset + size < 8 * self.size: self.buffer[self.offset:self.offset + size] = gsocket.read(size) self.offset += size # if the buffer is not complete, return and wait for more return else: self.buffer[self.offset:8 * self.size] = gsocket.read(8 * self.size - self.offset) self.offset = 0 self.display_data()
def read_data(self): # wait for enough data and read to self.buffer size = gsocket.bytesAvailable() if size <= 0: return elif self.offset + size < 8 * self.size: self.buffer[self.offset:self.offset + size] = gsocket.read(size) self.offset += size # if the buffer is not complete, return and wait for more return else: self.buffer[self.offset:8 * self.size] = gsocket.read(8 * self.size - self.offset) self.offset = 0 current_data = self.data print("Read data - current index = {}".format(self.acqType_idx)) if self.acqType_idx == 1: # image self.avgs_received = 0 print("Acquired TR = {}".format(self.buffers_received)) self.buffers_received += 1 else: # for averaging projections self.data_sum += current_data self.avgs_received += 1 # print("Averages acquired = {}".format(self.avgs_received)) if self.buffers_received == self.num_pe: sp.savemat(self.fname, {"acq_data": self.full_data}) # Save the data print("Data saved!") self.buffers_received = 0 self.full_data = np.matrix(np.zeros(np.size(self.data))) self.startButton.setEnabled(False) self.freqValue.setEnabled(True) self.acqType.setEnabled(True) self.stopButton.setEnabled(True) self.acquireButton.setEnabled(True) self.loadShimButton.setEnabled(True) self.zeroShimButton.setEnabled(True) self.display_data()