summaryrefslogtreecommitdiff
path: root/gnss/gnssUmdf/FixSession.h
blob: f82983062d034d14b51813553ea85f5cdd37d03b (plain)
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
/*++

Copyright (c) Microsoft Corporation.  All rights reserved.

Module Name:

    Fixsession.h

Abstract:

    This module contains the type definitions of the fix logic of the Umdf Gnss Driver.

Environment:

    Windows User-Mode Driver Framework

--*/

#pragma once

//
// This class implements the Fix sessions and contains logic to provide position within GNSS driver.
//
class CFixSession
{
public:
    CFixSession();
    ~CFixSession();

    void AcquireSingleFix();
    NTSTATUS Initialize(_In_ WDFQUEUE Queue);
    NTSTATUS StartAcquiringFix(_In_ PGNSS_FIXSESSION_PARAM FixSessionParameters);
    NTSTATUS StopAcquiringFix(_In_ PGNSS_STOPFIXSESSION_PARAM StopFixSessionParam);
    NTSTATUS ModifyAcquiringFix(_In_ PGNSS_FIXSESSION_PARAM ModifyFixSessionParam);
    NTSTATUS GetFix(_In_ WDFREQUEST Request);
    NTSTATUS UpdateCurrentPosition(_In_ PGNSS_FIXDATA GnssFix);

    NTSTATUS RetrievePosition(_Inout_ PGNSS_FIXDATA GnssFixData);
    NTSTATUS RetrievePositionFromPredefinedValue(_Out_ PGNSS_FIXDATA GnssFixData);

private:
    enum STATE
    {
        ACQUIRING = 0,
        STOPPED
    };

    ULONG _Id = INVALID_SESSION_ID;
    STATE _State = STOPPED;
    GNSS_FIXSESSION_PARAM _FixParameter = {};
    WDFQUEUE _FixAcquisitionRequestQueue = nullptr;
    bool _HasCachedFix = false;
    GNSS_FIXDATA _GnssPosition = {};
    HANDLE _StopFixEvent = nullptr;
    PTP_WORK _ThreadpoolWork = nullptr;
    CRITICAL_SECTION _Lock;

    NTSTATUS CompleteRequestWithGnssFix(_In_ WDFREQUEST Request, PGNSS_FIXDATA GnssFix);
    NTSTATUS ReportGnssFix(_In_ PGNSS_FIXDATA GnssFix);
};