Commit 297e73e8 authored by Jan Wagemakers's avatar Jan Wagemakers

RPI send OT YY MM DD hh mm

parent e019bf5a
......@@ -39,8 +39,7 @@ class Serial {
public boolean setSP(float temp) {
if (temp < 0 ) return false;
DecimalFormat dec = new DecimalFormat("00.0");
String sp = dec.format(temp);
String tx = "SP=" + sp;
String tx = "SP=" + dec.format(temp);
float rx = get(tx);
if( temp != rx ) {
......@@ -50,6 +49,78 @@ class Serial {
return true;
}
public boolean setOT(float temp) {
DecimalFormat dec = new DecimalFormat("00.0");
String tx = "OT=" + dec.format(temp);
float rx = get(tx);
if( temp != rx ) {
data.add("ERROR");
return false;
}
return true;
}
public boolean setYY(int number) {
DecimalFormat dec = new DecimalFormat("00");
String tx = "YY=" + dec.format(number);
float rx = get(tx);
if( number != rx ) {
data.add("ERROR");
return false;
}
return true;
}
public boolean setMM(int number) {
DecimalFormat dec = new DecimalFormat("00");
String tx = "MM=" + dec.format(number);
float rx = get(tx);
if( number != rx ) {
data.add("ERROR");
return false;
}
return true;
}
public boolean setDD(int number) {
DecimalFormat dec = new DecimalFormat("00");
String tx = "DD=" + dec.format(number);
float rx = get(tx);
if( number != rx ) {
data.add("ERROR");
return false;
}
return true;
}
public boolean sethh(int number) {
DecimalFormat dec = new DecimalFormat("00");
String tx = "hh=" + dec.format(number);
float rx = get(tx);
if( number != rx ) {
data.add("ERROR");
return false;
}
return true;
}
public boolean setmm(int number) {
DecimalFormat dec = new DecimalFormat("00");
String tx = "mm=" + dec.format(number);
float rx = get(tx);
if( number != rx ) {
data.add("ERROR");
return false;
}
return true;
}
private float get(String tx) {
Float rx;
data.add("---------------");
......
......@@ -28,6 +28,12 @@ public class StartupRunner implements CommandLineRunner {
protected final Log logger = LogFactory.getLog(getClass());
private static final Serial SERIAL = new Serial();
private float oldOT = -1;
private float oldYY = -1;
private float oldMM = -1;
private float oldDD = -1;
private float oldhh = -1;
private float oldmm = -1;
// private static float outsideTemp;
@Autowired
......@@ -100,6 +106,42 @@ public class StartupRunner implements CommandLineRunner {
float outsideTemp = ot.getOutsideTemp();
data.add("Outside_temp = " + outsideTemp);
if (SERIAL.open()) {
// set current outside temp / YY / MM / DD / hh / mm
if (oldOT != outsideTemp) {
oldOT = outsideTemp;
SERIAL.setOT(outsideTemp);
}
int YY=rightNow.get(Calendar.YEAR)-2000;
if (oldYY != YY) {
oldYY = YY;
SERIAL.setYY(YY);
}
int MM=rightNow.get(Calendar.MONTH) + 1;
if (oldMM != MM) {
oldMM = MM;
SERIAL.setMM(MM);
}
int DD=rightNow.get(Calendar.DAY_OF_MONTH);
if (oldDD != DD) {
oldDD = DD;
SERIAL.setDD(DD);
}
int hh=rightNow.get(Calendar.HOUR_OF_DAY);
if (oldhh != hh) {
oldhh = hh;
SERIAL.sethh(hh);
}
int mm=rightNow.get(Calendar.MINUTE);
if (oldmm != mm) {
oldmm = mm;
SERIAL.setmm(mm);
}
// get status of thermostats relais (OutPut)
int op = SERIAL.getOP();
data.add("" + op);
......
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