12345678910111213141516171819202122232425262728293031 |
- #include <iostream>
- #include <vector>
- #include <string>
- #include <utility>
- #include <thread>
- #include <chrono>
- #include "tsdb_hf.h"
- int main() {
- //初始化高频时序数据入口类
- tsdb_hf_cpp::tsdb_entry db;
- //设置高频采集数据本地暂存路径
- db.set_data_dir("../work/watch-daemon/data");
- //300个采集数据形成一个本地暂存压缩文件,实际应用需要调整
- db.set_part_size(300);
- //新建传感器名为test_pts_1的stream对象,从UTC时间1000000000毫秒开始,两点间的时间间隔为1000纳秒
- auto stream = db.new_stream("test_pts_1", 1000000000, 1000);
- //采集的传感器数据
- std::vector<double> pts{ 1.1, 2.2, 3.3, 4.4, 8.8, 7.7, 6.6, 5.5 };
- for (int i = 0; i < 10000; i++) {
- pts.push_back(4.2);
- }
- //插入采集数据
- stream.insert_points(pts.data(), size(pts));
- //关闭stream
- stream.close();
- std::cout << "All success!" << std::endl;
- }
|