Renaming folders for testing sensor fusion
[platform/core/system/sensord.git] / src / sensor_fusion / test / test_projects / sensor_data_test / sensor_data_main.cpp
1 /*
2  * sensord
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include "../../../sensor_data.h"
21
22 int main()
23 {
24         float arr1[3] = {1.04, -4.678, -2.34};
25
26         vect<float> v1(3, arr1);
27
28         sensor_data<float> sd1(2.0, 3.0, 4.0, 140737488355328);
29         sensor_data<float> sd2(1.04, -4.678, -2.34);
30         sensor_data<float> sd3(0.054, 1.097, 4.456, 140737488355328);
31         sensor_data<float> sd10(v1, 140737488355328);
32
33         cout << "Constructor tests\n";
34         cout << "input\t" << v1 << "\n";
35         cout << "output\t" << sd10.m_data << "\t" << sd10.m_time_stamp << "\n\n";
36         cout << "input\t" << v1 << "\n";
37         cout << "output\t" << sd2.m_data << "\t" << sd2.m_time_stamp << "\n\n";
38
39         cout<< "Addition:\n";
40         sensor_data<float> sd4 = sd1 + sd2;
41         cout<< "\n" << sd1.m_data << "\n" << sd2.m_data;
42         cout<< "\nSum:\n" << sd4.m_data << endl;
43         sensor_data<float> sd9 = sd1 + sd10;
44         cout<< "\n" << sd1.m_data << "\n" << sd10.m_data;
45         cout<< "\nSum:\n" << sd9.m_data << endl;
46
47         cout<< "\n\n\nNormalization:\n";
48         cout<< "\n" << sd3.m_data;
49         normalize(sd3);
50         cout<< "\nResult:\n" << sd3.m_data << endl;
51         cout<< "\n" << sd2.m_data;
52         normalize(sd2);
53         cout<< "\nResult:\n" << sd2.m_data << endl;
54
55         float xx = 2.5;
56         cout<<"\n\n\nScale data:\n";
57         sensor_data<float> sd8 = scale_data(sd2, xx);
58         cout<< "\n" << sd2.m_data << "\n" << xx;
59         cout<< "\nResult:\n" << sd8.m_data << endl;
60 }
61