• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Chipsea Technologies (Shenzhen) Corp., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef REPORT_DATA_CALLBACK_H
17 #define REPORT_DATA_CALLBACK_H
18 
19 #include <vector>
20 
21 #include "refbase.h"
22 #include "medical_native_type.h"
23 
24 namespace OHOS {
25 namespace Sensors {
26 constexpr int32_t CIRCULAR_BUF_LEN = 1024;
27 constexpr int32_t SENSOR_DATA_LENGHT = 1024;
28 
29 struct CircularEventBuf {
30     struct  SensorEvent *circularBuf;
31     int32_t readPosition;
32     int32_t writePosition;
33     int32_t eventNum;
34 };
35 
36 class ReportDataCache : public RefBase {
37 public:
38     ReportDataCache();
39     ~ReportDataCache();
40     int32_t CacheData(const struct SensorEvent *event, sptr<ReportDataCache> cache);
41     struct CircularEventBuf &GetEventData();
42     struct CircularEventBuf eventsBuf_;
43 };
44 
45 using DataCacheFunc = int32_t (ReportDataCache::*)(const struct SensorEvent *event, sptr<ReportDataCache> cb);
46 }  // namespace Sensors
47 }  // namespace OHOS
48 #endif  // REPORT_DATA_CALLBACK_H
49