Connector class
Methods
Connect to a device
void Connect(string portName)
Attempts to open a connection with the port name specified by portName. Calling this method results in one of two events being broadcasted:
DeviceConnected - A connection was successfully opened on portName
DeviceConnectFail - The connection attempt was unsuccessful
void ConnectScan()
Attempts to open a connection to the first Device seen by the Connector. Calling this method results in one of two events being broadcasted:
DeviceConnected - A connection was successfully opened on portName
DeviceConnectFail - The connection attempt was unsuccessful
void ConnectScan(string portName)
Same as ConnectScan but scans the port specified by portName first. Calling this method results in one of two events being broadcasted:
DeviceConnected - A connection was successfully opened on portName
DeviceConnectFail - The connection attempt was unsuccessful
Disconnect from a device
void Disconnect()
Closes all open connections. Calling this method will result in the following event being broadcasted for each open device:
DeviceDisconnected - The device was disconnected
void Disconnect(Connection connection)
Closes a specific Connection specified by connection. Calling this method will result in the following event being broadcasted for a specific open device:
DeviceDisconnected - The device was disconnected
void Disconnect(Device device)
Closes a specific Device specified by device. Calling this method will result in the following event being broadcasted for a specific open device:
DeviceDisconnected - The device was disconnected
Send bytes to a device
void Send(string portName, byte[] bytesToSend)
Sends an array of bytes to a specific port
Configure Mental Effort/Familiarity
void enableMentalEffort() DEPRECATED
Starts recording data for 60 seconds. Once the recording is complete, the Mental Effort will be calculated. Note: the first time the Mental Effort 2) is calculated, the result is 0.
void enableFamiliarity() DEPRECATED
Starts recording data for 60 seconds. Once the recording is complete, the Familiarity will be calculated. Note: the first time the Familiarity is calculated, the result is 0.
Events
DeviceFound
Occurs when a ThinkGear device is found. This is where the application chooses to connect to that port or not.
DeviceNotFound
Occurs when a ThinkGear device could not be found. This is usually where the application displays an error that it did not find any device.
DeviceValidating
Occurs right before the connector attempts a serial port. Mainly used to notify the GUI which port it is trying to connect.
DeviceConnected
Occurs when a ThinkGear device is connected. This is where the application links the OnDataReceived for that device.
DeviceConnectFail
Occurs when the Connector fails to connect to that port specified.
DeviceDisconnected
Occurs when the Connector disconnects from a ThinkGear device.
DataReceived
Occurs when data is available from a ThinkGear device.
TGParser Class
The TGParser class is used to convert the received data into easily accessible data contained in a Dictionary.