Beispiel #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;
     }
 }
Beispiel #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;
     }
 }
Beispiel #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;
     }
 }