GPIO Tutorial
From RifidiWiki
Getting Started
This page will give a very brief explanation of how to use the GPIO interface for a given reader. For this example we will use an LLRP reader.
Steps
1. Reference the abstract GPIO service in spring and filter it by the reader type that you would like to control. In this case, we would like the LLRP GPIO service, so our block of spring code will look like this:
<osgi:reference id="llrpGPIOService" interface="org.rifidi.edge.sensors.AbstractGPIOService" filter="(reader=LLRP)" />
2. Inject it into your application class, like so (place the 'property' line with 'gpoController' into the 'bean' block for you application):
<bean id="SampleApp" class="com.sample.app.SampleApp"> <constructor-arg index="0" value="Sample" /> <constructor-arg index="1" value="SampleApp" /> <property name="readZoneMonitoringService" ref="readZoneMonitoringService" /> <property name="gpoController" ref="llrpGPIOService" /> </bean>
3. In the application class, add the "setter" method as specified via the 'name' field of the property object you specified before:
public void setGpoController(AbstractGPIOService<?> gpoController) { this.gpoController = gpoController; }