S

slapos.android

==============
slapos.android
==============

This package regroups multiple tools that are usefull for running slapos on an 
android device.

eventpoll
=========

Eventpoll is a daemon polling system files to detect events.
(for example plugging events). It uses runparts when any event is detected on 
the folder matching the event.
Here is an example of what script you would want to run on plug::
    #!/bin/bash
    echo slapos > /sys/power/wake_lock
    # Takes a wakelock, so we are sure the device will compute as intended
    /opt/slapos/bin/slapgrid-supervisorctl /etc/opt/slapos/slapos.cfg start all
    # Run all processes needed for your slapos softwares to work

You'd also want to run this on unplug to stop draining battery life::
    #!/bin/bash
    /opt/slapos/bin/slapgrid-supervisorctl /etc/opt/slapos/slapos.cfg stop all
    # Stop all processes
    echo slapos > /sys/power/wake_unlock
    # Remove the wakelock so your phone can save battery when you don't use it


predictd
========

Predictd is a daemon which tries to foresee future events, given the data of 
past events. It also passes events through as they arrive. So don't put the
same script in both eventpoll's event folder and predictd's event folder or it
will be run two times.
You have to tell him when the events happens if you want him to work, 
this can be done by using his tell() function with the port corresponding
to the one it is listening to, in a script within the folder of the event.
For example, you could put this script in the folder of the plug event::
    #!/usr/bin/env python
    """inform the learning daemon"""
    from predictd import learning, foresee

    def main():
        """transmit information
	the second argument of tell is the port used to send the information,
	it has to be the same as the one passed as argument to predictd"""
        learning.tell(foresee.plug, 50008)

    if __name__ == '__main__':
        main()

The learning daemon uses the calculator class in the module foresee to predict
future events so you can improve it easily by changing the foresee.py file.
See pydoc predictd.foresee

runparts
========

The runparts provided by slapos.android works like the debian run-parts:
it runs every executable in a folder whose name doesn't start with '.' or '_'.
It's usefull to chose what you want to do when events are detected,
you just have to put the script you want to run in the folder matching the
event.