final code? working on reports
This commit is contained in:
parent
ac791ce418
commit
d93a980ed5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
obj_*
|
obj_*
|
||||||
*~
|
*~
|
||||||
|
*#*
|
BIN
Coursework-Reports/12to1.jpg
Normal file
BIN
Coursework-Reports/12to1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 KiB |
BIN
Coursework-Reports/12to12.jpg
Normal file
BIN
Coursework-Reports/12to12.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 219 KiB |
BIN
Coursework-Reports/12to3.jpg
Normal file
BIN
Coursework-Reports/12to3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 188 KiB |
BIN
Coursework-Reports/SaxBy2,4Break.png
Normal file
BIN
Coursework-Reports/SaxBy2,4Break.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
BIN
Coursework-Reports/SaxBy4,4Break.png
Normal file
BIN
Coursework-Reports/SaxBy4,4Break.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 88 KiB |
@ -123,7 +123,7 @@ LatexCommand lstlistoflistings
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/coursework.c"
|
filename "../Coursework/coursework.c"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={Main coursework program: 2 processes for reading and aggregating data}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt},caption={Main coursework program: 2 processes for reading and aggregating data}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentst
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/buffer.h"
|
filename "../Coursework/buffer.h"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={Buffer header file: get, free and manipulate buffers}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt},caption={Buffer header file: get, free and manipulate buffers}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentst
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/sax.h"
|
filename "../Coursework/sax.h"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={SAX header file: z-normalise and stringify buffers}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt},caption={SAX header file: z-normalise and stringify buffers}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentst
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/math.h"
|
filename "../Coursework/math.h"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={Math header file: mean, standard deviation, implementations of ceil, sqrt}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt},caption={Math header file: mean, standard deviation, implementations of ceil, sqrt}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentst
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/io.h"
|
filename "../Coursework/io.h"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={IO header file: init function for starting sensors}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt},caption={IO header file: init function for starting sensors}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentst
|
|||||||
\begin_inset CommandInset include
|
\begin_inset CommandInset include
|
||||||
LatexCommand lstinputlisting
|
LatexCommand lstinputlisting
|
||||||
filename "../Coursework/util.h"
|
filename "../Coursework/util.h"
|
||||||
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},caption={Other utilities: short and float printing functions from earlier labs}"
|
lstparams "breaklines=true,frame=tb,language=C,basicstyle={\\ttfamily},commentstyle={\\color{commentgreen}\\itshape},keywordstyle={\\color{blue}},emphstyle={\\color{red}},stringstyle={\\color{red}},identifierstyle={\\color{cyan}},otherkeywords={PROCESS_THREAD, PROCESS_BEGIN, PROCESS_END, etimer_set, process_alloc_event, initIO, getBuffer, PROCESS_WAIT_EVENT, PROCESS_WAIT_EVENT_UNTIL, leds_off, leds_on, getLight, printf, putFloat, putchar, process_post, etimer_reset, etimer_stop, handleSAXBufferRotation, handleSimpleBufferRotation, free, freeBuffer, calculateStdDev, handleFinalBuffer, ceil, normaliseBuffer, aggregateBuffer, printBuffer, stringifyBuffer, swapBufferMemory, malloc, calculateMean, valueToSAXChar, sqrt, putShort},caption={Other utilities: short and float printing functions from earlier labs}"
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
|
Binary file not shown.
@ -36,7 +36,7 @@ customHeadersFooters
|
|||||||
\output_sync 0
|
\output_sync 0
|
||||||
\bibtex_command default
|
\bibtex_command default
|
||||||
\index_command default
|
\index_command default
|
||||||
\paperfontsize default
|
\paperfontsize 10
|
||||||
\spacing single
|
\spacing single
|
||||||
\use_hyperref true
|
\use_hyperref true
|
||||||
\pdf_title "IoT Aggregation Algorithm Coursework"
|
\pdf_title "IoT Aggregation Algorithm Coursework"
|
||||||
@ -117,21 +117,224 @@ Andy Pack / 6420013
|
|||||||
Description
|
Description
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
Symbolic Aggregation Approximation (SAX) was implemented as an in-network
|
||||||
|
data processing technique, compressing the representation while allowing
|
||||||
|
further processing on this symbolic string.
|
||||||
|
Figure
|
||||||
|
\begin_inset CommandInset ref
|
||||||
|
LatexCommand ref
|
||||||
|
reference "fig:Demonstration-of-SAX"
|
||||||
|
plural "false"
|
||||||
|
caps "false"
|
||||||
|
noprefix "false"
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
shows two rounds of SAX output following data collection, a window size
|
||||||
|
of 2 was used and an alphabet of length 4, i.e the characters
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
a
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
through
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
d
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
inclusive.
|
||||||
|
12 C
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
floats
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
total 48 bytes of data, this can be reduced by a factor of 4 using
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
char
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
representation instead, a window size of 2 halves the number of output
|
||||||
|
samples and lowers the required memory to just 6 bytes.
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Section
|
\begin_layout Section
|
||||||
Specification
|
Specification
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
SAX is implemented in two separate steps, that of transforming the time-series
|
||||||
|
into Piecewise Aggregate Approximation (PAA) representation and then representi
|
||||||
|
ng this numeric series with a symbolic alphabet.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Subsection
|
||||||
|
PAA
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
The standard deviation and mean of the data series were first calculated,
|
||||||
|
these are required for Z-normalisation.
|
||||||
|
This normalisation process takes a series of data and transforms it into
|
||||||
|
one with a mean of 0 and a standard deviation of 1.
|
||||||
|
This changes the context of the value from being measured in lux to being
|
||||||
|
a measure of a samples distance from the mean, 0, in standard deviations.
|
||||||
|
This allows comparison of different time-series.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
Following Z-normalisation, the size of the series is reduced by applying
|
||||||
|
a windowing function.
|
||||||
|
This takes subsequent equally-sized groups of samples and reduces the group
|
||||||
|
to the mean of those values.
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
As a result of these two actions, the original time series has been reduced
|
||||||
|
to a given length of samples with a mean of 0 and standard deviation of
|
||||||
|
1.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Subsection
|
||||||
|
SAX
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
With the result of the above, the remaining step is to replace each sample
|
||||||
|
value with a symbol to represent it.
|
||||||
|
The amount of symbols to be used is given, each will represent the same
|
||||||
|
probability range when considering a Gaussian distribution of mean 0 and
|
||||||
|
standard deviation of 1.
|
||||||
|
This can be achieved by using standard deviation breakpoints defined such
|
||||||
|
that the area under Gaussian curve between breakpoints is the same.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Section
|
\begin_layout Section
|
||||||
Implementation
|
Implementation
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Section
|
\begin_layout Standard
|
||||||
Output
|
The SAX functionality was added as an alternative buffer rotating mechanism
|
||||||
|
over the original 12-to-1/4-to-1/12-to-12 aggregation system.
|
||||||
|
The length of the output buffer is calculated such that it can be allocated.
|
||||||
|
From here the input buffer is Z-normalised using the
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
normaliseBuffer(buffer)
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
function from the
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
buffer.h
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
header.
|
||||||
|
This function iterates over each value in the buffer, subtracts the buffer's
|
||||||
|
mean and then divides by the standard deviation.
|
||||||
|
Following this, the buffer is aggregated using the same 4-to-1 aggregation
|
||||||
|
function
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
aggregateBuffer(bufferIn, bufferOut, groupSize)
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
as the group size is variable.
|
||||||
|
The output from this function represents the PAA form of the initial data
|
||||||
|
series.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
This final buffer is handled using
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
handleFinalBuffer(buffer)
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
where a pre-processor directive checks whether SAX is being used.
|
||||||
|
If so the PAA buffer is
|
||||||
|
\emph on
|
||||||
|
stringified
|
||||||
|
\emph default
|
||||||
|
using
|
||||||
|
\begin_inset listings
|
||||||
|
lstparams "basicstyle={\ttfamily}"
|
||||||
|
inline true
|
||||||
|
status open
|
||||||
|
|
||||||
|
\begin_layout Plain Layout
|
||||||
|
|
||||||
|
stringifyBuffer(buffer)
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
which performs the SAX symbolic representation.
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
\begin_inset Float figure
|
\begin_inset Float figure
|
||||||
placement h
|
|
||||||
wide false
|
wide false
|
||||||
sideways false
|
sideways false
|
||||||
status open
|
status open
|
||||||
@ -139,8 +342,8 @@ status open
|
|||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
\align center
|
\align center
|
||||||
\begin_inset Graphics
|
\begin_inset Graphics
|
||||||
filename SaxBy2,10Break.png
|
filename SaxBy2,4Break.png
|
||||||
width 100col%
|
width 30col%
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -152,7 +355,14 @@ status open
|
|||||||
|
|
||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
Demonstration of SAX aggregation with window size of 2 and alphabet of length
|
Demonstration of SAX aggregation with window size of 2 and alphabet of length
|
||||||
10
|
4
|
||||||
|
\begin_inset CommandInset label
|
||||||
|
LatexCommand label
|
||||||
|
name "fig:Demonstration-of-SAX"
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
Binary file not shown.
@ -113,8 +113,31 @@ November 2020
|
|||||||
Andy Pack / 6420013
|
Andy Pack / 6420013
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
\begin_inset FloatList figure
|
||||||
|
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
\begin_inset VSpace defskip
|
||||||
|
\end_inset
|
||||||
|
|
||||||
|
|
||||||
|
\end_layout
|
||||||
|
|
||||||
|
\begin_layout Standard
|
||||||
|
|
||||||
|
\emph on
|
||||||
|
Standard deviation thresholds of 400 for some activity and 1,000 for high
|
||||||
|
activity.
|
||||||
|
\end_layout
|
||||||
|
|
||||||
\begin_layout Standard
|
\begin_layout Standard
|
||||||
\begin_inset Float figure
|
\begin_inset Float figure
|
||||||
|
placement bh
|
||||||
wide false
|
wide false
|
||||||
sideways false
|
sideways false
|
||||||
status open
|
status open
|
||||||
@ -122,8 +145,9 @@ status open
|
|||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
\align center
|
\align center
|
||||||
\begin_inset Graphics
|
\begin_inset Graphics
|
||||||
filename NonSaxAggregate.png
|
filename 12to1.jpg
|
||||||
width 100col%
|
lyxscale 50
|
||||||
|
width 80col%
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
|
||||||
@ -134,7 +158,7 @@ status open
|
|||||||
\begin_inset Caption Standard
|
\begin_inset Caption Standard
|
||||||
|
|
||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
Demonstration of 4-into-1 aggregation taking place following moderate activity
|
Demonstration of 12-into-1 aggregation for little activity
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
@ -156,7 +180,8 @@ status open
|
|||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
\align center
|
\align center
|
||||||
\begin_inset Graphics
|
\begin_inset Graphics
|
||||||
filename NonSaxWithRed.png
|
filename 12to3.jpg
|
||||||
|
lyxscale 50
|
||||||
width 100col%
|
width 100col%
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
@ -168,9 +193,7 @@ status open
|
|||||||
\begin_inset Caption Standard
|
\begin_inset Caption Standard
|
||||||
|
|
||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
Demonstration of both no aggregation for high activity (First output) and
|
Demonstration of 4-into-1 aggregation for moderate activity
|
||||||
tight 12-into-1 average for little activity (Last output), red LED on as
|
|
||||||
aggregation occurs
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
@ -192,7 +215,8 @@ status open
|
|||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
\align center
|
\align center
|
||||||
\begin_inset Graphics
|
\begin_inset Graphics
|
||||||
filename SaxBy2,10Break.png
|
filename 12to12.jpg
|
||||||
|
lyxscale 50
|
||||||
width 100col%
|
width 100col%
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
@ -204,8 +228,7 @@ status open
|
|||||||
\begin_inset Caption Standard
|
\begin_inset Caption Standard
|
||||||
|
|
||||||
\begin_layout Plain Layout
|
\begin_layout Plain Layout
|
||||||
Demonstration of SAX aggregation with window size of 2 and alphabet of length
|
Demonstration of no aggregation for high activity
|
||||||
10
|
|
||||||
\end_layout
|
\end_layout
|
||||||
|
|
||||||
\end_inset
|
\end_inset
|
||||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
|||||||
#define INITIAL_STATE true // whether begins running or not
|
#define INITIAL_STATE true // whether begins running or not
|
||||||
|
|
||||||
#define SAX // use sax aggregation and transform instead of simple average aggregation
|
#define SAX // use sax aggregation and transform instead of simple average aggregation
|
||||||
#define SAX_BREAKPOINTS 10 // number of characters to be used
|
#define SAX_BREAKPOINTS 4 // number of characters to be used
|
||||||
|
|
||||||
#include "contiki.h"
|
#include "contiki.h"
|
||||||
|
|
||||||
@ -35,15 +35,13 @@ PROCESS_THREAD(sensing_process, ev, data)
|
|||||||
/*INIT*/
|
/*INIT*/
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
|
static bool isRunning = INITIAL_STATE;
|
||||||
static struct etimer timer;
|
static struct etimer timer;
|
||||||
etimer_set(&timer, CLOCK_SECOND/READING_INTERVAL);
|
if(isRunning) etimer_set(&timer, CLOCK_SECOND/READING_INTERVAL); // start timer if running
|
||||||
|
|
||||||
event_buffer_full = process_alloc_event();
|
event_buffer_full = process_alloc_event();
|
||||||
|
|
||||||
initIO();
|
initIO();
|
||||||
|
|
||||||
static bool isRunning = INITIAL_STATE;
|
|
||||||
|
|
||||||
static Buffer buffer;
|
static Buffer buffer;
|
||||||
buffer = getBuffer(BUFFER_SIZE);
|
buffer = getBuffer(BUFFER_SIZE);
|
||||||
/*END INIT*/
|
/*END INIT*/
|
||||||
@ -54,7 +52,6 @@ PROCESS_THREAD(sensing_process, ev, data)
|
|||||||
PROCESS_WAIT_EVENT();
|
PROCESS_WAIT_EVENT();
|
||||||
|
|
||||||
if (ev == PROCESS_EVENT_TIMER){
|
if (ev == PROCESS_EVENT_TIMER){
|
||||||
if (isRunning == true) {
|
|
||||||
leds_off(LEDS_RED);
|
leds_off(LEDS_RED);
|
||||||
|
|
||||||
float light_lx = getLight(); // GET
|
float light_lx = getLight(); // GET
|
||||||
@ -62,7 +59,6 @@ PROCESS_THREAD(sensing_process, ev, data)
|
|||||||
buffer.items[counter] = light_lx; // STORE
|
buffer.items[counter] = light_lx; // STORE
|
||||||
|
|
||||||
printf("%2i/%i: ", counter + 1, buffer.length);putFloat(light_lx);putchar('\n'); // DISPLAY CURRENT VALUE
|
printf("%2i/%i: ", counter + 1, buffer.length);putFloat(light_lx);putchar('\n'); // DISPLAY CURRENT VALUE
|
||||||
//printBuffer(buffer);putchar('\n'); // DISPLAY CURRENT BUFFER
|
|
||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
if(counter == buffer.length) // CHECK WHETHER FULL
|
if(counter == buffer.length) // CHECK WHETHER FULL
|
||||||
@ -71,7 +67,6 @@ PROCESS_THREAD(sensing_process, ev, data)
|
|||||||
counter = 0;
|
counter = 0;
|
||||||
buffer = getBuffer(BUFFER_SIZE); // get new buffer for next data, no freeing in this thread
|
buffer = getBuffer(BUFFER_SIZE); // get new buffer for next data, no freeing in this thread
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
etimer_reset(&timer);
|
etimer_reset(&timer);
|
||||||
}
|
}
|
||||||
@ -82,12 +77,12 @@ PROCESS_THREAD(sensing_process, ev, data)
|
|||||||
if (isRunning == true)
|
if (isRunning == true)
|
||||||
{
|
{
|
||||||
printf("Starting...\n");
|
printf("Starting...\n");
|
||||||
|
etimer_set(&timer, CLOCK_SECOND/READING_INTERVAL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Stopping, clearing buffer...\n");
|
printf("Stopping, clearing buffer...\n");
|
||||||
//freeBuffer(buffer);
|
etimer_stop(&timer);
|
||||||
//buffer = getBuffer(BUFFER_SIZE);
|
|
||||||
counter = 0; // just reset counter, used as index on buffer items, will overwrite
|
counter = 0; // just reset counter, used as index on buffer items, will overwrite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,10 +153,10 @@ handleSimpleBufferRotation(Buffer *inBufferPtr)
|
|||||||
printf("Insignificant std. dev.: ");putFloat(sd.std);printf(", squashing buffer\n");
|
printf("Insignificant std. dev.: ");putFloat(sd.std);printf(", squashing buffer\n");
|
||||||
|
|
||||||
outBuffer = getBuffer(1); // CREATE OUTPUT BUFFER
|
outBuffer = getBuffer(1); // CREATE OUTPUT BUFFER
|
||||||
|
|
||||||
outBuffer.items[0] = sd.mean;
|
outBuffer.items[0] = sd.mean;
|
||||||
}
|
}
|
||||||
outBuffer.stats = sd; // final compressed buffer has pointer to stats for uncompressed data in case of further interest
|
outBuffer.stats = sd; // final compressed buffer has stats for uncompressed data in case of further interest
|
||||||
inBuffer.stats = sd;
|
|
||||||
|
|
||||||
/*********************/
|
/*********************/
|
||||||
handleFinalBuffer(outBuffer); // PASS FINAL BUFFER
|
handleFinalBuffer(outBuffer); // PASS FINAL BUFFER
|
||||||
|
Binary file not shown.
@ -36,26 +36,25 @@
|
|||||||
void
|
void
|
||||||
normaliseBuffer(Buffer bufferIn) // z normalise buffer for SAX
|
normaliseBuffer(Buffer bufferIn) // z normalise buffer for SAX
|
||||||
{
|
{
|
||||||
if(bufferIn.stats.std == 0) // error check
|
if(bufferIn.stats.std == 0) // error check, don't divide by 0
|
||||||
{
|
{
|
||||||
printf("Standard deviation of zero, unable to normalise\n");
|
printf("Standard deviation of zero, unable to normalise\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i; // for group number
|
int i;
|
||||||
float *inputPtr = bufferIn.items; // cursor for full buffer
|
float *inputPtr = bufferIn.items; // cursor
|
||||||
for(i = 0; i < bufferIn.length; i++)
|
for(i = 0; i < bufferIn.length; i++)
|
||||||
{
|
{
|
||||||
*inputPtr = (*inputPtr - bufferIn.stats.mean) / bufferIn.stats.std;
|
*inputPtr = (*inputPtr - bufferIn.stats.mean) / bufferIn.stats.std;
|
||||||
|
|
||||||
inputPtr++; // increment both cursors
|
inputPtr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char
|
char
|
||||||
valueToSAXChar(float inputValue)
|
valueToSAXChar(float inputValue)
|
||||||
{
|
{
|
||||||
float below, above;
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < SAX_BREAKPOINTS; i++)
|
for(i = 0; i < SAX_BREAKPOINTS; i++)
|
||||||
{
|
{
|
||||||
@ -69,7 +68,7 @@ valueToSAXChar(float inputValue)
|
|||||||
}
|
}
|
||||||
else // in between check interval of two breakpoints
|
else // in between check interval of two breakpoints
|
||||||
{
|
{
|
||||||
if(breakPoints[i - 1] < inputValue < breakPoints[i]) return SAX_CHAR_START + i;
|
if((breakPoints[i - 1] < inputValue) && (inputValue < breakPoints[i])) return SAX_CHAR_START + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '0';
|
return '0';
|
||||||
@ -78,7 +77,7 @@ valueToSAXChar(float inputValue)
|
|||||||
char* // map buffer of normalised floats into SAX chars
|
char* // map buffer of normalised floats into SAX chars
|
||||||
stringifyBuffer(Buffer bufferIn)
|
stringifyBuffer(Buffer bufferIn)
|
||||||
{
|
{
|
||||||
char* outputString = (char*) malloc((bufferIn.length + 1) * sizeof(char));
|
char* outputString = (char*) malloc((bufferIn.length + 1) * sizeof(char)); // +1 for null terminator
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < bufferIn.length; i++)
|
for(i = 0; i < bufferIn.length; i++)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
typedef unsigned short USHORT;
|
typedef unsigned short USHORT;
|
||||||
|
|
||||||
//print a unsigned short (as returned from rand) picewise char by char
|
//print a unsigned short picewise char by char
|
||||||
void
|
void
|
||||||
putShort(USHORT in)
|
putShort(USHORT in)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user