top of page

Prototype IoT Project "Intelligent Greenhouse System"---Client side software design


With the development of Internet and micro electronic technology, the concept of Internet of Tings (IoT) has raised. On the other hand, benefit from the leaps of technologies, mobile terminals and mobile Internet are also playing more important roles in people’s lives.


Last year, I played the role of software developer of Agricultural Internet of Things project at SDU, which is very exciting! During that five months, a we constructed an intelligent greenhouse system. With in our team of eight, five members focused on hardware, i.e. sensors, power system, transmission models; two worked on server side (server and database); and me, in charge of client side software design and server-client communication. In this post, I will introduce the both the big picture of IoT and my part of work in detail.


In the following parts, I am going to introduce the programming ideas, the macroscopic and microscopic view of software structure as well as some key technologies.


* *One core technology of the software is WebService model, and some parts of article is allocated to this. Varies Android widgets are also used to accomplish the aim. Since a major part of this article is talking about technological issues, it could be as well considered a learning tool of Java/Android programming.


#Big-System Structure


The whole system is composed by three sub-systems: sensors group, server & database, and client-side software. The sensors group extracts the environment information of the greenhouse e.g. temperature, humidity, luminosity, carbon dioxide intensity, and some hyper-spectrum data of the crops, and then accumulates these data and send them to the server via 3/4G model (in the test stage we sent data via internet from a local PC) ; the server will keep receiving and accepting the data from all sensors group of different greenhouses and store the data in the database. While the client-side software would enable users to check their greenhouses’ real time data or data sets from any time interval they specify and do some basic analysis---after they log into their account.

system structure



If you care for a more detailed picture of the local sensor group, here is how it works: the sensor extracts environment parameter and sends the data to microprocessor MSP430, and the data is sent for the local accumulation by wirelesss model nRF905, under the control of microprocessor; on the data accumulation side, there is also a microprocessor and a receiver model nRF905. After converging all data from diferent sensors, it will send them to the server by Internet.(or 3/4G)

*Since sensors are detecting environment and sending data at different frequencies, the data accumulation model has to sending data to server at the highest frequency of all sensors.

The image below is quite clear for this:

sensor side


convergence side



#Key words and ideas

Activity

The “activity” is a key concept in Android programming. In the concept of Objected- Oriented programming, it is a class. However, still we can understand it as a “page”. Just imagine when you are trying to login your Facebook account, the first page you see is the one that requires your username and password. In the realm of Android, this is essentially a activity, and when after you have input all the stuff and click “login”, you will be direct to any page (activity) which is a new activity. Say there are friends list/ message list, and when you click them, you will be direct to another activity and so on. When programming an android software you can actually set any attribute of an activity (page), for example, any set background, display any picture, set buttons, drop-down menu, and under what conditions the users will be direst to another activity.

To design an activity involves the design in two parts: First part I call it “flesh” which is the core of an activity, everything about the logic / algorithm / how the activity would behave is contained in this class. I refer the other part as “bone”---which is an XML file that tells the layout of the page, for example, where the retrieved data should be displayed, where the buttons should be, where the text should be, Should the menu be above or below the button, and etc. And still, we can arrange the layout in any way we want.

Note that we also need some programs or functions to support the function of an activity, and don’t need to show to users how they are working. So we don't provide the relative “bone” for them. In this design, the “interface” class is this kind of program, which plays the role of a messenger between our software and the server (database).

Now we can start introducing the more detailed structure of our software!

First, let's take a look at the data structure of this system:

As shown above, each term of data contains of five layers of information: the upper most layer info tells us the owner of the specific greenhouse; the second layer tells which greenhouse of the owner send out this term of data; the third layer narrates which sensor group of that greenhouse the data belongs to; the fourth layer tells what kind of environment data it is (from what kind of sensor), for example, temperature, humidity and etc.; the last layer is essentially in another domain: time. Because we want to enable the user to check the specific data of all the possible time, so the label of time is a must.

Each term of data has to have all of these five labels so that we could appropriately store them in the database and develop corresponding algorithms to retrieve them to the user side. For example, an valid data should has labels like: Tongda's// greenhouse#35 // sensor group#2 // hyper spectrum sensor // "2016-01-01 15:00". That tell us this slice of data belongs to the sensor at the lower right corner at suggested time.

pictures of sensors we used in the project :)

Having the data structure in mind, now let's take a step further to see how the data is stored and retrieved. A logical way to construct the database is just to build it in the same way of the data structure (tree shape) and this is what my partner did in this project. And what I need to do is to develop algorithms to get data from the database designed in this way.

As shown below, the client-side software is composed by a series of activities (pages, if it is easier to understand), they are: login page, greenhouse selection page, node (sensor group) selection page, real-time environment display page (of the specific node), searching page, historical data display pages (table/plot), hyper spectrum display page.

# Data Retrieval Algorithm &“dynamic programming”

Just like the way the data is stored in the database, the retrieval method also need the user to specify which slice(s) data they want to get. Let's see this algorithm from the perspective of activity. The first activity allows the user input their username and password and send these data to the server, verify whether these information match any items in the database and if the information pass the verification, our program will guide them to the next page--- greenhouse selection page. In the page of greenhouse selection, the user will see a series of button corresponding to each of their greenhouse, when they click one of them they will be directed to the node selection page in which they could choose which sensor group’s information of that greenhouse they want to check within the specific greenhouse they have selected in the previous page. If the user want further information of that sensor group they can check the historical data of by clicking the button and then selecting the specific date and time. He or she can they choose to observe the data in the table or plot them. In the real world implementation, we installed hyper-spectrum sensor in some greenhouse. The owner of that greenhouse could also observe and check the historical of spectrum data. And I put hyper-spectrum sensor at same level as the sensor group.

Here, a problem occurred. That almost each page’s layout can’t be static, since different owner of greenhouse may have different number of greenhouse, so there will be different number of button to be selected on the page after they login and similarly there will be different number of sensor group in different greenhouse, each sensor group would also contain different kinds of sensor. In a word, we have to specify the number of buttons and their functions in each page. And the information we need is contained database of the server. To achieved the function we need to do two things:


In the login page we send username and password to server and if verified, the server will return the information of greenhouses about this user i.e the number of the greenhouse.-->then we use this information to initialize the greenhouse selected page- then, say, we click button of greenhouse#1, we will send the username, greenhouse#1 to the server, to let it know we want the information of greenhouse#1 of this specify user. then the server will return the information of nodes of greenhosue#1, again we use this to initialize the node selection page. Is that clear? If we want to check then temperature of this node what should we send to the server? Right! Username, greenhouse#1, node X, temperature. That's how it working! You can see the communication is the key point of this software design. I used Webservice model for this purpose which I will introduce later.

Here is the classes I have written: (codes attached below)

When we are initialize an activity, we need to dynamically set its buttons. Which I called “dynamic programming”, this concept is different from dynamic programming in solving a math problem—this is the real dynamic programming. As below:

**************************************************************************

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView;

public class Greenhouse extends Activity {

private String confirmedname;

private TextView gt;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.greenhouse); gt = (TextView) findViewById(R.id.gt); Intent intent = getIntent(); confirmedname = intent.getStringExtra("name"); Greenhouseweb ghb = new Greenhouseweb(confirmedname); gt.setText("username");

Thread t2 = new Thread(ghb); t2.start(); while (ghb.tag) {

} for (int j = 0; j <= ghb.length - 1; j++) { LinearLayout greenlayout = (LinearLayout) findViewById(R.id.greenlayout); final Button t = new Button(this); t.setText(ghb.listcontent[j]); greenlayout.addView(t);

class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", t.getText().toString()); intent.setClass(Greenhouse.this, Node.class); Greenhouse.this.startActivity(intent); } }

t.setOnClickListener(new Buttonlistener()); } } }

In the above program, I open a thread to run the communication process with the server (about multithreading techniques used in this design will be introduced later). When the thread is completed its operation, I use its returned information to set button’s proprieties and the information to be passed to the server in order to enter the next page.

# Webservice Model and Multi-threading

The communication between client software and the server is the central of this software design, for which I choose Webservice model, which could also be understood as a “remote call technique”. It actually allows client side software call the function in server.As said above, before entering the next page, we need to acquire the permission and the information to initialize the page. This step is accomplished by the communication with the server----our Webservice. For each page, I wrote a Webservice class to contact the server and implement different functions in the server. Here is an example (for the login page)

**************************************************************************************

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Greenhouseweb implements Runnable { public ListView list; public int length; private SoapObject result; public String[] listcontent = new String[20]; private static final String namespace = "http://greenhouse"; private static final String methodname = "greenhouse"; private static final String URL = "http://202.194.26.192:8080/greenhouse/services/greenhouse"; public boolean tag = true; private String username = null;

Greenhouseweb(String username1) { this.username = username1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try { transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse();

} } catch (Exception e) { e.printStackTrace(); }

length = result.getPropertyCount(); if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString(); }

} tag = false; }

}

All webservie class will be running in a new thread instead of in the main thread. The main thread has to wait the webservice thread to complete its duty.

concerns about the data:

In our test stage, we set different data frequencies for different type of sensors: humidity data-every 5 minutes; lux data-every 15 minutes; carbon dioxide data-every 1minute; hyper-spectrum data-every 10 minutes; temperature data-every 10 minutes. Except for the hyper-spectrum data, all other kind of different data at a specific time point is nothing but a numerical number. So when we encapsulate the data into a piece of string, which contains the labels introduced before and the parameter data. The hyper-spectrum data, on the other hand, is little bit complex. As you might perceive, the hyper-spectrum sensor actually return the spectrum data, which is a two dimension array: the parameter at different wave-length. And this data is quite large, it looks like this:

  1. The data size is around 65KB, and this kind of data is transmitted every 10 minutes from every sensor groups that equipped with hyper-spectrum sensor. So the total data amount is very large. For real-time inquiry it is okay---the user only want the latest data, which is 65KB from the server. This can barely cause any delay of display. But what if the user want to analyze the data within a specific time range? if the time range is wide, this could be a serious problem! The data size is way to large to be gotten at an instant time. So by the time I passed my duty to my college, we were trying to develop some cache strategy: set up a lite database at user's terminal and cache some data at local database. And there are several ways to choose what to cache. Here are some typical algorithms:

  1. Least Recently Used (LRU)

  2. Discards the least recently used items first. This algorithm requires keeping track of what was used when, which is expensive if one wants to make sure the algorithm always discards the least recently used item. General implementations of this technique require keeping "age bits" for cache-lines and track the "Least Recently Used" cache-line based on age-bits. In such an implementation, every time a cache-line is used, the age of all other cache-lines changes. LRU is actually a family of caching algorithms with members including 2Q by Theodore Johnson and Dennis Shasha,[3] and LRU/K by Pat O'Neil, Betty O'Neil and Gerhard Weikum.[4]

