alielie
2025-08-25 c4a3f8db90530a727ffab77c3bb5bb7d782792bf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace Plugin.DODriverControl.Api
{
    public class PCIController : IDIOController
    {
        public string Name { get; set; }
 
        private short id;
 
        public bool Start(out string msg)
        {
            msg = string.Empty;
            id = DASK.Register_Card(DaskHelper.CardType(Name), 0);
            return id >= 0;
        }
 
        public bool ReadDIBool(string address, out bool res, out string msg)
        {
            msg = string.Empty;
            DASK.DI_ReadLine((ushort)id, 0, ushort.Parse(address), out ushort value);
            res = Convert.ToBoolean(value);
            return true;
        }
 
        public bool ReadDOBool(string address, out bool res, out string msg)
        {
            msg = string.Empty;
            DASK.DO_ReadLine((ushort)id, 0, ushort.Parse(address), out ushort value);
            res = Convert.ToBoolean(value);
            return true;
        }
 
        public bool WriteBool(string address, bool value, out string msg)
        {
            msg = string.Empty;
            var res = DASK.DO_WriteLine((ushort)id, 0, ushort.Parse(address), Convert.ToUInt16(value));
            return res == 0;
        }
 
        public bool Close()
        {
            return DASK.Release_Card((ushort)id) == 0;
        }
 
        public void Dispose()
        {
            this.Close();
        }
    }
}