Commit dc1a467d22a54b111f868624e1fb69405e7606b7
1 parent
88a88fcc
Exists in
master
and in
9 other branches
Add executable to test GetData
Showing
2 changed files
with
91 additions
and
3 deletions
Show diff stats
tests/CMakeLists.txt
... | ... | @@ -12,12 +12,18 @@ file( |
12 | 12 | ./* |
13 | 13 | ) |
14 | 14 | |
15 | -ADD_EXECUTABLE (testParallel ${source_files} ) | |
16 | - | |
15 | +ADD_EXECUTABLE (testParallel testParallel.c ) | |
17 | 16 | target_link_libraries( |
18 | 17 | testParallel |
19 | 18 | ${CMAKE_THREAD_LIBS_INIT} |
20 | 19 | ${DDCLIENTLIBRARY} |
21 | 20 | ) |
22 | 21 | |
23 | -install (TARGETS testParallel DESTINATION tests) | |
22 | +ADD_EXECUTABLE (testGetData testGetData.c ) | |
23 | +target_link_libraries( | |
24 | + testGetData | |
25 | + ${CMAKE_THREAD_LIBS_INIT} | |
26 | + ${DDCLIENTLIBRARY} | |
27 | +) | |
28 | + | |
29 | +install (TARGETS testParallel testGetData DESTINATION tests) | ... | ... |
... | ... | @@ -0,0 +1,82 @@ |
1 | +/*============================================================= | |
2 | + * testGetData.c | |
3 | + * Test data collection for a a given parameter (hard coded) | |
4 | + * Oct 2019, V.1.0, Renard | |
5 | + *=============================================================*/ | |
6 | +#include <stdio.h> | |
7 | +#include <stdlib.h> | |
8 | +#include <unistd.h> | |
9 | +#include <DD.h> | |
10 | +#include <time.h> | |
11 | +#include <string.h> | |
12 | +#include <sys/time.h> | |
13 | + | |
14 | +#define DATA_VI "mes:mag:orb\0" | |
15 | +#define DATA_STARTTIME "2012000000000000\0" | |
16 | +#define DATA_TIMEINT "0000010000000000\0" | |
17 | +#define DATA_TIMENAME "Time\0" | |
18 | +#define DATA_PARAMNAME "B_MSO\0" | |
19 | + | |
20 | + | |
21 | +/* | |
22 | + * Main | |
23 | + */ | |
24 | +int main() | |
25 | +{ | |
26 | + char ViName[100]; | |
27 | + char StartTime[17]; | |
28 | + char TimeInt[17]; | |
29 | + char ParamName[100]; | |
30 | + char TimeName[100]; | |
31 | + | |
32 | + strcpy(ViName,DATA_VI); | |
33 | + strcpy(StartTime, DATA_STARTTIME); | |
34 | + strcpy(TimeInt, DATA_TIMEINT); | |
35 | + strcpy(ParamName, DATA_PARAMNAME); | |
36 | + strcpy(TimeName, DATA_TIMENAME); | |
37 | + | |
38 | + char* ParNames[2] = {TimeName, ParamName}; | |
39 | + | |
40 | + int ID, error; | |
41 | + | |
42 | + double RealTime; | |
43 | + DD_data_t *data; | |
44 | + | |
45 | + ID = DD_SetVariable(ViName); | |
46 | + if(ID < 0) | |
47 | + { | |
48 | + error = DD_Close(99); | |
49 | + printf("[ERROR]\n"); | |
50 | + return 0; | |
51 | + } | |
52 | + | |
53 | + error = DD_SetTimeInfo(ID, StartTime, &RealTime); | |
54 | + if(error < 0) | |
55 | + { | |
56 | + error = DD_Close(ID); | |
57 | + printf("[ERROR]\n"); | |
58 | + return 0; | |
59 | + } | |
60 | + | |
61 | + do | |
62 | + { | |
63 | + error = DD_GetMultiData(ID, 2, ParNames, TimeInt, &data, 1); | |
64 | + if(error < 0) | |
65 | + { | |
66 | + error = DD_Close(ID); | |
67 | + printf("[ERROR]\n"); | |
68 | + return 0; | |
69 | + } | |
70 | + if(error == MOREDELAY) | |
71 | + { | |
72 | + error = MOREDATA; | |
73 | + } | |
74 | + } | |
75 | + while(error == MOREDATA); | |
76 | + | |
77 | + error = DD_Close(ID); | |
78 | + | |
79 | + printf("[SUCESS]\n"); | |
80 | + | |
81 | + return 1; | |
82 | +} | ... | ... |