Skip to content

Commit 89d46aa

Browse files
Added sensor implementation chapter, to be reviewed by @ChristophStanik
1 parent 02d572a commit 89d46aa

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

MUSESDevGuide.tex

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,47 @@ \subsection{Adding Apache Tomcat as a server}
234234
\chapter{Creating and integrating new sensors}
235235
\label{ch:sensors}
236236

237+
A new sensor must implement the \texttt{eu.musesproject.client.contextmonitoring.\\sensors.ISensor} interface. This interface has six methods:
238+
239+
\begin{description}
240+
\item[void addContextListener(ContextListener listener);] This method takes a ContextListener object, the listener method \textbf{onEvent(ContextEvent contextEvent)} must be called whenever the sensor shall send an event to the MUSES system.
241+
\item[void removeContextListener(ContextListener listener);] Should contain a null object to remove the reference to the previous ContextListener object. Usually it is not necessary to call this method.
242+
\item[void enable();] The startup process of the sensor should be written or triggered in this method.
243+
\item[void disable();] Contains code to stop the sensor so that no more context events are fired to the system.
244+
\item[ContextEvent getLastFiredContextEvent();] Each sensor has a history of its fired context events; therefore a List<ContextEvents> must be implemented. The size of the list is limited by the static field CONTEXT\_EVENT\_HISTORY\_SIZE, which is located in the ISensor class. The developer has to take care to update the list probably.
245+
\item[void configure(List<SensorConfiguration> config);] If a sensor needs to be configured as it might expect specific values in order run as intended, the developer has to take care about the List<SensorConfiguration> config object. The SensorConfiguration class is located in the package: \texttt{eu.musesproject.client.db.entity}.
246+
\end{description}
247+
248+
Each sensor must provide a \textbf{public static final String} \textit{TYPE} field. This field is used to identify the sensor. The naming convention is:\\\texttt{CONTEXT\_SENSOR\_<SensorIdentifier>}.
249+
In addition, and in order to create properties for context events, the sensor must contain a \textbf{public static final String} field for each property identifier.
250+
251+
\section{How to integrate new sensors}
252+
\label{sec:integratesensor}
253+
254+
First, new sensors should be placed within the MUSES Client project in the following package:
255+
256+
\begin{verbatim}
257+
package eu.musesproject.client.contextmonitoring.sensors;
258+
\end{verbatim}
259+
260+
Second, in the class:
261+
262+
\begin{verbatim}
263+
eu.musesproject.client.contextmonitoring.SensorController
264+
\end{verbatim}
265+
266+
the new sensor has to be initialized. And this has to be done inside the method:
267+
268+
\begin{verbatim}
269+
public void startAndConfigureSensors(List<String> enabledSensor){}
270+
\end{verbatim}
271+
272+
Within this method the initialization has to be done as in the following example:
273+
274+
\begin{verbatim}
275+
else if(sensorType.equals(SettingsSensor.TYPE)) {
276+
sensor = new SettingsSensor(context); }
277+
\end{verbatim}
237278

238279
\chapter{Installing MUSES}
239280
\label{ch:installmuses}

0 commit comments

Comments
 (0)