Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
IOT Device Codev1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022_162-water quality and usage monitoring system
IOT Device Codev1
Commits
5ca8e772
Commit
5ca8e772
authored
Oct 09, 2022
by
Amarasiri Munasinghelage Janith Lakshan Rachintha Darmarathne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Data Bufferingv1
parent
c845551b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
Data buffering.txt
Data buffering.txt
+50
-0
No files found.
Data buffering.txt
View file @
5ca8e772
//buffering arrays to store data from sensors
ArrayList<Double> phArray = new ArrayList<Double>();
ArrayList<Double> tdsArray = new ArrayList<Double>();
ArrayList<Double> distanceArray = new ArrayList<Double>();
ArrayList<Double> turbidityArray = new ArrayList<Double>();
switch(value){
case "tds":
// imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
double tdsVal = Double.parseDouble(arrOfStr[1]);
tdsArray.add(tdsVal);
textViewInfo.setText("TDS : " + arrOfStr[1]);
break;
case "distance":
// imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
double disVal = Double.parseDouble(arrOfStr[1]);
distanceArray.add(disVal); //add to distance buffer
textViewInfo.setText("Distance : " + arrOfStr[1]);
break;
case "ph":
// imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
double phVal = Double.parseDouble(arrOfStr[1]);
phArray.add(phVal);
textViewInfo.setText("PH : " + arrOfStr[1]);
break;
case "turbidity":
// imageView.setBackgroundColor(getResources().getColor(R.color.colorOff));
double turbVal = Double.parseDouble(arrOfStr[1]);
turbidityArray.add(turbVal);
textViewInfo.setText("Turbidity : " + arrOfStr[1]);
break;
}
private Double getAvg(ArrayList<Double> valArray) {//calculate average value from buffers
double avg=0;
double total = 0;
for(int i = 0; i < valArray.size(); i++){
total += valArray.get(i);
}
avg = total/(valArray.size());
return avg;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment