Code cleanup and small fixes: *Sun data is updated when browsing between days (dark/light areas, point positions), *More efficient reuse of sun data, *Moving points with keys only available in state 'absolute', *Removing timers from jobs loaded from storage correctly

This commit is contained in:
Stefan Persson 2011-02-16 11:09:38 +00:00
parent 84d6008dee
commit f808e3b079
5 changed files with 207 additions and 447 deletions

View file

@ -22,6 +22,7 @@ Rectangle{
property variant lastRun: 0; property variant lastRun: 0;
//property int parentPointAbsoluteHour //TEST changed from int, want "undefined" //property int parentPointAbsoluteHour //TEST changed from int, want "undefined"
property alias deviceRow: pointRect.parent property alias deviceRow: pointRect.parent
property variant selectedDate: (deviceRow == null || deviceRow == undefined) ? new Date() : deviceRow.selectedDate
Component.onCompleted: { Component.onCompleted: {
//TODO useless really, still gets Cannot anchor to a null item-warning... //TODO useless really, still gets Cannot anchor to a null item-warning...
@ -41,27 +42,10 @@ Rectangle{
z: 100 z: 100
state: "on" state: "on"
focus: true focus: true
//actionTypeColor: getColor()
//TODO make this work:
/*Keys.onLeftPressed: {
pointRect.x = pointRect.x - 1
}
Keys.onRightPressed: {
pointRect.x = pointRect.x + 1
}
Text {
//focus: true
text: pointRect.activeFocus ? "I HAVE active focus!" : "I do NOT have active focus"
}
*/
//reflect changes on parent/siblings: //reflect changes on parent/siblings:
onAbsoluteHourChanged: { onAbsoluteHourChanged: {
updateChanges(); updateChanges();
//print("ABSOLUTE HOUR CHANGED");
} }
onAbsoluteMinuteChanged: { onAbsoluteMinuteChanged: {
@ -167,14 +151,14 @@ Rectangle{
PropertyChanges { target: triggerImage; source: imageTriggerSunrise; opacity: 1 } PropertyChanges { target: triggerImage; source: imageTriggerSunrise; opacity: 1 }
PropertyChanges { target: triggerTime; opacity: 0 } PropertyChanges { target: triggerTime; opacity: 0 }
PropertyChanges { target: pointRectMouseArea; drag.target: undefined } PropertyChanges { target: pointRectMouseArea; drag.target: undefined }
PropertyChanges { target: pointRect; x: getSunRiseTime.callWith(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO se nedan PropertyChanges { target: pointRect; x: getSunRiseTime.callWith(pointRect.parent.width, pointRect.width, pointRect.selectedDate) + minutesToTimelineUnits(pointRect.offset) } //TODO se nedan
}, },
State { State {
name: "sunset" name: "sunset"
PropertyChanges { target: triggerImage; source: imageTriggerSunset; opacity: 1 } PropertyChanges { target: triggerImage; source: imageTriggerSunset; opacity: 1 }
PropertyChanges { target: triggerTime; opacity: 0 } PropertyChanges { target: triggerTime; opacity: 0 }
PropertyChanges { target: pointRectMouseArea; drag.target: undefined } PropertyChanges { target: pointRectMouseArea; drag.target: undefined }
PropertyChanges { target: pointRect; x: getSunSetTime.callWith(pointRect.parent.width, pointRect.width) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits PropertyChanges { target: pointRect; x: getSunSetTime.callWith(pointRect.parent.width, pointRect.width, pointRect.selectedDate) + minutesToTimelineUnits(pointRect.offset) } //TODO räkna om till tidsunits
}, },
State { State {
name: "absolute"; when: !pointRectMouseArea.drag.active name: "absolute"; when: !pointRectMouseArea.drag.active
@ -272,8 +256,8 @@ Rectangle{
//print("Different x"); //print("Different x");
point = pointRect.parentPoint; point = pointRect.parentPoint;
} }
//print("ABSOLUTE X-value: " + (point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2)); print("ABSOLUTE X-value: " + (point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2));
//print("AbsoluteHour: " +point.absoluteHour+ " hourSize: " + hourSize + " AbsoluteMinute: " + point.absoluteMinute + " Width: " + point.width); print("AbsoluteHour: " +point.absoluteHour+ " hourSize: " + hourSize + " AbsoluteMinute: " + point.absoluteMinute + " Width: " + point.width);
return point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2; return point.absoluteHour * hourSize + hourSize * (point.absoluteMinute/60) - point.width/2;
} }

View file

@ -11,12 +11,9 @@
focus: true focus: true
Keys.onPressed: { Keys.onPressed: {
tryme(event, "container");
var hours = 0; var hours = 0;
var minutes = 0; var minutes = 0;
if (event.key == Qt.Key_Left) { if (event.key == Qt.Key_Left && actionPoint.triggerstate == "absolute") { //step left, 1 min
//actionPoint.x = actionPoint.x - 1
var minutes = parseInt(inputAbsoluteMinuteText.text, 10); var minutes = parseInt(inputAbsoluteMinuteText.text, 10);
var hours = parseInt(inputAbsoluteHourText.text, 10); var hours = parseInt(inputAbsoluteHourText.text, 10);
if(minutes == 0){ if(minutes == 0){
@ -31,8 +28,7 @@
} }
event.accepted = true; event.accepted = true;
} }
else if (event.key == Qt.Key_Right) { else if (event.key == Qt.Key_Right && actionPoint.triggerstate == "absolute") { //step right, 1 min
//actionPoint.x = actionPoint.x + 1
var minutes = parseInt(inputAbsoluteMinuteText.text, 10); var minutes = parseInt(inputAbsoluteMinuteText.text, 10);
var hours = parseInt(inputAbsoluteHourText.text, 10); var hours = parseInt(inputAbsoluteHourText.text, 10);
if(minutes == 59){ if(minutes == 59){
@ -49,9 +45,7 @@
} }
else if( event.key == Qt.Key_Delete){ else if( event.key == Qt.Key_Delete){
//TODO warning? //TODO warning?
print("DELETING");
container.actionPoint.remove(); container.actionPoint.remove();
} }
else{ else{
return; return;
@ -69,7 +63,7 @@
//create default actionPoint, to avoid null values and binding errors //create default actionPoint, to avoid null values and binding errors
var component = Qt.createComponent("ActionPoint.qml") var component = Qt.createComponent("ActionPoint.qml")
var dynamicPoint = component.createObject(container) var dynamicPoint = component.createObject(container)
dynamicPoint.opacity = 0 //TODO why not use "visible"? Test that... dynamicPoint.opacity = 0
dynamicPoint.width = 0 dynamicPoint.width = 0
dynamicPoint.height = 0 dynamicPoint.height = 0
container.actionPoint = dynamicPoint container.actionPoint = dynamicPoint
@ -88,7 +82,7 @@
container.actionPoint = actionPoint container.actionPoint = actionPoint
var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y); var rootCoordinates = actionPoint.mapToItem(null, actionPoint.x, actionPoint.y);
container.y = rootCoordinates.y + actionPoint.height + 10; container.y = rootCoordinates.y + actionPoint.height + 10; //TODO poistion in other way, too far down in some cases now
container.width = actionPoint.parent.width; container.width = actionPoint.parent.width;
container.x = (actionPoint.parent.parent.width - container.width)/2; container.x = (actionPoint.parent.parent.width - container.width)/2;
container.opacity = 1; container.opacity = 1;
@ -104,8 +98,7 @@
smooth: true smooth: true
radius: 5 radius: 5
//width: 500 //TODO height: 500
height: 500 // typelist.height * 2 + 50
opacity: 0 opacity: 0
Button{ Button{
@ -118,11 +111,6 @@
onClicked: { onClicked: {
container.actionPoint.toggleType(); container.actionPoint.toggleType();
} }
Keys.onLeftPressed: {
debug("Left pressed"); //TODO make it work
}
} }
Button{ Button{
@ -559,13 +547,10 @@
width: weekColumn.width width: weekColumn.width
Column{ Column{
id: "weekColumn" id: "weekColumn"
//anchors.verticalCenter: parent.verticalCenter
//anchors.fill: parent
spacing: 2 spacing: 2
Repeater{ Repeater{
id: weekRepeater id: weekRepeater
model: 7 //actionPoint.daysOfWeek model: 7 //7 days, one week...
//delegate: weekDayDelegate
Rectangle{ Rectangle{
width: 30 width: 30
height: 30 height: 30
@ -582,13 +567,11 @@
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
actionPoint.toggleTickedWeekDay(index) actionPoint.toggleTickedWeekDay(index)
print("Just toggled, now update image: " + actionPoint);
tickBox.source = actionPoint.getTickedImageSource(index) tickBox.source = actionPoint.getTickedImageSource(index)
} }
} }
} }
Text{ Text{
//anchors.fill: parent
anchors.left: tickBox.right anchors.left: tickBox.right
anchors.leftMargin: 10 anchors.leftMargin: 10
text: Scripts.getOffsetWeekdayName(index) text: Scripts.getOffsetWeekdayName(index)
@ -611,9 +594,7 @@
id: closeButton id: closeButton
text: "Close" text: "Close"
anchors.top: weekDayPanel.bottom anchors.top: weekDayPanel.bottom
anchors.horizontalCenter: weekDayPanel.right //horizontalCenter anchors.horizontalCenter: weekDayPanel.right
//y: circleTrigger.y + 30
//x: parent.x + 30
onClicked: { onClicked: {
hide(); hide();
} }
@ -625,20 +606,19 @@
anchors.topMargin: 20 anchors.topMargin: 20
anchors.left: currentType.right anchors.left: currentType.right
anchors.leftMargin: 10 anchors.leftMargin: 10
width: 100 //TODO relative width: 100
height: 100 //TODO relative height: 100
model: typeSelection model: typeSelection
delegate: typeSelectionRow delegate: typeSelectionRow
highlight: Rectangle { color: "lightsteelblue"; radius: 5 } highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
snapMode: ListView.SnapToItem snapMode: ListView.SnapToItem
interactive: false interactive: false
//TODO can these paths be turned into some kind of constants? Import from common file or something?
ListModel{ ListModel{
id: typeSelection id: typeSelection
ListElement{ ListElement{
name: "on" name: "on"
imagesource: "on.png" //TODO cannot use javascript properties here... do in some other way, maybe a list with names here? imagesource: "on.png"
} }
ListElement{ ListElement{
name: "off" name: "off"
@ -683,17 +663,12 @@
width: 30; height: 30 width: 30; height: 30
Image{ Image{
anchors.fill: parent anchors.fill: parent
//anchors.left: typeSelectionText.right
//anchors.leftMargin: 10
//anchors.centerIn: parent
source: imagesource source: imagesource
MouseArea{ MouseArea{
anchors.fill: parent anchors.fill: parent
onClicked: { onClicked: {
//pointRect.focus = true
container.actionPoint.setType(name) container.actionPoint.setType(name)
//typeList.highlight = name
} }
} }
} }
@ -701,10 +676,6 @@
} }
} }
function tryme(event, origin){
print("KEY: " + event.key + " Från: " + origin);
}
function getMinimumOffset(state){ function getMinimumOffset(state){
//TODO this will not work if a value is set to the highest limit, then not reentering scheduler until the sunrise/set has changed so much that the device will be hidden anyway... Not common though //TODO this will not work if a value is set to the highest limit, then not reentering scheduler until the sunrise/set has changed so much that the device will be hidden anyway... Not common though
var minutes = 0; var minutes = 0;
@ -735,6 +706,6 @@
return 0 ; return 0 ;
} }
return 24 * 60 - (parseInt(time[0], 10) * 60 + parseInt(time[1], 10)); return 24 * 60 - (parseInt(time[0], 10) * 60 + parseInt(time[1], 10));
} }
} }

View file

@ -8,10 +8,11 @@ __postInit__ = function() {
com.telldus.schedulersimplegui = function() { com.telldus.schedulersimplegui = function() {
var deviceList; var deviceList;
var view; var view;
var restoredJobsTimerKeys;
var sunData;
function init() { function init() {
view = new com.telldus.qml.view({ view = new com.telldus.qml.view({
addDevice: addDevice,
addJobsToSchedule: addJobsToSchedule, addJobsToSchedule: addJobsToSchedule,
getJob: getJob, getJob: getJob,
getMethodFromState: getMethodFromState, getMethodFromState: getMethodFromState,
@ -21,7 +22,8 @@ com.telldus.schedulersimplegui = function() {
getSunData: getSunData, getSunData: getSunData,
getTypeFromTriggerstate: getTypeFromTriggerstate, getTypeFromTriggerstate: getTypeFromTriggerstate,
getTriggerstateFromType: getTriggerstateFromType, getTriggerstateFromType: getTriggerstateFromType,
restoreJobs: restoreJobs restoreJobs: restoreJobs,
updateSunData: updateSunData
}); });
//devices: //devices:
@ -37,9 +39,8 @@ com.telldus.schedulersimplegui = function() {
//Listen for device-change //Listen for device-change
com.telldus.core.deviceChange.connect(deviceChange); com.telldus.core.deviceChange.connect(deviceChange);
//var storedPoints = loadJobs(); updateSunData(new Date()); //default
//view.setProperty('storedPoints', storedPoints);
//set images: //set images:
view.setProperty("imageTriggerSunrise", "sunrise.png"); view.setProperty("imageTriggerSunrise", "sunrise.png");
view.setProperty("imageTriggerSunset", "sunset.png"); view.setProperty("imageTriggerSunset", "sunset.png");
@ -55,16 +56,14 @@ com.telldus.schedulersimplegui = function() {
view.setProperty("constDeviceRowHeight", 50); view.setProperty("constDeviceRowHeight", 50);
view.setProperty("constDeviceRowWidth", 600); view.setProperty("constDeviceRowWidth", 600);
view.setProperty("constPointWidth", 30); view.setProperty("constPointWidth", 30);
view.setProperty("mainHeight", 700); //TODO get this from somewhere
view.setProperty("mainWidth", 800); //TODO get this from somewhere
view.load("main.qml"); view.load("main.qml");
application.addWidget("scheduler.simple", "icon.png", view); application.addWidget("scheduler.simple", "icon.png", view);
} }
function addDevice() {
deviceList.push({name:'Stallet istallet'});
}
function deviceChange( deviceId, eventType ) { function deviceChange( deviceId, eventType ) {
if (eventType == com.telldus.core.TELLSTICK_DEVICE_ADDED) { if (eventType == com.telldus.core.TELLSTICK_DEVICE_ADDED) {
var item = com.telldus.core.deviceList.getDevice(deviceId); var item = com.telldus.core.deviceList.getDevice(deviceId);
@ -81,6 +80,13 @@ com.telldus.schedulersimplegui = function() {
com.telldus.scheduler.removeJob(deviceTimerKeys[i]); com.telldus.scheduler.removeJob(deviceTimerKeys[i]);
} }
} }
if(restoredJobsTimerKeys != undefined && restoredJobsTimerKeys[deviceId] != undefined){
for(var i=0;i<restoredJobsTimerKeys[deviceId].length;i++){
var waitForMore = (i == restoredJobsTimerKeys[deviceId].length-1) ? "true" : undefined;
com.telldus.scheduler.removeJob(restoredJobsTimerKeys[deviceId][i]);
}
restoredJobsTimerKeys[deviceId] = undefined;
}
//add new schedules: //add new schedules:
var jobs = new Array(); var jobs = new Array();
@ -88,9 +94,7 @@ com.telldus.schedulersimplegui = function() {
var jobtemp = getJob(points[i], callbackFunc); var jobtemp = getJob(points[i], callbackFunc);
jobs.push(jobtemp); jobs.push(jobtemp);
} }
print("Adding some jobs " + jobs.length);
saveJobs(deviceId, jobs); saveJobs(deviceId, jobs);
//return [];
return com.telldus.scheduler.addJobs(jobs); return com.telldus.scheduler.addJobs(jobs);
} }
@ -108,13 +112,14 @@ com.telldus.schedulersimplegui = function() {
function loadJobs(updateLastRun){ function loadJobs(updateLastRun){
var settings = new com.telldus.settings(); var settings = new com.telldus.settings();
var storedJobs = settings.value("jobs", ""); var storedJobs = settings.value("jobs", "");
restoreJobsToSchedule(storedJobs, updateLastRun); //Start timers here restoredJobsTimerKeys = restoreJobsToSchedule(storedJobs, updateLastRun); //Start timers here, save keys so they can be removed if jobs are updated
return storedJobs; return storedJobs;
} }
function restoreJobsToSchedule(storedJobs, updateLastRun){ function restoreJobsToSchedule(storedJobs, updateLastRun){
var jobs = new Array(); var deviceTimerKeys = {};
for(var devicekey in storedJobs){ for(var devicekey in storedJobs){
var jobs = new Array();
for(var i=0;i<storedJobs[devicekey].length;i++){ for(var i=0;i<storedJobs[devicekey].length;i++){
if(storedJobs[devicekey][i] == undefined){ if(storedJobs[devicekey][i] == undefined){
continue; continue;
@ -122,8 +127,11 @@ com.telldus.schedulersimplegui = function() {
var jobtemp = restoreJob(storedJobs[devicekey][i], updateLastRun); var jobtemp = restoreJob(storedJobs[devicekey][i], updateLastRun);
jobs.push(jobtemp); jobs.push(jobtemp);
} }
if(jobs.length > 0){
deviceTimerKeys[devicekey] = com.telldus.scheduler.addJobs(jobs); //have to do this per device, so that the timerkeys are stored for each device
}
} }
return com.telldus.scheduler.addJobs(jobs) return deviceTimerKeys;
} }
function restoreJob(storedJob, updateLastRunInGUI){ function restoreJob(storedJob, updateLastRunInGUI){
@ -141,7 +149,6 @@ com.telldus.schedulersimplegui = function() {
function getJob(pointArray, updateLastRunInGUI){ //deviceId, pointName, startdate, lastrun, pointMethod, pointDimValue, pointTime, pointType, pointFuzzinessBefore, pointFuzzinessAfter, pointOffset, pointDays function getJob(pointArray, updateLastRunInGUI){ //deviceId, pointName, startdate, lastrun, pointMethod, pointDimValue, pointTime, pointType, pointFuzzinessBefore, pointFuzzinessAfter, pointOffset, pointDays
//updateLastRunInGUI: deviceId, day of week, id //updateLastRunInGUI: deviceId, day of week, id
var execFunc = function(job){ print("Custom execute function running"); print("Job: " + job.v.name); var lastRun = new Date().getTime(); updateLastRun(job, lastRun); updateLastRunInGUI(job.v.device, job.v.events[job.v.id + "_0"].d.value, job.v.id, lastRun); return job.executeDefault();}; var execFunc = function(job){ print("Custom execute function running"); print("Job: " + job.v.name); var lastRun = new Date().getTime(); updateLastRun(job, lastRun); updateLastRunInGUI(job.v.device, job.v.events[job.v.id + "_0"].d.value, job.v.id, lastRun); return job.executeDefault();};
print("POINTARRAY3: " + pointArray[3]);
var job = new com.telldus.scheduler.JobRecurringWeek({id: pointArray[13], executeFunc: execFunc, name: pointArray[1], type: com.telldus.scheduler.JOBTYPE_RECURRING_WEEK, startdate: pointArray[2], lastRun: pointArray[3], device: pointArray[0], method: pointArray[4], value: pointArray[5], absoluteTime: pointArray[12]}); var job = new com.telldus.scheduler.JobRecurringWeek({id: pointArray[13], executeFunc: execFunc, name: pointArray[1], type: com.telldus.scheduler.JOBTYPE_RECURRING_WEEK, startdate: pointArray[2], lastRun: pointArray[3], device: pointArray[0], method: pointArray[4], value: pointArray[5], absoluteTime: pointArray[12]});
var event = {}; var event = {};
var pointFuzzinessBefore = (pointArray[8]*60); var pointFuzzinessBefore = (pointArray[8]*60);
@ -160,20 +167,13 @@ com.telldus.schedulersimplegui = function() {
return job; return job;
} }
//Update last run for this job from storage, then store it again
function updateLastRun(job, lastRun){ function updateLastRun(job, lastRun){
//TODO uppdatera både storage och värdet i pointen...
var settings = new com.telldus.settings(); var settings = new com.telldus.settings();
var storedjobs = settings.value("jobs", ""); var storedjobs = settings.value("jobs", "");
//settings.setValue("test", "TESTAR");
print("UPDATING LAST RUN 3 " + storedjobs);
for(var devicekey in storedjobs){ for(var devicekey in storedjobs){
print("Key: " + devicekey);
if(devicekey == job.v.device){ if(devicekey == job.v.device){
print("En bra bit");
for(var i=0;i<storedjobs[devicekey].length;i++){ for(var i=0;i<storedjobs[devicekey].length;i++){
print("GREJ 2: " + storedjobs[devicekey][i].v.id);
print("JMF: " + job.v.id);
if(storedjobs[devicekey][i].v.id == job.v.id){ if(storedjobs[devicekey][i].v.id == job.v.id){
storedjobs[devicekey][i].v.lastRun = lastRun; storedjobs[devicekey][i].v.lastRun = lastRun;
break; break;
@ -184,10 +184,6 @@ com.telldus.schedulersimplegui = function() {
} }
settings.setValue("jobs", storedjobs); settings.setValue("jobs", storedjobs);
print("saveD");
//för alla points denna... device och dag (parentpointens dag, dvs det som är lagrat i job)
//gå igenom punkterna, hitta punkt med korrekt id, uppdatera last run för den...
} }
function getMethodFromState(state){ function getMethodFromState(state){
@ -224,9 +220,14 @@ com.telldus.schedulersimplegui = function() {
return state; return state;
} }
function updateSunData(date){
sunData = com.telldus.suncalculator.riseset(date);
return sunData;
}
function getSun(riseset, rowWidth, pointWidth){ function getSun(riseset, rowWidth, pointWidth){
var date = new Date(); var timevalues = sunData;
var timevalues = com.telldus.suncalculator.riseset(date);
var hourminute; var hourminute;
if(riseset == "rise"){ if(riseset == "rise"){
hourminute = timevalues[0].split(':'); hourminute = timevalues[0].split(':');
@ -239,13 +240,12 @@ com.telldus.schedulersimplegui = function() {
} }
//Raw sun data //Raw sun data
function getSunData(){ function getSunData(date){
var date = new Date; print("GET SUN DATA - can be made more efficient if called often...");
return com.telldus.suncalculator.riseset(date); return com.telldus.suncalculator.riseset(date);
} }
function getSunRiseTime(rowWidth, pointWidth){ function getSunRiseTime(rowWidth, pointWidth){
return getSun("rise", rowWidth, pointWidth); return getSun("rise", rowWidth, pointWidth);
} }

View file

@ -1,32 +1,32 @@
//import QtQuick 1.0 TODO not until 4.7.1 //import QtQuick 1.0 TODO not until 4.7.1
import Qt 4.7 import Qt 4.7
import "schedulerscripts.js" as Scripts import "schedulerscripts.js" as Scripts
import "mainscripts.js" as MainScripts
Item{ Item{
id: main id: main
width: 800 //TODO how? width: mainWidth
height: 700 //TODO how? height: mainHeight
property variant sunData
property int dayListHeaderHeight: 15 property int dayListHeaderHeight: 15
property variant selectedDate: Scripts.getCurrentDate(); //Maybe just today
property variant sunData: MainScripts.getSunData();
Component.onCompleted: { Component.onCompleted: {
var dynamicDay = 0; var dynamicDay = 0;
var previousDayEndsWithPoint = null; //previous day, nothing to begin with var previousDayEndsWithPoint = null; //previous day, nothing to begin with
var startday = new Date(); var startday = new Date();
startday.setDate(startday.getDate() - 6); startday.setDate(startday.getDate() - 6);
for(var i=0;i<7;i++){ //One week, TODO dynamic for(var i=0;i<7;i++){ //One week
dynamicDay = dayListViewComponent.createObject(mainContent) dynamicDay = dayListViewComponent.createObject(mainContent)
dynamicDay.state = "hiddenLeft"; dynamicDay.state = "hiddenLeft";
var currentDay = new Date(startday); var currentDay = new Date(startday);
currentDay.setDate(startday.getDate() + i); currentDay.setDate(startday.getDate() + i);
dynamicDay.daydate = currentDay; dynamicDay.daydate = currentDay;
//TODO previousDayEndsWith =
Scripts.addDay(dynamicDay); Scripts.addDay(dynamicDay);
Scripts.updateDeviceIndex(); //TODO, don't run in every iteration
} }
dynamicDay.state = "visible" //set last one as visible dynamicDay.state = "visible" //set last day (today) as visible
weekDayText.text = Scripts.getCurrentDayName() weekDayText.text = Scripts.getCurrentDayName()
//Scripts.updateDeviceIndex(); Scripts.updateDeviceIndex();
Scripts.setLoading(); Scripts.setLoading();
var updateLastRunFunc = updateLastRun; var updateLastRunFunc = updateLastRun;
restoreJobs.callWith(updateLastRunFunc); restoreJobs.callWith(updateLastRunFunc);
@ -41,61 +41,26 @@ import "schedulerscripts.js" as Scripts
width: parent.width width: parent.width
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
Rectangle{ NavButton{
id: leftarrow
anchors.right: weekDayText.left anchors.right: weekDayText.left
anchors.verticalCenter: weekDayText.verticalCenter anchors.verticalCenter: weekDayText.verticalCenter
height: 20 arrowText: "<-"
width: 20 onClicked: {
border.color: "red" Scripts.decrementCurrentDay();
Text{
anchors.centerIn: parent
text: "<-"
}
MouseArea{
anchors.fill: parent
onClicked: {
//step to prev weekday
dialog.hide()
Scripts.updateEndsWith()
Scripts.decrementCurrentDay()
weekDayText.text = Scripts.getCurrentDayName()
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
//mainListView.currentIndex = mainListView.currentIndex - 1
}
} }
} }
Text{ Text{
id: weekDayText id: weekDayText
anchors.centerIn: parent anchors.centerIn: parent
//text: ""
/*states: State{
name: "loaded";
PropertyChanges{ target: weekDayText; text: Scripts.getCurrentDay().dayName }
}
*/
} }
Rectangle{ NavButton{
id: rightarrow
anchors.left: weekDayText.right anchors.left: weekDayText.right
anchors.verticalCenter: weekDayText.verticalCenter anchors.verticalCenter: weekDayText.verticalCenter
height: 20 arrowText: "->"
width: 20 onClicked: {
border.color: "red" Scripts.incrementCurrentDay();
Text{
anchors.centerIn: parent
text: "->"
}
MouseArea{
anchors.fill: parent
onClicked: {
//step to next weekday
dialog.hide()
Scripts.updateEndsWith() //mainListView)
Scripts.incrementCurrentDay()
weekDayText.text = Scripts.getCurrentDayName()
//mainListView.positionViewAtIndex(mainListView.currentIndex, ListView.Center)
//mainListView.currentIndex = mainListView.currentIndex + 1
}
} }
} }
} }
@ -108,9 +73,6 @@ import "schedulerscripts.js" as Scripts
Column{ Column{
id: mainHeader id: mainHeader
//anchors.left: parent.left
//anchors.top: parent.top
//anchors.topMargin: dayListHeaderHeight
width: main.width - constDeviceRowWidth width: main.width - constDeviceRowWidth
spacing: 0 spacing: 0
@ -148,6 +110,7 @@ import "schedulerscripts.js" as Scripts
//TODO implement setProperty if this is to be stored... or do something else... modelData.setProperty(index, isEnabled, modelData.isEnabled == "enabled" ? "disabled" : "enabled"); //TODO implement setProperty if this is to be stored... or do something else... modelData.setProperty(index, isEnabled, modelData.isEnabled == "enabled" ? "disabled" : "enabled");
//TODO also implement disabled/enabled for all (deviceEnabled=false on all) and per point (set isPoint=false and opacity=0.4)... //TODO also implement disabled/enabled for all (deviceEnabled=false on all) and per point (set isPoint=false and opacity=0.4)...
//take that value into consideration when saving and sending jobs for execution //take that value into consideration when saving and sending jobs for execution
//else, remove this button
deviceNameRect.isEnabled = deviceNameRect.isEnabled == "enabled" ? "disabled" : "enabled" deviceNameRect.isEnabled = deviceNameRect.isEnabled == "enabled" ? "disabled" : "enabled"
Scripts.deviceEnabled(modelData.id, deviceNameRect.isEnabled); Scripts.deviceEnabled(modelData.id, deviceNameRect.isEnabled);
} }
@ -159,10 +122,8 @@ import "schedulerscripts.js" as Scripts
Rectangle{ Rectangle{
id: mainContent id: mainContent
height: 700 //TODO height: mainHeight
width: constDeviceRowWidth //TODO width: constDeviceRowWidth
//anchors.top: parent.top
//anchors.left: mainListViewHeaderColumn.right
clip: true clip: true
z: 50 z: 50
} }
@ -175,200 +136,173 @@ import "schedulerscripts.js" as Scripts
id: dayListView id: dayListView
property date daydate property date daydate
width: constDeviceRowWidth width: constDeviceRowWidth
height: 700 //TODO height: mainHeight
//anchors.fill: parent
model: deviceModel model: deviceModel
delegate: listRow delegate: listRow
//focus: true
//footer: addButtonComponent //TODO move...
header: timeline header: timeline
snapMode: ListView.SnapToItem snapMode: ListView.SnapToItem
interactive: false //no scroll between devices at the moment interactive: false //no scroll between devices at the moment
//anchors.top: parent.top;
//state: "hidden" //default
states: [ states: [
State { State {
name: "hiddenRight"; //when: parent.left != null name: "hiddenRight";
AnchorChanges { target: dayListView; anchors.left: parent.right; anchors.right: undefined } AnchorChanges { target: dayListView; anchors.left: parent.right; anchors.right: undefined }
//PropertyChanges { target: dayListView; opacity: 0 }
}, },
State { State {
name: "hiddenLeft"; //when: parent.left != null name: "hiddenLeft";
AnchorChanges { target: dayListView; anchors.left: undefined; anchors.right: parent.left } AnchorChanges { target: dayListView; anchors.left: undefined; anchors.right: parent.left }
//PropertyChanges { target: dayListView; opacity: 0 }
}, },
State { State {
name: "visible"; //when: parent.left != null name: "visible";
PropertyChanges { target: dayListView; opacity: 1 } PropertyChanges { target: dayListView; opacity: 1 }
AnchorChanges { target: dayListView; anchors.right: undefined; anchors.left: parent.left } AnchorChanges { target: dayListView; anchors.right: undefined; anchors.left: parent.left }
} }
] ]
onChildrenChanged: {
//TODO REMOVE
print("-------------- CHILDREN CHANGED ----------------");
}
transitions: [ transitions: [
Transition { Transition {
from: "hiddenLeft" from: "hiddenLeft"
to: "visible" to: "visible"
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 }
}, },
Transition { Transition {
from: "visible" from: "visible"
to: "hiddenRight" to: "hiddenRight"
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 }
}, },
Transition { Transition {
from: "visible" from: "visible"
to: "hiddenLeft" to: "hiddenLeft"
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 }
}, },
Transition { Transition {
from: "hiddenRight" from: "hiddenRight"
to: "visible" to: "visible"
AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 } //PropertyAnimation { properties: "x"; duration: 1000; easing.type: Easing.InOutQuad } AnchorAnimation { easing.type: Easing.InOutQuad; duration: 1000 }
} }
] ]
//TODO transition between state, animation
} }
} }
Component{ Component{
id: listRow id: listRow
/* Rectangle { id: "deviceRow"; border.color: "blue"; width: constDeviceRowWidth; height: constDeviceRowHeight;
Row{ clip: true
id: mainRow property variant endPoint: undefined
property int deviceId: modelData.id;
property alias continuingBar: continuingBar
property variant selectedDate: main.selectedDate
state: "enabled"
width: constDeviceRowWidth //parent.width; //TODO relative states: [
height: constDeviceRowHeight State{
/* name: "enabled"
Rectangle { PropertyChanges{ target: deviceRow; opacity: 1 }
border.color: "red"; width: 100; height:parent.height; },
Text{ State{
anchors.verticalCenter: parent.verticalCenter name: "disabled"
anchors.horizontalCenter: parent.horizontalCenter PropertyChanges{ target: deviceRow; opacity: 0.4 }
text: modelData.name
} }
} ]
*/
Rectangle { id: "deviceRow"; border.color: "blue"; width: constDeviceRowWidth; height: constDeviceRowHeight; MouseArea {
clip: true id: deviceMouseArea
property variant endPoint: undefined //: Scripts.getEndsWith(deviceRow.children, index, modelData.id); anchors.fill: parent
property int deviceId: modelData.id; onClicked: {
property alias continuingBar: continuingBar
state: "enabled"
states: [
State{
name: "enabled"
PropertyChanges{ target: deviceRow; opacity: 1 }
},
State{
name: "disabled"
PropertyChanges{ target: deviceRow; opacity: 0.4 }
}
]
MouseArea {
id: deviceMouseArea
anchors.fill: parent
//hoverEnabled: true
//TODO ändra muspekaren kanske?
//onEntered: parent.border.color = onHoverColor
//onExited: parent.border.color = borderColor
onClicked: {
//Scripts.debugPrintDeviceIndex();
Scripts.setChanged(deviceId, true);
Scripts.updateDeviceIndex(); //TODO why is this needed here? (but it is, adding points to empty device will get wrong state otherwise)
//print("Mainrow: " + mainRow.parent.children[0].height);
var component = Qt.createComponent("ActionPoint.qml")
var dynamicPoint = component.createObject(deviceRow)
//dynamicPoint.x = mouseX - dynamicPoint.width/2 //xposition
var hourMinute = dynamicPoint.getTimeFromPosition(mouse.x)
dynamicPoint.absoluteHour = hourMinute[0]
dynamicPoint.absoluteMinute = hourMinute[1]
dynamicPoint.x = dynamicPoint.getAbsoluteXValue();
dynamicPoint.border.color = "blue"
//TODO different states depending on the device
dynamicPoint.addActiveState("on");
dynamicPoint.addActiveState("off");
dynamicPoint.addActiveState("dim");
dynamicPoint.addActiveState("bell");
//dynamicPoint.setFirstState("dim"); //when type is a stored value
dynamicPoint.setFirstState();
dynamicPoint.pointId = new Date().getTime(); //just needed for storage update
deviceRow.updateContinuingBars();
dialog.show(dynamicPoint)
}
}
ActionBar{
id: "continuingBar"
hangOnToPoint: deviceRow
firstBar: "true"
state: "continuing"
}
ListView.onAdd: SequentialAnimation {
PropertyAction { target: mainRow; property: "height"; value: 0 }
NumberAnimation { target: mainRow; property: "height"; to: 50; duration: 250; easing.type: Easing.InOutQuad }
}
function hasPoints(){
return Scripts.hasBarChangingPoints(deviceRow.children);
}
function updateContinuingBars(){
Scripts.updateEndsWith();
}
function getDeviceRow(dayIndex, deviceId){
print("CALLING getDeviceRow");
return Scripts.getDeviceRow(dayIndex, deviceId);
}
function createChildPoint(index, pointRect, deviceId){
print("CREATING child point");
return Scripts.createChildPoint(index, pointRect, deviceId);
}
function setChanged(){
Scripts.setChanged(deviceId, true); Scripts.setChanged(deviceId, true);
} //TODO really needed? Scripts.updateDeviceIndex(); //needed here, adding points to empty device will get wrong state otherwise
var component = Qt.createComponent("ActionPoint.qml")
function isLoading(){ var dynamicPoint = component.createObject(deviceRow)
return Scripts.isLoading(); var hourMinute = dynamicPoint.getTimeFromPosition(mouse.x)
dynamicPoint.absoluteHour = hourMinute[0]
dynamicPoint.absoluteMinute = hourMinute[1]
dynamicPoint.x = dynamicPoint.getAbsoluteXValue();
dynamicPoint.border.color = "blue"
//TODO different states depending on the device
dynamicPoint.addActiveState("on");
dynamicPoint.addActiveState("off");
dynamicPoint.addActiveState("dim");
dynamicPoint.addActiveState("bell");
dynamicPoint.setFirstState();
dynamicPoint.pointId = new Date().getTime(); //just needed for storage update
deviceRow.updateContinuingBars();
dialog.show(dynamicPoint)
} }
} }
//}
ActionBar{
id: "continuingBar"
hangOnToPoint: deviceRow
firstBar: "true"
state: "continuing"
}
ListView.onAdd: SequentialAnimation {
PropertyAction { target: mainRow; property: "height"; value: 0 }
NumberAnimation { target: mainRow; property: "height"; to: 50; duration: 250; easing.type: Easing.InOutQuad }
}
//device functions:
function createChildPoint(index, pointRect, deviceId){
return Scripts.createChildPoint(index, pointRect, deviceId);
}
function getDeviceRow(dayIndex, deviceId){
return Scripts.getDeviceRow(dayIndex, deviceId);
}
function hasPoints(){
return Scripts.hasBarChangingPoints(deviceRow.children);
}
function isLoading(){
return Scripts.isLoading();
}
function setChanged(){
Scripts.setChanged(deviceId, true);
}
function updateContinuingBars(){
Scripts.updateEndsWith();
}
}
} }
Component{ Component{
id: timeline id: timeline
Item{ Item{
width: constDeviceRowWidth //TODO parent.width id: timelinerange
width: constDeviceRowWidth
height: dayListHeaderHeight height: dayListHeaderHeight
property int morningDarkWidth: MainScripts.getMorningDarkWidth()
property double morningDarkStart: MainScripts.getMorningDarkStart()
property int eveningDarkWidth: MainScripts.getEveningDarkWidth()
property double eveningDarkStart: MainScripts.getEveningDarkStart()
property variant currentDate: main.selectedDate;
onCurrentDateChanged: {
//update values
timelinerange.morningDarkWidth = MainScripts.getMorningDarkWidth()
timelinerange.morningDarkStart = MainScripts.getMorningDarkStart()
timelinerange.eveningDarkWidth = MainScripts.getEveningDarkWidth()
timelinerange.eveningDarkStart = MainScripts.getEveningDarkStart()
}
Rectangle{ Rectangle{
id: morningDark id: morningDark
color: "black" color: "black"
height: parent.height height: parent.height
border.width: 0 border.width: 0
width: getMorningDarkWidth() width: timelinerange.morningDarkWidth
opacity: 0.1 opacity: 0.1
x: getMorningDarkStart() x: timelinerange.morningDarkStart
} }
Rectangle{ Rectangle{
@ -376,9 +310,9 @@ import "schedulerscripts.js" as Scripts
color: "black" color: "black"
height: parent.height height: parent.height
border.width: 0 border.width: 0
width: getEveningDarkWidth() width: timelinerange.eveningDarkWidth
opacity: 0.1 opacity: 0.1
x: getEveningDarkStart() x: timelinerange.eveningDarkStart
} }
Rectangle{ Rectangle{
@ -386,13 +320,12 @@ import "schedulerscripts.js" as Scripts
border.color: "red" border.color: "red"
Row{ Row{
//x: 100
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenterOffset: parent.width/24 anchors.horizontalCenterOffset: parent.width/24
width: parent.width //listRow.width width: parent.width
height: parent.height height: parent.height
spacing: (parent.width-24)/24 //before: -124 spacing: (parent.width-24)/24
Repeater{ Repeater{
model:24 model:24
Rectangle{ Rectangle{
@ -418,116 +351,20 @@ import "schedulerscripts.js" as Scripts
} }
} }
/* Not in use, adding all devices always instead
Component{
id: addButtonComponent
Row {
id: addButton
Rectangle {
height: 20
width: 100
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: 30
property color buttonColor: "lightgrey"
Text{
text: "Add an item"
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
anchors.margins: 2
}
MouseArea {
id: buttonMouseArea
anchors.fill: parent
onClicked: {
addDevice.call()
}
}
color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
}
}
}
*/
Dialog { Dialog {
id: dialog id: dialog
z: 150 z: 150
} }
//TODO move functions, and test odd cases: function mainGetMethodFromState(state){
function getEveningDarkStart(){ return getMethodFromState.callWith(state);
if(!willSunSet){
return 0;
}
if(Scripts.isMidnightDark()){
return sunToTimeUnits(main.sunData[1]); // + 100;
}
else{
return 0;
}
} }
function getMorningDarkStart(){ function mainGetTypeFromTriggerstate(triggerstate){
//TODO the day of the year when the sun "begins" not to set, will it work then? return getTypeFromTriggerstate.callWith(triggerstate);
if(!willSunSet){
return 0;
}
if(Scripts.isMidnightDark()){
return 0; //100; //TODO constants
}
else{
return sunToTimeUnits(main.sunData[1]); // + 100; //TODO constants
}
} }
function getEveningDarkWidth(){
if(!willSunSet){
return 0;
}
if(Scripts.isMidnightDark()){
return constDeviceRowWidth - sunToTimeUnits(main.sunData[1]); //(main.width - 100) - sunToTimeUnits(main.sunData[1]); //TODO constant or something
}
else{
return 0;
}
}
function getMorningDarkWidth(){
if(!willSunSet){
return 0;
}
if(Scripts.isMidnightDark()){
return sunToTimeUnits(main.sunData[0]);
}
else{
return sunToTimeUnits(main.sunData[1]) - sunToTimeUnits(main.sunData[0]);
}
}
function willSunSet(){
if(main.sunData == undefined){
main.sunData = getSunData.call();
}
return !(main.sunData[2] && main.sunData[2] != "")
}
function sunToTimeUnits(suntime){
suntime = suntime.split(':');
var hourSize = constDeviceRowWidth/24; //(main.width - 100)/24; //TODO constant or something?
return hourSize * suntime[0] + hourSize * suntime[1]/60;
}
function saveAll(){ function saveAll(){
print("Save all and reset jobs");
//var jobs = new Array();
//var points = new Array();
var days = Scripts.getDays(); var days = Scripts.getDays();
if(dialog.dialogOpacity == 1){ if(dialog.dialogOpacity == 1){
Scripts.setChanged(dialog.actionPoint.deviceRow.deviceId, true); //set the devicerow that the currently visible dialog is connected to as dirty Scripts.setChanged(dialog.actionPoint.deviceRow.deviceId, true); //set the devicerow that the currently visible dialog is connected to as dirty
@ -537,20 +374,17 @@ import "schedulerscripts.js" as Scripts
var deviceId = deviceModel.get(i).id; var deviceId = deviceModel.get(i).id;
if(!Scripts.hasChanged(deviceId)){ if(!Scripts.hasChanged(deviceId)){
//no point has been updated, removed or added, ignore this device //no point has been updated, removed or added, ignore this device
print("Not updated: " + deviceId);
continue; continue;
} }
Scripts.setChanged(deviceId, false); //reset hasChanged-status Scripts.setChanged(deviceId, false); //reset hasChanged-status
print("Updated: " + deviceId);
if(Scripts.deviceIsEnabled(deviceId)){ //if device is disabled, don't add any points to schedule (but remove current) if(Scripts.deviceIsEnabled(deviceId)){ //if device is disabled, don't add any points to schedule (but remove current)
print("Device is enabled: " + deviceId);
for(var j=0;j<days.length;j++){ for(var j=0;j<days.length;j++){
var row = Scripts.getDeviceRow(days[j].daydate.getDay(), deviceId); var row = Scripts.getDeviceRow(days[j].daydate.getDay(), deviceId);
for(var k=0;k<row.children.length;k++){ for(var k=0;k<row.children.length;k++){
var point = row.children[k]; var point = row.children[k];
if(point.isPoint && point.parentPoint == undefined){ //and not disabled if(point.isPoint && point.parentPoint == undefined){ //and not disabled
points.push(pointToArray(point)); points.push(MainScripts.pointToArray(point));
} }
} }
} }
@ -563,45 +397,18 @@ import "schedulerscripts.js" as Scripts
} }
} }
function updateLastRun(deviceId, day, pointId, lastRun){ function updateCurrentDay(){
print("deviceid: " + deviceId); main.selectedDate = Scripts.getCurrentDate();
print("day: " + day); main.sunData = updateSunData.callWith(main.selectedDate);
print("pointid: " + pointId); MainScripts.updateSunData(main.sunData);
Scripts.updateLastRun(deviceId, day, pointId, lastRun); weekDayText.text = Scripts.getCurrentDayName();
} }
function pointToArray(point){ //TODO another way than using arrays... function updateEndsWith(){
var deviceId = point.deviceRow.deviceId; //not really in use yet Scripts.updateEndsWith();
var pointName = "Job_" + deviceId; }
var startdate = new Date(); //startdate, not in use, always "now"
var pointDimValue = point.dimvalue * (255/100); function updateLastRun(deviceId, day, pointId, lastRun){
var pointMethod = getMethodFromState.callWith(point.state); Scripts.updateLastRun(deviceId, day, pointId, lastRun);
var pointId = point.pointId;
var lastRun = point.lastRun;
print("LASTRUN pointToArray: " + lastRun);
var pointTime = point.absoluteHour * 3600 + point.absoluteMinute * 60;
var absolutePointTime = pointTime;
var pointType = getTypeFromTriggerstate.callWith(point.triggerstate);
if(point.triggerstate == "sunrise"){
var suntime = main.sunData[0].split(':');
pointTime = suntime[0] * 3600 + suntime[1] * 60;
}
else if(point.triggerstate == "sunset"){
var suntime = main.sunData[1].split(':');
pointTime = suntime[0] * 3600 + suntime[1] * 60;
}
var pointFuzzinessBefore = point.fuzzyBefore;
var pointFuzzinessAfter = point.fuzzyAfter;
var pointOffset = point.triggerstate == "absolute" ? 0 : point.offset;
var pointDays = new Array();
pointDays.push(point.deviceRow.parent.parent.daydate.getDay());
var childPoints = point.getChildPoints();
for(var child in childPoints){
pointDays.push(childPoints[child].deviceRow.parent.parent.daydate.getDay()); //different per event
print("GOT DAY " + childPoints[child].deviceRow.parent.parent.daydate.getDay());
}
return new Array(deviceId, pointName, startdate, lastRun, pointMethod, pointDimValue, pointTime, pointType, pointFuzzinessBefore, pointFuzzinessAfter, pointOffset, pointDays, absolutePointTime, pointId);
} }
} }

View file

@ -55,6 +55,7 @@ function addDay(day){
} }
function decrementCurrentDay(){ function decrementCurrentDay(){
print("Currentdayindex: " + currentDayIndex);
days[currentDayIndex].state = "hiddenRight"; days[currentDayIndex].state = "hiddenRight";
var workDate = days[currentDayIndex].daydate; var workDate = days[currentDayIndex].daydate;
workDate.setDate(workDate.getDate() - 7); workDate.setDate(workDate.getDate() - 7);
@ -73,6 +74,15 @@ function getCurrentDay(){
return days[currentDayIndex]; return days[currentDayIndex];
} }
function getCurrentDate(){
if(days.length < 7){
//not initiated yet
return new Date(); //now
}
var date = new Date(days[currentDayIndex].daydate);
return date;
}
function getCurrentDayName(){ function getCurrentDayName(){
var day = getCurrentDay().daydate; var day = getCurrentDay().daydate;
return weekday_name_array[day.getDay()] + " " + day.getDate(); return weekday_name_array[day.getDay()] + " " + day.getDate();
@ -186,19 +196,7 @@ function getPreviousState(currentPointRect){
return prevPoint.state; return prevPoint.state;
} }
function isMidnightDark(){
if(main.sunData == undefined){
main.sunData = getSunData.call();
}
var sunrise = main.sunData[0].split(':');;
var sunset = main.sunData[1].split(':');
if(sunset[0] < sunrise[0] || (sunset[0] == sunrise[0] && sunset[1] < sunrise[1])){
return false;
}
return true;
}
function pad(number, length) { function pad(number, length) {
@ -596,11 +594,11 @@ function createChildPoint(index, pointRect, deviceId){
dynamicPoint.fuzzyBefore = pointRect.fuzzyBefore; dynamicPoint.fuzzyBefore = pointRect.fuzzyBefore;
dynamicPoint.fuzzyAfter = pointRect.fuzzyAfter; dynamicPoint.fuzzyAfter = pointRect.fuzzyAfter;
dynamicPoint.offset = pointRect.offset; dynamicPoint.offset = pointRect.offset;
dynamicPoint.triggerstate = pointRect.triggerstate;
dynamicPoint.dimvalue = pointRect.dimvalue; dynamicPoint.dimvalue = pointRect.dimvalue;
dynamicPoint.parentPoint = pointRect dynamicPoint.parentPoint = pointRect
dynamicPoint.x = dynamicPoint.getAbsoluteXValue(); dynamicPoint.x = dynamicPoint.getAbsoluteXValue();
dynamicPoint.triggerstate = pointRect.triggerstate;
dynamicPoint.border.color = "blue" dynamicPoint.border.color = "blue"
dynamicPoint.setActiveStates(pointRect.getActiveStates()); dynamicPoint.setActiveStates(pointRect.getActiveStates());