packetprinter.cpp
1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "packetprinter.h"
#include "ui_packetprinter.h"
#include <QTextStream>
#include "all_share.h"
PacketPrinter::PacketPrinter(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PacketPrinter)
{
ui->setupUi(this);
}
PacketPrinter::~PacketPrinter()
{
delete ui;
}
void PacketPrinter::printControl(oven_control_t &control)
{
QString str;
QTextStream stream(&str);
stream << "Control\n";
for (int idx = 0; idx < (int) sizeof(control) / sizeof(unsigned short); idx++)
{
QString str;
stream << str.sprintf("0x%04X 0x%04X\n", idx, ((unsigned short *) &control)[idx]);
}
ui->control->setPlainText(str);
}
void PacketPrinter::printState(oven_state_t &state)
{
QString str;
QTextStream stream(&str);
stream << "State\n";
for (int idx = 0; idx < (int) sizeof(state) / sizeof(unsigned short); idx++)
{
QString str;
stream << str.sprintf("0x%04X 0x%04X\n", idx, ((unsigned short *) &state)[idx]);
}
ui->state->setPlainText(str);
}