/// <summary> /// /// </summary> protected DaqPciClass() { // Step 1: // Create a 'InstantAiCtrl' for Instant AI function. InstantAiContrl = new InstantAiCtrl(); // Create a 'InstantAoCtrl' for Instant AO function. InstantAoContrl = new InstantAoCtrl(); // DioCtrlBase class used for digital input(DI),digital input // related interrupt,digital output operations(DO); _baseDioCtrl = new DioCtrlBase(); // Create a 'InstantDiCtrl' for DI function. InstantDiCtrl = new InstantDiCtrl(); // Create a 'InstantDoCtrl' for DO function. InstantDoCtrl = new InstantDoCtrl(); }
public double[] StartInstantAI() { instantAiCtrl = new InstantAiCtrl(); instantAiCtrl.SelectedDevice = new DeviceInformation(deviceCode); if (!instantAiCtrl.Initialized) { throw new Exception("No device be selected or device open failed!"); } double[] data = new double[4]; ErrorCode er0 = instantAiCtrl.Read(0, out data[0]); ErrorCode er1 = instantAiCtrl.Read(1, out data[1]); ErrorCode er2 = instantAiCtrl.Read(2, out data[2]); ErrorCode er3 = instantAiCtrl.Read(3, out data[3]); return(data); }
/// <summary> /// Подпрограмма инициализации формы /// </summary> private void Init() { // Настройка изображений //var path = App.MyGmainTest.ConfigProgram.ImageUri; Icon = new IconClass().get_icon(); Image1.Source = new IconClass().get_image(); // Get a list of serial port names var list = SerialPort.GetPortNames(); // Формирования коллекции ComboBox ComboBoxCom1.Items.Clear(); foreach (var str in list) { ComboBoxCom1.Items.Add(str); } // Получение списка плат работающих с разовыми командами var base_dio_ctrl = new DioCtrlBase(); // Список плат PCI-1716, PCI-1721, PCI-1753 var device_list = base_dio_ctrl.SupportedDevices; foreach (var str in device_list) { //if ( string.Equals( "PCI-1716", str.Description.Substring( 0, "PCI-1716".Length ) ) ) { // comboBoxPci1716.Items.Add( str ); //} if (string.Equals("PCI-1721", str.Description.Substring(0, "PCI-1721".Length))) { ComboBoxPci1721.Items.Add(str); } // ReSharper disable once InvertIf if (string.Equals("PCI-1753", str.Description.Substring(0, "PCI-1753".Length))) { ComboBoxPci1753N1.Items.Add(str); ComboBoxPci1753N2.Items.Add(str); } } // Получение списка плат раб отающихс аналоговыми сигналами var instant_ao_contrl = new InstantAoCtrl(); // Список плат PCI-1716, PCI-1721, PCI-1724 device_list = instant_ao_contrl.SupportedDevices; foreach (var str in device_list) { if (string.Equals("PCI-1724", str.Description.Substring(0, "PCI-1724".Length))) { ComboBoxPci1724U.Items.Add(str); } } var instant_ai_contrl = new InstantAiCtrl(); // Получение списка плат работающих с разовыми командами device_list = instant_ai_contrl.SupportedDevices; foreach (var str in device_list) { if (string.Equals("PCI-1747", str.Description.Substring(0, "PCI-1747".Length))) { ComboBoxPci1747U.Items.Add(str); } } // Получение списка плат Arinc429 var devices = new List <ushort>(); App.TaskManager.PortArinc.GetDevice(devices); TextBoxPci429N1.Items.Clear(); TextBoxPci429N2.Items.Clear(); foreach (var item in devices) { TextBoxPci429N1.Items.Add(item.ToString()); TextBoxPci429N2.Items.Add(item.ToString()); } // Установка настроек var xml = new XmlClass(); if (xml.Exist) { fill_form_file(); } else { fill_form_default(); } }
static void Main(string[] args) { //----------------------------------------------------------------------------------- // Configure the following three parameters before running the demo //----------------------------------------------------------------------------------- //The default device of project is demo device, users can choose other devices according to their needs. //string deviceDescription = "DemoDevice,BID#0"; string deviceDescription = "USB-4702,BID#0"; int startChannel = 4; const int channelCount = 1; ErrorCode errorCode = ErrorCode.Success; // Ilosc probek = 250, Czas akwizycji - 1s, Czas miedzy probkami - 1/256 s, Czestotliwosc probkowania 256 Hz // Spelnia Twierdzenie Kotielnikowa-Shannona (badany sygnal ma czestliwosc 100 Hz) int sampleIter = 0; int sampleCount = 256; float sampleFrequency = 100; //[Hz] float timeSample = (1f / sampleFrequency) * 1000; int timeSample_i = (int)Math.Round(timeSample); //[ms] // int convertClkRatePerChan = 1000; // Step 1: Create a 'InstantAiCtrl' for Instant AI function. InstantAiCtrl instantAIContrl = new InstantAiCtrl(); try { // Step 2: Select a device by device number or device description and specify the access mode. // in this example we use AccessWriteWithReset(default) mode so that we can // fully control the device, including configuring, sampling, etc. instantAIContrl.SelectedDevice = new DeviceInformation(deviceDescription); // Step 3: Read samples and do post-process, we show data here. Console.WriteLine(" InstantAI is in progress...\n"); int channelCountMax = instantAIContrl.Features.ChannelCountMax; double[] scaledData = new double[channelCount];//the count of elements in this array should not be less than the value of the variable channelCount for (int i = 0; i < channelCount; ++i) { Console.Write(" channel: {0}", (i % channelCount + startChannel) % channelCountMax); } Console.WriteLine(); using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"probki.txt")) do { // read samples, just scaled data in this demo errorCode = instantAIContrl.Read(startChannel, channelCount, scaledData); if (BioFailed(errorCode)) { throw new Exception(); } // process the acquired samples for (int i = 0; i < channelCount; ++i) { Console.Write(" {0,11:f8}", scaledData[i]); file.WriteLine(" {0,11:f8}", scaledData[i]); } Console.Write("\n"); sampleIter++; Thread.Sleep(timeSample_i); } while (sampleIter < sampleCount); } catch (Exception e) { // Something is wrong string errStr = BioFailed(errorCode) ? " Some error occurred. And the last error code is " + errorCode.ToString() : e.Message; Console.WriteLine(errStr); } finally { // Step 4: Close device and release any allocated resource. instantAIContrl.Dispose(); Console.ReadKey(false); } }