Most Recently Used (MRU)

Discards, in contrast to LRU, the most recently used items first. In findings presented at the 11th VLDB conference, Chou and DeWitt noted that "When a file is being repeatedly scanned in a [Looping Sequential] reference pattern, MRU is the best replacement algorithm."[5] Subsequently other researchers presenting at the 22nd VLDB conference noted that for random access patterns and repeated scans over large datasets (sometimes known as cyclic access patterns) MRU cache algorithms have more hits than LRU due to their tendency to retain older data.[6] MRU algorithms are most useful in situations where the older an item is, the more likely it is to be accessed.

Pseudo-LRU (PLRU)

For CPU caches with large associativity (generally >4 ways), the implementation cost of LRU becomes prohibitive. In many CPU caches, a scheme that almost always discards one of the least recently used items is sufficient. So many CPU designers choose a PLRU algorithm which only needs one bit per cache item to work.

PLRU typically has a slightly worse miss ratio, has a slightly better latency, and uses slightly less power than LRU. Source: wikipedia

Appendix- codes:

In the following place I am going to post my codes for this software in the order of:

#0.AchartEngine plotting program for spectrum line

#1.login page/ landing interface

#2.greenhouse page/ greenhouse interface (for next step--node)

#3.node page/ node interface (for next step--real time)

#4.real time parameter/ ...interface

#5.searching page/searching page interface

#6.spectrum searching/ display/ intercace

#0. AchartEngine plotting program for spectrum line

*************************************************************************

package com.example.iot;

import org.achartengine.ChartFactory; import org.achartengine.model.XYMultipleSeriesDataset; import org.achartengine.model.XYSeries; import org.achartengine.renderer.XYMultipleSeriesRenderer; import org.achartengine.renderer.XYSeriesRenderer;

import android.app.Activity; import android.content.Intent; import android.graphics.Color; import android.graphics.Paint.Align; import android.os.Bundle;

public class SpectrumLine extends Activity {

private String confirmedname; private String greenhouse; private String node; private String time;

private String[] getpara; private String[] wavelength; private Double[] wavelengthset; private String[] ref; private Double[] refset;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.spectrumline);

Intent intent = getIntent(); confirmedname = intent.getStringExtra("username"); greenhouse = intent.getStringExtra("greenhouse"); node = intent.getStringExtra("node"); time = intent.getStringExtra("time");

SpectrumInquirybydateweb siqb = new SpectrumInquirybydateweb( confirmedname, greenhouse, node, time); System.out.println(confirmedname+greenhouse+node+time); Thread t6 = new Thread(siqb); t6.start(); while (siqb.tag) {

} if(siqb.length==0) { Intent intenterror = new Intent(); intent.setClass(SpectrumLine.this, Error.class); SpectrumLine.this.startActivity(intent); } else { //杅擂煦賃 getpara=siqb.listcontent[0].split("\\s+"); for(int x=0;x<getpara.length-1;x++) { System.out.println(getpara[x]); } //杅擂煦郪 ref = new String[getpara.length/ 2]; wavelength = new String[getpara.length/ 2];

for (int x = 0; x <= (getpara.length / 2 - 1); x++) { wavelength[x] = getpara[2 * x]; ref[x] = getpara[2 * x + 1]; } wavelengthset = new Double[wavelength.length]; refset = new Double[ref.length];

for (int x = 0; x <= ref.length - 1; x++) { refset[x] = Double.parseDouble(ref[x]); if(refset[x]>2) refset[x]=2.0; else if (refset[x]<-1) refset[x]=-1.0; }

for (int x = 0; x <= wavelength.length - 1; x++) { wavelengthset[x] = Double.parseDouble(wavelength[x]); } System.out.println(wavelengthset.length); System.out.println(refset.length);

XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer(); XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset(); renderer.setZoomButtonsVisible(false); renderer.setYAxisMin(-30); renderer.setYAxisMax(30); renderer.setYAxisMin(-1); renderer.setYAxisMax(2); renderer.setApplyBackgroundColor(true); renderer.setBackgroundColor(Color.BLACK); renderer.setShowGrid(true); renderer.setYTitle("毀扞掀/%"); renderer.setXTitle("疏酗/nm"); renderer.setLabelsColor(Color.CYAN); renderer.setAxisTitleTextSize(20); renderer.setLabelsTextSize(25); renderer.setYLabels(20); renderer.setXLabels(40); renderer.setPanEnabled(true, false); renderer.setXLabelsAngle(300); renderer.setShowLegend(true);

XYSeries spseries = new XYSeries(" ");

renderer.setXLabelsAlign(Align.RIGHT); dataset.addSeries(spseries);

for(int i=0; i<ref.length-1;i++) { spseries.add(wavelengthset[i], refset[i]); } XYSeriesRenderer xyRenderer1 = new XYSeriesRenderer(); xyRenderer1.setColor(Color.CYAN); xyRenderer1.setDisplayChartValues(false); xyRenderer1.setLineWidth(2); renderer.addSeriesRenderer(xyRenderer1);

Intent spline = ChartFactory.getLineChartIntent(this, dataset, renderer); startActivity(spline);

} }

}

