private void button1_Click(object sender, EventArgs e) { if (button1.Text.Equals("Disconnect")) { if (MessageBox.Show("您將中斷與裝置的連線,確定嗎?", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { NativeThinkgear.TG_Disconnect(ConnectionID); NativeThinkgear.TG_FreeConnection(ConnectionID); label1.Text = ("disconnected!"); button1.Text = ("Connect"); } } else if (button1.Text.Equals("Connect")) { if (MessageBox.Show("您將開始與裝置的連線,確定嗎?", "My Application", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { String comPortName = "\\\\.\\COM4"; ConnectionID = NativeThinkgear.TG_GetNewConnectionId(); int tem1 = NativeThinkgear.TG_SetStreamLog(ConnectionID, "myStreamLog.txt"); int tem2 = NativeThinkgear.TG_SetDataLog(ConnectionID, "myDataLog.txt"); Console.WriteLine(tem1); Console.WriteLine(tem2); errCode = NativeThinkgear.TG_Connect(ConnectionID, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { Console.WriteLine("ERROR: TG_Connect() returned: " + errCode); label1.Text = ("ERROR: TG_Connect() returned: " + errCode); ifConnect = false; startDraw = false; } else if (errCode == 0) { label1.Text = ("Connect success!!!"); Console.WriteLine(ConnectionID); button1.Text = ("Disconnect"); ifConnect = true; } } } }
static void Main(string[] args) { NativeThinkgear thinkgear = new NativeThinkgear(); /* Print driver version number */ Console.WriteLine("Version: " + NativeThinkgear.TG_GetVersion()); /* Get a connection ID handle to ThinkGear */ int connectionID = NativeThinkgear.TG_GetNewConnectionId(); Console.WriteLine("Connection ID: " + connectionID); if (connectionID < 0) { Console.WriteLine("ERROR: TG_GetNewConnectionId() returned: " + connectionID); return; } int errCode = 0; /* Set/open stream (raw bytes) log file for connection */ errCode = NativeThinkgear.TG_SetStreamLog(connectionID, "streamLog.txt"); Console.WriteLine("errCode for TG_SetStreamLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetStreamLog() returned: " + errCode); return; } /* Set/open data (ThinkGear values) log file for connection */ errCode = NativeThinkgear.TG_SetDataLog(connectionID, "dataLog.txt"); Console.WriteLine("errCode for TG_SetDataLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetDataLog() returned: " + errCode); return; } /* Attempt to connect the connection ID handle to serial port "COM5" */ string comPortName = "\\\\.\\COM40"; errCode = NativeThinkgear.TG_Connect(connectionID, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { Console.WriteLine("ERROR: TG_Connect() returned: " + errCode); return; } /* Read 10 ThinkGear Packets from the connection, 1 Packet at a time */ int packetsRead = 0; while (packetsRead < 10) { /* Attempt to read a Packet of data from the connection */ errCode = NativeThinkgear.TG_ReadPackets(connectionID, 1); Console.WriteLine("TG_ReadPackets returned: " + errCode); /* If TG_ReadPackets() was able to read a complete Packet of data... */ if (errCode == 1) { packetsRead++; /* If attention value has been updated by TG_ReadPackets()... */ if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_RAW) != 0) { /* Get and print out the updated attention value */ Console.WriteLine("New RAW value: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_RAW)); } /* end "If attention value has been updated..." */ } /* end "If a Packet of data was read..." */ } /* end "Read 10 Packets of data from connection..." */ Console.WriteLine("auto read test begin:"); errCode = NativeThinkgear.TG_EnableAutoRead(connectionID, 1); int reset_data_count = 0; int conOut3 = 0; int conOut4 = 0; if (errCode == 0) { packetsRead = 0; //NativeThinkgear.MWM15_setFilterType(connectionID, NativeThinkgear.FilterType.MWM15_FILTER_TYPE_50HZ); while (packetsRead < 15000) { /* If raw value has been updated ... */ if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW) != 0) { /* Get and print out the updated raw value */ if (packetsRead % 200 == 0) { Console.WriteLine("New RAW value: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW)); } else { NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW); } packetsRead++; /* * if (packetsRead == 800 || packetsRead == 1600) * { * NativeThinkgear.MWM15_getFilterType(connectionID); * Console.WriteLine(" MWM15_getFilterType called"); * }*/ } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_POOR_QUALITY) != 0) { Console.WriteLine("BMD200_DATA_POOR_QUALITY: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_POOR_QUALITY)); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_HEART_RATE) != 0) { Console.WriteLine("BMD200_DATA_HEART_RATE: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_HEART_RATE)); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_SQS_LAST) != 0) { Console.WriteLine("BMD200_DATA_SQS_LAST: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_SQS_LAST)); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_SQS_OVERALL) != 0) { Console.WriteLine("BMD200_DATA_SQS_OVERALL: : " + NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_SQS_OVERALL)); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_RR_INTERVAL) != 0) { Console.WriteLine("BMD200_DATA_RR_INTERVAL: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_RR_INTERVAL)); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_1_RAW_FLAG) != 0) { Console.WriteLine("BMD200_1_RAW_FLAG: : "); NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_1_RAW_FLAG); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_ConOut4) != 0) { conOut4 = (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_ConOut4); Console.WriteLine("BMD200_DATA_ConOut4: : " + conOut4); } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_ConOut3) != 0) { conOut3 = (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_ConOut3); Console.WriteLine("BMD200_DATA_ConOut3: " + conOut3 + " BMD200_DATA_ConOut4: " + conOut4); reset_data_count++; if (reset_data_count == 2) { Console.WriteLine("BMD200_set8PacketMode: : "); NativeThinkgear.BMD200_set8PacketMode(connectionID, conOut4, conOut3); } else if (reset_data_count == 15) { NativeThinkgear.BMD200_set1PacketMode(connectionID, conOut4, conOut3); Console.WriteLine("BMD200_set1PacketMode: : "); } } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW_8B_1) != 0) { if (packetsRead % 100 == 0) { Console.WriteLine("BMD200_DATA_RAW_8B_1: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW_8B_1)); } else { NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_DATA_RAW_8B_1); } packetsRead += 8; } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.BMD200_8_RAW_FLAG) != 0) { Console.WriteLine("BMD200_8_RAW_FLAG: : "); NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.BMD200_8_RAW_FLAG); } /* * if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.MWM15_DATA_FILTER_TYPE) != 0) * { * Console.WriteLine(" Find Filter Type: " + NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.MWM15_DATA_FILTER_TYPE)); * break; * }*/ } errCode = NativeThinkgear.TG_EnableAutoRead(connectionID, 0); //stop Console.WriteLine("auto read test stoped: " + errCode); } else { Console.WriteLine("auto read test failed: " + errCode); } NativeThinkgear.TG_Disconnect(connectionID); // disconnect test /* Clean up */ NativeThinkgear.TG_FreeConnection(connectionID); /* End program */ Console.ReadLine(); }
static void Main(string[] args) { NativeThinkgear thinkgear = new NativeThinkgear(); /* Print driver version number */ Console.WriteLine("Version: " + NativeThinkgear.TG_GetVersion()); /* Get a connection ID handle to ThinkGear */ int connectionID = NativeThinkgear.TG_GetNewConnectionId(); Console.WriteLine("Connection ID: " + connectionID); if (connectionID < 0) { Console.WriteLine("ERROR: TG_GetNewConnectionId() returned: " + connectionID); return; } int errCode = 0; /* Set/open stream (raw bytes) log file for connection */ errCode = NativeThinkgear.TG_SetStreamLog(connectionID, "streamLog.txt"); Console.WriteLine("errCode for TG_SetStreamLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetStreamLog() returned: " + errCode); return; } /* Set/open data (ThinkGear values) log file for connection */ errCode = NativeThinkgear.TG_SetDataLog(connectionID, "dataLog.txt"); Console.WriteLine("errCode for TG_SetDataLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetDataLog() returned: " + errCode); return; } /* Attempt to connect the connection ID handle to serial port "COM5" */ string comPortName = "\\\\.\\COM40"; errCode = NativeThinkgear.TG_Connect(connectionID, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { Console.WriteLine("ERROR: TG_Connect() returned: " + errCode); return; } /* Read 10 ThinkGear Packets from the connection, 1 Packet at a time */ int packetsRead = 0; while (packetsRead < 10) { /* Attempt to read a Packet of data from the connection */ errCode = NativeThinkgear.TG_ReadPackets(connectionID, 1); Console.WriteLine("TG_ReadPackets returned: " + errCode); /* If TG_ReadPackets() was able to read a complete Packet of data... */ if (errCode == 1) { packetsRead++; /* If attention value has been updated by TG_ReadPackets()... */ if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_RAW) != 0) { /* Get and print out the updated attention value */ Console.WriteLine("New RAW value: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_RAW)); } /* end "If attention value has been updated..." */ } /* end "If a Packet of data was read..." */ } /* end "Read 10 Packets of data from connection..." */ Console.WriteLine("auto read test begin:"); errCode = NativeThinkgear.TG_EnableAutoRead(connectionID, 1); if (errCode == 0) { packetsRead = 0; NativeThinkgear.MWM15_setFilterType(connectionID, NativeThinkgear.FilterType.MWM15_FILTER_TYPE_50HZ); while (packetsRead < 2000) { /* If raw value has been updated ... */ if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_RAW) != 0) { /* Get and print out the updated raw value */ if (packetsRead % 20 == 0) { Console.WriteLine("New RAW value: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_RAW)); } else { NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_RAW); } packetsRead++; if (packetsRead == 800 || packetsRead == 1600) { NativeThinkgear.MWM15_getFilterType(connectionID); Console.WriteLine(" MWM15_getFilterType called"); } } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.MWM15_DATA_FILTER_TYPE) != 0) { Console.WriteLine(" Find Filter Type: " + NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.MWM15_DATA_FILTER_TYPE)); break; } } errCode = NativeThinkgear.TG_EnableAutoRead(connectionID, 0); //stop Console.WriteLine("auto read test stoped: " + errCode); } else { Console.WriteLine("auto read test failed: " + errCode); } NativeThinkgear.TG_Disconnect(connectionID); // disconnect test /* Clean up */ NativeThinkgear.TG_FreeConnection(connectionID); /* End program */ Console.ReadLine(); }
private void getMindData() { NativeThinkgear thinkgear = new NativeThinkgear(); Console.WriteLine("Version: " + NativeThinkgear.TG_GetVersion()); int connectionID = NativeThinkgear.TG_GetNewConnectionId(); Console.WriteLine("Connection ID: " + connectionID); if (connectionID < 0) { Console.WriteLine("ERROR: TG_GetNewConnectionId() returned: " + connectionID); return; } errCode = NativeThinkgear.TG_SetStreamLog(connectionID, "streamLog.txt"); Console.WriteLine("errCode for TG_SetStreamLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetStreamLog() returned: " + errCode); return; } errCode = NativeThinkgear.TG_SetDataLog(connectionID, "dataLog.txt"); Console.WriteLine("errCode for TG_SetDataLog : " + errCode); if (errCode < 0) { Console.WriteLine("ERROR: TG_SetDataLog() returned: " + errCode); return; } string comPortName = "\\\\.\\COM4"; errCode = NativeThinkgear.TG_Connect(connectionID, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { Console.WriteLine("ERROR: TG_Connect() returned: " + errCode); return; } int packetsRead = 0; while (packetsRead < 10) { errCode = NativeThinkgear.TG_ReadPackets(connectionID, 1); Console.WriteLine("TG_ReadPackets returned: " + errCode); if (errCode == 1) { packetsRead++; if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_ATTENTION) != 0) { /* Get and print out the updated attention value */ Console.WriteLine("New ATT value: : " + (int)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_ATTENTION)); } } } Console.WriteLine("Preparation is complete"); errCode = NativeThinkgear.TG_EnableAutoRead(connectionID, 1); packetsRead = 0; if (errCode == 0) { Date = DateTime.Now; NativeThinkgear.MWM15_setFilterType(connectionID, NativeThinkgear.FilterType.MWM15_FILTER_TYPE_50HZ); while (Run) { if (!controllType) { newData = false; for (int i = 0; i < Signals.Count; i++) { if (NativeThinkgear.TG_GetValueStatus(connectionID, Signals[i].Type) != 0) { Console.WriteLine("New Signal(" + Signals[i].Name + "): " + (int)NativeThinkgear.TG_GetValue(connectionID, Signals[i].Type)); Double value = (Double)NativeThinkgear.TG_GetValue(connectionID, Signals[i].Type); Signals[i].Add(value); newData = true; } } if (Chart.IsHandleCreated && newData) { this.Invoke((MethodInvoker) delegate { UpdateChart(); }); } } else { if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_ATTENTION) != 0) { bufAtt = (Double)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_ATTENTION); Console.WriteLine("New ATT value#" + Ca + ": " + (int)bufAtt); if (bufAtt != 0) { A = true; Ca++; } else { A = false; } } else { A = false; } if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_MEDITATION) != 0) { bufMed = (Double)NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_MEDITATION); Console.WriteLine("New MED value#" + Cm + ": " + (int)bufMed); if (bufMed != 0) { M = true; Cm++; } else { M = false; } } else { M = false; } if (A || M) { dataAtt[readyFor] = bufAtt; dataMed[readyFor] = bufMed; Graph[(int)bufAtt][(int)bufMed] = true; readyFor++; if (Clust) { addPoint((int)bufAtt, (int)bufMed); } if (readyFor == sizeFor) { Clusterisation(); Clust = true; } if (Chart.IsHandleCreated) { this.Invoke((MethodInvoker) delegate { UpdateChart(); }); } } } packetsRead++; } NativeThinkgear.TG_Disconnect(connectionID); NativeThinkgear.TG_FreeConnection(connectionID); } else { Console.WriteLine("Disable to read"); return; } ListSign.Enabled = true; }
public int ConnectDriver(string com) { // 创建连接 connectionId = NativeThinkgear.TG_GetNewConnectionId(); Console.WriteLine("Connection ID: " + connectionId); if (connectionId < 0) { // 创建连接失败 Console.WriteLine("ERROR: TG_GetNewConnectionId() returned: " + connectionId); foreach (IDriverConnectListener dc in arr) { dc.AfterDriverConnectedFailed(); } return(-1); } int errCode = 0; /* 设置流 */ errCode = NativeThinkgear.TG_SetStreamLog(connectionId, "streamLog.txt"); Console.WriteLine("errCode for TG_SetStreamLog : " + errCode); if (errCode < 0) { // 设置流失败 Console.WriteLine("ERROR: TG_SetStreamLog() returned: " + errCode); foreach (IDriverConnectListener dc in arr) { dc.AfterDriverConnectedFailed(); } return(-2); } errCode = NativeThinkgear.TG_SetDataLog(connectionId, "./tmp/dataLog.log"); if (errCode < 0) { // 设置数据流失败 Console.WriteLine("ERROR: TG_SetDataLog() returned: " + errCode); foreach (IDriverConnectListener dc in arr) { dc.AfterDriverConnectedFailed(); } return(-3); } string comPortName = "\\\\.\\COM"; comPortName += com; errCode = NativeThinkgear.TG_Connect(connectionId, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { // 连接设备失败 Console.WriteLine("ERROR: TG_Connect() returned: " + errCode); foreach (IDriverConnectListener dc in arr) { dc.AfterDriverConnectedFailed(); } return(-4); } else { Console.WriteLine("Connect successful。"); } isOff = false; foreach (IDriverConnectListener dc in arr) { dc.AfterDriverConnectedSuc(); } return(connectionId); }
public static void CollectData(string userId, int numTrials, int trialStatus, string savePath, int sampleRate, bool toFile) { #region INITIALIZE Console.WriteLine("[INFO] Finding trial offset..."); int trialOffset = GetTrialOffset(savePath, userId, trialStatus); Console.WriteLine("[INFO] Trial offset = " + trialOffset.ToString()); StreamWriter rawWriter = new StreamWriter(savePath, true); DateTime previousTime; double seconds = 0.0f; int currentTrial = 0; int packetsRead = 0; int currentPacket = 0; string comPortName = "COM3"; Console.WriteLine("[INFO] Starting data collection in 3 seconds..."); Thread.Sleep(3000); Console.WriteLine("[INFO] Initializing headset..."); NativeThinkgear thinkgear = new NativeThinkgear(); Console.WriteLine("[INFO] Version: " + NativeThinkgear.TG_GetVersion()); /* Get a connection ID handle to ThinkGear */ int connectionID = NativeThinkgear.TG_GetNewConnectionId(); Console.WriteLine("[INFO] Connection ID: " + connectionID); if (connectionID < 0) { Console.WriteLine("[ERROR] TG_GetNewConnectionId() returned: " + connectionID); return; } int errCode = 0; /* Set/open stream (raw bytes) log file for connection */ errCode = NativeThinkgear.TG_SetStreamLog(connectionID, "streamLog.txt"); Console.WriteLine("[INFO] errCode for TG_SetStreamLog : " + errCode); if (errCode < 0) { Console.WriteLine("[ERROR] TG_SetStreamLog() returned: " + errCode); return; } /* Set/open data (ThinkGear values) log file for connection */ errCode = NativeThinkgear.TG_SetDataLog(connectionID, "dataLog.txt"); Console.WriteLine("[INFO] errCode for TG_SetDataLog : " + errCode); if (errCode < 0) { Console.WriteLine("[ERROR] TG_SetDataLog() returned: " + errCode); return; } /* Attempt to connect the connection ID handle to serial port "COM5" */ errCode = NativeThinkgear.TG_Connect(connectionID, comPortName, NativeThinkgear.Baudrate.TG_BAUD_57600, NativeThinkgear.SerialDataFormat.TG_STREAM_PACKETS); if (errCode < 0) { Console.WriteLine("[ERROR] TG_Connect() returned: " + errCode); return; } Console.WriteLine("[INFO] Initializing headset finsihed."); #endregion #region PROCESS List <Trial> trialList = new List <Trial>(); while (currentTrial < numTrials) { /* Attempt to read a Packet of data from the connection */ errCode = NativeThinkgear.TG_ReadPackets(connectionID, 1); /* If TG_ReadPackets() was able to read a complete Packet of data... */ if (errCode == 1) { /* The raw data was updated since the last call */ if (NativeThinkgear.TG_GetValueStatus(connectionID, NativeThinkgear.DataType.TG_DATA_RAW) != 0) { /* Skip the first 2 seconds to avoid bad data */ if (packetsRead < sampleRate * 2) { Console.Write("\r[INFO] Skipping Packet (" + currentPacket + "/" + sampleRate * 2 + ")"); packetsRead++; currentPacket++; continue; } if (currentPacket % sampleRate == 0) { currentPacket = 0; currentTrial++; previousTime = DateTime.Now; seconds = (DateTime.Now - previousTime).TotalSeconds; if (toFile && trialList.Count > 0) { InsertTrialData(trialList, rawWriter); } trialList.Clear(); } //! Set up data for Trial float _raw = NativeThinkgear.TG_GetValue(connectionID, NativeThinkgear.DataType.TG_DATA_RAW); DateTime _time = DateTime.Now; Trial _currentTrial = new Trial(userId, trialStatus, currentTrial + trialOffset, _raw, currentPacket, _time); trialList.Add(_currentTrial); if (toFile && (currentPacket % sampleRate == 0 || currentPacket % sampleRate == 511)) { Console.WriteLine("[TRIAL] Trial=" + currentTrial + " Packet=" + currentPacket + " UserID=" + userId + " Status=" + trialStatus + " Total_Trial=" + (currentTrial + trialOffset)); } //! Update trackers packetsRead++; currentPacket++; } } /* end "If a Packet of data was read..." */ } /* end "Read 10 Packets of data from connection..." */ #endregion #region DISCONNECT Console.WriteLine("[INFO] Disconnecting..."); NativeThinkgear.TG_Disconnect(connectionID); // disconnect test /* Clean up */ NativeThinkgear.TG_FreeConnection(connectionID); /* End program */ Console.ReadLine(); rawWriter.Close(); #endregion }