Exemple #1
0
 public void initializeBuffer()
 {
     Debug.Log("Connecting to " + hostname + ":" + port);
     if (bufferClient.connect(hostname, port))
     {
         hdr = bufferClient.getHeader();
         if (bufferClient.errorReturned == BufferClient.BUFFER_READ_ERROR)
         {
             Debug.Log("Connection to " + hostname + ":" + port + " failed");
             bufferIsConnected = false;
             return;
         }
         latestBufferSample = hdr.nSamples;
         nSamples           = hdr.nSamples;
         nChans             = hdr.nChans;
         fSample            = hdr.fSample;
         initializeData();
         bufferIsConnected = true;
         bufferTimer       = new BufferTimer(fSample);
         Debug.Log("Connection to " + hostname + ":" + port + " succeeded");
     }
     else
     {
         Debug.Log("Connection to " + hostname + ":" + port + " failed");
         bufferIsConnected = false;
         return;
     }
 }
Exemple #2
0
 public void initializeBuffer()
 {
     if (hostname == null)
     {
         //hostname = GetLocalIPAddress ();
         hostname = "127.0.0.1";
     }
     Debug.Log("Connecting to " + hostname + ":" + port);
     if (!bufferClient.isConnected())          // attempt to re-connect
     {
         bufferClient.connect(hostname, port);
     }
     if (bufferClient.isConnected())
     {
         Debug.Log("Connected to " + hostname + ":" + port + " succeeded");
         hdr = bufferClient.getHeader();
         if (bufferClient.errorReturned == BufferClient.BUFFER_READ_ERROR)
         {
             Debug.Log("No header on " + hostname + ":" + port + " failed");
             bufferConnectionInitialized = false;
             return;
         }
         latestBufferSample = hdr.nSamples;
         lastNumberOfEvents = hdr.nEvents;
         nChans             = hdr.nChans;
         fSample            = hdr.fSample;
         if (storeData)
         {
             initializeData();
         }
         bufferTimer = new BufferTimer(fSample);
         Debug.Log("Got valid header on " + hostname + ":" + port);
         // compute the min-update-interval in samples
         if (MINUPDATEINTERVAL_ms > 0)
         {
             DATAUPDATEINTERVAL_SAMP = (int)(MINUPDATEINTERVAL_ms * 1000.0 / hdr.fSample);
             if (DATAUPDATEINTERVAL_SAMP < 1)
             {
                 DATAUPDATEINTERVAL_SAMP = 1;
             }
         }
         bufferConnectionInitialized = true;
         if (bufferUpdateThread == null)
         {
             bufferUpdateThread = new Thread(run)
             {
                 Name = "BufferUpdateThread"
             };
             bufferUpdateThread.Start();                  // start the buffer-monitoring thread
         }
     }
     else
     {
         Debug.Log("Connection to " + hostname + ":" + port + " failed");
         bufferConnectionInitialized = false;
         return;
     }
 }
Exemple #3
0
 public void initializeBuffer()
 {
     if (hostname == null)
     {
         hostname = GetLocalIPAddress();
     }
     Debug.Log("Connecting to " + hostname + ":" + port);
     if (bufferClient.connect(hostname, port))
     {
         hdr = bufferClient.getHeader();
         if (bufferClient.errorReturned == BufferClient.BUFFER_READ_ERROR)
         {
             Debug.Log("No header on " + hostname + ":" + port + " failed");
             bufferIsConnected = false;
             return;
         }
         latestBufferSample = hdr.nSamples;
         lastNumberOfEvents = hdr.nEvents;
         nChans             = hdr.nChans;
         fSample            = hdr.fSample;
         if (storeData)
         {
             initializeData();
         }
         bufferIsConnected = true;
         bufferTimer       = new BufferTimer(fSample);
         Debug.Log("Connection to " + hostname + ":" + port + " succeeded");
         // compute the min-update-interval in samples
         if (MINUPDATEINTERVAL_ms > 0)
         {
             DATAUPDATEINTERVAL_SAMP = (int)(MINUPDATEINTERVAL_ms * 1000.0 / hdr.fSample);
             if (DATAUPDATEINTERVAL_SAMP < 1)
             {
                 DATAUPDATEINTERVAL_SAMP = 1;
             }
         }
     }
     else
     {
         Debug.Log("Connection to " + hostname + ":" + port + " failed");
         bufferIsConnected = false;
         return;
     }
 }
Exemple #4
0
    public UnityBuffer()
    {
        bufferClient = new BufferClient();
        bufferEvents = new List <BufferEvent>();
        //Debug.Log("Connecting to "+hostname+":"+port);
        if (bufferClient.connect(hostname, port))
        {
            hdr = bufferClient.getHeader();
            latestBufferSample = hdr.nSamples;
            nSamples           = hdr.nSamples;
            nChans             = hdr.nChans;
            fSample            = hdr.fSample;
            initializeData();
            //  System.Windows.Forms.MessageBox.Show("hello");
            //Debug.Log("#channels....: "+hdr.nChans);
            //Debug.Log("#samples.....: "+hdr.nSamples);
            //Debug.Log("#events......: "+hdr.nEvents);
            //Debug.Log("Sampling Freq: "+hdr.fSample);
            //Debug.Log("data type....: "+hdr.dataType);

            for (int n = 0; n < nChans; n++)
            {
                if (hdr.labels[n] != null)
                {
                    //Debug.Log("Channel number " + n + ": " + hdr.labels[n]);
                }
            }
        }
        else          //Debug.LogError("Connection to "+hostname+":"+port+" failed");

        {
            latestCapturedSample = 0;
        }
        newDataIn                    = false;
        dataPacketsLost              = 0;
        lastNumberOfEvents           = 0;
        latestNumebrOfEventsInBuffer = 0;
    }