Subversion Repositories group.electronics

Rev

Rev 153 | Rev 156 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 153 Rev 155
Line 29... Line 29...
29
        public int id { get; set; }
29
        public int id { get; set; }
30
        public string hw { get; set; }
30
        public string hw { get; set; }
31
        public string sw { get; set; }
31
        public string sw { get; set; }
32
        public string status { get; set; }
32
        public string status { get; set; }
33
        public string serial { get; set; }
33
        public string serial { get; set; }
-
 
34
        public int assigned { get; set; }
34
 
35
 
35
        protected UsbDevice usbDevice;
36
        protected UsbDevice usbDevice;
36
        public UsbRegistry usbRegistry { get; set; }
37
        public UsbRegistry usbRegistry { get; set; }
37
 
38
 
38
        public NITDevice(UsbRegistry usbRegistry, string type, int vid, int pid) : base(type, vid, pid) {
39
        public NITDevice(UsbRegistry usbRegistry, string type, int vid, int pid) : base(type, vid, pid) {
Line 68... Line 69...
68
        }
69
        }
69
 
70
 
70
        public bool isOpen() {
71
        public bool isOpen() {
71
            if (this.usbDevice == null || ! usbDevice.IsOpen)
72
            if (this.usbDevice == null || ! usbDevice.IsOpen)
72
                return false;
73
                return false;
-
 
74
            
73
 
75
 
74
            return true;
76
            return true;
75
        }
77
        }
76
 
78
 
77
        public bool SendCommand(byte command, short value, short index) {
79
        public bool SendCommand(byte command, short value, short index) {
Line 110... Line 112...
110
        }
112
        }
111
 
113
 
112
        public int UsbScan() {
114
        public int UsbScan() {
113
 
115
 
114
            List<Device> regDevices = new List<Device>();
116
            List<Device> regDevices = new List<Device>();
115
            regDevices.Add(new Device("NITCommNav", 0x20a0, 0x4236));
117
            regDevices.Add(new Device("NITNavComm", 0x20a0, 0x4236));
116
            regDevices.Add(new Device("NITAudioSel", 0x20a0, 0x4237));
118
            regDevices.Add(new Device("NITAudioSel", 0x4242, 0xe231));
117
            regDevices.Add(new Device("NITAdf", 0x20a0, 0x4238));
119
            regDevices.Add(new Device("NITAdf", 0x20a0, 0x4238));
118
 
120
 
119
            int idCount = 0;
121
            int idCount = 0;
120
            devices = new List<NITDevice>();
122
            devices = new List<NITDevice>();
121
 
123
 
Line 123... Line 125...
123
            foreach (UsbRegistry usbReg in allDevices) {
125
            foreach (UsbRegistry usbReg in allDevices) {
124
                foreach (Device device in regDevices) {
126
                foreach (Device device in regDevices) {
125
                    if (usbReg.Vid == device.vid 
127
                    if (usbReg.Vid == device.vid 
126
                        && usbReg.Pid == device.pid) {
128
                        && usbReg.Pid == device.pid) {
127
                            NITDevice found = null;
129
                            NITDevice found = null;
128
 
-
 
129
                            switch (device.type) {
130
                            switch (device.type) {
130
                                case ("NITCommNav") : {
131
                                case ("NITNavComm"): {
131
                                    found = new NITNavCommDevice(usbReg, device.type, device.vid, device.pid);
132
                                    found = new NITNavCommDevice(usbReg, device.type, device.vid, device.pid);
132
                                    break;
133
                                    break;
133
                                }
134
                                }
-
 
135
                                case ("NITAudioSel"): {
-
 
136
                                    found = new NITDevice(usbReg, device.type, device.vid, device.pid);
-
 
137
                                    break;
-
 
138
                                }
134
                            }
139
                            }
135
 
140
 
136
                            found.id = idCount;
141
                            found.id = idCount;
137
                            found.status = "Found";
142
                            found.status = "Found";
138
                            
143