1 | #include "pierrdisp.h"
|
---|
2 | #include "utils.h"
|
---|
3 |
|
---|
4 |
|
---|
5 | PIErrorBox::PIErrorBox(PIContainerGen* par, int sx, int sy,
|
---|
6 | int px, int py)
|
---|
7 | : PIBaseWdg(par, "Error Message", sx, sy, px, py)
|
---|
8 | {
|
---|
9 | currErrText = "";
|
---|
10 | state = 0;
|
---|
11 | }
|
---|
12 |
|
---|
13 | PIErrorBox::~PIErrorBox()
|
---|
14 | {
|
---|
15 | }
|
---|
16 |
|
---|
17 | void
|
---|
18 | PIErrorBox::Draw()
|
---|
19 | {
|
---|
20 | if (currErrText == "") {
|
---|
21 | SelBackground();
|
---|
22 | EraseWindow();
|
---|
23 | } else {
|
---|
24 | switch(state) {
|
---|
25 | case 0:
|
---|
26 | EraseWindow();
|
---|
27 | SelForeground(PI_Red);
|
---|
28 | DrawFBox(0,0,1000,1000);
|
---|
29 | SelForeground(PI_Black);
|
---|
30 | break;
|
---|
31 | default:
|
---|
32 | SelBackground();
|
---|
33 | SelForeground();
|
---|
34 | }
|
---|
35 | SelFont(PI_BigSizeFont, PI_BoldFont);
|
---|
36 | DrawString(20,30,(char*)currErrText.c_str());
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | void
|
---|
41 | PIErrorBox::Cycle()
|
---|
42 | {
|
---|
43 | state = (state + 1) % 2;
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 | PIErrorDisplay::PIErrorDisplay(PIContainerGen* par, int sx, int sy,
|
---|
50 | int px, int py)
|
---|
51 | : PIContainer(par, "Error Display", sx, sy, px, py), PIPeriodX(1)
|
---|
52 | {
|
---|
53 | currErrId = 0;
|
---|
54 |
|
---|
55 | errorBox = new PIErrorBox(this, 150, 80, 0, 0);
|
---|
56 | ackButton = new PIButton(this, "OK", 5000, 40, 20, 155, 20);
|
---|
57 | updButton = new PIButton(this, "Upd", 5001, 40, 20, 155, 50);
|
---|
58 | Start();
|
---|
59 | }
|
---|
60 |
|
---|
61 | PIErrorDisplay::~PIErrorDisplay()
|
---|
62 | {
|
---|
63 | delete updButton;
|
---|
64 | delete ackButton;
|
---|
65 | delete errorBox;
|
---|
66 | }
|
---|
67 |
|
---|
68 | void
|
---|
69 | PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
|
---|
70 | {
|
---|
71 | msg = UserMsg(msg);
|
---|
72 | switch(msg) {
|
---|
73 | case 5000:
|
---|
74 | // On valide
|
---|
75 | if (currErrId)
|
---|
76 | AcqAckError(currErrId);
|
---|
77 | UpdData();
|
---|
78 | break;
|
---|
79 | case 5001:
|
---|
80 | UpdData();
|
---|
81 | break;
|
---|
82 |
|
---|
83 | default:
|
---|
84 | PIContainer::Process(msg, sender, data);
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | void
|
---|
89 | PIErrorDisplay::UpdData()
|
---|
90 | {
|
---|
91 | currErrId = 0;
|
---|
92 | char tache[80];
|
---|
93 | char msg[200];
|
---|
94 | int code;
|
---|
95 | int severite;
|
---|
96 | int rc = AcqGetNextError(&currErrId, tache, &code, &severite, msg);
|
---|
97 | if (rc)
|
---|
98 | errorBox->SetText("");
|
---|
99 | else
|
---|
100 | errorBox->SetText(string(tache) + " : (" + itos(code) + "/" +
|
---|
101 | itos(severite) +") " + msg);
|
---|
102 | errorBox->Draw();
|
---|
103 | }
|
---|
104 |
|
---|
105 |
|
---|