public Dictionary <string, List <string> > GetLoggedMyndband()
    {
        var logCollection = new Dictionary <string, List <string> >();

        logCollection["SystemTime"] = new List <string>();
        logCollection["Delta"]      = new List <string>();
        logCollection["Theta"]      = new List <string>();
        logCollection["AlphaLow"]   = new List <string>();
        logCollection["AlphaHigh"]  = new List <string>();
        logCollection["BetaLow"]    = new List <string>();
        logCollection["BetaHigh"]   = new List <string>();
        logCollection["GammaLow"]   = new List <string>();
        logCollection["GammaHigh"]  = new List <string>();
        var loggedEvents = new MyndbandEvent[loggedmyndbandPacketList.Count];

        loggedmyndbandPacketList.CopyTo(loggedEvents);
        foreach (MyndbandEvent bandEvent in loggedEvents)
        {
            var myndbandData = (IDictionary)JsonConvert.Import(typeof(IDictionary), bandEvent.packet);
            if (myndbandData.Contains("eegPower"))
            {
                IDictionary eegPowers = (IDictionary)myndbandData["eegPower"];
                logCollection["Delta"].Add(eegPowers["delta"] != null ? eegPowers["delta"].ToString() : "NA");
                logCollection["Theta"].Add(eegPowers["theta"].ToString());
                logCollection["AlphaLow"].Add(eegPowers["lowAlpha"].ToString());
                logCollection["AlphaHigh"].Add(eegPowers["highAlpha"].ToString());
                logCollection["BetaLow"].Add(eegPowers["lowBeta"].ToString());
                logCollection["BetaHigh"].Add(eegPowers["highBeta"].ToString());
                logCollection["GammaLow"].Add(eegPowers["lowGamma"].ToString());
                logCollection["GammaHigh"].Add(eegPowers["highGamma"].ToString());
                logCollection["SystemTime"].Add(bandEvent.systemTime.ToString("yyyy-MM-dd HH:mm:ss.ffff"));
            }
        }
        return(logCollection);
    }
    private void ReceiveCallback(IAsyncResult AR)
    {
        String      content = String.Empty;
        StateObject state   = (StateObject)AR.AsyncState;
        Socket      handler = state.workSocket;

        int bytesRead = stream.EndRead(AR);

        if (bytesRead > 0)
        {
            string[] packets = Encoding.ASCII.GetString(state.buffer, 0, bytesRead).Split('\r');
            foreach (string packet in packets)
            {
                if (packet.Length == 0)
                {
                    continue;
                }
                var newEvent = new MyndbandEvent();
                newEvent.systemTime = System.DateTime.Now;
                newEvent.packet     = packet;
                if (packet.IndexOf("rawEeg") > -1)
                {
                    if (isLogging)
                    {
                        loggedRawEegList.Add(newEvent);
                    }
                    rawEegPacketList.Add(newEvent);
                }
                else
                {
                    if (isLogging)
                    {
                        loggedmyndbandPacketList.Add(newEvent);
                    }
                    myndbandPacketList.Add(newEvent);
                }
            }
        }

        Thread.Sleep(10);
        stream.BeginRead(state.buffer, 0, StateObject.BufferSize, new AsyncCallback(ReceiveCallback), state);
    }
    public Dictionary <string, List <string> > GetLoggedRawEEG()
    {
        var logCollection = new Dictionary <string, List <string> >();

        logCollection["SystemTime"] = new List <string>();
        logCollection["RawEEG"]     = new List <string>();
        var loggedEvents = new MyndbandEvent[loggedRawEegList.Count];

        loggedRawEegList.CopyTo(loggedEvents);
        foreach (MyndbandEvent bandEvent in loggedEvents)
        {
            var myndbandData = (IDictionary)JsonConvert.Import(typeof(IDictionary), bandEvent.packet);
            if (myndbandData.Contains("rawEeg"))
            {
                logCollection["RawEEG"].Add(myndbandData["rawEeg"].ToString());
                logCollection["SystemTime"].Add(bandEvent.systemTime.ToString("yyyy-MM-dd HH:mm:ss.ffff"));
            }
        }
        return(logCollection);
    }