Commit 3103d797 authored by Jan Wagemakers's avatar Jan Wagemakers

Configuration DEMO mode by Config.java

parent b46a7bea
export DEMO=false
#!/bin/bash
sed -i 's#DEMO = true#DEMO = false#g' src/main/java/be/janwagemakers/controlthermostatbluetooth/Config.java
gradlew clean build
scp build/libs/controlthermostatbluetooth-0.0.1-SNAPSHOT.jar 192.168.1.244://home/jan/thermostat.jar
#!/bin/bash
sed -i 's#DEMO = false#DEMO = true#g' src/main/java/be/janwagemakers/controlthermostatbluetooth/Config.java
gradlew clean build
scp build/libs/controlthermostatbluetooth-0.0.1-SNAPSHOT.jar 192.168.2.183://home/jan/thermostat.jar
package be.janwagemakers.controlthermostatbluetooth;
public class Config {
public static final boolean DEMO = true;
}
......@@ -15,7 +15,7 @@ import java.text.DecimalFormat;
*/
class Serial {
private final SerialPort rfcomm;
private boolean demo = false;
private final static boolean DEMO = Config.DEMO;
private DataList data = new DataList();
public Serial() {
......@@ -24,9 +24,8 @@ class Serial {
SerialPort.TIMEOUT_WRITE_BLOCKING, 2000, 0);
}
public boolean open(boolean demo) {
this.demo = demo;
if (demo) return true;
public boolean open() {
if (DEMO) return true;
rfcomm.closePort();
data.add("---------------");
data.add("open");
......@@ -96,7 +95,7 @@ class Serial {
data.add("---------------");
data.add("CMD : " + tx);
if (demo) {
if (DEMO) {
if (tx.length() > 3) return Float.parseFloat(tx.substring(3));
if (tx.equals("OP?")) {
return (int)(Math.random()+.5);
......
......@@ -31,6 +31,8 @@ import org.springframework.scheduling.annotation.Scheduled;
public class StartupRunner implements CommandLineRunner {
protected final Log logger = LogFactory.getLog(getClass());
private static boolean DEMO = Config.DEMO;
private static final Serial SERIAL = new Serial();
private Configuration config;
private int oldOA = -1;
......@@ -39,8 +41,6 @@ public class StartupRunner implements CommandLineRunner {
private int oldMonth = -1;
private int oldDay = -1;
private int oldHour = -1;
@Value("${demo}")
private boolean demo;
@Autowired
private ConfigurationRepository configurationRepository;
......@@ -65,7 +65,7 @@ public class StartupRunner implements CommandLineRunner {
config = configurationRepository.save(config);
}
System.out.println("CONFIG : " + config.getAirport() + " " + config.getLowTemp());
if (demo) System.out.println("DEMO");
if (DEMO) System.out.println("DEMO");
}
@Scheduled(initialDelay = 5 * 1000, fixedDelay = 15 * 60 * 1000)
......@@ -129,7 +129,7 @@ public class StartupRunner implements CommandLineRunner {
int outsidePressure = outside.getPressure();
data.add("Outside Temperature = " + outsideTemp);
data.add("Outside Atmospheric Pressure = " + outsidePressure);
if (SERIAL.open(demo)) {
if (SERIAL.open()) {
// set current outside temp / YY / MM / DD / hh / mm
if (oldOA != outsidePressure) {
if (SERIAL.setOA(outsidePressure)) oldOA = outsidePressure;
......@@ -222,7 +222,7 @@ public class StartupRunner implements CommandLineRunner {
}
if (count-- < 0) break;
data.add("OK");
if (demo) break;
if (DEMO) break;
}
if (count >= 0) data.add("Control SP OK");
} else {
......
......@@ -10,7 +10,7 @@ spring.datasource.password =
# Do not create database - use schema.sql
spring.jpa.hibernate.ddl-auto=none
demo = ${DEMO}
# demo = ${DEMO}
# security set user/password
#spring.security.user.name=${user}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment