Database and IO Simulation working

This commit is contained in:
Patrick McDonagh
2017-02-02 18:01:18 -06:00
parent 3093ddcdd9
commit 2730d2ee0f
22 changed files with 789 additions and 296 deletions

View File

@@ -4,31 +4,6 @@ package com.henrypump.poc;
* Created by patrickjmcd on 1/31/17.
*/
/*
* Author: Brendan Le Foll <brendan.le.foll@intel.com>
* Author: Petre Eftime <petre.p.eftime@intel.com>
* Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import mraa.Dir;
import mraa.Gpio;
import mraa.mraa;
@@ -40,28 +15,21 @@ public class DigitalIn {
private Gpio gpioPin;
private int lastValue;
static {
try {
System.loadLibrary("mraajava");
} catch (UnsatisfiedLinkError e) {
System.err.println(
"Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
e);
System.exit(1);
}
}
DigitalIn(int channel){
Platform platform = mraa.getPlatformType();
this.channel = channel;
if (channel != 99) {
if (platform != Platform.INTEL_EDISON_FAB_C) {
System.err.println("Error: This program can only be run on edison");
System.exit(Result.ERROR_INVALID_PLATFORM.swigValue());
Platform platform = mraa.getPlatformType();
if (platform != Platform.INTEL_EDISON_FAB_C) {
System.err.println("Error: This program can only be run on edison");
System.exit(Result.ERROR_INVALID_PLATFORM.swigValue());
}
this.gpioPin = new Gpio(this.channel);
gpioPin.dir(Dir.DIR_IN);
}
this.channel = channel;
this.gpioPin = new Gpio(this.channel);
gpioPin.dir(Dir.DIR_IN);
}
public int read(){
@@ -75,8 +43,8 @@ public class DigitalIn {
DigitalIn testIn8 = new DigitalIn(8);
DigitalIn testIn9 = new DigitalIn(9);
DigitalOut testOut2 = new DigitalOut(2);
DigitalOut testOut3 = new DigitalOut(3);
DigitalOut testOut2 = new DigitalOut(2,0);
DigitalOut testOut3 = new DigitalOut(3,0);
int in8val, in9val;
do {