# Path: rtlsdr_scanner/events.py
# def post_event(destination, status):
#     if isinstance(destination, Queue.Queue):
#         destination.put(status)
#     elif isinstance(destination, wx.EvtHandler):
#         wx.PostEvent(destination, status)
# 
# class EventThread(wx.PyEvent):
#     def __init__(self, status, arg1=None, arg2=None):
#         wx.PyEvent.__init__(self)
#         self.SetEventType(EVENT_THREAD)
#         self.data = Status(status, arg1, arg2)
# 
# class Event(object):
#     STARTING, STEPS, INFO, DATA, STOPPED, ERROR, FINISHED, PROCESSED, \
#         CAL, LEVEL, UPDATED, DRAW, \
#         DELAY_COUNT, DELAY_START, \
#         LOC, LOC_RAW, LOC_WARN, LOC_ERR, LOC_SAT = range(19)


import array
import socket
import struct
import threading
import numpy
from rtlsdr_scanner.events import post_event, EventThread, Event

    def __read_stream(self):
        data = []
        recv = ""

        self.buffer = ""
        while self.readLen > 0:
            recv = self.socket.recv(self.readLen)
            if len(recv) == 0:
                break
            data.append(recv)
            self.readLen -= len(recv)

        self.buffer = bytearray(''.join(data))
        self.__do_notify()

    def __skip_stream(self):
        total = self.READ_SIZE
        while total > 0:
            recv = self.socket.recv(total)
            if len(recv) == 0:
                break
            total -= len(recv)

    def get_header(self):
        return self.header

    def recv(self, length):
        self.readLen = length
        self.__do_wait()

# Path: rtlsdr_scanner/events.py
# def post_event(destination, status):
#     if isinstance(destination, Queue.Queue):
#         destination.put(status)
#     elif isinstance(destination, wx.EvtHandler):
#         wx.PostEvent(destination, status)
# 
# class EventThread(wx.PyEvent):
#     def __init__(self, status, arg1=None, arg2=None):
#         wx.PyEvent.__init__(self)
#         self.SetEventType(EVENT_THREAD)
#         self.data = Status(status, arg1, arg2)
# 
# class Event(object):
#     STARTING, STEPS, INFO, DATA, STOPPED, ERROR, FINISHED, PROCESSED, \
#         CAL, LEVEL, UPDATED, DRAW, \
#         DELAY_COUNT, DELAY_START, \
#         LOC, LOC_RAW, LOC_WARN, LOC_ERR, LOC_SAT = range(19)


# Path: rtlsdr_scanner/rtltcp.py
import array
import socket
import struct
import threading
import numpy
from rtlsdr_scanner.events import post_event, EventThread, Event


    def __read_stream(self):
        data = []
        recv = ""

        self.buffer = ""
        while self.readLen > 0:
            recv = self.socket.recv(self.readLen)
            if len(recv) == 0:
                break
            data.append(recv)
            self.readLen -= len(recv)

        self.buffer = bytearray(''.join(data))
        self.__do_notify()

    def __skip_stream(self):
        total = self.READ_SIZE
        while total > 0:
            recv = self.socket.recv(total)
            if len(recv) == 0:
                break
            total -= len(recv)

    def get_header(self):
        return self.header

    def recv(self, length):
        self.readLen = length
        self.__do_wait()

        return self.buffer