Здравствуйте.
Создаю XML через дом-элементы.
Проблема в следующем - при записи большого массива данных записываются не все, в только первая часть. Притом ограничение примерно 20 кб.
QDomElement Argoenergo::SetArea(QDomDocument& domDoc, int starttime, int stoptime, QList<int> points)
{
QDomElement domElement = domDoc.createElement("area");
QDomElement inn = domDoc.createElement("inn");
QDomElement name = domDoc.createElement("name");
QDomText inn_text = domDoc.createTextNode("1234567890");
QDomText name_text = domDoc.createTextNode("Mega-company");
domElement.appendChild(inn);
inn.appendChild(inn_text);
domElement.appendChild(name);
name.appendChild(name_text);
QSqlQueryModel *sql_model = new QSqlQueryModel();
QString q = QString("SELECT ...");
sql_model->setQuery(q, currentDatabase());
QSqlQuery query = sql_model->query();
for(int i = 0; i < points.length(); i++)
{
QDomElement measurepoint = domDoc.createElement("measurepoint");
QDomAttr domAttr1 = domDoc.createAttribute("code");
domAttr1.setValue(QString("CODE_1234567%1").arg(points[i]));
measurepoint.setAttributeNode(domAttr1);
QDomAttr domAttr2 = domDoc.createAttribute("name");
domAttr2.setValue(QString("KTP 1121-7-%1").arg(points[i]));
measurepoint.setAttributeNode(domAttr2);
domElement.appendChild(measurepoint);
QDomElement measurecannel1 = domDoc.createElement("measurecannel");
QDomAttr domAttr11 = domDoc.createAttribute("code");
domAttr11.setValue("02");
measurecannel1.setAttributeNode(domAttr11);
QDomAttr domAttr21 = domDoc.createAttribute("desc");
domAttr21.setValue(QString(tr("Active energy, out")));
measurecannel1.setAttributeNode(domAttr21);
measurepoint.appendChild(measurecannel1);
int l = 0;
int k_1 = 0;
int prev = 0;
for(int k = 0; k < sql_model->rowCount(); k++)
{
if(sql_model->record(k).value("num_point").toInt() == points[i])
{
if(l == 0)
{
prev = sql_model->record(k).value("pwr").toDouble();
k_1 = k;
}
else
{
QDomElement period = domDoc.createElement("period");
QDomAttr periodStart = domDoc.createAttribute("start");
periodStart.setValue(sql_model->record(k_1).value("datetime_r").toDateTime().toString("hhmm"));
QDomAttr periodStop = domDoc.createAttribute("end");
periodStop.setValue(sql_model->record(k).value("datetime_r").toDateTime().toString("hhmm"));
period.setAttributeNode(periodStart);
period.setAttributeNode(periodStop);
QDomElement value = domDoc.createElement("value");
QDomText value_text = domDoc.createTextNode(QString("%1").arg(sql_model->record(k).value("pwr").toDouble() - sql_model->record(k_1).value("pwr").toDouble()));
if(sql_model->record(k).value("Status").toInt() != 0)
{
QDomAttr status = domDoc.createAttribute("status");
status.setValue(sql_model->record(k).value("status").toString());
value.setAttributeNode(status);
}
value.appendChild(value_text);
period.appendChild(value);
measurecannel1.appendChild(period);
k_1 = k;
}
l++;
}
}
}
return domElement;
}
В итоге при большом колличестве данных получаем:
<area>
<inn>1234567890</inn>
<name>Mega-company</name>
<measurepoint code="CODE_12345671" name="KTP 1121-7-1" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.272</value>
</period>
...
<period end="2300" start="2200" >
<value>1.079</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345672" name="KTP 1121-7-2" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>3e-05</value>
</period>
...
<period end="2300" start="2200" >
<value>8e-05</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345673" name="KTP 1121-7-3" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.313</value>
</period>
...
<period end="2300" start="2200" >
<value>1.177</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345674" name="KTP 1121-7-4" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.055</value>
</period>
...
<period end="2300" start="2200" >
<value>0.754</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345675" name="KTP 1121-7-5" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0</value>
</period>
...
<period end="2300" start="2200" >
<value>0</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345676" name="KTP 1121-7-6" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.276</value>
</period>
...
<period end="2300" start="2200" >
<value>1.22</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345677" name="KTP 1121-7-7" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.227</value>
</period>
...
<period end="2300" start="2200" >
<value>0.667</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345678" name="KTP 1121-7-8" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.747</value>
</period>
... ...
<period end="2300" start="2200" >
<value>1.129</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_12345679" name="KTP 1121-7-9" >
<measurecannel desc="Active energy, out" code="02" >
<period end="0100" start="0030" >
<value>0.361</value>
</period>
...
<period end="1900" start="1800" > <----------------------------------------- не дописал
<value>0.107</value>
</period>
</measurecannel>
</measurepoint>
<measurepoint code="CODE_123456710" name="KTP 1121-7-10" >
<measurecannel desc="Active energy, out" code="02" /> <------------------------------ не писал вообще
</measurepoint>
<measurepoint code="CODE_123456711" name="KTP 1121-7-11" >
<measurecannel desc="Active energy, out" code="02" />
</measurepoint>
<measurepoint code="CODE_123456712" name="KTP 1121-7-12" >
<measurecannel desc="Active energy, out" code="02" />
</measurepoint>
<measurepoint code="CODE_123456713" name="KTP 1121-7-13" >
<measurecannel desc="Active energy, out" code="02" />
</measurepoint>
</area>
Если обратить внимание на последних 5 секций <measurepoint>, то видно, что данные просто перестали записываться.
Данные есть все. При дебаге заходит везде, где надо и выполняет инструкции на запись и в последних 5 секциях. В чем проблема?