Added some structural classes
Former-commit-id: 5750452adfe6fecd4893130c9e24354c3dae31fe
This commit is contained in:
parent
958f36dc7e
commit
b985776394
9 changed files with 104 additions and 30 deletions
BIN
hal.db
BIN
hal.db
Binary file not shown.
29
src/se/koc/hal/PowerChallenge.java
Executable file
29
src/se/koc/hal/PowerChallenge.java
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
package se.koc.hal;
|
||||
|
||||
|
||||
import se.koc.hal.deamon.DataAggregatorDaemon;
|
||||
import se.koc.hal.deamon.HalDaemon;
|
||||
import zutil.db.DBConnection;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class PowerChallenge {
|
||||
private static HalDaemon[] daemons = new HalDaemon[]{
|
||||
new DataAggregatorDaemon()
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// init Database
|
||||
final DBConnection db = new DBConnection(DBConnection.DBMS.SQLite, "hal.db");
|
||||
|
||||
// init daemons
|
||||
Timer daemonTimer = new Timer();
|
||||
for(HalDaemon daemon : daemons){
|
||||
daemon.initiate(daemonTimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
22
src/se/koc/hal/deamon/DataAggregatorDaemon.java
Executable file
22
src/se/koc/hal/deamon/DataAggregatorDaemon.java
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
package se.koc.hal.deamon;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class DataAggregatorDaemon extends TimerTask implements HalDaemon {
|
||||
private static final int FIVE_MINUTES_IN_MS = 5 * 60 * 1000;
|
||||
|
||||
|
||||
public void initiate(Timer timer){
|
||||
timer.schedule(this, FIVE_MINUTES_IN_MS);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
12
src/se/koc/hal/deamon/HalDaemon.java
Executable file
12
src/se/koc/hal/deamon/HalDaemon.java
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
package se.koc.hal.deamon;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public interface HalDaemon {
|
||||
public void initiate(Timer timer);
|
||||
|
||||
public void run();
|
||||
}
|
||||
7
src/se/koc/hal/struct/PowerMeterSensor.java
Executable file
7
src/se/koc/hal/struct/PowerMeterSensor.java
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
package se.koc.hal.struct;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class PowerMeterSensor extends Sensor{
|
||||
}
|
||||
11
src/se/koc/hal/struct/Sensor.java
Executable file
11
src/se/koc/hal/struct/Sensor.java
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
package se.koc.hal.struct;
|
||||
|
||||
import zutil.db.bean.DBBean;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
@DBBean.DBTable("sensor")
|
||||
public class Sensor extends DBBean{
|
||||
|
||||
}
|
||||
7
src/se/koc/hal/struct/TemperatureSensor.java
Executable file
7
src/se/koc/hal/struct/TemperatureSensor.java
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
package se.koc.hal.struct;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
public class TemperatureSensor extends Sensor {
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015 Ziver
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package se.koc.hal.struct;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-05-07.
|
||||
*/
|
||||
public interface Trigger {
|
||||
|
||||
}
|
||||
16
src/se/koc/hal/struct/User.java
Executable file
16
src/se/koc/hal/struct/User.java
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
package se.koc.hal.struct;
|
||||
|
||||
import zutil.db.bean.DBBean;
|
||||
|
||||
/**
|
||||
* Created by Ziver on 2015-12-03.
|
||||
*/
|
||||
@DBBean.DBTable("user")
|
||||
public class User extends DBBean{
|
||||
|
||||
private String name;
|
||||
private String address;
|
||||
private boolean external;
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue