コード例 #1
0
 protected virtual uint ChannelBlock_AddQueue(out int handle, int number_of_queues, int queuesize, int threshold, SampleSizeNet samplesize, SampleDstSizeNet sampleDstSize);
コード例 #2
0
 public virtual void SetSelectedData(bool[] selectedChannels, int queuesize, int threshold, SampleSizeNet samplesize, SampleDstSizeNet sampleDstSize, int ChannelsInBlock);
コード例 #3
0
 public virtual int AddSelectedChannelsQueue(int nOffset, int nChannels, int queuesize, int threshold, SampleSizeNet samplesize, SampleDstSizeNet sampleDstSize);
コード例 #4
0
 //
 // Summary:
 //     Create a common FIFO queue for all channels. Data in callback will be a list
 //     per channel. Use ChannelBlock_ReadFramesDict... with handle = 0 to read the data.
 //
 // Parameters:
 //   nChannels:
 //     Number of channels to be collected in the FIFO.
 //
 //   queuesize:
 //     Size of sample frames the FIFO can hold.
 //
 //   threshold:
 //     Number of sample frames the FIFO must acquire before the callback function is
 //     called.
 //
 //   samplesize:
 //     size of the datawords, either 16 or 32bit.
 //
 //   ChannelsInBlock:
 //     value obtained from GetChannelsInBlock.
 //
 // Remarks:
 //     When using 32 bit data format, ChannelsInBlock is still the number of 16 bit
 //     channels per frame, as obtained from GetChannelsInBlock, while nChannels is the
 //     number of 32 bit channels to be read from the device. So when all channels from
 //     a device are read in 32 bit data format nChannels = ChannelsInBlock/2
 public virtual void SetSelectedChannelsQueue(int nChannels, int queuesize, int threshold, SampleSizeNet samplesize, int ChannelsInBlock);
コード例 #5
0
ファイル: DAQcontroller.cs プロジェクト: thentnucyborg/MEAME2
        public bool connectDataAcquisitionDevice(uint index)
        {
            this.dataFormat = SampleSizeNet.SampleSize32Signed;

            if (dataAcquisitionDevice != null)
            {
                dataAcquisitionDevice.StopDacq();
                dataAcquisitionDevice.Disconnect();
                dataAcquisitionDevice.Dispose();
                dataAcquisitionDevice = null;
                throw new System.ArgumentException("Reached bad code path", "DAQ is null, mcs cruft");
            }

            dataAcquisitionDevice = new CMeaDeviceNet(usblist.GetUsbListEntry(index).DeviceId.BusType,
                                                      _onChannelData,
                                                      onError);


            // The second arg refers to lock mask, allowing multiple device objects to be connected
            // to the same physical device. Yes, I know, what the f**k...
            dataAcquisitionDevice.Connect(usblist.GetUsbListEntry(index), 1);
            dataAcquisitionDevice.SendStop();

            int what = 0;

            dataAcquisitionDevice.HWInfo().GetNumberOfHWADCChannels(out what);
            hwchannels = what;

            dataAcquisitionDevice.SetNumberOfChannels(hwchannels);
            dataAcquisitionDevice.EnableDigitalIn(false, 0);
            dataAcquisitionDevice.EnableChecksum(false, 0);
            dataAcquisitionDevice.SetDataMode(DataModeEnumNet.dmSigned32bit, 0);

            // block:
            // get the number of 16 bit datawords which will be collected per sample frame,
            // use after the device is configured. (which means?, setting data mode, num channels etc?)
            int ana, digi, che, tim, block;

            dataAcquisitionDevice.GetChannelLayout(out ana, out digi, out che, out tim, out block, 0);


            dataAcquisitionDevice.SetSampleRate(samplerate, 1, 0);

            int gain = dataAcquisitionDevice.GetGain();

            List <CMcsUsbDacqNet.CHWInfo.CVoltageRangeInfoNet> voltageranges;

            dataAcquisitionDevice.HWInfo().
            GetAvailableVoltageRangesInMicroVoltAndStringsInMilliVolt(out voltageranges);


            bool[] selectedChannels = new bool[block];
            for (int i = 0; i < block; i++)
            {
                selectedChannels[i] = true;
            }                                                        // hurr


            // *org [[file:killme.cs::/%20a%20device%20are%20read%20in%2032%20bit%20data%20format%20nChannels%20=%20ChannelsInBlock/2][documentation]]
            bool[]        nChannels       = selectedChannels;
            int           queueSize       = 120000;
            int           threshold       = segmentLength;
            SampleSizeNet sampleSize      = dataFormat;
            int           ChannelsInBlock = block / 2;

            dataAcquisitionDevice.SetSelectedChannelsQueue
                (nChannels,
                queueSize, // huh?
                threshold,
                sampleSize,
                ChannelsInBlock);

            mChannelHandles = block;

            dataAcquisitionDevice.ChannelBlock_SetCheckChecksum((uint)che, (uint)tim); // ???

            // int voltrange = voltageranges.ToArray()[0];

            int validDataBits    = -1;
            int deviceDataFormat = -1;

            /**
             * Summary:
             *  Get the real number of data bits.
             *
             * Remarks:
             *  This value may be different from the value returned by GetDataFormat, e.g. in
             *  MC_Card the data are shifted 2 bits so the real number is 14 while the data format
             *  is 16 bits
             */
            dataAcquisitionDevice.GetNumberOfDataBits(0,
                                                      DacqGroupChannelEnumNet.HeadstageElectrodeGroup,
                                                      out validDataBits);

            dataAcquisitionDevice.GetDataFormat(0,
                                                DacqGroupChannelEnumNet.HeadstageElectrodeGroup,
                                                out deviceDataFormat);

            DataModeEnumNet dataMode = dataAcquisitionDevice.GetDataMode(0);


            /**
             * Summary:
             * Get the number of 16 bit datawords which will be collected per sample frame,
             * use after the device is configured.
             *
             * Returns:
             * Number of 16 bit datawords per sample frame.
             * Returns 132 (66 32 bit words???)
             */
            int meme = dataAcquisitionDevice.GetChannelsInBlock();

            deviceInfo =
                "Data acquisition device connected to physical device with parameters: \n" +
                $"[SetSelectedChannelsQueue arguments:]\n" +
                $"nChannels           \t{selectedChannels}\n" +
                $"queueSize:          \t{queueSize}\n" +
                $"threshold:          \t{threshold}\n" +
                $"samplesize:         \t{sampleSize}\n" +
                $"channelsInBlock:    \t{ChannelsInBlock}\n\n" +
                $"[Experiment params]\n" +
                $"sample rate:        \t{samplerate}\n" +
                $"Voltage range:      \t{voltageranges[0].VoltageRangeDisplayStringMilliVolt}\n" +
                $"Corresponding to    \t{voltageranges[0].VoltageRangeInMicroVolt} µV\n" +
                $"[Device channel layout]\n\n" +
                $"hardware channels:  \t{hwchannels}\n" + // 64
                $"analog channels:    \t{ana}\n" +        // 128
                $"digital channels:   \t{digi}\n" +       // 2
                $"che(??) channels:   \t{che}\n" +        // 4
                $"tim(??) channels:   \t{tim}\n\n" +
                $"[Other..]\n" +
                $"valid data bits:    \t{validDataBits}\n" +    // 24
                $"device data format: \t{deviceDataFormat}\n" + // 32
                $"device data mode:   \t{dataMode}\n" +         // dmSigned24bit
                $"nice meme:          \t{meme}\n" +
                "";

            return(true);
        }