#1.login page/ landing interface

**********************************************************************************

package com.example.iot;

import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView;

public class MainActivity extends Activity { private Button button11 = null; private EditText edittext11 = null; private EditText edittext12 = null; private TextView show = null; private CheckBox passwordcheckbox=null; public SharedPreferences sp; private String name; private String password; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); show = (TextView) findViewById(R.id.show); passwordcheckbox=(CheckBox)findViewById(R.id.passwordcheckbox); sp = this.getSharedPreferences("userInfo", Context.MODE_WORLD_READABLE); edittext11 = (EditText) findViewById(R.id.edittext11); edittext12 = (EditText) findViewById(R.id.edittext12); button11 = (Button) findViewById(R.id.button11); button11.setOnClickListener(new Buttonlistener());

edittext11.setText(sp.getString("USER_NAME", "")); edittext12.setText(sp.getString("PASSWORD", "")); passwordcheckbox.setChecked(true); }

class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) { name = edittext11.getText().toString(); password = edittext12.getText().toString(); Landing ld = new Landing(name, password); Thread t1 = new Thread(ld); t1.start(); while (ld.tag) {

} //show.setText(ld.result); if (ld.result.equals("true")) { Intent intent = new Intent(); intent.putExtra("name", name); intent.setClass(MainActivity.this, Greenhouse.class); MainActivity.this.startActivity(intent);

} if (ld.result.equals("false")) {

edittext12.setError("渣昫腔蚚誧靡麼躇鎢"); edittext11.requestFocus(); edittext12.requestFocus();

} if (ld.result.equals("督昢籵陓祑都")) {

edittext12.setError("督昢籵陓祑都"); edittext11.requestFocus(); edittext12.requestFocus();

} //彆腎翹傖髡寀暮蛂梛瘍躇鎢 if(passwordcheckbox.isChecked()) { Editor editor = sp.edit(); editor.putString("USER_NAME", name); editor.putString("PASSWORD",password); editor.commit(); } if(!(passwordcheckbox.isChecked())) { Editor editor = sp.edit(); editor.putString("USER_NAME", ""); editor.putString("PASSWORD",""); editor.commit(); } }

}

} *******

Interface:

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

public class Landing implements Runnable { private static final String namespace = "http://landing"; private static final String methodname = "landing"; private static final String URL = "http://202.194.26.192:8080/landing/services/landing"; public String result =null; public boolean tag = true; private String username = null; private String userpassword = null;

Landing(String username, String userpassword) { this.username = username; this.userpassword = userpassword; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username); rpc.addProperty("userID", userpassword);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try { // 覃蚚WebService transport.call(null, envelope); if (envelope.getResponse() != null) { org.ksoap2.serialization.SoapPrimitive soapPrimitive = (SoapPrimitive) envelope .getResponse(); result = soapPrimitive.toString();

} } catch (Exception e) { e.printStackTrace(); result="督昢籵陓祑都"; }

tag = false; }

}

#2.greenhouse page/ greenhouse interface (for next step--node)

page:

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView;

public class Greenhouse extends Activity {

private String confirmedname;

private TextView gt;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.greenhouse); gt = (TextView) findViewById(R.id.gt); Intent intent = getIntent(); confirmedname = intent.getStringExtra("name"); Greenhouseweb ghb = new Greenhouseweb(confirmedname); gt.setText("湮麟陓洘");

Thread t2 = new Thread(ghb); t2.start(); while (ghb.tag) {

} for (int j = 0; j <= ghb.length - 1; j++) {// 蔚鳳腔蜆蚚誧腔湮麟眕偌聽腔倛宒煦蹈狟懂ㄛ甜跤藩跺偌聽扢离偌瑩岈璃 LinearLayout greenlayout = (LinearLayout) findViewById(R.id.greenlayout); final Button t = new Button(this); t.setText(ghb.listcontent[j]); greenlayout.addView(t);

class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", t.getText().toString()); intent.setClass(Greenhouse.this, Node.class); Greenhouse.this.startActivity(intent); } }

t.setOnClickListener(new Buttonlistener()); } } }

****

interface:

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Greenhouseweb implements Runnable { public ListView list; public int length; private SoapObject result; public String[] listcontent = new String[20]; private static final String namespace = "http://greenhouse"; private static final String methodname = "greenhouse"; private static final String URL = "http://202.194.26.192:8080/greenhouse/services/greenhouse"; public boolean tag = true; private String username = null;

Greenhouseweb(String username1) { this.username = username1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try { // 覃蚚WebService transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse();

} } catch (Exception e) { e.printStackTrace(); }

length = result.getPropertyCount(); if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString(); }

} tag = false; }

}

