1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
-
- #include <iostream>
- #include <unistd.h>
- #include <signal.h>
- #include "waterlevel.h"
-
- using namespace std;
-
- int shouldRun = true;
-
- void sig_handler(int signo)
- {
- if (signo == SIGINT)
- shouldRun = false;
- }
-
- int main(int argc, char **argv)
- {
- signal(SIGINT, sig_handler);
-
-
-
-
- upm::WaterLevel* waterlevel = new upm::WaterLevel(2);
-
- while (shouldRun)
- {
- if (waterlevel->isSubmerged())
- cout << "Sensor is submerged in liquid" << endl;
- else
- cout << "Liquid is below water level sensor" << endl;
- sleep(1);
- }
-
-
- cout << "Exiting" << endl;
-
- delete waterlevel;
- return 0;
- }
|