// Define the LED Intensities of both sensors (CH1 and CH2) as: {RED, INFRARED}
// Define the LED Intensities of both sensors (CH1 and CH2) as: {RED, INFRARED}
int redLedIntensity = (int) (int.Parse(RedIntensityDropdown.options[RedIntensityDropdown.value].text) * (MaxLedIntensity / 100f)); // A 8-bit value (0-255)
int redLedIntensity = (int) (int.Parse(RedIntensityDropdown.options[RedIntensityDropdown.value].text) * (MaxLedIntensity / 100f)); // A 8-bit value (0-255)
int infraredLedIntensity = (int)(int.Parse(InfraredIntensityDropdown.options[InfraredIntensityDropdown.value].text) * (MaxLedIntensity / 100f)); // A 8-bit value (0-255)
int infraredLedIntensity = (int)(int.Parse(InfraredIntensityDropdown.options[InfraredIntensityDropdown.value].text) * (MaxLedIntensity / 100f)); // A 8-bit value (0-255)
int[] ledIntensities = new int[2] { redLedIntensity, infraredLedIntensity };
int[] ledIntensities = new int[2] { redLedIntensity, infraredLedIntensity };
// Enable the "Stop Acquisition" button and disable the "Start Acquisition" button.
// Enable the "Stop Acquisition" button and disable the "Start Acquisition" button.
StartAcqButton.interactable = false;
StartAcqButton.interactable = false;
StopAcqButton.interactable = true;
StopAcqButton.interactable = true;
}
}
else
else
{
{
// Present an informative message about the error.
// Present an informative message about the error.
OutputMsgText.text = !exceptionRaised ? "It was not possible to start a real-time data acquisition. Please, try to repeat the scan/connect/start workflow." : exceptionMessage;
OutputMsgText.text = !exceptionRaised ? "It was not possible to start a real-time data acquisition. Please, try to repeat the scan/connect/start workflow." : exceptionMessage;
// Reboot GUI.
// Reboot GUI.
RebootGUI();
RebootGUI();
}
}
}
}
// Callback invoked every time an exception is raised in the PLUX API Plugin.
// Callback invoked every time an exception is raised in the PLUX API Plugin.
// exceptionCode -> ID number of the exception to be raised.
// exceptionCode -> ID number of the exception to be raised.
// exceptionDescription -> Descriptive message about the exception.
// exceptionDescription -> Descriptive message about the exception.
public void OnExceptionRaised(int exceptionCode, string exceptionDescription)
public void OnExceptionRaised(int exceptionCode, string exceptionDescription)
{
{
if (pluxDevManager.IsAcquisitionInProgress())
if (pluxDevManager.IsAcquisitionInProgress())
{
{
// Present an informative message about the error.
// Present an informative message about the error.
OutputMsgText.text = exceptionDescription;
OutputMsgText.text = exceptionDescription;
// Reboot GUI.
// Reboot GUI.
RebootGUI();
RebootGUI();
}
}
}
}
// Callback that receives the data acquired from the PLUX devices that are streaming real-time data.
// Callback that receives the data acquired from the PLUX devices that are streaming real-time data.
// nSeq -> Number of sequence identifying the number of the current package of data.
// nSeq -> Number of sequence identifying the number of the current package of data.
// data -> Package of data containing the RAW data samples collected from each active channel ([sample_first_active_channel, sample_second_active_channel,...]).
// data -> Package of data containing the RAW data samples collected from each active channel ([sample_first_active_channel, sample_second_active_channel,...]).
public void OnDataReceived(int nSeq, int[] data)
public void OnDataReceived(int nSeq, int[] data)
{
{
// Show samples with a 1s interval.
// Show the current package of data.
if (nSeq % samplingRate == 0)
string outputString = "Acquired Data:\n";
for (int j = 0; j < data.Length; j++)
{
{
// Show the current package of data.
outputString += data[j] + "\t";
string outputString = "Acquired Data:\n";
for (int j = 0; j < data.Length; j++)
{
outputString += data[j] + "\t";
}
// Show the values in the GUI.
OutputMsgText.text = outputString;
}
}
// Show the values in the GUI.
OutputMsgText.text = outputString;
}
}
// Callback that receives the events raised from the PLUX devices that are streaming real-time data.
// Callback that receives the events raised from the PLUX devices that are streaming real-time data.
// pluxEvent -> Event object raised by the PLUX API.
// pluxEvent -> Event object raised by the PLUX API.
public void OnEventDetected(PluxDeviceManager.PluxEvent pluxEvent)
public void OnEventDetected(PluxDeviceManager.PluxEvent pluxEvent)
{
{
if (pluxEvent is PluxDeviceManager.PluxDisconnectEvent)
if (pluxEvent is PluxDeviceManager.PluxDisconnectEvent)
{
{
// Present an error message.
// Present an error message.
OutputMsgText.text =
OutputMsgText.text =
"The connection between the computer and the PLUX device was interrupted due to the following event: " +
"The connection between the computer and the PLUX device was interrupted due to the following event: " +
(pluxEvent as PluxDeviceManager.PluxDisconnectEvent).reason;
(pluxEvent as PluxDeviceManager.PluxDisconnectEvent).reason;
// Securely stop the real-time acquisition.
// Securely stop the real-time acquisition.
pluxDevManager.StopAcquisitionUnity(-1);
pluxDevManager.StopAcquisitionUnity(-1);
// Reboot GUI.
// Reboot GUI.
RebootGUI();
RebootGUI();
} else if (pluxEvent is PluxDeviceManager.PluxDigInUpdateEvent)
} else if (pluxEvent is PluxDeviceManager.PluxDigInUpdateEvent)
{
{
PluxDeviceManager.PluxDigInUpdateEvent digInEvent = (pluxEvent as PluxDeviceManager.PluxDigInUpdateEvent);
PluxDeviceManager.PluxDigInUpdateEvent digInEvent = (pluxEvent as PluxDeviceManager.PluxDigInUpdateEvent);
Console.WriteLine("Digital Input Update Event Detected on channel " + digInEvent.channel + ". Current state: " + digInEvent.state);
Console.WriteLine("Digital Input Update Event Detected on channel " + digInEvent.channel + ". Current state: " + digInEvent.state);