Revision 40 logic/trunk/src/init/devicelist.c
devicelist.c | ||
---|---|---|
1 | 1 |
#include "devicelist.h" |
2 | 2 |
#include <string.h> |
3 | 3 |
#include <mxml.h> |
4 |
#include <time.h> |
|
4 | 5 |
|
5 |
device *hDevice; //device list |
|
6 | 6 |
short NUMBER_OF_DEVICES = 0; |
7 | 7 |
|
8 | 8 |
device *setDeviceList() |
... | ... | |
38 | 38 |
|
39 | 39 |
//getting to the correct level of the xml tree (descend 2 levels) |
40 | 40 |
node=node->child->child; |
41 |
// printf("hDevice %d\n", hDevice); |
|
42 | 41 |
|
43 | 42 |
// fill the list of known devices |
44 | 43 |
while(node!=NULL) |
... | ... | |
70 | 69 |
curr->param = (char *)malloc(sizeof(mxml_deviceNode->value.element.attrs->value)*strlen(node->value.element.attrs->value)); |
71 | 70 |
strcpy(curr->param, mxml_deviceNode->value.element.attrs->value); |
72 | 71 |
//printf("param:\t %s\n", curr->param ); |
73 |
|
|
72 |
curr->buf = 0; |
|
74 | 73 |
curr->running = 0; |
75 | 74 |
// moving to the next XML node |
76 | 75 |
node=node->next; |
... | ... | |
93 | 92 |
return NUMBER_OF_DEVICES; |
94 | 93 |
} |
95 | 94 |
|
96 |
// TODO add this func |
|
95 |
device *getDevice1(char *devName) |
|
96 |
{ |
|
97 |
return NULL; |
|
98 |
} |
|
99 |
|
|
100 |
device *getDevice2(device *dev) |
|
101 |
{ |
|
102 |
return NULL; |
|
103 |
} |
|
104 |
|
|
97 | 105 |
device *getDevice(device *dev, char *devName) |
98 | 106 |
{ |
99 |
printf("getDevice(device *dev, char *devName)\n"); |
|
100 |
printf("%s\n",devName); |
|
101 | 107 |
while(dev) |
102 | 108 |
{ |
103 |
printf("loop\n"); |
|
104 |
printf("dev->id %s\n", dev->id); |
|
105 | 109 |
if(0==strcmp(dev->id,devName)) |
106 | 110 |
{ |
107 |
printf("hooking device %s with status %d\n", dev->id, dev->running); |
|
108 | 111 |
return dev; |
109 | 112 |
} |
110 | 113 |
dev=dev->nxt; |
111 | 114 |
} |
112 |
printf("Device not found!\n"); |
|
113 | 115 |
return NULL; |
114 | 116 |
} |
115 | 117 |
|
... | ... | |
120 | 122 |
if(!dev->running) |
121 | 123 |
{ |
122 | 124 |
dev->running = 1; |
123 |
printf("activating device %s with status %d\n", dev->id, dev->running); |
|
125 |
//printf("activating device %s with status %d\n", dev->id, dev->running);
|
|
124 | 126 |
return dev; |
125 | 127 |
} |
126 | 128 |
dev=dev->nxt; |
... | ... | |
128 | 130 |
|
129 | 131 |
return NULL; |
130 | 132 |
} |
133 |
|
|
134 |
int getLocalFormattedTime() |
|
135 |
{ |
|
136 |
// desired format hhmm, 4 digit int; 1430 = 14:30 |
|
137 |
time_t epoch_time; |
|
138 |
struct tm *tm_p; |
|
139 |
int wntForm=0; |
|
140 |
|
|
141 |
epoch_time = time( NULL ); |
|
142 |
tm_p = localtime( &epoch_time ); |
|
143 |
|
|
144 |
return tm_p->tm_hour*100+tm_p->tm_min; |
|
145 |
} |
|
146 |
|
|
131 | 147 |
/* |
132 | 148 |
void updateDeviceList(device_d *deviceList) |
133 | 149 |
{ |
Also available in: Unified diff