コード例 #6
0
ファイル: Form.cs プロジェクト: balefebvre/MeaDataAcquisition
        // Occurs when the value of the selected index of the combo box (i.e. the seleted MEA device) changes.
        private void ComboBoxMeaDevices_SelectedIndexChanged(object sender, EventArgs e)
        {
            var index = (uint)this.comboBoxMeaDevices.SelectedIndex;

            // TODO understand MCS black magic.
            usb = this.usbList.GetUsbListEntry(index);
            // TODO understand MCS black magic.
            this.device = new CMeaDeviceNet(usb.DeviceId.BusType, ChannelDataCallback, ErrorCallback);
            // Establish a connection to the required DAQ device.
            this.device.Connect(usb);
            // TODO understand MCS black magic.
            this.device.SendStop();
            // TODO understand MCS black magic.
            var hardwareInfo = this.device.HWInfo();

            // Get the number of available analog hardware channels.
            hardwareInfo.GetNumberOfHWADCChannels(out nb_channels);
            // Set the number of analog hardware channels to the maximum.
            this.device.SetNumberOfChannels(nb_channels);
            // Update the text box which displays the number of analog hardware channels.
            this.textBoxNumberOfChannels.Text = nb_channels.ToString();
            // TODO understand MCS black magic.
            //hardwareInfo.GetAvailableSampleRates(out List<int> sample_rates);
            this.sample_rate = 20000;
            // TODO understand MCS black magic.
            var oversample    = (uint)1;
            var virtualDevice = 0;

            this.device.SetSampleRate(sample_rate, oversample, virtualDevice);
            this.textBoxSampleRate.Text = sample_rate.ToString();
            // TODO understand MCS black magic.
            gain = this.device.GetGain();
            this.textBoxGain.Text = gain.ToString();
            // TODO understand MCS black magic.
            //hardwareInfo.GetAvailableVoltageRangesInMicroVoltAndStringsInMilliVolt(out List<CMcsUsbDacqNet.CHWInfo.CVoltageRangeInfoNet> voltage_ranges);
            //var voltage_range = 10;
            // TODO understand MCS black magic.
            //this.device.SetVoltageRangeInMicroVolt(voltage_range);
            // TODO understand MCS black magic.
            this.device.EnableDigitalIn(true, virtualDevice);
            // TODO understand MCS black magic.
            this.device.EnableChecksum(true, virtualDevice);
            // TODO understand MCS black magic.
            //this.device.EnableTimestamp(false);
            // TODO understand MCS black magic.
            int analog_channels;
            int digital_channels;
            int checksum_channels;
            int timestamp_channels;

            this.device.GetChannelLayout(out analog_channels, out digital_channels, out checksum_channels, out timestamp_channels, out this.channels_in_block, (uint)virtualDevice);
            this.channels_in_block           = this.device.GetChannelsInBlock();
            this.textBoxChannelsInBlock.Text = this.channels_in_block.ToString();
            // ...
            this.selected_channels = new bool[this.channels_in_block];
            for (var i = 0; i < this.channels_in_block; i++)
            {
                this.selected_channels[i] = true;
            }
            // TODO check the value of the buffer size.
            this.buf_size = sample_rate / 10;
            //this.buf_size = sample_rate / 100;
            this.queue_size            = 20 * this.buf_size;
            this.textBoxQueueSize.Text = this.queue_size.ToString();
            // ...
            this.threshold             = this.buf_size;
            this.textBoxThreshold.Text = this.threshold.ToString();
            // ...
            this.sample_size            = SampleSizeNet.SampleSize16Unsigned;
            this.textBoxSampleSize.Text = sample_size.ToString();
            // TODO understand MCS black magic.
            this.device.ChannelBlock_SetCheckChecksum((uint)checksum_channels, (uint)timestamp_channels);
            // Enable control.
            this.textBoxQueueSize.Enabled           = true;
            this.textBoxThreshold.Enabled           = true;
            this.buttonDataAcquisitionStart.Enabled = true;
        }