Added description for flows and turn on and off option
This commit is contained in:
parent
89d4291168
commit
60e5131850
7 changed files with 99 additions and 19 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#define TIMER_MILLISECOND 60000 // poling in minutes
|
#define TIMER_MILLISECOND 60000 // poling in minutes
|
||||||
#define INDICATOR_PIN 13 // diode
|
#define INDICATOR_PIN 13 // diode
|
||||||
#define DEVICE_BASE_ID 20
|
#define DEVICE_BASE_ID 98
|
||||||
|
|
||||||
// POWER CONSUMPTION SENSOR
|
// POWER CONSUMPTION SENSOR
|
||||||
//#define POWERCON_ENABLED // comment out to disable sensor
|
//#define POWERCON_ENABLED // comment out to disable sensor
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#define TEMPERATURE_TIMER_MULTIPLIER 10
|
#define TEMPERATURE_TIMER_MULTIPLIER 10
|
||||||
|
|
||||||
// LIGHT SENSOR
|
// LIGHT SENSOR
|
||||||
#define LIGHT_ENABLED // comment out to disable sensor
|
//#define LIGHT_ENABLED // comment out to disable sensor
|
||||||
#define LIGHT_SENSOR SensorBH1750()
|
#define LIGHT_SENSOR SensorBH1750()
|
||||||
#define LIGHT_PROTOCOL ProtocolOregon(11, DEVICE_BASE_ID + 3)
|
#define LIGHT_PROTOCOL ProtocolOregon(11, DEVICE_BASE_ID + 3)
|
||||||
#define LIGHT_TIMER_MULTIPLIER 10
|
#define LIGHT_TIMER_MULTIPLIER 10
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,14 @@ void Interrupt::sleep()
|
||||||
sleep_enable(); // enables the sleep bit in the mcucr register
|
sleep_enable(); // enables the sleep bit in the mcucr register
|
||||||
// so sleep is possible. just a safety pin
|
// so sleep is possible. just a safety pin
|
||||||
|
|
||||||
power_adc_disable();
|
//power_adc_disable();
|
||||||
//power_spi_disable();
|
//power_spi_disable();
|
||||||
|
//power_usart0_disable();
|
||||||
//power_timer0_disable();
|
//power_timer0_disable();
|
||||||
//power_timer1_disable();
|
//power_timer1_disable();
|
||||||
//power_timer2_disable();
|
//power_timer2_disable();
|
||||||
//power_twi_disable();
|
//power_twi_disable();
|
||||||
//power_all_disable()
|
//power_all_disable();
|
||||||
|
|
||||||
while( ! Interrupt::wakeUpNow)
|
while( ! Interrupt::wakeUpNow)
|
||||||
{
|
{
|
||||||
|
|
@ -52,7 +53,7 @@ void Interrupt::sleep()
|
||||||
sleep_disable(); // first thing after waking from sleep:
|
sleep_disable(); // first thing after waking from sleep:
|
||||||
// disable sleep...
|
// disable sleep...
|
||||||
|
|
||||||
power_adc_enable();
|
//power_adc_enable();
|
||||||
//power_spi_enable();
|
//power_spi_enable();
|
||||||
//power_usart0_enable();
|
//power_usart0_enable();
|
||||||
//power_timer0_enable();
|
//power_timer0_enable();
|
||||||
|
|
|
||||||
BIN
hal-default.db
BIN
hal-default.db
Binary file not shown.
4
resource/web/css/hal.css
vendored
4
resource/web/css/hal.css
vendored
|
|
@ -99,6 +99,10 @@ body {
|
||||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12)
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.disabled {
|
||||||
|
background-color: lightgray;
|
||||||
|
opacity: .6;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Placeholder dashboard ideas
|
* Placeholder dashboard ideas
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,18 @@
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="panel panel-default drop-shadow">
|
<div class="panel panel-default drop-shadow">
|
||||||
<div class="panel-heading clearfix">
|
<div class="panel-heading clearfix">
|
||||||
<form method="POST">
|
{{.getName()}}
|
||||||
<input type="hidden" name="flow-id" value="{{.getId()}}">
|
<div class="pull-right">
|
||||||
<div class="btn-toolbar pull-right">
|
<button type="button" class="btn btn-default btn-xs" data-toggle="modal" style="padding: 1px 20px;"
|
||||||
<button type="submit" class="btn btn-danger btn-xs" style="padding: 1px 20px;" name="action" value="remove_flow">
|
data-target="#flowModal"
|
||||||
<span class="glyphicon glyphicon-trash"></span>
|
data-flow-id="{{.getId()}}"
|
||||||
</button>
|
data-enabled="{{.isEnabled()}}"
|
||||||
</div>
|
data-name="{{.getName()}}" >
|
||||||
</form>
|
<span class="glyphicon glyphicon-pencil"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body {{^.isEnabled()}}disabled{{/.isEnabled()}}">
|
||||||
<table class="table table-condensed">
|
<table class="table table-condensed">
|
||||||
<thead class="row">
|
<thead class="row">
|
||||||
<th class="col-md-5 text-center">
|
<th class="col-md-5 text-center">
|
||||||
|
|
@ -138,9 +140,63 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
initDynamicModalForm("triggerModal", "trigger-data-conf", "trigger-data-conf-template");
|
initDynamicModalForm("triggerModal", "trigger-data-conf", "trigger-data-conf-template");
|
||||||
initDynamicModalForm("actionModal", "action-data-conf", "action-data-conf-template");
|
initDynamicModalForm("actionModal", "action-data-conf", "action-data-conf-template");
|
||||||
|
|
||||||
|
$("#flowModal").on('show.bs.modal', function (event) {
|
||||||
|
var button = $(event.relatedTarget);
|
||||||
|
var modal = $(this);
|
||||||
|
modal.find("input[type=text]").val(""); // Reset all inputs
|
||||||
|
|
||||||
|
modal.find("input[name=flow-id]").val(button.data("flow-id"));
|
||||||
|
modal.find("input[name=name]").val(button.data("name"));
|
||||||
|
modal.find("input[name=enabled]").prop('checked', button.data("enabled"));
|
||||||
|
modal.find("input[name=enabled]").bootstrapSwitch('state', button.data("enabled"), true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div class="modal fade" id="flowModal" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal"><span>×</span></button>
|
||||||
|
<h4 class="modal-title">Flow</h4>
|
||||||
|
</div>
|
||||||
|
<form method="POST">
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="hidden" name="action" value="modify_flow">
|
||||||
|
<input type="hidden" name="flow-id">
|
||||||
|
|
||||||
|
<!--<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" name="enabled"> Enabled
|
||||||
|
</label>
|
||||||
|
</div>-->
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label">Enabled:</label>
|
||||||
|
<div class="checkbox">
|
||||||
|
<input class="toggle-switch" type="checkbox" name="enabled"
|
||||||
|
data-size="small" data-off-color="danger" >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label">Name:</label>
|
||||||
|
<input type="text" class="form-control" name="name">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="pull-left">
|
||||||
|
<button type="submit" class="btn btn-danger" name="action" value="remove_flow">
|
||||||
|
<span class="glyphicon glyphicon-trash"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button type="reset" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Save</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="modal fade" id="triggerModal" tabindex="-1">
|
<div class="modal fade" id="triggerModal" tabindex="-1">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
@ -176,7 +232,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="modal fade" id="actionModal" tabindex="-1">
|
<div class="modal fade" id="actionModal" tabindex="-1">
|
||||||
<div class="modal-dialog">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,11 @@ public class TriggerHttpPage extends HalHttpPage {
|
||||||
flow = new TriggerFlow();
|
flow = new TriggerFlow();
|
||||||
flow.save(db);
|
flow.save(db);
|
||||||
break;
|
break;
|
||||||
|
case "modify_flow":
|
||||||
|
flow.setEnabled("on".equals(request.get("enabled")));
|
||||||
|
flow.setName(request.get("name"));
|
||||||
|
flow.save(db);
|
||||||
|
break;
|
||||||
case "remove_flow":
|
case "remove_flow":
|
||||||
flow.delete(db);
|
flow.delete(db);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,15 @@ import java.util.logging.Logger;
|
||||||
public class TriggerFlow extends DBBean {
|
public class TriggerFlow extends DBBean {
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
|
private boolean enabled = true;
|
||||||
|
private String name = "";
|
||||||
|
|
||||||
@DBLinkTable(beanClass=Trigger.class, table="trigger", idColumn = "flow_id")
|
@DBLinkTable(beanClass=Trigger.class, table="trigger", idColumn = "flow_id")
|
||||||
private List<Trigger> triggerList = new ArrayList<>();
|
private List<Trigger> triggerList = new ArrayList<>();
|
||||||
@DBLinkTable(beanClass=Action.class, table="action", idColumn = "flow_id")
|
@DBLinkTable(beanClass=Action.class, table="action", idColumn = "flow_id")
|
||||||
private List<Action> actionList = new ArrayList<>();
|
private List<Action> actionList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static List<TriggerFlow> getTriggerFlows(DBConnection db) throws SQLException {
|
public static List<TriggerFlow> getTriggerFlows(DBConnection db) throws SQLException {
|
||||||
PreparedStatement stmt = db.getPreparedStatement("SELECT * FROM trigger_flow");
|
PreparedStatement stmt = db.getPreparedStatement("SELECT * FROM trigger_flow");
|
||||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(TriggerFlow.class, db));
|
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(TriggerFlow.class, db));
|
||||||
|
|
@ -57,6 +59,19 @@ public class TriggerFlow extends DBBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addTrigger(Trigger trigger) {
|
public void addTrigger(Trigger trigger) {
|
||||||
triggerList.add(trigger);
|
triggerList.add(trigger);
|
||||||
|
|
@ -84,7 +99,7 @@ public class TriggerFlow extends DBBean {
|
||||||
* Note: this method will not execute any actionList
|
* Note: this method will not execute any actionList
|
||||||
*/
|
*/
|
||||||
public boolean evaluate(){
|
public boolean evaluate(){
|
||||||
if (triggerList.isEmpty())
|
if (triggerList.isEmpty() || !enabled)
|
||||||
return false;
|
return false;
|
||||||
for(Trigger trigger : triggerList){
|
for(Trigger trigger : triggerList){
|
||||||
if (!trigger.evaluate())
|
if (!trigger.evaluate())
|
||||||
|
|
@ -97,6 +112,8 @@ public class TriggerFlow extends DBBean {
|
||||||
* Executes the associated actionList in this flow
|
* Executes the associated actionList in this flow
|
||||||
*/
|
*/
|
||||||
public void execute(){
|
public void execute(){
|
||||||
|
if (!enabled)
|
||||||
|
return;
|
||||||
for(Action action : actionList){
|
for(Action action : actionList){
|
||||||
action.execute();
|
action.execute();
|
||||||
}
|
}
|
||||||
|
|
@ -110,6 +127,4 @@ public class TriggerFlow extends DBBean {
|
||||||
trigger.reset();
|
trigger.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue