def METHOD_NAME(self):
    """Main loop. If there're new files, read and put into store."""
    t = time.time()
    # TODO: use poller instead to prevent blocking, include a timeout
    try:
        msg = self.socket.recv(flags=zmq.NOBLOCK)
        msg_parts = [part.strip() for part in msg.split(b": ", 1)]
        # logger.info(msg_parts[0].split(b' ')[:4])
        tag = msg_parts[0].split(b" ")[0]
        # sendtime = msg_parts[0].split(b' ')[1].decode()
        if tag == b"stimid":
            msg_parts = [part.strip() for part in msg.split(b" ")]
            # print(msg_parts)
            sendtime = msg_parts[2].decode()
            angle = int(msg_parts[7].decode()[:-1])
            vel = float(msg_parts[9].decode()[:-1])
            # print('stim sendtime ', sendtime)
            # print('stimulus id: {}, {}'.format(angle, vel))
            # output example: stimulus id: b'background_stim'
            # calibration check:
            angle = 270 + angle
            if angle > 360:
                angle -= 360
            stim = 0
            # stimonOff = 20
            if np.abs(vel) > 0:
                stimonOff = 20
            else:
                stimonOff = 0
            # if msg_parts[1] == b'Left':
            #     stim = 4
            # elif msg_parts[1] == b'Right':
            #     stim = 3
            # elif msg_parts[1] == b'forward':
            #     stim = 9
            # elif msg_parts[1] == b'backward':
            #     stim = 13
            # elif msg_parts[1] == b'background_stim':
            #     stimonOff = 0
            #     print('Stim off')
            # elif msg_parts[1] == b'Left_Backward':
            #     stim = 14
            # elif msg_parts[1] == b'Right_Backward':
            #     stim = 12
            # elif msg_parts[1] == b'Left_Forward':
            #     stim = 16
            # elif msg_parts[1] == b'Right_Forward':
            #     stim = 10
            if angle == 0:
                stim = 9
            elif angle == 90:
                stim = 3
            elif angle == 180:
                stim = 13
            elif angle == 270:
                stim = 4
            elif angle == 45:
                stim = 10
            elif angle == 135:
                stim = 12
            elif angle == 225:
                stim = 14
            elif angle == 315:
                stim = 16
            else:
                logger.error("Stimulus unrecognized")
            logger.info("Stimulus: {}".format(stim))
            self.links["stim_queue"].put({self.frame_num: [stim, stimonOff]})
            self.stimmed.append([self.frame_num, stim, time.time()])
            self.stimsendtimes.append([sendtime])
        elif tag == b"frame":
            t0 = time.time()
            sendtime = msg_parts[0].split(b" ")[2].decode()
            # print(sendtime)
            array = np.array(
                json.loads(msg_parts[1])
            )  # assuming the following message structure: 'tag: message'
            # print('frame ', self.frame_num)
            # print('{}'.format(msg_parts[0])) # messsage length: {}. Element sum: {}; time to process: {}'.format(msg_parts[0], len(msg),
            # array.sum(), time.time() - t0))
            # output example: b'frame ch0 10:02:01.115 AM 10/11/2019' messsage length: 1049637. Element sum: 48891125; time to process: 0.04192757606506348
            obj_id = self.client.put(array, "acq_raw" + str(self.frame_num))
            self.q_out.put([{str(self.frame_num): obj_id}])
            self.saveArray.append(array)
            self.frametimes.append([self.frame_num, time.time()])
            self.framesendtimes.append([sendtime])
            self.frame_num += 1
            self.total_times.append(time.time() - t0)
        elif tag == b"tail":
            t0 = time.time()
            sendtime = msg_parts[0].split(b" ")[1].decode()
            msg = msg_parts[0].split(b" ")[4:]
            # print(msg)
            vlist = []
            for i, m in enumerate(msg):
                try:
                    v = int(m.decode())
                except ValueError:
                    v = int(m.decode()[:-1])
                vlist.append(v)
            self.tails.append(np.array(vlist))
            self.tailsendtimes.append([sendtime])
        else:
            if len(msg) < 100:
                print(msg)
            else:
                print("msg length: {}".format(len(msg)))
    except zmq.Again as e:
        pass  # no messages available
    except Exception as e:
        print("error: {}".format(e))