Repository navigation
Expand file tree
/
Copy pathappBrammi.cpp
More file actions
122 lines (113 loc) · 5.34 KB
/
Copy pathappBrammi.cpp
File metadata and controls
122 lines (113 loc) · 5.34 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// BrammiDev.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <memory>
#include <type_traits>
#include "devBrammi.hpp"
int main()
{
std::cout << "main test";
auto brammiDev = std::make_unique<Brammi::Driver>();
Brammi::stData_t brmData;
std::is_trivially_copyable<Brammi::stData_t> value;
if (value == true) {
std::cout << "stData_t is copyable\n";
}
std::is_trivially_copyable<std::string> value2;
if (value2 == true) {
std::cout << "string is copyable\n";
}
if (brammiDev->start(Brammi::enConnectionType_t::UART, 6)) {
size_t timeout = 10000;
int readCounter = 0;
char text[20];
brammiDev->stop();
brammiDev->start(Brammi::enConnectionType_t::UART, 6);
brammiDev->stop();
brammiDev->start(Brammi::enConnectionType_t::UART, 6);
brammiDev->stop();
brammiDev->start(Brammi::enConnectionType_t::UART, 6);
brammiDev->stop();
while (timeout--) {
Brammi::enStatus_t retval = (Brammi::enStatus_t)brammiDev->getBrammiData(brmData);
if ( retval == Brammi::enStatus_t::SUCCESS) {
std::cout << "*** ";
if (brammiDev->getDeviceName(text, sizeof(text)) == 0)
std::cout << "DevName: " << text << " ";
if (brammiDev->getMotherName(text, sizeof(text)) == 0)
std::cout << "Mother: " << text;
brammiDev->getMotherName(nullptr, sizeof(text));
std::cout << " Cnt: " << readCounter++ << " ***\n\n";
printf("- Info - ID: %i, Mode: %c, TimeSet: %imin, TimeRun: %imin\n",
brmData.patientID, brmData.mode, brmData.therapySetTime, brmData.therapyRuntime);
printf("- Temperatures - Set: %2.1f*C, Rectal: %2.1f*C, Matress: %2.1f*C, Skin: %2.1f*C\n",
brmData.setTemp, brmData.rectalTemp, brmData.mattressTemp, brmData.skinTemp);
printf("- Other - WaterFlow: %i, WaterLevel: %i, PowerLevel: %i\n",
brmData.waterFlow, brmData.waterLevel, brmData.pletierPowerLevel);
printf("- Alarms - 1: 0x%x, 2: 0x%x, 3: 0x%x, 4: 0x%x\n\n",
brmData.alarm1.value, brmData.alarm2.value, brmData.alarm3.value, brmData.alarm4.value);
std::cout << "*** End of data " << sizeof(brmData) << " ***\n\n";
}
else {
switch (retval)
{
case Brammi::enStatus_t::INVALID_PARAMETER:
std::cout << "Invalid parameters\n";
break;
case Brammi::enStatus_t::NOT_CONECTED:
std::cout << "Brammi device not started\n";
break;
case Brammi::enStatus_t::CONNECTION_LOST:
std::cout << "Brammi device conection lost\n";
break;
case Brammi::enStatus_t::TIMEOUT:
std::cout << "Brammi device timeout\n";
break;
case Brammi::enStatus_t::CONECTING:
std::cout << "Brammi connecting...\n";
break;
case Brammi::enStatus_t::SUCCESS:
std::cout << "Brammi no errors\n";
break;
default:
std::cout << "Brami unknow error\n";
break;
}
}
if (retval == Brammi::enStatus_t::CONNECTION_LOST) break;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
brammiDev->stop();
}
// if (d_brm.start(Brammi::enDeviceType_t::BRAMMI_UART, 5)) {
// std::this_thread::sleep_for(std::chrono::seconds(1));
// d_brm.stop();
// }
// if (d_brm.start(Brammi::enDeviceType_t::BRAMMI_UART, 5)) {
// std::cout << "Brammi open succes\n";
// std::this_thread::sleep_for(std::chrono::seconds(1));
// //std::this_thread::sleep_for(std::chrono::seconds(30));
// d_brm.stop();
// } else std::cout << "Brammi open failed\n";
// std::unique_ptr<Brammi::Driver_Brammi> drv;
// for (int i = 0; i < 10; i++) {
// drv = std::make_unique<Brammi::Driver_Brammi>();
// if (drv->start(Brammi::enDeviceType_t::BRAMMI_UART, 5)) {
// std::cout << "Brammi open succes " << i << "\n";
// } else std::cout << "Brammi open failed " << i << "\n";
// drv->stop();
// drv.reset();
// }
// if (drv == nullptr) {
// drv = std::make_unique<Brammi::Driver_Brammi>();
// }
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file