static void Main(string[] args)
    {
        try
        {
            // Device MAC address
            string macAddr = "BTH00:07:80:F9:DC:D5"; // replace with your device MAC address
            //string macAddr = "COM48";


            System.Console.WriteLine("Connecting to {0}...", macAddr);


            // Example without "using" keyword - need to call Dispose() at the end
            MyDevice dev = new MyDevice(macAddr);
            Dictionary <string, object> props = dev.GetProperties();
            System.Console.WriteLine("Device description: {0} - {1}", props["description"], props["path"]);


            dev.freq = 1000; // acquisition base frequency of 1000 Hz


            // Setting sensor sources individually...

            PluxDotNet.Source src_acc = new PluxDotNet.Source();
            src_acc.port   = 11;   // ACC source port
            src_acc.chMask = 0x07; // bitmask for channels 1,2,3
            // src_acc.nBits kept at default value of 16


            PluxDotNet.Source src_spo2 = new PluxDotNet.Source();
            src_spo2.port   = 9;    // SPO2 source port
            src_spo2.chMask = 0x0F; // 2-Pair of Leds

            int[] LED_param = { 80, 40 };
            dev.SetParameter(0x09, 0x03, LED_param, 2); // update oximeter LED values (Red and IR)


            List <PluxDotNet.Source> srcs = new List <PluxDotNet.Source>()
            {
                src_acc, src_spo2
            };


            dev.Start(dev.freq, srcs); // start acquisition


            System.Console.WriteLine("Acquisition started. Press a key to stop.");

            dev.Loop();    // run message loop

            dev.Stop();    // stop acquisition

            dev.Dispose(); // disconnect from device
        }
        catch (PluxDotNet.Exception.PluxException e)
        {
            System.Console.WriteLine("Exception: {0}", e.Message);
            //System.Console.WriteLine("Exception: {0} - {1}:{2} ({3})", e.Message, e.file, e.line, e.function);
        }
    }
    static void Main(string[] args)
    {
        try
        {
            // Device MAC address
            string macAddr = null;

            if (args.Length > 0)
            {
                if (String.Compare(args[0], "scan", true) == 0)
                {
                    // Search for Plux devices in range and use the first found
                    System.Console.WriteLine("Scanning for devices...");
                    List <PluxDotNet.DevInfo> devs = PluxDotNet.BaseDev.FindDevices();
                    if (devs.Count > 0)
                    {
                        System.Console.WriteLine("Devices found:");
                        foreach (PluxDotNet.DevInfo devInfo in devs)
                        {
                            System.Console.WriteLine(" * {0} - {1}", devInfo.path, devInfo.description);
                        }
                        macAddr = devs[0].path;
                    }
                    else
                    {
                        System.Console.WriteLine("No devices found.");
                        System.Environment.Exit(1);
                    }
                }
                else
                {
                    // Device MAC address:
                    macAddr = args[0];
                    //macAddr = "BTH58:8E:81:A2:41:A6";  // replace with your device MAC address
                    //macAddr = "BLE58:8E:81:A2:41:A6";
                    //macAddr = "COM48";
                }
            }
            else
            {
                //System.Console.WriteLine(" ERROR: NULL input parameter. \n Please define device MAC address as input parameter or 'scan' keyword to search for Plux devices in range");
            }

            if (!String.IsNullOrEmpty(macAddr))
            {
                System.Console.WriteLine("Connecting to {0}...", macAddr);


                // Example without "using" keyword - need to call Dispose() at the end
                MyDevice dev = new MyDevice(macAddr);

                Dictionary <string, object> props = dev.GetProperties();
                System.Console.WriteLine("Device description: {0} - {1}", props["description"], props["path"]);


                dev.freq = 200; // acquisition base frequency of 200 Hz


                if (props["description"].ToString() == "biosignalsplux")
                {
                    // (connecting to biosignalsplux Device)


                    // start acquisition (CH1-CH4 acquisition, 16-bits)
                    //dev.Start(dev.freq, 0x0F, 16);


                    // Setting sensor sources individually...

                    PluxDotNet.Source src_emg1 = new PluxDotNet.Source();
                    src_emg1.port = 1; // EMG source port
                    // src_emg1.freqDivisor kept at default value of 1
                    // src_emg1.chMask kept at default value of 1 (channel 1 only)
                    // src_emg1.nBits kept at default value of 16

                    PluxDotNet.Source src_emg2 = new PluxDotNet.Source();
                    src_emg2.port = 2; // EMG source port
                    // src_emg2.freqDivisor kept at default value of 1
                    // src_emg2.chMask kept at default value of 1 (channel 1 only)
                    // src_emg2.nBits kept at default value of 16

                    PluxDotNet.Source src_ecg = new PluxDotNet.Source();
                    src_ecg.port = 3; // ECG source port
                    // src_ecg.freqDivisor kept at default value of 1
                    // src_ecg.chMask kept at default value of 1 (channel 1 only)
                    // src_ecg.nBits kept at default value of 16

                    // ...

                    PluxDotNet.Source src_spo2 = new PluxDotNet.Source();
                    src_spo2.port   = 5;    // SPO2 source port
                    src_spo2.chMask = 0x03; // One-pair of leds (Red + IR)


                    List <PluxDotNet.Source> srcs = new List <PluxDotNet.Source>()
                    {
                        src_emg1, src_emg2, src_ecg, src_spo2
                    };


                    int[] LED_param = { 80, 40 };               // LED values (0-255). Default values:
                                                                //  * Head band -> Red = 80, IR = 40;
                                                                //  * Arm band -> Red = 4, IR = 2;
                    dev.SetParameter(0x05, 0x03, LED_param, 2); // update oximeter LED values (Red and IR)

                    dev.Start(dev.freq, srcs);                  // start acquisition

                    System.Console.WriteLine("Acquisition started. Press a key to stop.");

                    dev.Loop(); // run message loop

                    dev.Stop(); // stop acquisition
                }
                else
                {
                    System.Console.WriteLine("Device is not a biosignalsplux: {0}", props["description"]);
                }

                dev.Dispose(); // disconnect from device
            }
            else
            {
                System.Console.WriteLine(" ERROR: NULL input parameter. \n Please define device MAC address as input parameter or 'scan' keyword to search for Plux devices in range");
            }
        }
        catch (PluxDotNet.Exception.PluxException e)
        {
            System.Console.WriteLine("Exception: {0}", e.Message);
            //System.Console.WriteLine("Exception: {0} - {1}:{2} ({3})", e.Message, e.file, e.line, e.function);
        }
    }
