Newer
Older

Jan Reher
committed
#include <vector>
#include <iostream>
#include <QtCore/QString>
#include <QtXml/QXmlStreamWriter> // For Compilation: QXml/QXmlStreamWriter
#include "productiondatabaseclient.h"

Jan Reher
committed
ProductionDatabase::ProductionDatabaseClient *proddbclient;
void initialize();
void screeningInfo();
void assignApds(std::string redSerial, std::string blueSerial);
void assignUnit(std::string detectorSerial, std::string crystalSerial, std::string barcode);
void assignToModule(std::vector<uint> barcodes, std::string moduleSN);

Jan Reher
committed
int main() {
initialize();
std::vector<uint> barcodes;
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(0);
barcodes.push_back(1309009619);
barcodes.push_back(1309009602);
barcodes.push_back(1309009633);
barcodes.push_back(1309009664);
barcodes.push_back(1309009657);
barcodes.push_back(1309009696);
barcodes.push_back(1309009640);
barcodes.push_back(1309009626);
assignToModule(barcodes, "29012015-9");
return 0;
}
void initialize() {
proddbclient = new ProductionDatabase::ProductionDatabaseClient();
std::cerr << proddbclient->getVersionShort() << std::endl;
proddbclient->queryCredentials();
proddbclient->checkConnectivityAndCredentials();
}
void assignToModule(std::vector<uint> barcodes, std::string moduleSN) {
if (barcodes.size() != 16) {
throw "Vector with barcodes must contain exactly 16 elements!";
}
QString buffer;
QXmlStreamWriter xml ( &buffer );
xml.setAutoFormatting(true);
xml.writeStartDocument( QString::fromUtf8( "1.0" ) );
xml.writeStartElement( QString::fromUtf8( "productiondb" ) ) ;
xml.writeTextElement("moduleSN",QString::fromStdString(moduleSN));
for (size_t i = 0; i < 16; i++) {
std::string entryname = std::string("Slot") + std::to_string(i);
if (barcodes[i]==0)
xml.writeEmptyElement(QString::fromStdString(entryname));
else
xml.writeTextElement(QString::fromStdString(entryname),QString::number(barcodes[i]));
}
xml.writeEndDocument();
std::string xmlRequest = buffer.toStdString();
std::cerr << xmlRequest << std::endl;
//proddbclient->postXmlRequest("",xmlRequest);
}
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
void assignUnit(std::string detectorSerial, std::string crystalSerial, std::string barcode) {
QString buffer;
QXmlStreamWriter xml ( &buffer );
xml.setAutoFormatting(true);
xml.writeStartDocument( QString::fromUtf8( "1.0" ) );
xml.writeStartElement( QString::fromUtf8( "productiondb" ) ) ;
xml.writeTextElement( QString::fromUtf8( "detectorSerial" ), QString::fromStdString( detectorSerial ) );
xml.writeTextElement( QString::fromUtf8( "crystalSerial" ), QString::fromStdString( crystalSerial ) );
xml.writeTextElement( QString::fromUtf8( "barcode" ), QString::fromStdString( barcode ) );
xml.writeEndDocument();
std::string xmlRequest = buffer.toStdString();
std::cerr << xmlRequest << std::endl;
proddbclient->postXmlRequest("unit_assemble.php", xmlRequest);
}
void assignApds(std::string redSerial, std::string blueSerial) {
QString buffer;
QXmlStreamWriter xml ( &buffer );
xml.setAutoFormatting(true);
xml.writeStartDocument( QString::fromUtf8( "1.0" ) );
xml.writeStartElement( QString::fromUtf8( "productiondb" ) ) ;
xml.writeTextElement( QString::fromUtf8( "redSerial" ), QString::fromStdString( redSerial ) );
xml.writeTextElement( QString::fromUtf8( "blueSerial" ), QString::fromStdString( blueSerial ) );
xml.writeEndDocument();
std::string xmlRequest = buffer.toStdString();
std::cerr << xmlRequest << std::endl;
proddbclient->postXmlRequest("detector_assemble.php", xmlRequest);
}
void screeningInfo() {

Jan Reher
committed
std::vector<QString> apds;
apds.push_back(QString::fromUtf8("0608004648"));
apds.push_back(QString::fromUtf8("APD123"));
apds.push_back(QString::fromUtf8("APD456"));

Jan Reher
committed
QString buffer;
QXmlStreamWriter xml ( &buffer );
xml.setAutoFormatting ( true );
xml.writeStartDocument ( QString::fromUtf8 ( "1.0" ) );
xml.writeStartElement ( QString::fromUtf8 ( "productiondb" ) );
xml.writeStartElement ( QString::fromUtf8 ( "elements" ) );
int j = 1;
for ( auto i = apds.begin(); i != apds.end(); i++, j++ ) {
xml.writeStartElement ( QString::fromUtf8 ( "apd" ) );
xml.writeTextElement ( QString::fromUtf8 ( "serial" ), *i );
xml.writeTextElement ( QString::fromUtf8 ( "u_m100_warm" ), QString::number( 100.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m100_cold" ), QString::number( 100.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m100_warm" ), QString::number( 10.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m100_cold" ), QString::number( 10.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m150_warm" ), QString::number( 150.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m150_cold" ), QString::number( 150.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m150_warm" ), QString::number( 15.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m150_cold" ), QString::number( 15.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m200_warm" ), QString::number( 200.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m200_cold" ), QString::number( 200.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m200_warm" ), QString::number( 20.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m200_cold" ), QString::number( 20.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m300_warm" ), QString::number( 300.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "u_m300_cold" ), QString::number( 300.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m300_warm" ), QString::number( 30.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "s_m300_cold" ), QString::number( 30.4 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "ubreak_warm" ), QString::number( 30.3 + j ) );
xml.writeTextElement ( QString::fromUtf8 ( "ubreak_cold" ), QString::number( 30.4 + j ) );

Jan Reher
committed
xml.writeEndElement();
}
xml.writeEndDocument(); // This closes all open tags automatically.
std::string xmlRequest = buffer.toStdString();
std::cerr << xmlRequest << std::endl;
// ProductionDatabase::ProductionDatabaseClient *proddbclient = new ProductionDatabase::ProductionDatabaseClient();
// std::cerr << proddbclient->getVersionShort() << std::endl;
// proddbclient->queryCredentials();
// proddbclient->checkConnectivityAndCredentials();
// proddbclient->postXmlRequest("apd_enter_characteristics.php", xmlRequest);