Skip to content
ccm026 edited this page Apr 20, 2018 · 6 revisions

INTRODUCTION

Purpose of Project

The main aim of this project is to create a virtual observation on the device. The device (Raspberry Pi with sensor) can be installed in a remote place or on a Robot and continually monitor the distance of the objects around it. The Project Live Data Plot on Webpage defines the following:

  • Project purpose
  • Scope and expectations
  • Assumptions and constraints
  • Ground rules for the project
  • The conceptual design of new technology
  • Plotting live data on the webpage

Background Information

The motive for this project is to deepen the knowledge of Java programming language. JavaScript has a wide range applications and can program various devices such as Raspberry Pi, Controllers etc. Plotting live data involves in the creation of Webpage and provides opportunity to learn HTML, creation of Web Servlets, Design of Webpage.

Project Approach

The future generation is leading to digitalized world which is also involved in monitoring and controlling the devices or robots virtually (called Virtual System). Automatically generate dynamic maps or plot live data, displaying hosts and guests, clusters, and real-time status.

Real-time up-to-date list of all hosts and attributes. Monitor the performance and resource consumption of hosts and guests, including Interface Utilization and the availability and performance of servers and tracks live migrations.

While Virtualization Monitoring is automatically set to plot every second, system admins can customize their plotting cycles to meet their specific needs. An event log provides a record of events generated from virtual devices.

The project involves various phases:

Phase I: Create Maven Project and Initiate Spring Boot

Phase II: Start a Server on Raspberry Pi

Phase III: Design Login page

Phase IV: Design Home page

Phase V: Controllers for the Login and Home Page

Phase VI: Controller Program for the Distance Measurement

Phase VII: Design for the Live Data plot page

Phase I: Create Maven Project and Initiate Spring Boot

com.piproject

At first glance Maven can appear to be many things, but in a nutshell Maven is an attempt to apply patterns to a project's build infrastructure in order to promote comprehension and productivity by providing a clear path in the use of best practices.

pom.xml contains the Project Object Model (POM) for this project. The POM is the basic unit of work in Maven. This is important to remember because Maven is inherently project-centric in that everything revolves around the notion of a project. In short, the POM contains every important piece of information about your project and is essentially one-stop-shopping for finding anything related to project.

project: This is the top-level element in all Maven pom.xml files.

modelVersion: This element indicates what version of the object model this POM is using. This project has version 4.

<modelVersion>4.0.0</modelVersion>

groupId: This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization.

<groupId>com.piproject</groupId>

artifactId: This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file.

<artifactId>piproject</artifactId>

packaging: This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process

version: This element indicates the version of the artifact generated by the project.

<version>1.0-SNAPSHOT</version>

parent: Is used to structure the project to avoid redundancies or duplicate configurations using inheritance between pom files. It helps in easy maintenance in long term.

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>1.5.6.RELEASE</version>

</parent>

Repositories: A repository in Maven is used to hold build artifacts and dependencies of varying types. There are strictly only two types of repositories: local and remote. The local repository refers to a copy on your own installation that is a cache of the remote downloads, and also contains the temporary build artifacts that you have not yet released.

<repositories>

<repository>

<id>oss-snapshots-repo</id>

<name>Sonatype OSS Maven Repository</name>

<url>https://oss.sonatype.org/content/groups/public</url>

<snapshots>

<enabled>true</enabled>

<updatePolicy>always</updatePolicy>

</snapshots>

</repository>

</repositories>

Dependencies: This allows project authors to directly specify the versions of artifacts to be used when they are encountered in dependencies where no version has been specified. Dependency scope is used to limit the transitivity of a dependency, and also to affect the class path used for various build tasks.

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

</dependencies>

Build: This is automation tool used primarily for Java projects. Maven addresses two aspects of building software: first, it describes how software is built, and second, it describes its dependencies. Build plugins will be executed during the build and they should be configured in the element from the POM.

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

</build>

public class Application

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that can "just run". We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.

Features

 Create stand-alone Spring applications

 Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)

 Provide opinionated 'starter' POMs to simplify your Maven configuration

 Automatically configure Spring whenever possible

 Provide production-ready features such as metrics, health checks and externalized configuration

 Absolutely no code generation and no requirement for XML configuration

SpringApplication.run(Application.class, args);

Phase II: Start a Server on Raspberry Pi

public class Webinit

public class Webconfig

public class RootConfig

A Java servlet is a Java program that extends the capabilities of a server. Although servlets can respond to any types of requests, they most commonly implement applications hosted on Web servers. Such Web servlets are the Java counterpart to other dynamic Web content technologies.

A Java servlet processes or stores a Java class in Java EE that conforms to the Java Servlet API, a standard for implementing Java classes that respond to requests. Servlets could in principle communicate over any client–server protocol, but they are most often used with the HTTP protocol. Thus "servlet" is often used as shorthand for "HTTP servlet". Thus, a software developer may use a servlet to add dynamic content to a web server using the Java platform. The generated content is commonly HTML, but may be other data such as XML. Servlets can maintain state in session variables across many server transactions by using HTTP cookies, or URL rewriting.

To deploy and run a servlet, a web container must be used. A web container (also known as a servlet container) is essentially the component of a web server that interacts with the servlets. The web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights.

The Apache Tomcat software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are developed under the Java Community Process. The Apache Tomcat software is developed in an open and participatory environment and released under the Apache License version 2. The Apache Tomcat project is intended to be a collaboration of the best-of-breed developers from around the world.

Phase III: Design Login page

login.jsp

A login, logging in or logging on is the entering of identifier information into a system by a user in order to access that system. It is an integral part of computer security procedures.

A login generally requires the user to enter two pieces of information, first a user name and then a password. Login page is HTML design to have a GUI interface on the webpage and linked to the controller.

Phase IV: Design Home page

home.jsp

A home page is a webpage that serves as the starting point of website. It is the default webpage that loads when you visit a web address that only contains a domain name. The home page is located in the root directory of a website.

Phase V: Controllers for the Login and Home Page

public class User

public class LoginController

Annotation for mapping web requests onto specific handler classes and/or handler methods. The controller classes in the project handles the mapping requests and redirects to the path declared.

Handler methods annotated with this annotation can have very flexible signatures. The exact details of the supported method arguments and return values depend on the specific @Controller model supported. Spring Web MVC support this annotation.

@RequestMapping will only be processed if an appropriate HandlerMappingHandlerAdapter pair is configured.

Configuration of User credentials and error messages are done in these classes of Java.

Phase VI: Design for the Live Data plot page

graph.jsp

public class DistanceController

LiveGraph is for real-time data visualisation, analysis and logging.

Distinctive features:

 A real-time plotter that can automatically update graphs of your data while it is still being computed by your application.

 Concise and simple point-and-click that allows quickly selecting and visualising data on the point.

 Transformation of data series for visual comparison by the virtue of a single click.