import numpy as np
import scipy as scp
import sigpy as sig
import msgpack
import json
import socket

class ServerSimulator:
    def __init__(self):
        self.events = []
        self.rfwaves = []
        self.time = 0
        #Socket parameters
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.conn = 0
        self.maxic = b'\xAA'
        self.cmd = b'\x00'
        self.data = b''
        #32bit Codes
        self.errCode = b'\x00\x00\x00\x00'
        self.statCode = b'\x00\x00\x00\x00'
        # Command callbacks
        cmd_dict = {
           b'\x10': self.addEvent,
           b'\x20': self.addRfwaveTable,
           b'\x00': self.disconnect
        }

    def connect(self, host, port):
        self.sock.bind((host, port))
        self.sock.listen(1)
        self.conn, addr = self.sock.accept()
        print(f"New connection from {addr}")

    def disconnect(self):
        self.conn.close()

    def recvMsg(self):
        self.data = self.conn.recv(4096)
        #Unpack data from socket
        def handler():
            pass

    def sendMsg():
        pass

    def getErrorMsg():
        pass
    def getStatusMsg():
        pass

    def acceptCommand(self):
        pass

    def addEvent(self, data):
        pass
    def addRfwaveTable(self, data):
        pass
    