Пример #3
0
    static void Main(string[] args)
    {
        try
        {
            // Device MAC address
            string macAddr = null;

            if (args.Length > 0)
            {
                if (String.Compare(args[0], "scan", true) == 0)
                {
                    // Search for Plux devices in range and use the first found
                    System.Console.WriteLine("Scanning for devices...");
                    List <PluxDotNet.DevInfo> devs = PluxDotNet.BaseDev.FindDevices();
                    foreach (PluxDotNet.DevInfo devInfo in devs)
                    {
                        System.Console.WriteLine(" * {0} - {1}", devInfo.path, devInfo.description);
                    }
                    macAddr = devs[0].path;
                }
                else
                {
                    // Device MAC address:
                    macAddr = args[0];
                    //macAddr = "BTH88:6B:0F:4D:F6:D0";  // replace with your device MAC address
                    //macAddr = "BLE88:6B:0F:4D:F6:D0";
                    //macAddr = "COM48";
                }
            }
            else
            {
                System.Console.WriteLine(" ERROR: NULL input parameter. \n Please define device MAC address as input parameter or 'scan' keyword to search for Plux devices in range");
            }


            if (!String.IsNullOrEmpty(macAddr))
            {
                System.Console.WriteLine("Connecting to {0}...", macAddr);


                // Example without "using" keyword - need to call Dispose() at the end
                MyDevice dev = new MyDevice(macAddr);
                //MyDevice dev = new MyDevice_mem(macAddr);
                Dictionary <string, object> props = dev.GetProperties();
                System.Console.WriteLine("Device description: {0} - {1}", props["description"], props["path"]);

                dev.freq = 1000; // acquisition base frequency of 1000 Hz


                if (props["description"].ToString() == "biosignalsplux")
                {
                    // (connecting to biosignalsplux Device)

                    // start acquisition (CH1-CH8 acquisition, 16-bits)
                    dev.Start(dev.freq, 0xFF, 16);

                    /*
                     * // Setting sensor sources individually...
                     *
                     * PluxDotNet.Source src_emg1 = new PluxDotNet.Source();
                     * src_emg1.port = 1; // EMG source port
                     * // src_emg1.freqDivisor kept at default value of 1
                     * // src_emg1.chMask kept at default value of 1 (channel 1 only)
                     * // src_emg1.nBits kept at default value of 16
                     *
                     * PluxDotNet.Source src_emg2 = new PluxDotNet.Source();
                     * src_emg2.port = 2; // EMG source port
                     * // src_emg2.freqDivisor kept at default value of 1
                     * // src_emg2.chMask kept at default value of 1 (channel 1 only)
                     * // src_emg2.nBits kept at default value of 16
                     *
                     * PluxDotNet.Source src_ecg = new PluxDotNet.Source();
                     * src_ecg.port = 3; // ECG source port
                     * // src_ecg.freqDivisor kept at default value of 1
                     * // src_ecg.chMask kept at default value of 1 (channel 1 only)
                     * // src_ecg.nBits kept at default value of 16
                     *
                     * // ...
                     *
                     * List<PluxDotNet.Source> srcs = new List<PluxDotNet.Source>() { src_emg, src_ecg };
                     *
                     * dev.Start(dev.freq, srcs);  // start acquisition
                     */
                }
                else if (props["description"].ToString() == "MuscleBAN BE Plux")
                {
                    // (connecting to MuscleBAN Device)

                    PluxDotNet.Source src_emg = new PluxDotNet.Source();
                    src_emg.port        = 1;   // EMG source port
                    src_emg.freqDivisor = 100; // divide 1000 Hz by 100 to send EMG envelope at 10 Hz
                    // src_emg.chMask kept at default value of 1 (channel 1 only)
                    // src_emg.nBits kept at default value of 16

                    PluxDotNet.Source src_acc = new PluxDotNet.Source();
                    src_acc.port = 2;      // ACC source port
                    // src_acc.freqDivisor kept at default value of 1
                    src_acc.chMask = 0x07; // bitmask for channels 1,2,3
                    // src_acc.nBits kept at default value of 16

                    List <PluxDotNet.Source> srcs = new List <PluxDotNet.Source>()
                    {
                        src_emg, src_acc
                    };

                    dev.Start(dev.freq, srcs); // start acquisition
                }
                else if (props["description"].ToString() == "OpenBANPlux")
                {
                    // (connecting to OpenBAN Device)

                    PluxDotNet.Source src_mic = new PluxDotNet.Source();
                    src_mic.port = 1; // MIC source port
                    // src_mic.freqDivisor kept at default value of 1
                    // src_mic.chMask kept at default value of 1 (channel 1 only)
                    // src_mic.nBits kept at default value of 16

                    PluxDotNet.Source src_emg = new PluxDotNet.Source();
                    src_emg.port = 2; // EMG source port
                    // src_emg.freqDivisor kept at default value of 1
                    // src_emg.chMask kept at default value of 1 (channel 1 only)
                    // src_emg.nBits kept at default value of 16

                    PluxDotNet.Source src_acc = new PluxDotNet.Source();
                    src_acc.port = 11;     // ACC source port
                    // src_acc.freqDivisor kept at default value of 1
                    src_acc.chMask = 0x07; // bitmask for channels 1,2,3
                    // src_acc.nBits kept at default value of 16

                    List <PluxDotNet.Source> srcs = new List <PluxDotNet.Source>()
                    {
                        src_mic, src_emg, src_acc
                    };

                    dev.Start(dev.freq, srcs); // start acquisition
                }
                else
                {
                    // (...)
                }

                System.Console.WriteLine("Acquisition started. Press a key to stop.");

                dev.Loop();    // run message loop

                dev.Stop();    // stop acquisition

                dev.Dispose(); // disconnect from device
            }
        }
        catch (PluxDotNet.Exception.PluxException e)
        {
            System.Console.WriteLine("Exception: {0} - {1}:{2} ({3})", e.Message, e.file, e.line, e.function);
        }
    }