Update to dms control phase1.

This commit is contained in:
sunwen
2023-08-21 14:22:41 +08:00
parent d1dc5df680
commit 20fb814608
59 changed files with 2538 additions and 904 deletions

View File

@@ -0,0 +1,93 @@
#include "ReconManager.h"
#include "ReconClient.h"
#include "json/jsonobject.h"
#include "QDebug"
namespace
{
const std::string CRT_FILE = "./cfgs/client.crt";
const std::string KEY_FILE = "./cfgs/client.key";
std::string toReconServerAddress(const QString& aIp, const QString& aPort)
{
return ("https://" + aIp + ":" + aPort).toStdString();
}
}
ReconManager* ReconManager::getInstance()
{
static ReconManager instance;
return &instance;
}
ReconManager::ReconManager(QObject* aParent)
: QObject(aParent)
, mReconClient(new Recon::ReconClient(CRT_FILE, KEY_FILE))
{
init();
}
ReconManager::~ReconManager()
{
delete mReconClient;
}
void ReconManager::init()
{
host reconServerInfo = JsonObject::Instance()->getServer(JsonObject::RECON);
mReconClient->SetHost(toReconServerAddress(reconServerInfo.ip , reconServerInfo.port));
}
void ReconManager::setReconIpAndPort(const QString& aIp, const QString& aPort)
{
mReconClient->SetHost(toReconServerAddress(aIp, aPort));
}
void ReconManager::createEmptyScan(const QString& aScanID, const QString& aPath)
{
Scan empty{aScanID.toStdString(), "", "", aPath.toStdString(),0};
auto result = mReconClient->Create(empty);
if(result.good())
{
qDebug()<< "create empty scan success, scanID: "<< aScanID;
emit createEmptyScanResponsed(true, aScanID);
}
else
{
qDebug()<< "Create empty scan fail by %s\n" << result.error().data();
emit createEmptyScanResponsed(false, aScanID, result.error().data());
}
}
void ReconManager::createScan(const QString& aScanID, const QString& aPatientID, const QString& aReferenceID, const QString& aPath)
{
Scan scan{aScanID.toStdString(), aPatientID.toStdString(), aReferenceID.toStdString(), aPath.toStdString(), 1};
auto response = mReconClient->Create(scan);
if(response.good())
{
qDebug()<< "create scan success, scanID: "<< aScanID;
emit createScanResponsed(true, aScanID);
}
else
{
qDebug()<< "Create scan fail by " << response.error().data();
emit createScanResponsed(false, aScanID, response.error().data());
}
}
void ReconManager::queryReconStatus(const QStringList& aScanIDs)
{
QMap<QString, int> result;
for(QString scanID : aScanIDs)
{
int state;
auto response = mReconClient->QueryScan(scanID.toStdString(), state);
if(response.bad())
{
break;
}
result.insert(scanID, state);
}
emit queryReconStateResponsed(result);
}