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); }
// 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); }
//-------------------------------------------------------------------- // 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); }
//-------------------------------------------------------------------- // 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)); }
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); }
// 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); } }
// 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); }
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); }
//-------------------------------------------------------------------- // 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); }
//-------------------------------------------------------------------- // 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); }
// 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); }
//-------------------------------------------------------------------- // 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); }
// Use this for initialization void Start() { latestEvent = new BufferEvent("",0.0f,0); previousEvent = new BufferEvent("",0.0f,0); }
private void eventsAdded(UnityBuffer _buffer, EventArgs e) { latestEvent = _buffer.getLatestEvent(); Debug.Log (latestEvent.getType().toString()+": "+latestEvent.getValue().toString()); }