Subversion Repositories group.electronics

Rev

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

Rev 145 Rev 153
Line 51... Line 51...
51
 
51
 
52
            if (this.usbDevice == null)
52
            if (this.usbDevice == null)
53
                this.usbRegistry.Open(out this.usbDevice);
53
                this.usbRegistry.Open(out this.usbDevice);
54
            else
54
            else
55
                this.usbDevice.Open();
55
                this.usbDevice.Open();
56
            
-
 
57
                
56
                
58
            return true;
57
            return true;
59
        }
58
        }
60
 
59
 
61
        public bool Close() {
60
        public bool Close() {
Line 89... Line 88...
89
                | (byte)UsbEndpointDirection.EndpointIn, command, value, index, 0);
88
                | (byte)UsbEndpointDirection.EndpointIn, command, value, index, 0);
90
 
89
 
91
            return this.usbDevice.ControlTransfer(ref packet, buffer, 8, out transferred);
90
            return this.usbDevice.ControlTransfer(ref packet, buffer, 8, out transferred);
92
        }
91
        }
93
 
92
 
-
 
93
        public bool GetDeviceVersion() {
-
 
94
            byte[] data = new byte[8];
-
 
95
            int transferred;
-
 
96
            bool success = this.SendCommand(01, 0, 0, data, out transferred);
-
 
97
            this.hw = data[0].ToString();
-
 
98
            this.sw = data[1].ToString();
-
 
99
            return success;
-
 
100
        }
-
 
101
 
94
    }
102
    }
95
 
103
 
96
    class NITPanels {
104
    class NITPanels {
97
 
105
 
98
        public List<NITDevice> devices { get; set; }
106
        public List<NITDevice> devices { get; set; }
Line 114... Line 122...
114
            UsbRegDeviceList allDevices = UsbDevice.AllLibUsbDevices;
122
            UsbRegDeviceList allDevices = UsbDevice.AllLibUsbDevices;
115
            foreach (UsbRegistry usbReg in allDevices) {
123
            foreach (UsbRegistry usbReg in allDevices) {
116
                foreach (Device device in regDevices) {
124
                foreach (Device device in regDevices) {
117
                    if (usbReg.Vid == device.vid 
125
                    if (usbReg.Vid == device.vid 
118
                        && usbReg.Pid == device.pid) {
126
                        && usbReg.Pid == device.pid) {
-
 
127
                            NITDevice found = null;
-
 
128
 
-
 
129
                            switch (device.type) {
-
 
130
                                case ("NITCommNav") : {
119
                            NITDevice found = new NITDevice(usbReg, device.type, device.vid, device.pid);
131
                                    found = new NITNavCommDevice(usbReg, device.type, device.vid, device.pid);
-
 
132
                                    break;
-
 
133
                                }
-
 
134
                            }
120
 
135
 
121
                            found.id = idCount;
136
                            found.id = idCount;
122
                            found.status = "Found";
137
                            found.status = "Found";
123
                            
138
                            
124
                            found.usbRegistry = usbReg;
139
                            found.usbRegistry = usbReg;
125
                            UsbDevice dev; 
140
                            UsbDevice dev; 
126
                            if (usbReg.Open(out dev)) {
141
                            if (usbReg.Open(out dev)) {
127
                                found.status = "Connected";
142
                                found.status = "Available";
128
                                dev.Close();
143
                                dev.Close();
129
                            }
144
                            }
130
 
145
 
-
 
146
                            if (found.Open()) {
-
 
147
                                found.status = "Connected";
-
 
148
                                found.GetDeviceVersion();
-
 
149
                            }  else
-
 
150
                                found.status = "Failed";
-
 
151
                            
131
                            idCount++;
152
                            idCount++;
132
                            devices.Add(found);
153
                            devices.Add(found);
133
                    }
154
                    }
134
                }
155
                }
135
            }
156
            }