Esempio n. 1
0
    void readNeuro()
    {
        tgPacketCount = ThinkGear.TG_ReadPackets(tgHandleId, -1);

        attention = ThinkGear.TG_GetValue(tgHandleId, ThinkGear.DATA_ATTENTION);
        blink     = ThinkGear.TG_GetValue(tgHandleId, ThinkGear.DATA_BLINK_STRENGTH);
    }
Esempio n. 2
0
        public void UpdateState()
        {
            if (!_connected)
            {
                return;
            }

            // read all packets
            _tgState.PacketsRead = ThinkGear.TG_ReadPackets(_connectionId, 1);

            // if < 0, we have an error
            if (_tgState.PacketsRead < 0)
            {
                _errors++;
            }
            else
            {
                _errors = 0;
            }

            // a few errors may be normal.  if we get a LOT, we have a problem
            _tgState.Error = _errors > 25000;

            // if we read at least one packet, update the state values
            if (_tgState.PacketsRead > 0)
            {
                _tgState.Battery       = GetValue(ThinkGear.DATA_BATTERY) ?? _tgState.Battery;
                _tgState.PoorSignal    = GetValue(ThinkGear.DATA_POOR_SIGNAL) ?? _tgState.PoorSignal;
                _tgState.Attention     = GetValue(ThinkGear.DATA_ATTENTION) ?? _tgState.Attention;
                _tgState.Meditation    = GetValue(ThinkGear.DATA_MEDITATION) ?? _tgState.Meditation;
                _tgState.Raw           = GetValue(ThinkGear.DATA_RAW) ?? _tgState.Raw;
                _tgState.Delta         = GetValue(ThinkGear.DATA_DELTA) ?? _tgState.Delta;
                _tgState.Theta         = GetValue(ThinkGear.DATA_THETA) ?? _tgState.Theta;
                _tgState.Alpha1        = GetValue(ThinkGear.DATA_ALPHA1) ?? _tgState.Alpha1;
                _tgState.Alpha2        = GetValue(ThinkGear.DATA_ALPHA2) ?? _tgState.Alpha2;
                _tgState.Beta1         = GetValue(ThinkGear.DATA_BETA1) ?? _tgState.Beta1;
                _tgState.Beta2         = GetValue(ThinkGear.DATA_BETA2) ?? _tgState.Beta2;
                _tgState.Gamma1        = GetValue(ThinkGear.DATA_GAMMA1) ?? _tgState.Gamma1;
                _tgState.Gamma2        = GetValue(ThinkGear.DATA_GAMMA2) ?? _tgState.Gamma2;
                _tgState.BlinkStrength = GetValue(ThinkGear.DATA_BLINK_STRENGTH) ?? _tgState.BlinkStrength;

                // let those listening know
                if (ThinkGearChanged != null)
                {
                    ThinkGearChanged(this, new ThinkGearChangedEventArgs(_tgState));
                }
            }
        }