Esempio n. 1
0
 public void test_cDAQ9178()
 {
     try {
         DaqSys.showDevices();
         cDAQ9178 cDAQ  = new cDAQ9178("cDAQ1");
         cDAQ9421 di8   = new cDAQ9421("cDAQ1Mod1");
         cDAQ9482 ro4_1 = new cDAQ9482("cDAQ1Mod2");
         cDAQ9482 ro4_2 = new cDAQ9482("cDAQ1Mod3");
         cDAQ9215 ai4   = new cDAQ9215("cDAQ1Mod4");
         cDAQ[0] = di8;
         cDAQ[1] = ro4_1;
         cDAQ[2] = ro4_2;
         cDAQ[3] = ai4;
         cDAQ.reset();
         for (int i = 0; i < 10; i++)
         {
             ro4_1.setLine(0, i % 2 == 0);
             Thread.Sleep(1000);
         }
         for (uint i = 0; i < 16; i++)
         {
             ro4_1.setPort(i);
             Thread.Sleep(1000);
         }
     } catch (DaqException ex) {
         Console.WriteLine("DAQ exception {0}", ex.Message);
     } catch (Exception ex) {
         Console.WriteLine("exception {0}", ex.Message);
     }
 }
Esempio n. 2
0
 public void _test_cDAQ9188()
 {
     try {
         DaqSys.showDevices();
         // 1AFEC54
         cDAQ9188 cDAQ = new cDAQ9188("cDAQ9188-1AFEC54");
         cDAQ9482 ro4  = new cDAQ9482("cDAQ9188-1AFEC54Mod1");
         cDAQ9476 do32 = new cDAQ9476("cDAQ9188-1AFEC54Mod2");
         cDAQ9425 di32 = new cDAQ9425("cDAQ9188-1AFEC54Mod3");
         cDAQ[0] = ro4;
         cDAQ[1] = do32;
         cDAQ[2] = di32;
         cDAQ.reset();
         // test ro4
         for (uint i = 0u; i < 4u; i++)
         {
             //ro4.setLine(i, true);
             ro4.setLine(i, 1);
             Thread.Sleep(1000);
             //ro4.setLine(i, false);
             ro4.setLine(i, 0);
             Thread.Sleep(1000);
         }
         for (uint i = 0; i < 16; i++)
         {
             ro4.setPort(i);
             Thread.Sleep(1000);
         }
         // test di32
         Console.WriteLine("di32.port = {0}", di32.getPort());
         for (uint i = 0; i < 32; i++)
         {
             Console.WriteLine("di32.line[{0}] = {1}", i, di32.getLine(i));
         }
         // test do32
         do32.setPort(0xFF);
         for (uint i = 0; i < 32; i++)
         {
             //do32.setLine(i, true);
             do32.setLine(i, 1);
         }
     } catch (DaqException ex) {
         Console.WriteLine("DAQ exception {0}", ex.Message);
     } catch (Exception ex) {
         Console.WriteLine("exception {0}", ex.Message);
     }
 }
Esempio n. 3
0
    public void test_cDAQ9184()
    {
        try {
            DaqSys.showDevices();
            cDAQ9184 cDAQ = new cDAQ9184("cDAQ9184-1BDE983");
            cDAQ9482 ro4  = new cDAQ9482("cDAQ9184-1BDE983Mod1");
            cDAQ9476 do32 = new cDAQ9476("cDAQ9184-1BDE983Mod2");
            cDAQ9425 di32 = new cDAQ9425("cDAQ9184-1BDE983Mod3");
            cDAQ[0] = ro4;
            cDAQ[1] = do32;
            cDAQ[2] = di32;
            cDAQ.reset();

            // test ro4
            for (uint i = 0u; i < 4u; i++)
            {
                //ro4.setLine(i, true);
                ro4.setLine(i, 1);
                Thread.Sleep(1000);
                //ro4.setLine(i, false);
                ro4.setLine(i, 0);
                Thread.Sleep(1000);
            }
            for (uint i = 0; i < 16; i++)
            {
                ro4.setPort(i);
                Thread.Sleep(1000);
            }

            // test do32/di32
            for (uint i = 0; i < 32; i++)
            {
                do32.setLine(i, 1);
                Thread.Sleep(10);
                bool r = di32.getLine(i);
                Console.WriteLine("written 1, read {0}, {1}", r?1:0, r?"passed":"failed");

                do32.setLine(i, 0);
                Thread.Sleep(10);
                r = di32.getLine(i);
                Console.WriteLine("written 0, read {0}, {1}", r?1:0, r?"failed":"passed");
            }

            for (uint i = 0; i < 32; i++)
            {
                do32.setLine(i, 1);
                Thread.Sleep(10);
                uint value = di32.getPort();
                Console.WriteLine("written {0:X8}, read {1:X8}, {2}", 1u << ((int)i), value, 1u << ((int)i) == value ? "passed" : "failed");

                do32.setLine(i, 0);
                Thread.Sleep(10);
                value = di32.getPort();
                Console.WriteLine("written 00000000, read {0:X8}, {1}", value, value == 0u ? "passed" : "failed");
            }

            // random pattern
            Random rand = new Random();
            for (int i = 0; i < 32; i++)
            {
                uint w = (uint)rand.Next();
                do32.setPort(w);
                Thread.Sleep(10);
                uint r = di32.getPort();
                Console.WriteLine("w = {0:X8}, r = {1:X8}, {2}", w, r, r == w?"passed":"failed");
            }
        } catch (DaqException ex) {
            Console.WriteLine("DAQ exception {0}", ex.Message);
        } catch (Exception ex) {
            Console.WriteLine("exception {0}", ex.Message);
        }
    }
