Click or drag to resize
BioRadioDeviceManagerCreateVirtualDevice Method
Creates a virtual device wrapper to allow reading data from a file recorded by the BioRadio to its internal memory.

Namespace: GLNeuroTech.Devices.BioRadio
Assembly: BioRadioAPI (in BioRadioAPI.dll) Version: 1.0.266.19973 (1.0.266.19973)
Syntax
public override VirtualDeviceAdapter CreateVirtualDevice(
	string fileName
)

Parameters

fileName
Type: SystemString
The full path to the file to be read

Return Value

Type: VirtualDeviceAdapter
An adapter that can be used to parse the file and extract data.

Implements

IDeviceManagerTCreateVirtualDevice(String)
Remarks
The VirtualDeviceAdapter is a lightweight wrapper around the actual device instance, which allows a user to "feed" data in from the file and make it available on the device Signal instances. Typically, one will create an instance of VirtualDeviceAdapter and use it to loop through the data contained in the file until the end of the file is reached.
Examples
This example shows the basics of creating a VirtualDeviceAdapter instance and reading data from a file.
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GLNeuroTech.Devices.BioRadio;


namespace BioRadioAPIExamples
{
    class ParseMemoryFile
    {
        public static void ParseFile(string filePath)
        {
            var deviceManager = new BioRadioDeviceManager();
            var virtualDevice = deviceManager.CreateVirtualDevice(filePath);

            var deviceInstance = (BioRadioDevice) virtualDevice.BaseDevice;

            // Loop over the file until we reach the end.
            while (!virtualDevice.EndOfFileReached)
            {
                // Iterate through the BioPotential signals and read all samples. 
                // This example assumes the input file only contains biopotential data, and no data in the other device signal groups.
                foreach (var signal in deviceInstance.BioPotentialSignals)
                {
                    var data = signal.GetScaledValueArray();
                    foreach (var value in data)
                    {
                        Console.Write("{0} ", value);
                    }
                }

                // Feed the next chunk of file data. This causes the VirtualDeviceAdapter to parse the next set 
                //  of data and make it available on its BaseDevice's Signal instances.
                virtualDevice.FeedNextChunk();
            }
        }
    }
}
See Also