1 package org.minetti.astrodevice.server.usb.jni.impl;
2
3 import org.minetti.astrodevice.common.device.DeviceNode;
4 import org.minetti.astrodevice.server.usb.jni.UsbDeviceTreeBuilder;
5
6
7
8
9
10 public final class UsbDeviceTreeBuilderImpl
11 implements UsbDeviceTreeBuilder {
12
13
14
15
16 private DeviceNode currentParentNode;
17
18
19
20
21 private DeviceNode lastNode;
22
23
24
25
26
27 public UsbDeviceTreeBuilderImpl (final DeviceNode rootNode) {
28 super();
29 this.currentParentNode = null;
30 this.lastNode = rootNode;
31 }
32
33
34
35
36 public synchronized void down () {
37 this.currentParentNode = this.lastNode;
38 }
39
40
41
42
43 public synchronized void up () {
44 this.lastNode = this.currentParentNode;
45 this.currentParentNode = this.currentParentNode.getParent();
46 }
47
48
49
50
51 public synchronized void addHostController (final String description) {
52 this.lastNode = new DeviceNode(this.currentParentNode, description, null, null);
53 this.currentParentNode.getChildren().add(this.lastNode);
54 }
55
56
57
58
59 public synchronized void addRootHub () {
60 this.lastNode = new DeviceNode(this.currentParentNode, "Root hub", null, null);
61 this.currentParentNode.getChildren().add(this.lastNode);
62 }
63
64
65
66
67 public synchronized void addHub (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion, final String serialNumber, final short deviceClass,
68 final short deviceSubClass, final short deviceProtocol) {
69
70 this.lastNode = new DeviceNode(this.currentParentNode, "Root hub", null, null);
71
72
73
74 this.currentParentNode.getChildren().add(this.lastNode);
75 }
76
77
78
79
80 public synchronized void add (final int vendorId, final int productId, final String manufacturerName, final String productDescription, final int productVersion, final String serialNumber, final short deviceClass,
81 final short deviceSubClass, final short deviceProtocol) {
82
83
84 }
85
86 }