コード例 #1
0
ファイル: BufferClient.cs プロジェクト: abzaloid/buffer-bci
        public BufferEvent[] getEvents(int first, int last)
        {
            ByteBuffer buf;

            buf = ByteBuffer.allocate(16);
            buf.order(myOrder);

            buf.putShort(VERSION).putShort(GET_EVT).putInt(8);
            buf.putInt(first).putInt(last).rewind();

            writeAll(buf);
            buf = readResponse(GET_OK);

            int numEvt = BufferEvent.count(buf);

            if (numEvt != (last - first + 1))
            {
                errorReturned = INVALID_EVENT_DEF_ERROR;
                throw new IOException("Invalid event definitions in response.");
            }

            BufferEvent[] evs = new BufferEvent[numEvt];
            for (int n = 0; n < numEvt; n++)
            {
                evs[n] = new BufferEvent(buf);
            }
            return(evs);
        }
コード例 #2
0
ファイル: BufferComm.cs プロジェクト: giulio93/buffer_bci
        // Send the event to the FieldTrip buffer for string value
        public void SendEvent(string type, string value)
        {
            C.poll();
            BufferEvent E = new BufferEvent(type, value, -1);

            C.putEvent(E);
        }
コード例 #3
0
ファイル: BufferClientClock.cs プロジェクト: fbedada991/BCI
        //--------------------------------------------------------------------
        // overridden methods to
        // Fill in the estimated sample info

        /// <summary>
        /// Puts an event to the connected FieldTrip buffer.
        /// </summary>
        /// <param name="e">The event to send.</param>
        override public void putEvent(BufferEvent e)
        {
            if (e.sample < 0)
            {
                e.sample = (int)getSampOrPoll();
            }
            base.putEvent(e);
        }
コード例 #4
0
 //--------------------------------------------------------------------
 // overridden methods to
 // Fill in the estimated sample info
 override public BufferEvent putEvent(BufferEvent e)
 {
     if (e.sample < 0)
     {
         e.sample = (int)getSampOrPoll();
     }
     return(base.putEvent(e));
 }
コード例 #5
0
ファイル: BufferClient.cs プロジェクト: abzaloid/buffer-bci
        public void putEvent(BufferEvent e)
        {
            ByteBuffer buf;
            int        eventSize = e.size();

            buf = ByteBuffer.allocate(8 + eventSize);
            buf.order(myOrder);

            buf.putShort(VERSION).putShort(PUT_EVT).putInt(e.size());
            e.serialize(buf);
            buf.rewind();
            writeAll(buf);
            readResponse(PUT_OK);
        }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if(isBufferOn && latestEvent.getType().toString()=="alphaLat" &&
           latestEvent.getValue().toString()!=previousEvent.getValue().toString()){

            float alphaLatValue = float.Parse(latestEvent.getValue().toString());

            Vector3 targetPosition = new Vector3(0, 0, alphaLatValue);
            transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);

            previousEvent = latestEvent;
            Debug.Log (alphaLatValue);
        }
        if(isBufferOn){
            transform.Rotate (turningRate*Time.deltaTime, 0, 0);
        }
    }
コード例 #7
0
ファイル: BufferComm.cs プロジェクト: Wieke/buffer_bci
 // Send the event to the FieldTrip buffer for string value
 public void SendEvent(string type, string value)
 {
     C.poll();
     BufferEvent E = new BufferEvent(type, value, -1);
     C.putEvent(E);
 }
コード例 #8
0
ファイル: BufferClientClock.cs プロジェクト: Wieke/buffer_bci
 public override void putEvents(BufferEvent[] e)
 {
     int samp = -1;
     for( int i=0; i<e.Length; i++ )
       {
      if ( e[i].sample < 0 )
         {
           if ( samp<0 ) samp=(int)getSampOrPoll();
           e[i].sample=samp;
         }
       }
     base.putEvents(e);
 }
コード例 #9
0
ファイル: BufferClientClock.cs プロジェクト: Wieke/buffer_bci
 //--------------------------------------------------------------------
 // overridden methods to
 // Fill in the estimated sample info
 public override BufferEvent putEvent(BufferEvent e)
 {
     if ( e.sample < 0 ) { e.sample=(int)getSampOrPoll(); }
     return base.putEvent(e);
 }
コード例 #10
0
 //--------------------------------------------------------------------
 // overridden methods to
 // Fill in the estimated sample info
 /// <summary>
 /// Puts an event to the connected FieldTrip buffer.
 /// </summary>
 /// <param name="e">The event to send.</param>
 public override void putEvent(BufferEvent e)
 {
     if (e.sample < 0) {
         e.sample = (int)getSampOrPoll();
     }
     base.putEvent(e);
 }
コード例 #11
0
ファイル: BufferComm.cs プロジェクト: gbarresi/buffer_bci
 // Send the event to the FieldTrip buffer for int value
 public void SendEvent(string type, int value)
 {
     C.Poll();
     BufferEvent E = new BufferEvent(type, value, -1);
     C.PutEvent(E);
 }
コード例 #12
0
 //--------------------------------------------------------------------
 // overridden methods to
 // Fill in the estimated sample info
 /// <summary>
 /// Puts an event to the connected FieldTrip buffer.
 /// </summary>
 /// <param name="e">The event to send.</param>
 /// <returns>The sent buffer event.</returns>
 public override BufferEvent PutEvent(BufferEvent e)
 {
     if (e.Sample < 0) {
         e.Sample = (int)GetSampOrPoll();
     }
     return base.PutEvent(e);
 }
コード例 #13
0
 // Use this for initialization
 void Start()
 {
     latestEvent = new BufferEvent("",0.0f,0);
     previousEvent = new BufferEvent("",0.0f,0);
 }
コード例 #14
0
 private void eventsAdded(UnityBuffer _buffer, EventArgs e)
 {
     latestEvent = _buffer.getLatestEvent();
     Debug.Log (latestEvent.getType().toString()+": "+latestEvent.getValue().toString());
 }