Esempio n. 4
0
    public void run()
    {
        // out
        int FIL_PREHEAT_CH = 0;
        int FIL_LIMIT_CH   = 0;
        int KV_SET_CH      = 2;
        int MA_SET_CH      = 3;

        // ramp up

        // disable DXM interlock
        ro.setPort(0x00);
        Thread.Sleep(1000);

        // set fil.preheat
        // ao.setChannel(0, 10);
        // Thread.Sleep(1000);

        // set fil.limit
        // ao.setChannel(1, 10);
        // Thread.Sleep(1000);

        // set fil.preheat and fil.limit
        //
        ao.setChannel(FIL_PREHEAT_CH, 10);
        Thread.Sleep(1000);

        // set kv
        ao.setChannel(KV_SET_CH, 10);
        Thread.Sleep(1000);

        // set ma
        ao.setChannel(MA_SET_CH, 0);
        Thread.Sleep(1000);

        // enable DXM interlock
        ro.setPort(0x01);
        Thread.Sleep(1000);

        // sample and show the voltages
        Task   task        = new Task();
        string devFullname = string.Format("{0}Mod2/ai0:2", serialNumber);

        Console.WriteLine(devFullname);
        AIChannel channel = task.AIChannels.CreateVoltageChannel(devFullname, "", AITerminalConfiguration.Rse, 0.0, 10.0, AIVoltageUnits.Volts);
        AnalogMultiChannelReader reader = new AnalogMultiChannelReader(task.Stream);

        task.Timing.ConfigureSampleClock("", rate: 100, activeEdge: SampleClockActiveEdge.Rising, sampleMode: SampleQuantityMode.ContinuousSamples, samplesPerChannel: 1000);
        task.Control(TaskAction.Verify);
        //var sw = new Stopwatch(); // debug
        for (uint i = 0; i < 1000; i++)
        {
            //sw.Reset();
            //sw.Start();
            double[] vals = reader.ReadSingleSample();
            //Console.WriteLine("data length {0}, stopwatch elapsed {1}", vals.GetLength(0), sw.Elapsed);
            //sw.Stop();
            string   kVmon1        = (vals[0] / 10.0 * 50).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            string   kVmon2        = (vals[1] / 10.0 * 50).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            string   mAmon         = (vals[2] / 10.0 * 17).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            DateTime timestamp     = DateTime.UtcNow;
            int      unixTimestamp = (int)(timestamp.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            string   ms            = timestamp.Millisecond.ToString("000");
            string   line          = string.Format("{0}_{1}: {2}, {3}, {4}", unixTimestamp, ms, kVmon1, kVmon2, mAmon);
            if (silent == false)
            {
                Console.WriteLine(line);
            }
            if (outputFile != string.Empty)
            {
                System.IO.File.AppendAllText(outputFile, line + Environment.NewLine);
            }
        }

        // ramp down
        //
        // set ma
        ao.setChannel(MA_SET_CH, 0);
        Thread.Sleep(1000);
        //
        // set kv
        ao.setChannel(KV_SET_CH, 0);
        Thread.Sleep(1000);

        for (uint i = 0; i < 500; i++)
        {
            //sw.Reset();
            //sw.Start();
            double[] vals = reader.ReadSingleSample();
            //Console.WriteLine("data length {0}, stopwatch elapsed {1}", vals.GetLength(0), sw.Elapsed);
            //sw.Stop();
            string   kVmon1        = (vals[0] / 10.0 * 50).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            string   kVmon2        = (vals[1] / 10.0 * 50).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            string   mAmon         = (vals[2] / 10.0 * 17).ToString("0.000", CultureInfo.InvariantCulture).PadLeft(8);
            DateTime timestamp     = DateTime.UtcNow;
            int      unixTimestamp = (int)(timestamp.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            string   ms            = timestamp.Millisecond.ToString("000");
            string   line          = string.Format("{0}_{1}: {2}, {3}, {4}", unixTimestamp, ms, kVmon1, kVmon2, mAmon);
            if (silent == false)
            {
                Console.WriteLine(line);
            }
            if (outputFile != string.Empty)
            {
                System.IO.File.AppendAllText(outputFile, line + Environment.NewLine);
            }
        }

        //
        // disable DXM interlock
        ro.setPort(0x00);
        Thread.Sleep(1000);
    }