Exemplo n.º 1
0
 public static bool Open(int device)
 {
     if (device < 0 || device > 3)
     {
         throw new Exception("Invalid device");
     }
     if (_refCounts[device]++ == 0)
     {
         return(K8055.OpenDevice((long)device) == device);
     }
     return(true);
 }
Exemplo n.º 2
0
 public static void Write(int device, long data)
 {
     if (!_busy)
     {
         if (device < 0 || device > 3)
         {
             throw new Exception("Invalid device");
         }
         if (_refCounts[device] == 0)
         {
             throw new Exception("Device is not open");
         }
         K8055.SetCurrentDevice((long)device);
         K8055.WriteAllDigital(data);
     }
 }
Exemplo n.º 3
0
 public static long Read(int device)
 {
     if (_busy)
     {
         return(0L);
     }
     if (device < 0 || device > 3)
     {
         throw new Exception("Invalid device");
     }
     if (_refCounts[device] == 0)
     {
         throw new Exception("Device is not open");
     }
     K8055.SetCurrentDevice((long)device);
     return(K8055.ReadAllDigital());
 }
Exemplo n.º 4
0
 public static void Close(int device)
 {
     if (device < 0 || device > 3)
     {
         throw new Exception("Invalid device");
     }
     if (_refCounts[device] == 1)
     {
         K8055.SetCurrentDevice((long)device);
         K8055.CloseDevice();
         _refCounts[device] = 0;
     }
     else if (_refCounts[device] > 1)
     {
         _refCounts[device]--;
     }
 }
Exemplo n.º 5
0
        public static long SearchDevices()
        {
            int num;

            _busy = true;
            for (num = 0; num < _refCounts.Length; num++)
            {
                K8055.SetCurrentDevice((long)num);
                K8055.CloseDevice();
            }
            long numdevices = K8055.SearchDevices();

            for (num = 0; num < _refCounts.Length; num++)
            {
                if (_refCounts[num] > 0)
                {
                    K8055.OpenDevice((long)num);
                }
            }
            _busy = false;
            return(numdevices);
        }
Exemplo n.º 6
0
 public static void Version()
 {
     K8055.Version();
 }