source: trunk/FACT++/src/HeadersPower.cc@ 14568

Last change on this file since 14568 was 14526, checked in by tbretz, 12 years ago
Added missing ;
File size: 2.0 KB
Line 
1#include "HeadersPower.h"
2
3#include <string>
4#include <iomanip>
5#include <iostream>
6
7#include <QString>
8#include <QtXml/QDomNamedNodeMap>
9
10#include "WindowLog.h"
11
12using namespace std;
13using namespace Power;
14
15bool Status::Set(bool &rc, const QString &value)
16{
17 rc = value.toInt();
18 return true;
19}
20
21bool Status::Set(const QDomNamedNodeMap &map)
22{
23 if (!map.contains("id") || !map.contains("title"))
24 return false;
25
26 QString item = map.namedItem("id").nodeValue();
27 QString value = map.namedItem("title").nodeValue();
28
29 if (item==(QString("flow_meter")))
30 return Set(fWaterFlowOk, value);
31
32 if (item==(QString("level")))
33 return Set(fWaterLevelOk, value);
34
35 if (item==(QString("bias_power")))
36 return Set(fPwrBiasOn, value);
37
38 if (item==(QString("power_24v")))
39 return Set(fPwr24VOn, value);
40
41 if (item==(QString("pump")))
42 return Set(fPwrPumpOn, value);
43
44 if (item==(QString("drive_power")))
45 return Set(fPwrDriveOn, value);
46
47 if (item==(QString("drive_on")))
48 return Set(fDriveMainSwitchOn, value);
49
50 if (item==(QString("drive_enable")))
51 return Set(fDriveFeedbackOn, value);
52
53 return false;
54}
55
56void Status::Print(ostream &out, const char *title, const bool &val, const char *t, const char *f)
57{
58 out << setw(9) << title << " : ";
59 if (val)
60 out << kGreen << t << kReset << '\n';
61 else
62 out << kRed << f << kReset << '\n';
63}
64
65void Status::Print(ostream &out)
66{
67 out << kReset << '\n';
68 out << "------- WATER -------\n";
69 Print(out, "level", fWaterLevelOk, "ok", "low");
70 Print(out, "flow", fWaterFlowOk, "ok", "low");
71 out << "------- POWER -------\n";
72 Print(out, "24V", fPwr24VOn);
73 Print(out, "pump", fPwrPumpOn);
74 Print(out, "bias", fPwrBiasOn);
75 Print(out, "drive", fPwrDriveOn);
76 out << "------- DRIVE -------\n";
77 Print(out, "feedback", fDriveFeedbackOn, "on", "off");
78 Print(out, "main", fDriveMainSwitchOn, "on", "off");
79 out << "---------------------" << endl;
80}
Note: See TracBrowser for help on using the repository browser.