Difference between revisions of "GPIO Tutorial"
From RifidiWiki
(New page: ==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. Refere...) |
|||
Line 11: | Line 11: | ||
filter="(reader=LLRP)" /></pre> | filter="(reader=LLRP)" /></pre> | ||
− | 2. Inject it into your application class, like so: | + | 2. Inject it into your application class, like so (place the 'property' line with 'gpoController' into the 'bean' block for you application): |
− | <pre> | + | <pre> <bean id="SampleApp" class="com.sample.app.SampleApp"> |
<constructor-arg index="0" value="Sample" /> | <constructor-arg index="0" value="Sample" /> | ||
<constructor-arg index="1" value="SampleApp" /> | <constructor-arg index="1" value="SampleApp" /> | ||
Line 20: | Line 20: | ||
</bean></pre> | </bean></pre> | ||
− | 3. In the | + | 3. In the application class, add the "setter" method as specified via the 'name' field of the property object you specified before: |
+ | <pre> public void setGpoController(AbstractGPIOService<?> gpoController) { | ||
+ | this.gpoController = gpoController; | ||
+ | }</pre> |
Revision as of 03:57, 5 March 2012
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; }