Beispiel #1
0
        public static void TestDAQManager()
        {
            int[]      voltage_channels = { 0, 1, 2, 3, 4, 5 };
            DAQManager DM = new DAQManager(
                "Dev2",
                voltage_channels                 // device channels
                );

            DM.ConfigureContinuousAcquisitionClockRate(1000);
            DM.StartAcquisition(15);
            DM.WaitForData();
            NationalInstruments.AnalogWaveform <double>[] test_data = DM.data;
            DM.SignalDataConsumed();

            // print data
            String outs = "";
            int    j    = 0;

            foreach (NationalInstruments.AnalogWaveform <double> aw in test_data)
            {
                double [] channel_data = aw.GetRawData(0, aw.SampleCount);
                for (int i = 0; i < aw.SampleCount; ++i)
                {
                    outs += "Channel " + j.ToString() + "\tSample " + i.ToString() + "\tValue " + channel_data[i].ToString() + Environment.NewLine;
                }
                ++j;
            }

            DM.SignalDataConsumed();

            File.WriteAllText("D:\\OrigliaMarco\\CoDASync\\Hello.txt", outs);
        }
Beispiel #2
0
        // get necessary parameters and set the NIDAQmx manager
        public void ConfigureNIDAQmxButton_Click(object sender, EventArgs ea)
        {
            int[]  channels = parseIntRange(this.ChannelTextBox.Text);
            String device   = this.DeviceNameTextBox.Text;

            DM = new DAQManager(device, channels);

            IsDMSet = true;
            this.updateDeviceStatusLabel();
        }
Beispiel #3
0
        // Constructor
        public CoDASyncWindow()
        {
            InitializeComponent();

            CM      = null; //new CorvusManager("COM6", 57600);
            IsCMSet = false;

            DM      = null;
            IsDMSet = false;

            // initialize locker for signaling condition that computation is done
            done         = true;
            __doneLocker = new Object();


            __readSerialEvent      = new AutoResetEvent(false);
            __readDAQEvent         = new AutoResetEvent(false);
            __bufferReadyCountdown = new CountdownEvent(3);


            position     = null;
            sample       = null;
            sample_array = null;
            time         = null;
            output       = "";

            // output file name
            outputFileName           = "";
            outputStream             = null;
            __outputFileStreamLocker = new Object();

            // configure timer general parameters
            samplingTimer           = new System.Timers.Timer();
            __timerLocker           = new Object();
            samplingTimer.Elapsed  += TimerHandler;
            samplingTimer.AutoReset = true;
            acquisitionInProgress   = false;

            // create threads
            readSerialThread = null;
            readDAQThread    = null;
            storeDataThread  = null;

            // listing variables
            execInProgress     = false;
            executionThread    = null;
            __execThreadLocker = new Object();
        }
Beispiel #4
0
        public void TestPeriodicalAcquisition()
        {
            CM      = new CorvusManager("COM6", 57600);
            IsCMSet = true;

            int[] channels = { 0, 1, 2, 3, 4, 5 };
            DM      = new DAQManager("Dev2", channels);
            IsDMSet = true;


            System.Timers.Timer t = new System.Timers.Timer(1000);
            t.Elapsed  += TimerHandler;
            t.AutoReset = true;


            Thread thread_store = new Thread(Store);

            thread_store.Start();

            Thread thread_serial = new Thread(ReadSerial);

            thread_serial.Start();

            Thread thread_daq = new Thread(ReadDAQmx);

            thread_daq.Start();

            t.Enabled = true;

            Thread.Sleep(10000);

            thread_store.Abort();
            thread_daq.Abort();
            thread_serial.Abort();

            Console.WriteLine("Test ended, press enter to exit.");
            Console.Read();

            File.WriteAllText("D:\\OrigliaMarco\\CoDASync\\Acquisition.txt", output);
        }