70 lines
2.0 KiB
C++
70 lines
2.0 KiB
C++
//
|
|
// Database.hpp
|
|
// POCpp
|
|
//
|
|
// Created by Patrick McDonagh on 7/5/17.
|
|
// Copyright © 2017 Henry Pump. All rights reserved.
|
|
//
|
|
|
|
#ifndef Database_hpp
|
|
#define Database_hpp
|
|
|
|
#include <stdio.h>
|
|
#include <iostream>
|
|
#include <time.h>
|
|
|
|
#include <mongocxx/client.hpp>
|
|
#include <mongocxx/uri.hpp>
|
|
#include <mongocxx/instance.hpp>
|
|
|
|
#include <bsoncxx/builder/stream/document.hpp>
|
|
#include <bsoncxx/json.hpp>
|
|
|
|
|
|
|
|
#include "Card.h"
|
|
#include "Measurement.h"
|
|
#include "WellTest.h"
|
|
#include "FluidShot.h"
|
|
|
|
using bsoncxx::builder::stream::close_array;
|
|
using bsoncxx::builder::stream::close_document;
|
|
using bsoncxx::builder::stream::document;
|
|
using bsoncxx::builder::stream::finalize;
|
|
using bsoncxx::builder::stream::open_array;
|
|
using bsoncxx::builder::stream::open_document;
|
|
|
|
class Database{
|
|
private:
|
|
std::string pocDatabase = "poc";
|
|
// mongocxx::instance mongoInstance{};
|
|
// mongocxx::uri mongoUri;
|
|
// mongocxx::client mongoClient;
|
|
mongocxx::instance instance{};
|
|
mongocxx::client mongoClient{mongocxx::uri{"mongodb://poc_www:HenryPump1903@localhost/?authSource=poc"}};
|
|
mongocxx::database pocDb;
|
|
|
|
|
|
mongocxx::collection cardCollection, wellDataCollection, gaugeOffCollection, wellTestCollection,
|
|
fluidShotsCollection, runStatusCollection, wellConfigCollection, setpointCollection;
|
|
void initCollections();
|
|
|
|
public:
|
|
Database();
|
|
long getLastStrokeNumber();
|
|
long newCard(Card &inpCard);
|
|
long newMeasurement(Measurement &inpMeasurement);
|
|
int getLastStoredMeasurementAndUpdate(Measurement &inpMeasurement);
|
|
long newDailyTotal(Measurement &inpMeasurement);
|
|
double getPreviousDailyProductionTotal(std::chrono::milliseconds timestamp);
|
|
long newWellTest(WellTest inp);
|
|
WellTest getPreviousWellTest(std::chrono::milliseconds timeParameter);
|
|
double getLatestKFactor();
|
|
long newFluidShot(FluidShot inp);
|
|
double getLatestFrictionEstimate();
|
|
long newRunStatus(std::string runStatus, std::string initiator);
|
|
|
|
};
|
|
|
|
#endif /* Database_hpp */
|