public bool StartDAQ_Port_1(UInt32 mode) { int ChannelsInBlock; if (Port_1.Connect(RawPort) == 0) { Connected = true; FrameCount = 0; Port_1.SetSampleRate(Samplerate); switch (mode) { case 0: //Read from raw port Port_1.SetNumberOfAnalogChannels(Raw_Channels, 0, 0, 0, 0); Channels = Raw_Channels; break; case 1: Port_1.SetNumberOfAnalogChannels(0, 0, DSP_Channels, 0, 0); Channels = DSP_Channels; break; case 2: //Read from DSP port + Raw Port_1.SetNumberOfAnalogChannels(Raw_Channels, 0, DSP_Channels, 0, 0); Channels = DSP_Channels + Raw_Channels; break; } if (Checksum == 2) { Port_1.EnableChecksum(true); } else { Port_1.EnableChecksum(false); } Port_1.SetDataMode(DataModeEnumNet.dmSigned32bit, 0); //Port_1.SetDataMode(DataModeEnumNet.dmSigned16bit, 0); Port_1.GetChannelsInBlock(out ChannelsInBlock); Console.WriteLine("ChannelsInBlock " + ChannelsInBlock); TotalChannels = (int)((int)Channels + (int)Checksum); Port_1.SetSelectedData((int)TotalChannels, Samplerate * 10, Samplerate, CMcsUsbDacqNet.SampleSize.Size32, ChannelsInBlock); //Port_1.SetSelectedData((int)TotalChannels, Samplerate * 10, Samplerate, CMcsUsbDacqNet.SampleSize.Size16, ChannelsInBlock); Port_1.StartDacq(); return(true); } else { return(false); } }
private void startDacq_Click(object sender, EventArgs e) { startDacq.Enabled = false; stopDacq.Enabled = true; other_receiver = 0; if (((CMcsUsbListEntryNet)cbDeviceList.SelectedItem).SerialNumber.EndsWith("-B")) { other_receiver = 4; // bit 0/1 select the timeslot of: bit 2/3 = 0 receiver according to USB port, 1 receiver A, 2 receiver B } uint status = mea.Connect((CMcsUsbListEntryNet)cbDeviceList.SelectedItem, 63); if (status == 0) { int ChannelsInBlock; mea.SetDataMode(DataModeEnumNet.Signed_32bit, 0); if (mea.GetDeviceId().IdProduct == ProductIdEnumNet.W2100) { Samplerate = 20000; } mea.SetNumberOfAnalogChannels(Channels, 0, Channels, AnalogChannels, 0); // Read raw data try { mea.SetSamplerate(Samplerate, 1, 0); } catch (CUsbExceptionNet) { Samplerate = mea.GetSamplerate(0); } mea.EnableDigitalIn((use_digital_in ? (DigitalDatastreamEnableEnumNet)3 : 0), 0); // map feedback bit 0 to digital(in) stream bit 4 mea.SetDigitalSource(DigitalTargetEnumNet.Digstream, 4, W2100DigitalSourceEnumNet.Feedback, 0); mea.SetDigitalSource(DigitalTargetEnumNet.Digout, 0, W2100DigitalSourceEnumNet.Feedback, 0); mea.EnableChecksum(true, 0); ChannelsInBlock = mea.GetChannelsInBlock(0); mea.GetChannelLayout(out int analogChannels, out int digitalChannels, out int checksumChannels, out int timestampChannels, out int channelsInBlock, 0); TotalChannels = channelsInBlock / 2; mea.SetSelectedData(TotalChannels, Samplerate * 10, Samplerate, SampleSizeNet.SampleSize32Signed, ChannelsInBlock); mea.ChannelBlock_SetCheckChecksum((uint)checksumChannels, (uint)timestampChannels); mea.StartDacq(); if (mea.GetDeviceId().IdProduct == ProductIdEnumNet.W2100) { CW2100_FunctionNet func = new CW2100_FunctionNet(mea); w2100_hs_samling = func.GetHeadstageSamplingActive(other_receiver + 0); func.SetHeadstageSamplingActive(false, other_receiver + 0); #if true // Send Stimulation pattern bool first = true; int preplegth = 0; CW2100_StimulatorFunctionNet stim = new CW2100_StimulatorFunctionNet(mea); stim.SelectTimeSlot(other_receiver + 0); #if false // Different repetition int[] ampl = new[] { 0, 100000, -100000, 0, 6, 0 }; ulong[] dur = new ulong[] { 0, 10000, 10000, 10000, 0, 300000 }; for (int i = 0; i < 16; i++) { ampl[4] = i + 2; #else // Different strength int[] ampl = new[] { 1000000, -1000000, 0 } ; ulong[] dur = new ulong[] { 2000, 2000, 10000 - 2 * 2000 }; for (int i = 0; i < 16; i++) { ampl[0] = 40000 * i + 50000; ampl[1] = -40000 * i - 50000; #endif // choose, if global repeat is desired CStimulusFunctionNet.StimulusDeviceDataAndUnrolledData prep = stim.PrepareData(0, ampl, dur, STG_DestinationEnumNet.channeldata_current, 1); if (first) { first = false; preplegth = prep.DeviceDataLength; } Debug.Assert(preplegth == prep.DeviceDataLength); Debug.Assert(prep.DeviceDataLength <= 15); stim.SendPreparedData(0x10 * i + 0, prep, STG_DestinationEnumNet.channeldata_current); } #endif func.SetHeadstageSamplingActive(true, other_receiver + 0); } } else { MessageBox.Show(CMcsUsbNet.GetErrorText(status)); startDacq.Enabled = true; stopDacq.Enabled = false; } }