-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpump.cpp
More file actions
69 lines (58 loc) · 1.46 KB
/
pump.cpp
File metadata and controls
69 lines (58 loc) · 1.46 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
/**
* @file pump.cpp
* @author Connor, Ben
* @brief File representing a pump object to pour drinks.
* @version 0.1
* @date 2018-11-28
*
* @copyright Copyright (c) 2018
*
*/
#include "pump.h"
using namespace std;
/**
* @brief Construct a new pump object.
*
* @param ID is the unique identifier for the pump.
*/
pump::pump(int ID /**< [in] id of the current pump. */) {
pumpID = ID;
}
/**
* @brief Runs pump pumpID for amount time.
*
* @param pumpID Pump ID to run.
* @param amount Amount of time to run the pump for.
*/
void pump::runPump(int pumpID /**< [in] ID of the pump to run. */, float amount/**< [in] Amount of time for the pump to run.*/) {
// Temporary print statement until we figure out actual peripheral commands
cout << "This is pump: " << pumpID << " running for: " << amount << " mili seconds." << endl;
string pump = to_string(pumpID);
GPIOpin pin(pump);
//exporting the pin(setting it up)
if(pin.setdir_gpio("out") == 0){
cout << "direction set" << endl;
if(pin.setval_gpio("1") == 0){
cout << "pin on" << endl;
sleep(amount);
if(pin.setval_gpio("0") == 0){
cout << "pin off" << endl;
}
}
}
/*
wiringPiSetup();
pinMode(pumpID, OUTPUT);
digitalWrite(pumpID, HIGH);
sleep(10);
digitalWrite(pumpID, LOW);
*/
}
/**
* @brief Returns the ID of the current pump.
*
* @return int Returns the ID of the current
*/
int pump::getPumpID() {
return pumpID;
}