forked from sam-itt/sofis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock-data-source.c
79 lines (67 loc) · 1.75 KB
/
mock-data-source.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* SPDX-FileCopyrightText: 2021 Samuel Cuella <samuel.cuella@gmail.com>
*
* This file is part of SoFIS - an open source EFIS
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#include <stdlib.h>
#include "mock-data-source.h"
static bool mock_data_source_frame(MockDataSource *self, uint32_t dt);
static DataSourceOps mock_data_source_ops = {
.frame = (DataSourceFrameFunc)mock_data_source_frame,
.dispose = NULL
};
MockDataSource *mock_data_source_new(void)
{
MockDataSource *self;
self = calloc(1, sizeof(MockDataSource));
if(self){
if(!mock_data_source_init(self)){
data_source_free(DATA_SOURCE(self));
return NULL;
}
}
return self;
}
MockDataSource *mock_data_source_init(MockDataSource *self)
{
if(!data_source_init(DATA_SOURCE(self), &mock_data_source_ops))
return NULL;
#if 0
data_source_set_location(
DATA_SOURCE(self), &(LocationData){
.super.latitude = 45.215470,
.super.longitude = 5.844828,
.altitude = 718.267245
}
);
data_source_set_attitude(
DATA_SOURCE(self), &(AttitudeData){
.roll = 0,
.pitch = 0,
.heading = 43.698940
}
);
#endif
return self;
}
static bool mock_data_source_frame(MockDataSource *self, uint32_t dt)
{
data_source_set_location(
DATA_SOURCE(self), &(LocationData){
.super.latitude = 45.215470,
.super.longitude = 5.844828,
.altitude = 718.267245
}
);
data_source_set_attitude(
DATA_SOURCE(self), &(AttitudeData){
.roll = 0,
.pitch = 0,
.heading = 43.698940
}
);
DATA_SOURCE(self)->has_fix = true;
return true;
}