Skip to content

Commit f069a12

Browse files
committed
#454 Initial commit with some boilerplate
1 parent 16f1a76 commit f069a12

File tree

18 files changed

+832
-0
lines changed

18 files changed

+832
-0
lines changed

plugins/pi4j-plugin-ffm/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

plugins/pi4j-plugin-ffm/pom.xml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<groupId>com.pi4j</groupId>
7+
<artifactId>pi4j-plugin</artifactId>
8+
<version>3.1.0-SNAPSHOT</version>
9+
<relativePath>../pi4j-plugin/pom.xml</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
14+
<artifactId>pi4j-plugin-ffm</artifactId>
15+
<name>Pi4J :: PLUGIN :: FFM API Providers</name>
16+
<description>Pi4J Library Plugin for FFM API Providers</description>
17+
<packaging>jar</packaging>
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.slf4j</groupId>
21+
<artifactId>slf4j-api</artifactId>
22+
<version>${slf4j.version}</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.slf4j</groupId>
26+
<artifactId>slf4j-simple</artifactId>
27+
<version>${slf4j.version}</version>
28+
<scope>test</scope>
29+
</dependency>
30+
</dependencies>
31+
32+
<!-- STANDARD BUILD INSTRUCTIONS -->
33+
<build>
34+
<plugins>
35+
<!-- DOWNLOAD RUNTIME DEPENDENCIES -->
36+
<plugin>
37+
<groupId>org.apache.maven.plugins</groupId>
38+
<artifactId>maven-dependency-plugin</artifactId>
39+
<executions>
40+
<execution>
41+
<id>copy-dependencies</id>
42+
<phase>process-sources</phase>
43+
<goals>
44+
<goal>copy-dependencies</goal>
45+
</goals>
46+
<configuration>
47+
<includeScope>runtime</includeScope>
48+
<excludeGroupIds>com.pi4j</excludeGroupIds>
49+
<outputDirectory>${project.build.directory}/dependencies</outputDirectory>
50+
<overWriteReleases>false</overWriteReleases>
51+
<overWriteSnapshots>false</overWriteSnapshots>
52+
<overWriteIfNewer>true</overWriteIfNewer>
53+
</configuration>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
58+
<!-- OPTIONALLY DEPLOY THE FINAL JAR TO THE RASPBERRY PI -->
59+
<plugin>
60+
<groupId>org.apache.maven.plugins</groupId>
61+
<artifactId>maven-antrun-plugin</artifactId>
62+
<executions>
63+
64+
<!-- copy the compiled JAR file to the Raspberry Pi platform platform -->
65+
<execution>
66+
<id>transfer-compiled-pi4j-jar</id>
67+
<phase>install</phase>
68+
<goals>
69+
<goal>run</goal>
70+
</goals>
71+
<configuration>
72+
<target>
73+
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
74+
classpathref="maven.plugin.classpath"/>
75+
<if>
76+
<equals arg1="${pi4j.dev.transfer}" arg2="true"/>
77+
<then>
78+
<!-- ensure the target directory exists on the Raspberry Pi -->
79+
<sshexec host="${pi4j.dev.host}" port="${pi4j.dev.port}"
80+
username="${pi4j.dev.user}"
81+
password="${pi4j.dev.password}" trust="true" failonerror="false"
82+
verbose="false" command="mkdir --parents ${pi4j.dev.directory}"/>
83+
84+
<!-- copy the JAR file(s) to the Raspberry Pi -->
85+
<scp
86+
todir="${pi4j.dev.user}:${pi4j.dev.password}@${pi4j.dev.host}:${pi4j.dev.directory}"
87+
port="${pi4j.dev.port}" trust="true" verbose="false" failonerror="true">
88+
<fileset dir="${project.build.directory}">
89+
<include name="${project.build.finalName}.jar"/>
90+
</fileset>
91+
<fileset dir="${project.build.directory}/dependencies">
92+
<include name="*.jar"/>
93+
</fileset>
94+
</scp>
95+
</then>
96+
</if>
97+
</target>
98+
</configuration>
99+
</execution>
100+
</executions>
101+
</plugin>
102+
</plugins>
103+
</build>
104+
105+
</project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.pi4j.plugin.ffm;
2+
3+
import com.pi4j.context.Context;
4+
import com.pi4j.exception.ShutdownException;
5+
import com.pi4j.extension.Plugin;
6+
import com.pi4j.extension.PluginService;
7+
import com.pi4j.provider.Provider;
8+
9+
/**
10+
* <p>GpioDPlugin class.</p>
11+
*
12+
* @author Alexander Liggesmeyer (<a href="https://alexander.liggesmeyer.net/">https://alexander.liggesmeyer.net/</a>)
13+
* @version $Id: $Id
14+
*/
15+
public class FFMPlugin implements Plugin {
16+
17+
/**
18+
* Constant <code>NAME="GpioD"</code>
19+
*/
20+
public static final String NAME = "GpioD";
21+
/**
22+
* Constant <code>ID="gpiod"</code>
23+
*/
24+
public static final String ID = "gpiod";
25+
26+
// Digital Output (GPIO) Provider name and unique ID
27+
/**
28+
* Constant <code>DIGITAL_OUTPUT_PROVIDER_NAME="NAME + Digital Output (GPIO) Provider"</code>
29+
*/
30+
public static final String DIGITAL_OUTPUT_PROVIDER_NAME = NAME + " Digital Output (GPIO) Provider";
31+
/**
32+
* Constant <code>DIGITAL_OUTPUT_PROVIDER_ID="ID + -digital-output"</code>
33+
*/
34+
public static final String DIGITAL_OUTPUT_PROVIDER_ID = ID + "-digital-output";
35+
36+
/**
37+
* Constant <code>DIGITAL_INPUT_PROVIDER_NAME="NAME + Digital Input (GPIO) Provider"</code>
38+
*/
39+
public static final String DIGITAL_INPUT_PROVIDER_NAME = NAME + " Digital Input (GPIO) Provider";
40+
/**
41+
* Constant <code>DIGITAL_INPUT_PROVIDER_ID="ID + -digital-input"</code>
42+
*/
43+
public static final String DIGITAL_INPUT_PROVIDER_ID = ID + "-digital-input";
44+
45+
private Provider<?, ?, ?>[] providers;
46+
47+
/**
48+
* {@inheritDoc}
49+
*/
50+
@Override
51+
public void initialize(PluginService service) {
52+
53+
}
54+
55+
@Override
56+
public void shutdown(Context context) throws ShutdownException {
57+
if (this.providers != null) {
58+
for (Provider<?, ?, ?> provider : providers) {
59+
provider.shutdown(context);
60+
}
61+
}
62+
}
63+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.pi4j.plugin.ffm.providers.gpio;
2+
3+
import com.pi4j.context.Context;
4+
import com.pi4j.exception.InitializeException;
5+
import com.pi4j.exception.ShutdownException;
6+
import com.pi4j.io.gpio.digital.*;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
10+
public class FFMDigitalInput extends DigitalInputBase implements DigitalInput {
11+
private static final Logger logger = LoggerFactory.getLogger(FFMDigitalInput.class);
12+
13+
public FFMDigitalInput(DigitalInputProvider provider, DigitalInputConfig config) {
14+
super(provider, config);
15+
}
16+
17+
@Override
18+
public DigitalInput initialize(Context context) throws InitializeException {
19+
return this;
20+
}
21+
22+
@Override
23+
public DigitalInput shutdown(Context context) throws ShutdownException {
24+
super.shutdown(context);
25+
return this;
26+
}
27+
28+
@Override
29+
public DigitalState state() {
30+
return DigitalState.getState(true);
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.pi4j.plugin.ffm.providers.gpio;
2+
3+
import com.pi4j.context.Context;
4+
import com.pi4j.exception.InitializeException;
5+
import com.pi4j.exception.ShutdownException;
6+
import com.pi4j.io.gpio.digital.DigitalInput;
7+
import com.pi4j.io.gpio.digital.DigitalInputConfig;
8+
import com.pi4j.io.gpio.digital.DigitalInputProvider;
9+
import com.pi4j.io.gpio.digital.DigitalInputProviderBase;
10+
11+
public class FFMDigitalInputProviderImpl extends DigitalInputProviderBase implements DigitalInputProvider {
12+
/**
13+
* <p>Constructor for GpioDDigitalInputProviderImpl.</p>
14+
*/
15+
public FFMDigitalInputProviderImpl() {
16+
this.id = "1";
17+
this.name = "2";
18+
}
19+
20+
/**
21+
* {@inheritDoc}
22+
*/
23+
@Override
24+
public DigitalInput create(DigitalInputConfig config) {
25+
// create new I/O instance based on I/O config
26+
// GpioLine line = GpioDContext.getInstance().getOrOpenLine(config.address());
27+
var digitalInput = new FFMDigitalInput( this, config);
28+
this.context.registry().add(digitalInput);
29+
return digitalInput;
30+
}
31+
32+
@Override
33+
public int getPriority() {
34+
// the gpioD driver should be higher priority always
35+
return 15000;
36+
}
37+
38+
/**
39+
* {@inheritDoc}
40+
*/
41+
@Override
42+
public DigitalInputProvider initialize(Context context) throws InitializeException {
43+
DigitalInputProvider provider = super.initialize(context);
44+
return provider;
45+
}
46+
47+
@Override
48+
public DigitalInputProvider shutdown(Context context) throws ShutdownException {
49+
return super.shutdown(context);
50+
}
51+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.pi4j.plugin.ffm.providers.gpio;
2+
3+
import com.pi4j.context.Context;
4+
import com.pi4j.exception.InitializeException;
5+
import com.pi4j.exception.ShutdownException;
6+
import com.pi4j.io.exception.IOException;
7+
import com.pi4j.io.gpio.digital.*;
8+
9+
public class FFMDigitalOutput extends DigitalOutputBase implements DigitalOutput {
10+
11+
public FFMDigitalOutput(DigitalOutputProvider provider, DigitalOutputConfig config) {
12+
super(provider, config);
13+
}
14+
15+
@Override
16+
public DigitalOutput initialize(Context context) throws InitializeException {
17+
super.initialize(context);
18+
return this;
19+
}
20+
21+
@Override
22+
public DigitalOutput shutdown(Context context) throws ShutdownException {
23+
super.shutdown(context);
24+
return this;
25+
}
26+
27+
@Override
28+
public DigitalOutput state(DigitalState state) throws IOException {
29+
return super.state(state);
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.pi4j.plugin.ffm.providers.gpio;
2+
3+
import com.pi4j.context.Context;
4+
import com.pi4j.exception.InitializeException;
5+
import com.pi4j.exception.ShutdownException;
6+
import com.pi4j.io.gpio.digital.DigitalOutput;
7+
import com.pi4j.io.gpio.digital.DigitalOutputConfig;
8+
import com.pi4j.io.gpio.digital.DigitalOutputProvider;
9+
import com.pi4j.io.gpio.digital.DigitalOutputProviderBase;
10+
11+
public class FFMDigitalOutputProviderImpl extends DigitalOutputProviderBase implements DigitalOutputProvider {
12+
/**
13+
* <p>Constructor for PiGpioDigitalOutputProviderImpl.</p>
14+
*/
15+
public FFMDigitalOutputProviderImpl() {
16+
this.id = "";
17+
this.name = "";
18+
}
19+
20+
/**
21+
* {@inheritDoc}
22+
*/
23+
@Override
24+
public DigitalOutput create(DigitalOutputConfig config) {
25+
// create new I/O instance based on I/O config
26+
var digitalOutput = new FFMDigitalOutput(this, config);
27+
this.context.registry().add(digitalOutput);
28+
return digitalOutput;
29+
}
30+
31+
@Override
32+
public int getPriority() {
33+
// the gpioD driver should be higher priority always
34+
return 150;
35+
}
36+
37+
@Override
38+
public DigitalOutputProvider initialize(Context context) throws InitializeException {
39+
DigitalOutputProvider provider = super.initialize(context);
40+
return provider;
41+
}
42+
43+
@Override
44+
public DigitalOutputProvider shutdown(Context context) throws ShutdownException {
45+
return super.shutdown(context);
46+
}
47+
}

0 commit comments

Comments
 (0)