//#include "widget.h"
|
//#include <QApplication>
|
#include "LDBTool.h"
|
#include <QObject>
|
#include <list>
|
#include <string>
|
#include <iostream>
|
#include <QDebug>
|
#include "myThread.h"
|
#include "dbtest.h"
|
#if 1
|
|
//dev
|
|
|
int main(int argc, char *argv[])
|
{
|
std::cout<<__DATE__<<" "<<__TIME__<<std::endl;
|
{
|
CallBackFunc callf;
|
|
DbTest test_db/*(std::bind(&CallBackFunc::callback_func, &callf, std::placeholders::_1))*/;
|
// DbTest test_db2;
|
|
auto sp_task(std::make_shared<std::string>("haikang:12:34:56:78:90:ab"));
|
auto sp_task2(std::make_shared<std::string>("dahua:12:34:56:78:90:ab"));
|
// test_db.put_task(sp_task);
|
// test_db.put_task(sp_task2);
|
// test_db.put_task(sp_task);
|
// test_db.put_task(sp_task2);
|
// test_db.put_task(sp_task);
|
// test_db.put_task(sp_task2);
|
// test_db.put_task(sp_task);
|
// test_db.put_task(sp_task2);
|
// test_db2.put_task(sp_task);
|
// test_db2.put_task(sp_task2);
|
|
test_db.beginThreads(10);
|
// test_db2.beginThreads(1);
|
|
while(1){
|
test_db.put_task(sp_task);
|
test_db.put_task(sp_task2);
|
}
|
|
}
|
|
|
return 0;
|
}
|
|
|
|
|
|
#else
|
|
//sdkhdl
|
int main(int argc, char *argv[])
|
{
|
// QApplication a(argc, argv);
|
LDBTool test;
|
Record_Chn_Sdk record;
|
|
qDebug() << QDateTime::currentDateTime();
|
|
record.n_id = 0;
|
record.str_storage_dev_id = "str_storage_dev_id1";
|
record.n_chn = 111;
|
record.str_sdks = "1,2,3";
|
record.str_reserved = "str_reserved1";
|
|
test.insertChnSdkTable(record);
|
|
Record_Chn_Sdk record2;
|
record2.n_id = 0;
|
record2.str_storage_dev_id = "str_storage_dev_id2";
|
record2.n_chn = 222;
|
record2.str_sdks = "2,3,4";
|
record2.str_reserved = "str_reserved2";
|
test.insertChnSdkTable(record2);
|
|
std::list<Record_Chn_Sdk> vec;
|
vec = test.searchChnSdkTableAll();
|
// std::cout << vec << std::endl;
|
|
record2.str_sdks = "5,6,7";
|
test.updateChnSdkTable(record2);
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
int chn1 = 111;
|
int chn2 = 222;
|
|
Record_Chn_Sdk rec1 = test.searchChnSdkTableByChannelId(id1, chn1);
|
test.deleteChnSdkTable(id1, chn2);
|
test.deleteChnSdkTable(id2, chn1);
|
test.deleteChnSdkTable(id1, chn1);
|
test.deleteChnSdkTable(id2, chn2);
|
|
return 0;//a.exec();
|
}
|
//sdkhdl
|
int main(int argc, char *argv[])
|
{
|
QApplication a(argc, argv);
|
LDBTool test;
|
Record_Sdk_Hdl_info record;
|
|
qDebug() << QDateTime::currentDateTime();
|
|
record.n_id = 0;
|
record.str_storage_dev_id = "str_storage_dev_id1";
|
record.n_chn = 111;
|
record.str_src_path = "str_src_path1";
|
record.n_total = 11;
|
record.n_pos = 0;
|
record.str_reserved = "str_reserved1";
|
|
test.insertSdkHdlTable(record);
|
|
Record_Sdk_Hdl_info record2;
|
record2.n_id = 0;
|
record2.str_storage_dev_id = "str_storage_dev_id2";
|
record2.n_chn = 222;
|
record2.str_src_path = "str_src_path2";
|
record2.n_total = 22;
|
record2.n_pos = 0;
|
record2.str_reserved = "str_reserved2";
|
test.insertSdkHdlTable(record2);
|
|
|
std::list<Record_Sdk_Hdl_info> vec;
|
vec = test.searchSdkHdlTableAll();
|
// std::cout << vec << std::endl;
|
|
record2.n_pos = 6;
|
test.updateSdkHdlTable(record2);
|
|
test.updateSdkHdlTablePos("str_src_path1", 7);
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
int chn1 = 111;
|
int chn2 = 222;
|
// std::list<Record_Sdk_Hdl_info> vec1 = test.searchChannelTableByChannelId(id1, chn1);
|
// std::list<Record_Sdk_Hdl_info> vec2 = test.searchChannelTableByChannelId(id2, chn2);
|
// std::cout << vec1 << std::endl;
|
// std::cout << vec2 << std::endl;
|
//Record_Sdk_Hdl_info recOldest = test.searchOldestRecordfromSdkHdlTableByUpdateTime();
|
// Record_Sdk_Hdl_info recOldestID = test.searchOldestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
// Record_Sdk_Hdl_info recNewestID = test.searchNewestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
test.insertSdkHdlTableAndDeleteCutVideoTable(record2, id1, chn1, "str_src_path1");
|
test.deleteSdkHdlTable(QString::fromStdString("str_src_path1"));
|
test.deleteSdkHdlTable(QString::fromStdString("str_src_path2"));
|
|
return a.exec();
|
}
|
//cutvideo
|
int main(int argc, char *argv[])
|
{
|
QApplication a(argc, argv);
|
LDBTool test;
|
Record_Cut_Video_info record;
|
|
qDebug() << QDateTime::currentDateTime();
|
|
record.n_id = 0;
|
record.str_storage_dev_id = "str_storage_dev_id1";
|
record.n_chn = 111;
|
record.str_src_path = "str_src_path1";
|
record.str_dst_path = "";
|
record.n_total = 0;
|
record.b_finish_flag = 0;
|
record.tim_update_time = QDateTime::currentDateTime();
|
record.str_reserved = "str_reserved1";
|
|
test.insertCutVideoTable(record);
|
|
Record_Cut_Video_info record2;
|
record2.n_id = 0;
|
record2.str_storage_dev_id = "str_storage_dev_id2";
|
record2.n_chn = 222;
|
record2.str_src_path = "str_src_path2";
|
record2.str_dst_path = "";
|
record2.n_total = 0;
|
record2.b_finish_flag = 0;
|
record2.tim_update_time = QDateTime::currentDateTime();
|
record2.str_reserved = "str_reserved2";
|
test.insertCutVideoTable(record2);
|
|
|
std::list<Record_Cut_Video_info> vec;
|
vec = test.searchCutVideoTableAll();
|
// std::cout << vec << std::endl;
|
|
record2.b_finish_flag = 1;
|
record2.str_dst_path = "str_dst_path222";
|
record2.n_total = 6;
|
record2.tim_update_time = QDateTime::currentDateTime();
|
test.updateCutVideoTable(record2);
|
|
test.updateCutVideoTable("str_src_path1", "str_dst_path111", 7);
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
int chn1 = 111;
|
int chn2 = 222;
|
// std::list<Record_Cut_Video_info> vec1 = test.searchChannelTableByChannelId(id1, chn1);
|
// std::list<Record_Cut_Video_info> vec2 = test.searchChannelTableByChannelId(id2, chn2);
|
// std::cout << vec1 << std::endl;
|
// std::cout << vec2 << std::endl;
|
Record_Cut_Video_info recOldest = test.searchOldestRecordfromCutTableByUpdateTime();
|
// Record_Cut_Video_info recOldestID = test.searchOldestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
// Record_Cut_Video_info recNewestID = test.searchNewestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
test.insertCutVideoTableAndDeleteLoadFileTable(record2, "str_storage_dev_id2",222,\
|
QDateTime::fromString("2018-08-18 16:38:49.819","yyyy-MM-dd hh:mm:ss.zzz"));
|
|
test.deleteCutVideoTable(id1, chn1, QString::fromStdString("str_src_path1"));
|
test.deleteCutVideoTable(id2, chn2, QString::fromStdString("str_src_path2"));
|
|
return a.exec();
|
}
|
//loadfile
|
int main(int argc, char *argv[])
|
{
|
QApplication a(argc, argv);
|
LDBTool test;
|
Record_Load_File_info record;
|
|
qDebug() << QDateTime::currentDateTime();
|
|
record.n_id = 0;
|
record.str_storage_dev_id = "str_storage_dev_id1";
|
record.n_chn = 111;
|
record.tim_do_time = QDateTime::currentDateTime().addDays(-1);
|
record.b_finish_flag = 0;
|
record.str_load_file_path = "";
|
record.tim_update_time = QDateTime::currentDateTime();
|
record.str_reserved = "str_reserved1";
|
|
test.insertLoadFileTable(record);
|
|
Record_Load_File_info record2;
|
record2.n_id = 0;
|
record2.str_storage_dev_id = "str_storage_dev_id2";
|
record2.n_chn = 222;
|
record2.tim_do_time = QDateTime::currentDateTime().addDays(-1);
|
record2.b_finish_flag = 0;
|
record2.str_load_file_path = "";
|
record2.tim_update_time = QDateTime::currentDateTime();
|
record2.str_reserved = "str_reserved2";
|
test.insertLoadFileTable(record2);
|
|
|
std::list<Record_Load_File_info> vec;
|
vec = test.searchLoadFileTableAll();
|
// std::cout << vec << std::endl;
|
|
record2.b_finish_flag = 1;
|
record2.str_load_file_path = "str_load_file_path";
|
record2.tim_update_time = QDateTime::currentDateTime();
|
test.updateLoadFileTable(record2);
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
int chn1 = 111;
|
int chn2 = 222;
|
// std::list<Record_Load_File_info> vec1 = test.searchChannelTableByChannelId(id1, chn1);
|
// std::list<Record_Load_File_info> vec2 = test.searchChannelTableByChannelId(id2, chn2);
|
// std::cout << vec1 << std::endl;
|
// std::cout << vec2 << std::endl;
|
Record_Load_File_info recOldest = test.searchOldestRecordfromLoadTableByUpdateTime();
|
// Record_Load_File_info recOldestID = test.searchOldestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
// Record_Load_File_info recNewestID = test.searchNewestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
|
Record_Cam_Chn chn_record2 = test.searchChannelTableByChannelId("str_storage_dev_id2", 222);
|
chn_record2.tim_do_time = chn_record2.tim_do_time.addSecs(3600);
|
chn_record2.tim_update_time = QDateTime::currentDateTime();
|
test.insertLoadFileTableAndUpdateChannelTable(record2, chn_record2);
|
|
test.deleteLoadFileTable(id1, chn1, record.tim_do_time);
|
test.deleteLoadFileTable(id2, chn2, record2.tim_do_time);
|
|
return a.exec();
|
}
|
//camchn
|
int main(int argc, char *argv[])
|
{
|
QApplication a(argc, argv);
|
LDBTool test;
|
Record_Cam_Chn chn_record;
|
|
// std::cout << QDateTime().toString()<< std::endl;
|
|
chn_record.n_id = 1;
|
chn_record.str_storage_dev_id = "str_storage_dev_id1";
|
chn_record.n_chn = 111;
|
chn_record.str_chn_name = "str_chn_name1";
|
chn_record.str_addr = "str_addr1";
|
chn_record.str_longitude = "str_longitude1";
|
chn_record.str_latitude = "str_latitude1";
|
chn_record.tim_do_time = QDateTime::currentDateTime().addDays(-1);
|
chn_record.tim_update_time = QDateTime::currentDateTime();
|
chn_record.str_reserved = "str_reserved1";
|
|
|
test.insertChannelTable(chn_record);
|
|
Record_Cam_Chn chn_record2;
|
chn_record2.n_id = 2;
|
chn_record2.str_storage_dev_id = "str_storage_dev_id2";
|
chn_record2.n_chn = 222;
|
chn_record2.str_chn_name = "str_chn_name2";
|
chn_record2.str_addr = "str_addr2";
|
chn_record2.str_longitude = "str_longitude2";
|
chn_record2.str_latitude = "str_latitude2";
|
chn_record2.tim_do_time = QDateTime::currentDateTime().addDays(-1);
|
chn_record2.tim_update_time = QDateTime::currentDateTime();
|
chn_record2.str_reserved = "str_reserved2";
|
test.insertChannelTable(chn_record2);
|
|
|
std::list<Record_Cam_Chn> vec;
|
vec = test.searchChannelTableAll();
|
// std::cout << vec << std::endl;
|
|
chn_record2.n_id = 2;
|
chn_record2.str_storage_dev_id = "str_storage_dev_id2";
|
chn_record2.n_chn = 222;
|
chn_record2.str_chn_name = "str_chn_name3";
|
chn_record2.str_addr = "str_addr3";
|
chn_record2.str_longitude = "str_longitude3";
|
chn_record2.str_latitude = "str_latitude3";
|
chn_record2.tim_do_time = QDateTime::currentDateTime().addDays(-1);
|
chn_record2.tim_update_time = QDateTime::currentDateTime();
|
chn_record2.str_reserved = "str_reserved3";
|
test.updateChannelTable(chn_record2);
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
int chn1 = 111;
|
int chn2 = 222;
|
Record_Cam_Chn vec1 = test.searchChannelTableByChannelId(id1, chn1);
|
Record_Cam_Chn vec2 = test.searchChannelTableByChannelId(id2, chn2);
|
// std::cout << vec1 << std::endl;
|
// std::cout << vec2 << std::endl;
|
Record_Cam_Chn recOldest = test.searchOldestRecordfromChnTableByUpdateTime();
|
Record_Cam_Chn recOldestID = test.searchOldestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
Record_Cam_Chn recNewestID = test.searchNewestRecordfromChnTableByChannelId(QString::fromStdString("str_storage_dev_id2"), 222);
|
|
test.deleteChannelTable(id1, chn2);
|
test.deleteChannelTable(id2, chn1);
|
test.deleteChannelTable(id1, chn1);
|
test.deleteChannelTable(id2, chn2);
|
|
return a.exec();
|
}
|
|
//dev
|
int main(int argc, char *argv[])
|
{
|
QApplication a(argc, argv);
|
LDBTool test;
|
Record_Storage_Dev dev_record;
|
|
dev_record.n_id = 0;
|
dev_record.str_storage_dev_id = "str_storage_dev_id1";
|
dev_record.str_dev_name = "str_dev_name1";
|
dev_record.n_total_chn = 32;
|
dev_record.str_all_chn_num = "str_all_chn_num";
|
dev_record.str_addr = "str_addr";
|
dev_record.str_longitude = "str_longitude";
|
dev_record.str_latitude = "str_latitude";
|
dev_record.str_ip = "str_ip";
|
dev_record.n_port = 1;
|
dev_record.str_username = "str_username";
|
dev_record.str_password = "str_password";
|
dev_record.n_duration = 1;
|
dev_record.str_reserved = "str_reserved";
|
|
test.insertLDeviceTable(dev_record);
|
|
Record_Storage_Dev dev_record1;
|
dev_record1.n_id = 2;
|
dev_record1.str_storage_dev_id = "str_storage_dev_id2";
|
dev_record1.str_dev_name = "str_dev_name2";
|
dev_record1.n_total_chn = 16;
|
dev_record1.str_all_chn_num = "str_all_chn_num";
|
dev_record1.str_addr = "str_addr2";
|
dev_record1.str_longitude = "str_longitude2";
|
dev_record1.str_latitude = "str_latitude2";
|
dev_record1.str_ip = "str_ip2";
|
dev_record1.n_port = 222;
|
dev_record1.str_username = "str_username2";
|
dev_record1.str_password = "str_password2";
|
dev_record1.n_duration = 2;
|
dev_record1.str_reserved = "str_reserved2";
|
test.insertLDeviceTable(dev_record1);
|
|
Record_Storage_Dev dev_record2;
|
dev_record2.n_id = 2;
|
dev_record2.str_storage_dev_id = "str_storage_dev_id2";
|
dev_record2.str_dev_name = "str_dev_name3";
|
dev_record2.n_total_chn = 16;
|
dev_record2.str_all_chn_num = "str_all_chn_num3";
|
dev_record2.str_addr = "str_addr3";
|
dev_record2.str_longitude = "str_longitude3";
|
dev_record2.str_latitude = "str_latitude3";
|
dev_record2.str_ip = "str_ip3";
|
dev_record2.n_port = 333;
|
dev_record2.str_username = "str_username3";
|
dev_record2.str_password = "str_password3";
|
dev_record2.n_duration = 3;
|
dev_record2.str_reserved = "str_reserved3";
|
test.updateLDeviceTable(dev_record2);
|
|
|
std::list<Record_Storage_Dev> vec;
|
vec = test.searchDeviceTableAll();
|
|
QString id1("str_storage_dev_id1");
|
QString id2("str_storage_dev_id2");
|
Record_Storage_Dev s1 = test.searchDeviceTableByDeviceId(id1);
|
Record_Storage_Dev s2 = test.searchDeviceTableByDeviceId(id2);
|
|
int n = test.searchDeviceNumber();
|
|
int d = test.searchDurationByDeviceId(id1);
|
|
test.deleteLDeviceTable(id1);
|
test.deleteLDeviceTable(id2);
|
|
return a.exec();
|
}
|
#endif
|