summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/localization/src/c/readSensorData.c
blob: 12c0dc0e5025e35378349e286c53851c7ed667c0 (plain) (blame)
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
/********************************
Author: Sravanthi Kota Venkata
********************************/

#include <stdio.h>
#include <stdlib.h>
#include "localization.h"

F2D* readSensorData(I2D* index, F2D* fid, I2D* type, I2D* eof)
{
    F2D *retData;
    int rows, i, j, k;
    int atype=-1, aindex;

    aindex = asubsref(index, 0);

    asubsref(index,0) = asubsref(index,0) + 1;
    rows = fid->height;
    asubsref(type,0) = 0;
    retData = fSetArray(1, 8, 0);
    
    if( asubsref(index,0) > (rows-1) )
        asubsref(eof,0) = 1;
    else
    {
        if( asubsref(index,0) == rows)
            asubsref(eof,0) = 1;
        else
            asubsref(eof,0) = 0;

        k = asubsref(index,0);
        atype = subsref(fid, k, 1);
        if( (atype == 1) || (atype == 2) || (atype == 3) )
        {
            for(i=0; i<3; i++)
            {
                asubsref(retData,i) = subsref(fid,k,(i+2));
            }
        }
        if( atype == 4 )
        {
            for(i=0; i<3; i++)
            {
                asubsref(retData,i) = subsref(fid,k,(i+2));
            }
            for(i=3; i<8; i++)
            {
                asubsref(retData,i) = subsref(fid,k+1,(i-3));
            }
            aindex = aindex + 1;
        }
        aindex = aindex + 1;
    }

    asubsref(index,0) = aindex;
    asubsref(type, 0) = atype;

    return retData;
}