(Luận văn thạc sĩ) thiết kế thiết bị giám sát cảm biến từ xa qua smartphone

155 10 0
(Luận văn thạc sĩ) thiết kế thiết bị giám sát cảm biến từ xa qua smartphone

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

BỘ GIÁO DỤC VÀ ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP.HCM KHOA ĐIỆN - ĐIỆN TỬ ĐỒ ÁN TỐT NGHIỆP NGÀNH CÔNG NGHỆ KỸ THUẬT ĐIỆN TỬ - TRUYỀN THÔNG THIẾT KẾ THIẾT BỊ GIÁM SÁT CẢM BIẾN TỪ XA QUA SMARTPHONE GVHD: ThS NGUYỄN VĂN HIỆP SVTH: NGUYỄN GIA BẢO MSSV: 12141013 SVTH: HÀ THANH ĐẠT MSSV: 12141045 SKL004356 Tp Hồ Chí Minh, tháng 07/2016 BỘ GIÁO DỤC & ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH KHOA ĐIỆN - ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ - CÔNG NGHIỆP - ĐỒ ÁN TỐT NGHIỆP NGÀNH KỸ THUẬT ĐIỆN TỬ TRUYỀN THÔNG ĐỀ TÀI: THIẾT KẾ THIẾT BỊ GIÁM SÁT CẢM BIẾN TỪ XA QUA SMARTPHONE (3G, WIFI) GVHD: ThS Nguyễn Văn Hiệp SVTH: Nguyễn Gia Bảo 12141013 Hà Thanh Đạt 12141045 Tp Hồ Chí Minh - 07/2016 BỘ GIÁO DỤC & ĐÀO TẠO TRƯỜNG ĐẠI HỌC SƯ PHẠM KỸ THUẬT TP HỒ CHÍ MINH KHOA ĐIỆN - ĐIỆN TỬ BỘ MÔN ĐIỆN TỬ - CÔNG NGHIỆP - ĐỒ ÁN TỐT NGHIỆP NGÀNH KỸ THUẬT ĐIỆN TỬ TRUYỀN THÔNG ĐỀ TÀI: THIẾT KẾ THIẾT BỊ GIÁM SÁT CẢM BIẾN TỪ XA QUA SMARTPHONE (3G, WIFI) GVHD: ThS Nguyễn Văn Hiệp SVTH: Nguyễn Gia Bảo 12141013 Hà Thanh Đạt 12141045 Tp Hồ Chí Minh - 07/2016 i TRƯỜNG ĐH SƯ PHẠM KỸ THUẬT TP.HỒ CHÍ MINH CỘNG HỊA XÃ HỘI CHỦ NGHĨA VIỆT NAM Độc lập - Tự - Hạnh phúc KHOA ĐIỆN - ĐIỆN TỬ Tp HCM, ngày tháng năm 2016 NHIỆM VỤ ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên: Nguyễn Gia Bảo Hà Thanh Đạt MSSV: 12141013 MSSV: 12141045 Chuyên ngành: CNKT Điện Tử - Truyền Thông Mã ngành: 141 Hệ đào tạo: Đại học quy Mã hệ: Khóa: 2012 Lớp: 12141DT2B I TÊN ĐỀ TÀI: Thiết kế thiết bị giám sát cảm biến từ xa qua Smartphone (3G, WIFI) II NHIỆM VỤ Các số liệu ban đầu: Tài liệu liên quan đến đề tài datasheet, trang web module liên quan, phần mềm lập trình Nội dung thực hiện:          Nghiên cứu kit Arduino, Module SIM800L, Module wifi ESP8266 Lập trình cho Arduino Module SIM800L cho mơi trường 3G Lập trình cho Arduino Module ESP8266 cho mơi trường wifi Lập trình ứng dụng Android Thiết kế phần cứng Thi công cân chỉnh mạch Chạy thử nghiệm thiết bị Viết báo cáo Hoàn thiện sản phẩm III NGÀY GIAO NHIỆM VỤ: 01/03/2016 IV NGÀY HOÀN THÀNH NHIỆM VỤ: 07/07/2016 V HỌ VÀ TÊN CÁN BỘ HƯỚNG DẪN: CÁN BỘ HƯỚNG DẪN GV.THS NGUYỄN VĂN HIỆP ThS NGUYỄN VĂN HIỆP BM ĐIỆN TỬ CÔNG NGHIỆP GV.TS NGUYỄN THANH HẢI ii TRƯỜNG ĐH SƯ PHẠM KỸ THUẬT TP.HỒ CHÍ MINH CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM Độc Lập-Tự Do-Hạnh Phúc KHOA ĐIỆN-ĐIỆN TỬ Tp HCM, ngày tháng năm 2016 LỊCH TRÌNH THỰC HIỆN ĐỒ ÁN TỐT NGHIỆP Họ tên sinh viên 1: Ngyễn Gia Bảo Lớp: 12141DT2B Họ tên sinh viên 2: Hà Thanh Đạt Lớp: 12141DT2B MSSV: 12141013 MSSV: 12141045 Tên đề tài: Thiết kế thiết bị giám sát cảm biến từ xa qua Smartphone (3G, WIFI) Tuần Tuần Tuần Tuần Tuần 4+5 Tuần 6+7 Tuần Tuần 9+10 Tuần 11+12 ThS Nguyễn Văn Hiệp iii LỜI CAM ĐOAN Đề tài tự thực dựa vào số tài liệu trước khơng chép từ tài liệu hay cơng trình có trước Nhóm thực đề tài Nguyễn Gia Bảo - Hà Thanh Đạt iv LỜI CẢM ƠN  Sau thời gian nghiên cứu làm việc nghiêm túc, đến đồ án tốt nghiệp với đề tài: “Thiết kế thiết bị giám sát cảm biến từ xa qua Smartphone (3G, WIFI)” hoàn thành đạt kết theo mục tiêu đề Trong q trình thực hiện, nhóm thực đề tài gặp khơng khó khăn, vướng mắc thơng qua học hỏi thêm nhiều kinh nghiệm bổ ích tìm hướng giải vấn đề tốt Nhờ giúp đỡ tận tình quý Thầy Cô bạn tạo điều kiện để nhóm thực đồ án cách tốt Nhóm thực đề tài xin gửi lời cảm ơn chân thành đến thầy Nguyễn Văn Hiệp tận tình giúp đỡ, gợi ý hướng giải khắc phục vướng mắc, cố trình nghiên cứu Bên cạnh đó, nhóm thực xin gửi lời cảm ơn đến thầy TS Nguyễn Thanh Hải, Trưởng Bộ môn Điện tử công nghiệp, quý thầy/cô khoa Điện – Điện tử trường Đại học Sư Phạm Kỹ Thuật TP.HCM bạn bè giúp đỡ, chia sẻ kinh nghiệm để nhóm hồn thành đề tài tiến độ Cảm ơn đến cha mẹ, gia đình động viên tạo điều kiện để hoàn thành đề tài Do kinh nghiệm hạn chế thời gian nghiên cứu có hạn nên nhóm thực đề tài khơng tránh khỏi thiếu sót, mong q thầy cơ, bạn thơng cảm đóng góp ý kiến để đề tài ngày hoàn thiện Xin chân thành cảm ơn! Nhóm thực đề tài Nguyễn Gia Bảo – Hà Thanh Đạt v MỤC LỤC NỘI DUNG Trang bìa Nhiệm vụ đồ án Lịch trình Phiếu đánh giá Cam đoan Lời cảm ơn Mục lục Liệt kê hình vẽ Liệt kê bảng Tóm tắt Chương TỔNG QUAN 1.1 1.2 MỤC TIÊU 1.3 NỘI DUNG NGHIÊN CỨU 1.4 1.5 BỐ CỤC Chương CƠ SỞ LÝ THUYẾT 2.1 2.1.1 2.1.2 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.5.1 2.5.2 2.5.3 vi 2.5.4 2.6 Chương TÍNH TỐN VÀ THIẾT KẾ 3.1 3.1.1 3.1.2 3.2 3.2.1 3.2.1 Chương THI CÔNG HỆ THỐNG 4.1 4.1.1 Thi công thiết bị 4.1.2 4.1.3 4.2 defined THI CÔNG ỨNG DỤNG TRÊN ĐIỆN 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.3 GIỚI THIỆU PHẦN M 4.3.1 4.3.2 Bookmark not defined Phần mềm lập trình ứng 4.4 4.4.1 4.4.2 4.5 Bookmark not defined TÀI LIỆU HƯỚNG DẪN SỬ DỤNG 4.5.1 4.5.2 Chương KẾT QUẢ - NHẬN XÉT - ĐÁNH GIÁError! Bookmark not defined 5.1 CẢM BIẾN 5.2 BỘ VI ĐIỀU KHIỂN vii 5.3 MODULE KẾT NỐI MẠNG 5.4 PHẦN MỀM LẬP TRÌNH 5.5 PHẦN MỀM VẼ MẠCH 5.6 NHẬN XÉT - ĐÁNH GIÁ Chương KẾT LUẬN - HƯỚNG PHÁT TRIỂNError! Bookmark not defined 6.1 KẾT LUẬN 6.2 HƯỚNG PHÁT TRIỂN TÀI LIỆU THAM KHẢO PHU LỤC viii PHỤ LỤC icon_device1.setImageResource(R.drawable.device2); icon_device2.setImageResource(R.drawable.device1);} if (values[0].equals("22")){if (status_resum){switch1.setChecked(true); switch2.setChecked(true);} icon_device1.setImageResource(R.drawable.device2); icon_device2.setImageResource(R.drawable.device2);} } } } protected void onPause() { super.onPause(); Log.d("TAG", "onPause Activity_sensor"); if(!mLoadThingSpeak.isCancelled()) { mLoadThingSpeak.cancel(true); } } @Override protected void onResume() { super.onResume();Log.d("TAG", "onResume Activity_sensor"); mLoadThingSpeak= new LoadThingSpeak(); mLoadThingSpeak.execute(); status_resum=true; } public void ToastMessage(String message, int x, int y) { LayoutInflater inflater = getLayoutInflater(); View layout = inflater.inflate(R.layout.toast_layout, (ViewGroup) findViewById(R.id.toast_layout_root)); TextView text = (TextView) layout.findViewById(R.id.text); text.setTextSize(17); text.setText(message); Toast toast = new Toast(getApplicationContext()); toast.setGravity(Gravity.CENTER_VERTICAL, x, y); toast.setDuration(Toast.LENGTH_LONG); toast.setView(layout); toast.show(); } } Setting_Activity.java://class thiết lập ngưỡng vẽ biểu đồ package com.example.ngb.iotsensor; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; PHỤ LỤC import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; public class Setting_Activity extends AppCompatActivity { EditText Hthap, Hondinh, Hcao, Tthap, Tondinh,Tcao; Button btnOk; Intent myintent; public static final String MY_PREFS_NAME = "MyPrefsFile"; int VTthap=0, VTondinh=0, VTcao=0, VTvuot=0,VHthap=0, VHondinh=0, VHcao=0, VHvuot=0; @Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); super.onCreate(savedInstanceState); setContentView(R.layout.activity_setting); myintent=new Intent(Setting_Activity.this, ListViewMultiChartActivity.class); Hthap=(EditText)findViewById(R.id.editText_thap); Hondinh=(EditText)findViewById(R.id.editText_ondinh); Hcao=(EditText)findViewById(R.id.editText_cao); Tthap=(EditText)findViewById(R.id.editTextthap); Tondinh=(EditText)findViewById(R.id.editTextondinh); Tcao=(EditText)findViewById(R.id.editTextcao); btnOk=(Button)this.findViewById(R.id.buttonok); recieveData(); btnOk.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if ((!Hthap.getText().toString().equals("")) && (!Hondinh.getText().toString().equals("")) && (!Hcao.getText().toString().equals("")) && (!Tthap.getText().toString().equals("")) && (!Tondinh.getText().toString().equals("")) && (!Tcao.getText().toString().equals(""))) { VTthap = Integer.parseInt(Tthap.getText().toString()); VTondinh = Integer.parseInt(Tondinh.getText().toString()); VTcao = Integer.parseInt(Tcao.getText().toString()); VHthap = Integer.parseInt(Hthap.getText().toString()); VHondinh = Integer.parseInt(Hondinh.getText().toString()); VHcao = Integer.parseInt(Hcao.getText().toString()); saveData(); Bundle bundle = new Bundle(); bundle.putInt("Tthap", VTthap); bundle.putInt("Tondinh", VTondinh); bundle.putInt("Tcao", VTcao); bundle.putInt("Hthap", VHthap); PHỤ LỤC bundle.putInt("Hondinh", VHondinh); bundle.putInt("Hcao", VHcao); myintent.putExtra("MyPackage", bundle); startActivity(myintent); finish(); } else { Toast.makeText(Setting_Activity.this, "nhập đủ số liệu vào", Toast.LENGTH_LONG).show(); } } }); } public void saveData() { SharedPreferences pref = getApplicationContext().getSharedPreferences(MY_PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putString("tthap", ""+VTthap); editor.putString("tondinh", "" + VTondinh); editor.putString("tcao", "" + VTcao); editor.putString("hthap", "" + VHthap); editor.putString("hondinh", "" + VHondinh); editor.putString("hcao", "" + VHcao); editor.apply(); } public void recieveData() { SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, Context.MODE_PRIVATE); VTthap = Integer.parseInt(prefs.getString("tthap", "30")); VTondinh = Integer.parseInt(prefs.getString("tondinh", "60")); VTcao = Integer.parseInt(prefs.getString("tcao", "100")); VHthap = Integer.parseInt(prefs.getString("hthap", "20")); VHondinh = Integer.parseInt(prefs.getString("hondinh", "40")); VHcao = Integer.parseInt(prefs.getString("hcao", "60")); Tthap.setText(""+VTthap); Tondinh.setText(""+VTondinh); Tcao.setText(""+VTcao); Hthap.setText(""+VHthap); Hondinh.setText(""+VHondinh); Hcao.setText(""+VHcao); } } DowmloadWebpageTask.java://class truy cập mạng để tải xuống liệu package com.example.ngb.iotsensor; PHỤ LỤC import android.os.AsyncTask; import android.util.Log; import org.json.JSONException; import org.json.JSONObject; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class DownloadWebpageTask extends AsyncTask { AsyncResult callback; public DownloadWebpageTask(AsyncResult callback) { this.callback = callback; } @Override protected String doInBackground(String urls) { / params comes from the execute() call: params[0] is the url try { return downloadUrl("https://spreadsheets.google.com/tq?key=1TEIopdrPAXIbelUVB20a4e Ra0SNyyjyvQOvHFzjGMV4"); } catch (IOException e) { e.printStackTrace(); } return null; } / onPostExecute displays the results of the AsyncTask @Override protected void onPostExecute(String result) { / remove the unnecessary parts from the response and construct a JSON Log.d("esp",result); int start = -1; int end = -1; start = result.indexOf("{", result.indexOf("{") + 1); end = result.lastIndexOf("}"); if ((start !=-1)&&(end != -1)) { String jsonResponse = result.substring(start, end); try { JSONObject table = new JSONObject(jsonResponse); callback.onResult(table); } catch (JSONException e) { PHỤ LỤC e.printStackTrace(); } } } private String downloadUrl(String urlString) throws IOException { InputStream is = null; String contentAsString=null; try { { URL url = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setReadTimeout(5000 /* milliseconds */); conn.setConnectTimeout(5000 /* milliseconds*/); conn.setRequestMethod("GET"); conn.setDoInput(true); / Starts the query conn.connect(); int responseCode = conn.getResponseCode(); is = conn.getInputStream(); contentAsString = convertStreamToString(is); Log.d("esp_", contentAsString); }while (contentAsString.contains("HTTP/1.1 302 Moved Temporarily")); return contentAsString; } finally { if (is != null) { is.close(); contentAsString=null; } } } private String convertStreamToString(InputStream is) { BufferedReader reader = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } } catch (IOException e) { e.printStackTrace(); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(); } PHỤ LỤC } return sb.toString(); } } DemoBase.java://class vẽ biểu đồ đường package com.example.ngb.iotsensor; import android.support.v4.app.FragmentActivity; //import com.xxmassdeveloper.mpchartexample.R; /** * Baseclass of all Activities of the Demo Application * * @author Philipp Jahoda */ public abstract class DemoBase extends FragmentActivity { protected String[] mMonths = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" }; protected String[] mParties = new String[] { "Party A", "Party B", "Party C", "Party D", "Party E", "Party F", "Party G", "Party H", "Party I", "Party J", "Party K", "Party L", "Party M", "Party N", "Party O", "Party P", "Party Q", "Party R", "Party S", "Party T", "Party U", "Party V", "Party W", "Party X", "Party Y", "Party Z" }; @Override public void onBackPressed() { super.onBackPressed(); overridePendingTransition(R.anim.move_left_in_activity, R.anim.move_right_out_activity); } } TeamAdapter.java://class truy gán id cho đối tượng package com.example.ngb.iotsensor; import android.content.Context; import android.view.LayoutInflater; PHỤ LỤC import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; import java.util.ArrayList; public class TeamsAdapter extends ArrayAdapter { Context context; private ArrayList teams; public TeamsAdapter(Sheet_Activity context, int textViewResourceId, ArrayList items) { super(context, textViewResourceId, items); this.context = context; this.teams = items; } @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.team, null); } Team o = teams.get(position); if (o != null) { /*TextView pos = (TextView) v.findViewById(R.id.position); TextView name = (TextView) v.findViewById(R.id.name); TextView wins = (TextView) v.findViewById(R.id.wins); TextView draws = (TextView) v.findViewById(R.id.draws); TextView losses = (TextView) v.findViewById(R.id.losses); TextView points = (TextView) v.findViewById(R.id.points); pos.setText(String.valueOf(o.getPosition())); name.setText(String.valueOf(o.getName())); wins.setText(String.valueOf(o.getWins())); draws.setText(String.valueOf(o.getDraws())); losses.setText(String.valueOf(o.getLosses())); points.setText(String.valueOf(o.getPoints()));*/ TextView txt_Time = (TextView) v.findViewById(R.id.textView_time); TextView txt_cb1 = (TextView) v.findViewById(R.id.textView_cb1); TextView txt_cb2 = (TextView) v.findViewById(R.id.textView_cb2); txt_Time.setText(String.valueOf(o.getTime())); txt_cb1.setText(String.valueOf(o.getCb1())); txt_cb2.setText(String.valueOf(o.getCb2())); } PHỤ LỤC return v; } } ChartItem.java: //class truy gán lại biểu đồ package com.example.ngb.iotsensor; import android.content.Context; import android.view.View; import com.github.mikephil.charting.data.ChartData; /** * baseclass of the chart-listview items * @author philipp * */ public abstract class ChartItem { protected static final int TYPE_BARCHART = 0; protected static final int TYPE_LINECHART = 1; protected static final int TYPE_PIECHART = 2; protected ChartData mChartData; public ChartItem(ChartData cd) { this.mChartData = cd; } public abstract int getItemType(); public abstract View getView(int position, View convertView, Context c); } ListViewMultiChartActivity.java://class vẽ loại biểu đồ package com.example.ngb.iotsensor; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ArrayAdapter; PHỤ LỤC import android.widget.ListView; import com.github.mikephil.charting.data.Entry; import com.github.mikephil.charting.data.LineData; import com.github.mikephil.charting.data.LineDataSet; import com.github.mikephil.charting.data.PieData; import com.github.mikephil.charting.data.PieDataSet; import com.github.mikephil.charting.interfaces.datasets.ILineDataSet; import com.github.mikephil.charting.utils.ColorTemplate; import java.util.ArrayList; import java.util.List; //import com.xxmassdeveloper.mpchartexample.listviewitems.BarChartItem; //import com.xxmassdeveloper.mpchartexample.listviewitems.ChartItem; //import com.xxmassdeveloper.mpchartexample.listviewitems.LineChartItem; //import com.xxmassdeveloper.mpchartexample.notimportant.DemoBase; public class ListViewMultiChartActivity extends DemoBase { DatabaseHandler db; String id,pw; ListView lv; @Override protected void onCreate(Bundle savedInstanceState) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_listview_chart); //mDBSensor=new DBSensor(this); db= new DatabaseHandler(this); lv = (ListView) findViewById(R.id.listView1); Intent callerIntent=getIntent(); Bundle packageFromCaller= callerIntent.getBundleExtra("MyPackage"); int Tthap=packageFromCaller.getInt("Tthap"); int Tondinh=packageFromCaller.getInt("Tondinh"); int Tcao=packageFromCaller.getInt("Tcao"); int Hthap=packageFromCaller.getInt("Hthap"); int Hondinh=packageFromCaller.getInt("Hondinh"); int Hcao=packageFromCaller.getInt("Hcao"); ArrayList list = new ArrayList(); list.add(new LineChartItem(generateDataLineBeatTem(), getApplicationContext())); list.add(new PieChartItem(generateDataPieTemperature(Tthap,Tondinh,Tcao), getApplicationContext())); PHỤ LỤC list.add(new PieChartItem(generateDataPieHumidity(Hthap,Hondinh,Hcao), getApplicationContext())); ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list); lv.setAdapter(cda); } @Override protected void onResume(){ super.onResume(); //Display(); } /* public void Display(){ ArrayList list = new ArrayList(); list.add(new LineChartItem(generateDataLineBeatTem(), getApplicationContext())); list.add(new PieChartItem(generateDataPieTemperature(), getApplicationContext())); list.add(new PieChartItem(generateDataPieHumidity(), getApplicationContext())); ChartDataAdapter cda = new ChartDataAdapter(getApplicationContext(), list); lv.setAdapter(cda); }*/ /** adapter that supports different item types */ private class ChartDataAdapter extends ArrayAdapter { public ChartDataAdapter(Context context, List objects) { super(context, 0, objects); } @Override public View getView(int position, View convertView, ViewGroup parent) { return getItem(position).getView(position, convertView, getContext()); } @Override public int getItemViewType(int position) { // return the views type return getItem(position).getItemType(); } @Override public int getViewTypeCount() { return 3; // we have different item-types } } PHỤ LỤC private LineData generateDataLineBeatTem() { ArrayList mYValue1 = new ArrayList(); ArrayList mYValue2 = new ArrayList(); ArrayList mXLable=new ArrayList(); List data = db.getAllSensorData(); int dem=0; for (SensorTable cn : data) { mYValue1.add(new Entry(cn.getCb1(),dem)); mYValue2.add(new Entry(cn.getCb2(),dem)); mXLable.add(cn.getTime()); dem++; } LineDataSet d1 = new LineDataSet(mYValue1, "CB1 "); d1.setLineWidth(2.5f); d1.setCircleRadius(3.5f); d1.setHighLightColor(Color.rgb(244, 117, 117)); d1.setDrawValues(true); LineDataSet d2 = new LineDataSet(mYValue2, "CB2 "); d2.setLineWidth(2.5f); d2.setCircleRadius(3.5f); d2.setHighLightColor(Color.rgb(244, 117, 117)); d2.setColor(ColorTemplate.VORDIPLOM_COLORS[0]); d2.setCircleColor(ColorTemplate.VORDIPLOM_COLORS[0]); d2.setDrawValues(true); ArrayList sets = new ArrayList(); sets.add(d1); sets.add(d2); return new LineData(mXLable, sets); } private PieData generateDataPieTemperature(int value1, int value2, int value3) { ArrayList entries = new ArrayList(); List data = db.getAllSensorData(); int count = (int) db.getProfilesCount(); int dem=0; float data1, data2, data3, data4; int Cdata1=0, Cdata2=0, Cdata3=0, Cdata4=0; for(SensorTable cn: data) { if (cn.getCb1()

Ngày đăng: 30/12/2021, 16:38

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan