Skip to content

Commit 91c7689

Browse files
committed
upload usbboard
1 parent 9f31834 commit 91c7689

File tree

10 files changed

+305
-0
lines changed

10 files changed

+305
-0
lines changed

.classpath

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="lib" path="jna-5.6.0.jar"/>
6+
<classpathentry kind="lib" path="lib"/>
7+
<classpathentry kind="output" path="bin"/>
8+
</classpath>

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>USBBoard</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.release=disabled
12+
org.eclipse.jdt.core.compiler.source=1.8

bin/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/Board/
2+
/tarik/

doc/K8055N_DLL_manual_Rev1.pdf

72.9 KB
Binary file not shown.

lib/K8055D.dll

1.56 MB
Binary file not shown.

src/Board/Zaehler.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Board;
2+
3+
import tarik.board.control.*;
4+
public class Zaehler {
5+
6+
public static void main(String[] args) {
7+
System.out.println("Programm gestartet, warten auf Tastendruck");
8+
try {
9+
// Einziger Unterschied zum normalen Code
10+
TWUsbBoard TWUsb = USBBoard.getBoard();
11+
12+
TWUsb.OpenDevice(TWUsbBoard.ADDRESSE_0);
13+
TWUsb.ClearAllDigital();
14+
Thread.sleep(100);
15+
TWUsb.ClearAllAnalog();
16+
Thread.sleep(100);
17+
// *****************************************************************
18+
// hier kommt dann später euer eigener Code hinein
19+
for (int i = 0; i < 256; i++) {
20+
while ((TWUsb.ReadAllDigital() & 0b10000) == 0){ // Flanke
21+
Thread.sleep(1);
22+
}
23+
System.out.println("ein Tastendruck");
24+
TWUsb.WriteAllDigital(i);
25+
Thread.sleep(100);
26+
}
27+
// *****************************************************************
28+
TWUsb.CloseDevice();
29+
} catch (TWUsbException e) {
30+
// TODO Auto-generated catch block
31+
e.printStackTrace();
32+
} catch (InterruptedException e) {
33+
// TODO Auto-generated catch block
34+
e.printStackTrace();
35+
}
36+
}
37+
}
38+
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
package tarik.board.control;
2+
3+
import com.sun.jna.ptr.IntByReference;
4+
5+
import com.sun.jna.*;
6+
/**
7+
* Interface für das UsbBoard.
8+
* Um eine neue Instanz zu bekommen, führe die Methode USBBoard.getBoard() aus.
9+
* @author Tarik A.
10+
*
11+
*/
12+
public interface TWUsbBoard extends Library {
13+
int OpenDevice(int CardAddress);
14+
void CloseDevice();
15+
int SearchDevices();
16+
int SetCurrentDevice(int lngCardAddress);
17+
int Version();
18+
int ReadAnalogChannel(int Channel);
19+
void ReadAllAnalog(IntByReference Data1, IntByReference Data2);
20+
void OutputAnalogChannel(int Channel, int Data);
21+
void OutputAllAnalog(int Data1, int Data2);
22+
void ClearAnalogChannel(int Channel);
23+
void ClearAllAnalog();
24+
void SetAnalogChannel(int Channel);
25+
void SetAllAnalog();
26+
void WriteAllDigital(int Data);
27+
void ClearDigitalChannel(int Channel);
28+
void ClearAllDigital();
29+
void SetDigitalChannel(int Channel);
30+
void SetAllDigital();
31+
boolean ReadDigitalChannel(int Channel);
32+
int ReadAllDigital();
33+
void ResetCounter(int CounterNr);
34+
int ReadCounter(int CounterNr);
35+
void SetCounterDebounceTime(int CounterNr, int DebounceTime);
36+
int ReadBackDigitalOut();
37+
void ReadBackAnalogOut(IntByReference Buffer);
38+
39+
// Field descriptor #6 Ljava/lang/String;
40+
public static final java.lang.String VERSION_TWUSB = "1.0";
41+
42+
// Field descriptor #6 Ljava/lang/String;
43+
public static final java.lang.String TWUSB_DLL_NAME = "TWUsb";
44+
45+
// Field descriptor #14 I
46+
public static final int ADDRESSE_0 = 0;
47+
48+
// Field descriptor #14 I
49+
public static final int ADDRESSE_1 = 1;
50+
51+
// Field descriptor #14 I
52+
public static final int ADDRESSE_2 = 2;
53+
54+
// Field descriptor #14 I
55+
public static final int ADDRESSE_3 = 3;
56+
57+
// Field descriptor #14 I
58+
public static final int ADDRESSE_AUTO_SEARCH = 99;
59+
60+
// Field descriptor #14 I
61+
public static final int DIGITALER_AUSGABE_KANAL_1 = 1;
62+
63+
// Field descriptor #14 I
64+
public static final int DIGITALER_AUSGABE_KANAL_2 = 2;
65+
66+
// Field descriptor #14 I
67+
public static final int DIGITALER_AUSGABE_KANAL_3 = 3;
68+
69+
// Field descriptor #14 I
70+
public static final int DIGITALER_AUSGABE_KANAL_4 = 4;
71+
72+
// Field descriptor #14 I
73+
public static final int DIGITALER_AUSGABE_KANAL_5 = 5;
74+
75+
// Field descriptor #14 I
76+
public static final int DIGITALER_AUSGABE_KANAL_6 = 6;
77+
78+
// Field descriptor #14 I
79+
public static final int DIGITALER_AUSGABE_KANAL_7 = 7;
80+
81+
// Field descriptor #14 I
82+
public static final int DIGITALER_AUSGABE_KANAL_8 = 8;
83+
84+
// Field descriptor #14 I
85+
public static final int DIGITALER_EINGABE_KANAL_1 = 1;
86+
87+
// Field descriptor #14 I
88+
public static final int DIGITALER_EINGABE_KANAL_2 = 2;
89+
90+
// Field descriptor #14 I
91+
public static final int DIGITALER_EINGABE_KANAL_3 = 3;
92+
93+
// Field descriptor #14 I
94+
public static final int DIGITALER_EINGABE_KANAL_4 = 4;
95+
96+
// Field descriptor #14 I
97+
public static final int DIGITALER_EINGABE_KANAL_5 = 5;
98+
99+
// Field descriptor #43 Z
100+
public static final boolean DIGITALER_EINGABE_KANAL_AN = true;
101+
102+
// Field descriptor #43 Z
103+
public static final boolean DIGITALER_EINGABE_KANAL_AUS = false;
104+
105+
// Field descriptor #43 Z
106+
public static final boolean DIGITALER_EINGABE_KANAL_TASTE_GEDRUECKT = true;
107+
108+
// Field descriptor #43 Z
109+
public static final boolean DIGITALER_EINGABE_KANAL_TASTE_NICHT_GEDRUECKT = false;
110+
111+
// Field descriptor #14 I
112+
public static final int ANALOGER_EINGABE_KANAL_1 = 1;
113+
114+
// Field descriptor #14 I
115+
public static final int ANALOGER_EINGABE_KANAL_2 = 2;
116+
117+
// Field descriptor #14 I
118+
public static final int ANALOGER_AUSGABE_KANAL_1 = 1;
119+
120+
// Field descriptor #14 I
121+
public static final int ANALOGER_AUSGABE_KANAL_2 = 2;
122+
123+
// Field descriptor #14 I
124+
public static final int COUNTER_KANAL_1 = 1;
125+
126+
// Field descriptor #14 I
127+
public static final int COUNTER_KANAL_2 = 2;
128+
129+
// Field descriptor #14 I
130+
public static final int MAX_DATA = 255;
131+
132+
// Field descriptor #14 I
133+
public static final int MIN_DATA = 0;
134+
135+
// Field descriptor #14 I
136+
public static final int MAX_ENTPRELL_ZEIT = 5000;
137+
138+
// Field descriptor #14 I
139+
public static final int MIN_ENTPRELL_ZEIT = 0;
140+
141+
// Field descriptor #43 Z
142+
public static final boolean DEVICE_IS_CONNECT = true;
143+
144+
// Field descriptor #43 Z
145+
public static final boolean DEVICE_NOT_CONNECT = false;
146+
147+
// Field descriptor #14 I
148+
public static final int DEVICE_NOT_FOUND = -1;
149+
150+
// Field descriptor #14 I
151+
public static final int DATA_FEHLER = -1;
152+
153+
// Field descriptor #65 J
154+
public static final long ABFRAGE_INTERVAL_100_MILLISEKUNDEN = 100L;
155+
156+
// Field descriptor #65 J
157+
public static final long ABFRAGE_INTERVAL_500_MILLISEKUNDEN = 500L;
158+
159+
// Field descriptor #65 J
160+
public static final long ABFRAGE_INTERVAL_1_SEKUNDEN = 1000L;
161+
162+
// Field descriptor #65 J
163+
public static final long ABFRAGE_INTERVAL_5_SEKUNDEN = 5000L;
164+
165+
// Field descriptor #65 J
166+
public static final long ABFRAGE_INTERVAL_10_SEKUNDEN = 10000L;
167+
168+
// Field descriptor #65 J
169+
public static final long START_IN_1_SEKUNDE = 1000L;
170+
171+
// Field descriptor #65 J
172+
public static final long START_IN_10_SEKUNDEN = 10000L;
173+
174+
// Field descriptor #65 J
175+
public static final long START_IN_1_MINUTE = 60000L;
176+
177+
// Field descriptor #65 J
178+
public static final long START_IN_10_MINUTEN = 600000L;
179+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package tarik.board.control;
2+
3+
/**
4+
* Error for USBBoard
5+
* @author Tarik
6+
*
7+
*/
8+
public class TWUsbException extends Exception {
9+
private static final long serialVersionUID = 1L;
10+
public TWUsbException(String message)
11+
{
12+
super(message);
13+
}
14+
public TWUsbException()
15+
{
16+
17+
}
18+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package tarik.board.control;
2+
3+
import com.sun.jna.Native;
4+
5+
/**
6+
* Factory for USBoard
7+
* @author Tarik
8+
*
9+
*/
10+
public class USBBoard
11+
{
12+
private static TWUsbBoard usbBoard;
13+
14+
/**
15+
* @author Tarik A.
16+
* @return a instance to control the USB Board
17+
* @throws TWUsbException
18+
*/
19+
public static TWUsbBoard getBoard() throws TWUsbException
20+
{
21+
if(usbBoard == null)
22+
{
23+
usbBoard = (TWUsbBoard) Native.load("lib\\K8055D.dll", TWUsbBoard.class);
24+
if(usbBoard == null)
25+
{
26+
throw new TWUsbException();
27+
}
28+
}
29+
return usbBoard;
30+
}
31+
}

0 commit comments

Comments
 (0)