#3.node page/ node interface (for next step--real time)

page:

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView;

public class Node extends Activity { private String confirmedname; private String greenhouse; private TextView nt;

private String[] spnodenum;

//蚚衾換菰統杅腔 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.node); nt = (TextView) findViewById(R.id.nt);

Intent intent = getIntent(); this.confirmedname = intent.getStringExtra("username"); this.greenhouse = intent.getStringExtra("greenhouse"); nt.setText(greenhouse + "腔誹萸陓洘"); // 籵誹萸腔盄最 Nodeweb nb = new Nodeweb(confirmedname, greenhouse); Thread t2 = new Thread(nb); t2.start(); // 嫖誹萸腔盄最 SpectrumNodeweb snb = new SpectrumNodeweb(confirmedname, greenhouse); Thread t3 = new Thread(snb); t3.start(); while (nb.tag) { } while (snb.tag) { } // 扢离嫖誹萸腔偌聽眕摯綴哿魂雄 spnodenum=new String[snb.length]; for (int j = 0; j <= snb.length - 1; j++) { LinearLayout nodelayout = (LinearLayout) findViewById(R.id.nodelayout); final Button y = new Button(this); y.setText("覜眭誹萸"+snb.listcontent[j]+"瘍"); nodelayout.addView(y); spnodenum[j]=snb.listcontent[j]; final String df=spnodenum[j]; class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node",df); intent.setClass(Node.this, SpectrumInquiry.class); Node.this.startActivity(intent); } } y.setOnClickListener(new Buttonlistener());

}

// 扢离籵誹萸腔偌聽眕摯綴哿魂雄 for (int j = 0; j <= nb.length - 1; j++) { LinearLayout nodelayout = (LinearLayout) findViewById(R.id.nodelayout); final Button y = new Button(this); y.setText("誹萸"+nb.listcontent[j]+"瘍"); nodelayout.addView(y); final String nodenum=nb.listcontent[j];

class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) { Intent intent = new Intent(); intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", nodenum); System.out.println(nodenum); intent.setClass(Node.this, Deviceparameter.class); Node.this.startActivity(intent); } } y.setOnClickListener(new Buttonlistener());

}

}

}

*****

interface:

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Nodeweb implements Runnable { public ListView list; public int length; public SoapObject result; public String[] listcontent = new String[20]; private static final String namespace = "http://node"; private static final String methodname = "node"; private static final String URL = "http://202.194.26.192:8080/node/services/node"; public boolean tag = true; private String username = null; private String greenhouse = null;

Nodeweb(String username1, String greenhouse1) { this.username = username1; this.greenhouse = greenhouse1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username); rpc.addProperty("greenHouse", greenhouse);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try {

transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse();

} } catch (Exception e) { e.printStackTrace(); }

length = result.getPropertyCount(); if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString();

}

} tag = false; }

}

#4.real time parameter/ ...interface

page:

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView;

public class Deviceparameter extends Activity { private String confirmedname; private String greenhouse; private String node; private TextView[] textset = new TextView[4]; private TextView[] timeset=new TextView[4]; private TextView[] device = new TextView[4]; private Button[] buttonset = new Button[4]; private String[] unit = { "⊥", "%RH", "Ppm", "Lux" }; private int j; private double tran1; private double tran2; private int tran3;

private TextView pt;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.deviceparameter); pt = (TextView) findViewById(R.id.pt); textset[0] = (TextView) findViewById(R.id.textset0); textset[1] = (TextView) findViewById(R.id.textset1); textset[2] = (TextView) findViewById(R.id.textset2); textset[3] = (TextView) findViewById(R.id.textset3); timeset[0]=(TextView) findViewById(R.id.timeset0); timeset[1]=(TextView) findViewById(R.id.timeset1); timeset[2]=(TextView) findViewById(R.id.timeset2); timeset[3]=(TextView) findViewById(R.id.timeset3);

device[0] = (TextView) findViewById(R.id.device0); device[1] = (TextView) findViewById(R.id.device1); device[2] = (TextView) findViewById(R.id.device2); device[3] = (TextView) findViewById(R.id.device3);

buttonset[0] = (Button) findViewById(R.id.buttonset0); buttonset[1] = (Button) findViewById(R.id.buttonset1); buttonset[2] = (Button) findViewById(R.id.buttonset2); buttonset[3] = (Button) findViewById(R.id.buttonset3);

Intent intent = getIntent(); this.confirmedname = intent.getStringExtra("username"); this.greenhouse = intent.getStringExtra("greenhouse"); this.node = intent.getStringExtra("node"); pt.setText("誹萸"+node+"瘍腔" + "腔遠噫陓洘");

Deviceparameterweb db = new Deviceparameterweb(confirmedname, greenhouse, node); Thread t2 = new Thread(db); t2.start();

while (db.tag) {

} //勤殿隙腔杅擂輛俴潼聆彆岆0麼氪10000ㄗ媼欬趙抯ㄘ寀珆尨峈※---§ 峈淏都杅擂寀珆尨 for (j = 0; j < textset.length; j++) { String mo = db.listcontent[j*2] + unit[j]; if((db.listcontent[j*2].equals("0"))||(db.listcontent[j*2].equals("10000.0"))) textset[j].setText("---"); else textset[j].setText(mo); } for (j = 0; j < timeset.length; j++) { if(db.listcontent[j*2+1].equals("0")) { String jo =db.listcontent[j*2+1]; timeset[j].setText("---"); } else { String[] ss1=db.listcontent[j*2+1].split("\\s+"); timeset[j].setText(ss1[1]); } }

buttonset[0].setOnClickListener(new Buttonlistener0()); buttonset[1].setOnClickListener(new Buttonlistener1()); buttonset[2].setOnClickListener(new Buttonlistener2()); buttonset[3].setOnClickListener(new Buttonlistener3()); }

class Buttonlistener0 implements View.OnClickListener {

public void onClick(View v) { Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device[0].getText()); intent.setClass(Deviceparameter.this, Inquirybydate.class); Deviceparameter.this.startActivity(intent); }

}

class Buttonlistener1 implements View.OnClickListener {

public void onClick(View v) { Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device[1].getText()); intent.setClass(Deviceparameter.this, Inquirybydate.class); Deviceparameter.this.startActivity(intent); }

}

class Buttonlistener2 implements View.OnClickListener {

public void onClick(View v) { Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device[2].getText()); intent.setClass(Deviceparameter.this, Inquirybydate.class); Deviceparameter.this.startActivity(intent); }

}

class Buttonlistener3 implements View.OnClickListener {

public void onClick(View v) { Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device[3].getText()); intent.setClass(Deviceparameter.this, Inquirybydate.class); Deviceparameter.this.startActivity(intent); }

}

}

********

interface:

package com.example.iot;

import java.math.BigDecimal;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Deviceparameterweb implements Runnable { public ListView list; public int length; public SoapObject result; public String[] listcontent = new String[20]; public BigDecimal[] listcontent2 = new BigDecimal[20]; private static final String namespace = "http://deviceparameter"; private static final String methodname = "deviceparameter"; private static final String URL = "http://202.194.26.192:8080/deviceparameter/services/deviceparameter"; public boolean tag = true; private String username = null; private String greenhouse = null; private String node = null;

Deviceparameterweb(String username1, String greenhouse1, String node1) { this.username = username1; this.greenhouse = greenhouse1; this.node = node1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username); rpc.addProperty("greenHouse", greenhouse); rpc.addProperty("node", node);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try {

transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse();

} } catch (Exception e) { e.printStackTrace(); }

length = result.getPropertyCount(); if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString(); }

} tag = false; }

}

#5.searching page/searching page interface

page:

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker;

public class Inquirybydate extends Activity {

private String confirmedname; private String greenhouse; private String node; private String device;

private String sy; private String sm; private String sd; private String sh; private String smm; private String ey; private String em; private String ed; private String eh; private String emm; private String start; private String end; private String interval;

private String[] yearoption = { "2015", "2016", "2017" }; private String[] monthoption = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; private String[] dayoption31 = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }; public static ArrayAdapter<String> adapter1; public static ArrayAdapter<String> adapter2; public static ArrayAdapter<String> adapter3; public static ArrayAdapter<String> adapter4; public static ArrayAdapter<String> adapter5; public static ArrayAdapter<String> adapter6;

public int monthmark = 28; private Spinner startyear; private Spinner startmonth; private Spinner startday; private Spinner endyear; private Spinner endmonth; private Spinner endday; private TimePicker starttp; private TimePicker endtp;

private Button inquirydata; private Button inquirypicture; private TextView inquirytitle;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.inquirybydate); inquirytitle = (TextView) findViewById(R.id.inquirytitle); starttp = (TimePicker) findViewById(R.id.starttp); endtp = (TimePicker) findViewById(R.id.endtp); starttp.setIs24HourView(true); endtp.setIs24HourView(true);

Intent intent = getIntent(); this.confirmedname = intent.getStringExtra("username"); this.greenhouse = intent.getStringExtra("greenhouse"); this.node = intent.getStringExtra("node"); this.device = intent.getStringExtra("device"); inquirytitle.setText("偌桽脤戙" + device + "腔砆牉陓洘");

// 羲宎 爛爺狟嶺蹈桶 startyear = (Spinner) findViewById(R.id.startyear); adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, yearoption); adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); startyear.setAdapter(adapter1); startyear.setVisibility(View.VISIBLE); startyear.setOnItemSelectedListener(new SpinnerSelectedListener1()); // 羲宎堎爺狟懂蹈桶 startmonth = (Spinner) findViewById(R.id.startmonth); adapter2 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, monthoption); adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); startmonth.setAdapter(adapter2); startmonth.setVisibility(View.VISIBLE); startmonth.setOnItemSelectedListener(new SpinnerSelectedListener2()); // 羲宎狟嶺蹈桶場宎趙 startday = (Spinner) findViewById(R.id.startday); adapter3 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dayoption31); adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); startday.setAdapter(adapter3); startday.setVisibility(View.VISIBLE); startday.setOnItemSelectedListener(new SpinnerSelectedListener3());

// 賦旰 爛爺狟嶺蹈桶 endyear = (Spinner) findViewById(R.id.endyear); adapter4 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, yearoption); adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); endyear.setAdapter(adapter4); endyear.setVisibility(View.VISIBLE); endyear.setOnItemSelectedListener(new SpinnerSelectedListener4()); // 賦旰堎爺狟懂蹈桶 endmonth = (Spinner) findViewById(R.id.endmonth); adapter5 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, monthoption); adapter5.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); endmonth.setAdapter(adapter5); endmonth.setVisibility(View.VISIBLE); endmonth.setOnItemSelectedListener(new SpinnerSelectedListener5()); // 賦旰狟嶺蹈桶場宎趙 endday = (Spinner) findViewById(R.id.endday); adapter6 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dayoption31); adapter6.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); endday.setAdapter(adapter3); endday.setVisibility(View.VISIBLE); endday.setOnItemSelectedListener(new SpinnerSelectedListener6());

inquirydata = (Button) findViewById(R.id.inquirydata); inquirypicture = (Button) findViewById(R.id.inquirypicture); inquirydata.setOnClickListener(new Buttonlistener1()); inquirypicture.setOnClickListener(new Buttonlistener2());

}

class SpinnerSelectedListener1 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { sy = adapter1.getItem(arg2); // if(adapter1.getItem(arg2).equals("2016")) // System.out.println(adapter1.getItem(arg2));

}

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener2 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { sm = adapter2.getItem(arg2); if (adapter2.getItem(arg2).equals("01") || adapter2.getItem(arg2).equals("03") || adapter2.getItem(arg2).equals("05") || adapter2.getItem(arg2).equals("07") || adapter2.getItem(arg2).equals("08") || adapter2.getItem(arg2).equals("10") || adapter2.getItem(arg2).equals("12")) monthmark = 31; else if (adapter2.getItem(arg2).equals("04") || adapter2.getItem(arg2).equals("06") || adapter2.getItem(arg2).equals("09") || adapter2.getItem(arg2).equals("11")) monthmark = 30; else if (adapter1.getItem(arg2).equals("2016") || adapter2.getItem(arg2).equals("02")) monthmark = 29; else monthmark = 28; }

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener3 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { sd = adapter3.getItem(arg2); }

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener4 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ey = adapter4.getItem(arg2); }

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener5 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { em = adapter5.getItem(arg2);

}

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener6 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {

ed = adapter6.getItem(arg2); }

public void onNothingSelected(AdapterView<?> arg0) { } }

class Buttonlistener1 implements View.OnClickListener { @Override public void onClick(View v) {

sh = String.valueOf(starttp.getCurrentHour()); smm = String.valueOf(starttp.getCurrentMinute()); eh = String.valueOf(endtp.getCurrentHour()); emm = String.valueOf(endtp.getCurrentMinute());

start = sy + "-" + sm + "-" + sd + " " + sh + ":" + smm; end = ey + "-" + em + "-" + ed + " " + eh + ":" + emm; interval = "0";

Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device); intent.putExtra("start", start); intent.putExtra("end", end); intent.putExtra("interval", interval); intent.setClass(Inquirybydate.this, Listresult.class); Inquirybydate.this.startActivity(intent);

}

}

class Buttonlistener2 implements View.OnClickListener { @Override public void onClick(View v) {

sh = String.valueOf(starttp.getCurrentHour()); smm = String.valueOf(starttp.getCurrentMinute()); eh = String.valueOf(endtp.getCurrentHour()); emm = String.valueOf(endtp.getCurrentMinute());

start = sy + "-" + sm + "-" + sd + " " + sh + ":" + smm; end = ey + "-" + em + "-" + ed + " " + eh + ":" + emm; interval = "0";

System.out.println(start); Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("device", device); intent.putExtra("start", start); intent.putExtra("end", end); intent.putExtra("interval", interval); intent.setClass(Inquirybydate.this, Line.class); Inquirybydate.this.startActivity(intent);

}

}

}

*****

interface:

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Inquirybydateweb implements Runnable { public ListView list; public int length; public SoapObject result; public String[] listcontent; private static final String namespace = "http://category"; private static final String methodname = "category"; private static final String URL = "http://202.194.26.192:8080/category/services/category"; public boolean tag = true; private String username = null; private String greenhouse = null; private String node = null; private String device = null; private String starttime = null; private String endtime = null; private String interval = null;

Inquirybydateweb(String username1, String greenhouse1, String node1, String device1, String starttime1, String endtime1, String interval1) { this.username = username1; this.greenhouse = greenhouse1; this.node = node1; this.device = device1; this.starttime = starttime1; this.endtime = endtime1; this.interval = interval1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username); rpc.addProperty("greenHouse", greenhouse); rpc.addProperty("node", node); rpc.addProperty("device", device); rpc.addProperty("starttime", starttime); rpc.addProperty("endtime", endtime); rpc.addProperty("interval", interval);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try {

transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse(); length = result.getPropertyCount(); } else length=0; } catch (Exception e) { e.printStackTrace(); }

System.out.println(length); System.out.println(length); System.out.println(length); System.out.println(length); listcontent = new String[length]; if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString();

}

} tag = false; }

}

#6.spectrum searching/ display/ intercace

page:

package com.example.iot;

import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.Spinner; import android.widget.TextView; import android.widget.TimePicker;

public class SpectrumInquiry extends Activity {

private String confirmedname; private String greenhouse; private String node;

private String[] yearoption = { "2015", "2016", "2017" }; private String[] monthoption = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }; private String[] dayoption31 = { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }; public static ArrayAdapter<String> adapter11; public static ArrayAdapter<String> adapter22; public static ArrayAdapter<String> adapter33;

private Spinner year; private Spinner month; private Spinner day; private TimePicker tp;

private String y; private String m; private String d; private String h; private String mm; private String time;

private TextView spectruminquirytitle; private Button inquiry;

@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.spectruminquiry); spectruminquirytitle = (TextView) findViewById(R.id.spectruminquirytitle); inquiry = (Button) findViewById(R.id.inquiry); tp = (TimePicker) findViewById(R.id.tp); tp.setIs24HourView(true);

Intent intent = getIntent(); this.confirmedname = intent.getStringExtra("username"); this.greenhouse = intent.getStringExtra("greenhouse"); this.node = intent.getStringExtra("node"); spectruminquirytitle.setText("覜眭誹萸"+node+"瘍腔" + "腔嫖杅擂"); inquiry.setOnClickListener(new Buttonlistener());

// 羲宎 爛爺狟嶺蹈桶 year = (Spinner) findViewById(R.id.year); adapter11 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, yearoption); adapter11 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); year.setAdapter(adapter11); year.setVisibility(View.VISIBLE); year.setOnItemSelectedListener(new SpinnerSelectedListener11()); // 羲宎堎爺狟懂蹈桶 month = (Spinner) findViewById(R.id.month); adapter22 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, monthoption); adapter22 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); month.setAdapter(adapter22); month.setVisibility(View.VISIBLE); month.setOnItemSelectedListener(new SpinnerSelectedListener22()); // 羲宎狟嶺蹈桶場宎趙 day = (Spinner) findViewById(R.id.day); adapter33 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, dayoption31); adapter33 .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); day.setAdapter(adapter33); day.setVisibility(View.VISIBLE); day.setOnItemSelectedListener(new SpinnerSelectedListener33());

}

class SpinnerSelectedListener11 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { y = adapter11.getItem(arg2);

}

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener22 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { m = adapter22.getItem(arg2);

}

public void onNothingSelected(AdapterView<?> arg0) { } }

class SpinnerSelectedListener33 implements OnItemSelectedListener {

public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { d = adapter33.getItem(arg2); }

public void onNothingSelected(AdapterView<?> arg0) { } }

class Buttonlistener implements View.OnClickListener { @Override public void onClick(View v) {

h = String.valueOf(tp.getCurrentHour()); mm = String.valueOf(tp.getCurrentMinute());

time = y + "-" + m + "-" + d + " " + h + ":" + mm;

Intent intent = new Intent();

intent.putExtra("username", confirmedname); intent.putExtra("greenhouse", greenhouse); intent.putExtra("node", node); intent.putExtra("time", time);

intent.setClass(SpectrumInquiry.this, Spectrumtimerangeshow.class); SpectrumInquiry.this.startActivity(intent);

}

}

}

*****

display is shown in #0

******

interface:

package com.example.iot;

import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;

import android.widget.ListView;

public class Spectrumtimerangeshowweb implements Runnable { public ListView list; public int length; public SoapObject result; public String[] listcontent; private static final String namespace = "http://spectrumdatalist"; private static final String methodname = "spectrumdatalist"; private static final String URL = "http://202.194.26.192:8080/spectrumdatalist/services/spectrumdatalist"; public boolean tag = true; private String username = null; private String greenhouse = null; private String node = null; private String time = null;

Spectrumtimerangeshowweb(String username1, String greenhouse1, String node1, String time1) { this.username = username1; this.greenhouse = greenhouse1; this.node = node1; this.time = time1; }

public void run() { SoapObject rpc = new SoapObject(namespace, methodname); rpc.addProperty("userName", username); rpc.addProperty("greenHouse", greenhouse); rpc.addProperty("node", node); rpc.addProperty("time", time);

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope( SoapEnvelope.VER10); envelope.bodyOut = rpc; envelope.dotNet = true; envelope.setOutputSoapObject(rpc);

HttpTransportSE transport = new HttpTransportSE(URL);

try {

transport.call(null, envelope); if (envelope.getResponse() != null) { result = (SoapObject) envelope.getResponse(); length = result.getPropertyCount();

} else length=0; } catch (Exception e) { e.printStackTrace(); }

listcontent = new String[length]; if (length > 0) { for (int i = 0; i <= length - 1; i++) { listcontent[i] = result.getProperty(i).toString();

}

} tag = false; }

}












Who Am I?

Hello, My name is Tongda (Carl). I am currently a Math Finance graudate student at BU. I am fan of innovation and funny ideas! You can reach my by  LinkedIn below :)

Follow Me
  • LinkedIn Social Icon
bottom of page