Example #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);
 }
Example #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);
     }
 }
Example #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());
 }
Example #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]--;
     }
 }
Example #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);
        }
Example #6
0
 public static void Version()
 {
     K8055.Version();
 }