-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.c
49 lines (38 loc) · 1.13 KB
/
application.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* application.c
*
* Created on: Dec 21, 2014
* Author: lauril
*/
#include <stdio.h>
#include <stdlib.h>
#include "application.h"
#include "sys/resource_manager.h"
RESOURCE_TYPE_UINT32T temp=0;
APP_ERROR init(OBJECT self, ResourceManager rs){
((WaterApplication)self)->rsm = rs;
((WaterApplication)self)->temperature = rs->getResource(rs, RESOURCE_SENSOR_TEMPERATURE);
((WaterApplication)self)->temperature->setVar(self,RESOURCE_TYPE_UINT32T_T, (WRITEBACK) &temp);
if( rs->schedulePeriodic(self, ((WaterApplication)self)->temperature) == RESOURCE_SCHEDULING_SUCCESS){
printf("Init Successful\n");
} else {
//deal with scheduling issue (negotiation?)
printf("scheduling error\n");
}
return INIT_SUCCESSFULL;
}
APP_ERROR onWakeUp(OBJECT self){
return ON_WAKE_UP_SUCCESS;
}
APP_ERROR onEnteringLP(OBJECT self){
return ON_ENTERING_LPL_SUCCESS;
}
WaterApplication NewWaterApplication()
{
WaterApplication self = (WaterApplication) malloc(sizeof(struct Water_Application));
self->base = NewApplication();
self->init = &init;
self->onWakeUp = &onWakeUp;
self->onEnteringLP = &onEnteringLP;
return self;
}