Coder Social home page Coder Social logo

c8y-agent-java's Introduction

Repository Contents

This repository contains an example Java Agent with support for Raspberry Pi, Linux, Windows and Mac systems. It consists of the following modules:

  • jv-driver: Interface classes for writing hardware drivers and implementing new functionality.
  • jv-agent: The main executable agent including basic device management, should work on all Java platforms.
  • rpi-driver: Hardware driver for the Raspberry Pi.
  • parking-pi-driver : driver for c8y parkingpi.
  • kontron-driver: Hardware driver for
  • mac-driver: Hardware driver for Mac OS X systems.
  • generic-linux-driver: Hardware driver for linux systems lacking /proc/cpuinfo. It uses the MAC address to register the device.
  • win-driver: Hardware driver for Windows systems.
  • piface-driver: A simple Piface integration.
  • tinkerforge-driver: Support for Tinkerforge bricks.
  • assembly: Base packaging for all environments.
  • packages: Environment specific packaging.

parkingpi.json

The Whole parkingpi depends on this json file (/c8y-Agent-java/parking-pi-driver/parkingpi.json) in this repository. you can modify based on your needs say parking pi's name,location, number of sensors to your parkingpi name, your preferred location,your sensor needs in the parkingpi.json file respectively.

Pre Process

First Build this repository using maven get parkingPiDriver jar and then you have to remove the Piface Driver and copy the ParkingPiDriver to RaspberryPi after Installing The Cumulocity Latest Rpi Agent to do this Run the following commands as sudo in the Terminal window

rm /usr/share/cumulocity-rpi-agent/lib/<<pifacedriver.jar Exact filename as it is>>
cp <<ParkingPiDriver.jar Location>> /usr/share/cumulocity-rpi-agent/lib/
cp <<json-simple-1.1.1.jar Location>> /usr/share/cumulocity-rpi-agent/lib/
cd /home/pi/Desktop/
mkdir c8y
cp <<parkingpi.json location>> /home/pi/Desktop/c8y/

And Restart the agent.

Parking-pi-driver

ParkingPiDriver.java

  • To Run this Driver Apart from the above files You have add Google Simple Json dependency jar to the POM.XML.
  • The main Java class is parking-pi-driver\src\main\java\com\softwareag\parkingpi\ParkingPiDriver.java which updates the parking pi's name, position and parking pi's Status which is not set by the c8y raspberry-pi agent(sets only for the first time of running from the
  • ParkingPi.json File which has been at the location (/home/pi/Desktop/c8y/).
  • It also creates the ChildDevices(Basically the sensors) based on the Array size of sensors key in same Json file and copy the sensors array and updated with the SystemID(from c8y) also generate sendmeasure.Json file in same directory Using ManageChildDevices.java class.
  • The location of parkingPi.json be anywhere in pi but you have to update the file location in The class com\softwareag\parkingpi\PiProperties.java
  • Start to send Measurements to sensors using MeasurementPublisher.java class.

ManageChildDevices.java

  • This Class Creates the Sensors as ManagedObject and add it as Child device to The Parent parking Pi.
  • ManagedObjecet is Set type as c8y_DistanceSensor and Measurement Type as Distance Measurement And the name of this Device also get from ParkingPiJson

MeasurementPublisher.java

  • Reads Echo trig and sourceId From the sendmeasure.json file
  • set source to that Id, read the value from the sensor using trig and echo pin
  • set the readed value to MeasurementValue and unit as centimeter and send it to cumulocity.

ParkingPiStatus.java

  • Set ParkingPi as ACTIVE, INACTIVE or MAINTENANCE state.

c8y-agent-java's People

Contributors

thecreator007 avatar vethastanley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.