Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
        }
    }