Browse Source

first commit

Alex Volkmann 5 years ago
commit
b864339813
5 changed files with 96 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 17 0
      .project
  3. 11 0
      .settings/org.eclipse.jdt.core.prefs
  4. 7 0
      README.md
  5. 60 0
      src/pdu_jctrl/gpio_java.java

+ 1 - 0
.gitignore View File

@@ -0,0 +1 @@
1
+bin/

+ 17 - 0
.project View File

@@ -0,0 +1,17 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<projectDescription>
3
+	<name>pdu_jctrl</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>

+ 11 - 0
.settings/org.eclipse.jdt.core.prefs View File

@@ -0,0 +1,11 @@
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.source=1.8

+ 7 - 0
README.md View File

@@ -0,0 +1,7 @@
1
+# Overview
2
+
3
+# Deployment
4
+
5
+use the following command to transfer project to raspberry pi:
6
+
7
+scp -r gpio pi@192.168.1.77:~

+ 60 - 0
src/pdu_jctrl/gpio_java.java View File

@@ -0,0 +1,60 @@
1
+package pdu_jctrl;
2
+
3
+import java.io.IOException;
4
+import java.util.concurrent.TimeUnit;
5
+
6
+public class gpio_java 
7
+{
8
+
9
+	public static void main (String [] args) 
10
+	{
11
+		System.out.println("Hello World");
12
+		
13
+		setgpio(true);
14
+		
15
+		try {
16
+			TimeUnit.SECONDS.sleep(1);
17
+		}
18
+		catch(InterruptedException e) 
19
+		{
20
+			System.out.println("sleep error InterruptedException ocure");	
21
+		}	
22
+		
23
+		setgpio(false);
24
+	}
25
+	
26
+	public static void launchcmd(String cmd) 
27
+	{
28
+		// Wenn Simulation True ist kann sie auf dem PC ausfuehren
29
+		// wenn die Simulation false is auf dem Raspberry PI
30
+		boolean simulation = true;
31
+		
32
+		if(simulation==true){
33
+			System.out.println(cmd);	
34
+		} 
35
+		else {
36
+			try{
37
+				Runtime.getRuntime().exec(cmd);
38
+			}
39
+			catch(IOException e)
40
+			{
41
+				System.out.println("process error IOException");					
42
+			}
43
+		}
44
+	}
45
+	
46
+	
47
+	public static void setgpio(boolean status) 
48
+	{
49
+		launchcmd("/usr/bin/gpio -g mode 14 out");
50
+		
51
+		if(status == true) 
52
+		{
53
+			launchcmd("/usr/bin/gpio -g write 14 1");
54
+		}
55
+		else 
56
+		{
57
+			launchcmd("/usr/bin/gpio -g write 14 0");
58
+		}
59
+	}
60
+}