source: Sophya/trunk/Poubelle/DPC:FitsIOServer/PI/pierrdisp.cc@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 1.8 KB
RevLine 
[658]1#include "pierrdisp.h"
2#include "utils.h"
3
4
5PIErrorBox::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
13PIErrorBox::~PIErrorBox()
14{
15}
16
17void
18PIErrorBox::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
40void
41PIErrorBox::Cycle()
42{
43 state = (state + 1) % 2;
44}
45
46
47
48
49PIErrorDisplay::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
61PIErrorDisplay::~PIErrorDisplay()
62{
63 delete updButton;
64 delete ackButton;
65 delete errorBox;
66}
67
68void
69PIErrorDisplay::Process(PIMessage msg, PIMsgHandler *sender, void *data)
70{
71msg = 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
88void
89PIErrorDisplay::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
Note: See TracBrowser for help on using the repository browser.