Rev 1256 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1256 | Rev 1335 | ||
|---|---|---|---|
| Line 109... | Line 109... | ||
| 109 | 109 | ||
| 110 | /* Start interval timer for sending timestamp to network. Arguments are the callback function and time in milliseconds |
110 | /* Start interval timer for sending timestamp to network. Arguments are the callback function and time in milliseconds |
| 111 | used to make sure an eth-node gets its init packet (600s) */ |
111 | used to make sure an eth-node gets its init packet (600s) */ |
| 112 | this.myIntervalAlways = new Interval(function() { self.sendTimeStamp() }, 600000); |
112 | this.myIntervalAlways = new Interval(function() { self.sendTimeStamp() }, 600000); |
| 113 | this.myIntervalAlways.start(); |
113 | this.myIntervalAlways.start(); |
| - | 114 | ||
| - | 115 | this.myInterval = new Interval(function() { self.timerUpdate() }, 5000); |
|
| - | 116 | this.myInterval.start(); |
|
| 114 | 117 | ||
| 115 | this.screenSaverCnt = 0; |
118 | this.screenSaverCnt = 0; |
| 116 | this.mainScreenCnt = 0; |
119 | this.mainScreenCnt = 0; |
| 117 | this.exchangeUpdateCnt = exchangeUpdateTimeout-10; |
120 | this.exchangeUpdateCnt = exchangeUpdateTimeout-10; |
| 118 | 121 | ||
| Line 236... | Line 239... | ||
| 236 | menuChooseCancel.setDescItem(this.bookMenuItem); |
239 | menuChooseCancel.setDescItem(this.bookMenuItem); |
| 237 | /* set the function that shall be executed when knob is turned */ |
240 | /* set the function that shall be executed when knob is turned */ |
| 238 | menuChooseCancel.doRight = function(args) { self.changeToNext(); }; |
241 | menuChooseCancel.doRight = function(args) { self.changeToNext(); }; |
| 239 | menuChooseCancel.doLeft = function(args) { self.changeToPrev(); }; |
242 | menuChooseCancel.doLeft = function(args) { self.changeToPrev(); }; |
| 240 | menuChooseCancel.doPress = function(args) { self.changeToDesc(); }; |
243 | menuChooseCancel.doPress = function(args) { self.changeToDesc(); }; |
| 241 | 244 | ||
| 242 | /* connect the items as a linked list */ |
245 | /* connect the items as a linked list */ |
| 243 | menuChooseFrom.setNextItem(menuChooseTo); |
246 | menuChooseFrom.setNextItem(menuChooseTo); |
| 244 | menuChooseFrom.setPrevItem(menuChooseCancel); |
247 | menuChooseFrom.setPrevItem(menuChooseCancel); |
| 245 | /* set the function that shall be executed when knob is turned */ |
248 | /* set the function that shall be executed when knob is turned */ |
| 246 | menuChooseFrom.doRight = function(args) { self.changeToNext(); }; |
249 | menuChooseFrom.doRight = function(args) { self.changeToNext(); }; |
| 247 | menuChooseFrom.doLeft = function(args) { self.changeToPrev(); }; |
250 | menuChooseFrom.doLeft = function(args) { self.changeToPrev(); }; |
| 248 | menuChooseFrom.doPress = function(args) { self.changeToDesc(); }; |
251 | menuChooseFrom.doPress = function(args) { self.changeToDesc(); }; |
| 249 | 252 | ||
| 250 | /* create the menuitem where you can modify the to-time */ |
253 | /* create the menuitem where you can modify the to-time */ |
| 251 | var menuSetTo = new MenuItem(this); |
254 | var menuSetTo = new MenuItem(this); |
| 252 | menuSetTo.doUpdate = function(args) { self.setBookTimeTo(); }; |
255 | menuSetTo.doUpdate = function(args) { self.setBookTimeTo(); }; |
| 253 | menuSetTo.displayData[0] = this.lcdCenterText("Set end time"); |
256 | menuSetTo.displayData[0] = this.lcdCenterText("Set end time"); |
| 254 | menuSetTo.doRight = function(args) { self.incBookTimeTo(); }; |
257 | menuSetTo.doRight = function(args) { self.incBookTimeTo(); }; |
| Line 268... | Line 271... | ||
| 268 | menuChooseFrom.setDescItem(menuSetFrom); |
271 | menuChooseFrom.setDescItem(menuSetFrom); |
| 269 | 272 | ||
| 270 | } |
273 | } |
| 271 | 274 | ||
| 272 | Display.prototype.exchangeCalendarBookCallback = function(shortname, data) |
275 | Display.prototype.exchangeCalendarBookCallback = function(shortname, data) |
| 273 | { |
276 | { |
| 274 | if (shortname == this.shortName) |
277 | if (shortname == this.shortName) |
| 275 | { |
278 | { |
| 276 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
279 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
| 277 | if (data.result) |
280 | if (data.result) |
| 278 | { |
281 | { |
| 279 | if (data.error) |
282 | if (data.error) |
| 280 | { |
283 | { |
| 281 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking failed"); |
284 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking failed"); |
| 282 | log("Display:"+this.myId+"> Got this error from exchange server: " + data.error + "\n"); |
285 | log("Display:"+this.myId+"> Got this error from exchange server: " + data.error + "\n"); |
| 283 | } |
286 | } |
| 284 | else |
287 | else |
| 285 | { |
288 | { |
| 286 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking succeeded"); |
289 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking succeeded"); |
| Line 301... | Line 304... | ||
| 301 | } |
304 | } |
| 302 | 305 | ||
| 303 | Display.prototype.doBooking = function() |
306 | Display.prototype.doBooking = function() |
| 304 | { |
307 | { |
| 305 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking..."); |
308 | this.bookResultMenuItem.displayData[0] = this.lcdCenterText("Booking..."); |
| 306 | if (this.currentMenuItem.descItem) |
309 | if (this.currentMenuItem.descItem) |
| 307 | { |
310 | { |
| 308 | this.currentMenuItem = this.currentMenuItem.descItem; |
311 | this.currentMenuItem = this.currentMenuItem.descItem; |
| 309 | } |
312 | } |
| 310 | //this.changeToDesc(); |
313 | //this.changeToDesc(); |
| 311 | 314 | ||
| Line 324... | Line 327... | ||
| 324 | //this.bookToTime.setHours(8); |
327 | //this.bookToTime.setHours(8); |
| 325 | if (this.bookFromTime.getMinutes() < 30) |
328 | if (this.bookFromTime.getMinutes() < 30) |
| 326 | { |
329 | { |
| 327 | this.bookFromTime.setMinutes(0); |
330 | this.bookFromTime.setMinutes(0); |
| 328 | this.bookToTime.setMinutes(30); |
331 | this.bookToTime.setMinutes(30); |
| 329 | } |
332 | } |
| 330 | else |
333 | else |
| 331 | { |
334 | { |
| 332 | this.bookFromTime.setMinutes(30); |
335 | this.bookFromTime.setMinutes(30); |
| 333 | this.bookToTime.setHours(this.bookToTime.getHours()+1); |
336 | this.bookToTime.setHours(this.bookToTime.getHours()+1); |
| 334 | this.bookToTime.setMinutes(0); |
337 | this.bookToTime.setMinutes(0); |
| 335 | } |
338 | } |
| 336 | 339 | ||
| 337 | this.currentMenuItem = this.currentMenuItem.descItem; |
340 | this.currentMenuItem = this.currentMenuItem.descItem; |
| 338 | } |
341 | } |
| 339 | 342 | ||
| 340 | Display.prototype.changeToDesc = function() |
343 | Display.prototype.changeToDesc = function() |
| 341 | { |
344 | { |
| 342 | if (this.currentMenuItem.descItem) |
345 | if (this.currentMenuItem.descItem) |
| 343 | { |
346 | { |
| 344 | this.currentMenuItem = this.currentMenuItem.descItem; |
347 | this.currentMenuItem = this.currentMenuItem.descItem; |
| 345 | } |
348 | } |
| 346 | } |
349 | } |
| 347 | 350 | ||
| 348 | Display.prototype.changeToNext = function() |
351 | Display.prototype.changeToNext = function() |
| 349 | { |
352 | { |
| 350 | if (this.currentMenuItem.nextItem) |
353 | if (this.currentMenuItem.nextItem) |
| 351 | { |
354 | { |
| 352 | this.currentMenuItem = this.currentMenuItem.nextItem; |
355 | this.currentMenuItem = this.currentMenuItem.nextItem; |
| 353 | } |
356 | } |
| 354 | } |
357 | } |
| 355 | 358 | ||
| 356 | Display.prototype.changeToPrev = function() |
359 | Display.prototype.changeToPrev = function() |
| 357 | { |
360 | { |
| 358 | if (this.currentMenuItem.prevItem) |
361 | if (this.currentMenuItem.prevItem) |
| 359 | { |
362 | { |
| 360 | this.currentMenuItem = this.currentMenuItem.prevItem; |
363 | this.currentMenuItem = this.currentMenuItem.prevItem; |
| 361 | } |
364 | } |
| 362 | } |
365 | } |
| 363 | 366 | ||
| 364 | Display.prototype.incBookTimeTo = function() |
367 | Display.prototype.incBookTimeTo = function() |
| 365 | { |
368 | { |
| 366 | //FIXME: constraints? |
369 | //FIXME: constraints? |
| 367 | if (this.bookToTime.getHours() < 23) |
370 | if (this.bookToTime.getHours() < 23) |
| 368 | { |
371 | { |
| 369 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() + bookingIncrease); |
372 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() + bookingIncrease); |
| 370 | } |
373 | } |
| 371 | } |
374 | } |
| 372 | 375 | ||
| 373 | Display.prototype.decBookTimeTo = function() |
376 | Display.prototype.decBookTimeTo = function() |
| 374 | { |
377 | { |
| 375 | //FIXME: constraints? |
378 | //FIXME: constraints? |
| 376 | var now = new Date(); |
379 | var now = new Date(); |
| 377 | if (this.bookToTime.getHours() >= now.getHours()) |
380 | if (this.bookToTime.getHours() >= now.getHours()) |
| 378 | { |
381 | { |
| 379 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() - bookingIncrease); |
382 | this.bookToTime.setMinutes(this.bookToTime.getMinutes() - bookingIncrease); |
| 380 | } |
383 | } |
| 381 | } |
384 | } |
| 382 | 385 | ||
| 383 | Display.prototype.incBookTimeFrom = function() |
386 | Display.prototype.incBookTimeFrom = function() |
| Line 405... | Line 408... | ||
| 405 | } |
408 | } |
| 406 | 409 | ||
| 407 | Display.prototype.setBookTimeTo = function() |
410 | Display.prototype.setBookTimeTo = function() |
| 408 | { |
411 | { |
| 409 | this.currentMenuItem.displayData[1] = " <"+this.bookToTime.getTimeShortFormated()+"> "; |
412 | this.currentMenuItem.displayData[1] = " <"+this.bookToTime.getTimeShortFormated()+"> "; |
| 410 | } |
413 | } |
| 411 | 414 | ||
| 412 | Display.prototype.chooseBookTimeTo = function() |
415 | Display.prototype.chooseBookTimeTo = function() |
| 413 | { |
416 | { |
| 414 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - <" |
417 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - <" |
| 415 | +this.bookToTime.getTimeShortFormated()+"> "; |
418 | +this.bookToTime.getTimeShortFormated()+"> "; |
| Line 430... | Line 433... | ||
| 430 | Display.prototype.updateStatusMenuItem = function() |
433 | Display.prototype.updateStatusMenuItem = function() |
| 431 | { |
434 | { |
| 432 | var date = new Date(); |
435 | var date = new Date(); |
| 433 | var dateAndTime = "" + date.getTimeShortFormated(); |
436 | var dateAndTime = "" + date.getTimeShortFormated(); |
| 434 | this.statusMenuItem.displayData[1] = this.lcdCenterText(dateAndTime); |
437 | this.statusMenuItem.displayData[1] = this.lcdCenterText(dateAndTime); |
| 435 | } |
438 | } |
| 436 | 439 | ||
| 437 | Display.prototype.updateBookMenuItem = function() |
440 | Display.prototype.updateBookMenuItem = function() |
| 438 | { |
441 | { |
| 439 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
442 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
| 440 | { |
443 | { |
| 441 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
444 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
| 442 | this.bookMenuItem.setPrevItem(this.exchangeCalendarLastMenuItem); |
445 | this.bookMenuItem.setPrevItem(this.exchangeCalendarLastMenuItem); |
| 443 | } |
446 | } |
| 444 | else |
447 | else |
| 445 | { |
448 | { |
| 446 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
449 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
| 447 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
450 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
| 448 | } |
451 | } |
| 449 | } |
452 | } |
| 450 | 453 | ||
| Line 454... | Line 457... | ||
| 454 | { |
457 | { |
| 455 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
458 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
| 456 | if (data.error) |
459 | if (data.error) |
| 457 | { |
460 | { |
| 458 | log("Display:"+this.myId+"> got this error from exchange.php: " + data.error + "\n"); |
461 | log("Display:"+this.myId+"> got this error from exchange.php: " + data.error + "\n"); |
| 459 | } |
462 | } |
| 460 | else |
463 | else |
| 461 | { |
464 | { |
| 462 | this.exchangeData = data; |
465 | this.exchangeData = data; |
| 463 | this.createCalendarMenu(); |
466 | this.createCalendarMenu(); |
| 464 | } |
467 | } |
| 465 | } |
468 | } |
| 466 | } |
469 | } |
| Line 488... | Line 491... | ||
| 488 | menu.doLeft = function(args) { self.changeToPrev(); }; |
491 | menu.doLeft = function(args) { self.changeToPrev(); }; |
| 489 | 492 | ||
| 490 | if (i == 0) |
493 | if (i == 0) |
| 491 | { |
494 | { |
| 492 | this.exchangeCalendarFirstMenuItem = menu; |
495 | this.exchangeCalendarFirstMenuItem = menu; |
| 493 | } |
496 | } |
| 494 | else |
497 | else |
| 495 | { |
498 | { |
| 496 | menu.setPrevItem(lastMenuItem); |
499 | menu.setPrevItem(lastMenuItem); |
| 497 | lastMenuItem.setNextItem(menu); |
500 | lastMenuItem.setNextItem(menu); |
| 498 | } |
501 | } |
| 499 | 502 | ||
| 500 | lastMenuItem = menu; |
503 | lastMenuItem = menu; |
| 501 | } |
504 | } |
| 502 | if (lastMenuItem) |
505 | if (lastMenuItem) |
| 503 | { |
506 | { |
| 504 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
507 | this.exchangeCalendarLastMenuItem = lastMenuItem; |
| 505 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
508 | this.exchangeCalendarLastMenuItem.setNextItem(this.bookMenuItem); |
| 506 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
509 | this.exchangeCalendarFirstMenuItem.setPrevItem(this.statusMenuItem); |
| Line 616... | Line 619... | ||
| 616 | return returnText; |
619 | return returnText; |
| 617 | } |
620 | } |
| 618 | 621 | ||
| 619 | Display.prototype.lcdOffline = function() |
622 | Display.prototype.lcdOffline = function() |
| 620 | { |
623 | { |
| 621 | /* If we have no interval timer running do nothing */ |
- | |
| 622 | if (this.myInterval != null) |
- | |
| 623 | { |
- | |
| 624 | /* Stop the interval */ |
- | |
| 625 | this.myInterval.stop(); |
- | |
| 626 | } |
- | |
| 627 | } |
624 | } |
| 628 | 625 | ||
| 629 | Display.prototype.lcdOnline = function() |
626 | Display.prototype.lcdOnline = function() |
| 630 | { |
627 | { |
| 631 | /* If service is not online do nothing */ |
628 | /* If service is not online do nothing */ |
| 632 | if (this.myLCDService.isOnline()) |
629 | if (this.myLCDService.isOnline()) |
| 633 | { |
630 | { |
| 634 | /* Clear the LCD screen */ |
631 | /* Clear the LCD screen */ |
| 635 | this.myLCDService.clearScreen(); |
632 | this.myLCDService.clearScreen(); |
| 636 | /* Set backlight to max */ |
633 | /* Set backlight to max */ |
| 637 | this.myLCDService.setBacklight(255); |
634 | this.myLCDService.setBacklight(255); |
| 638 | - | ||
| 639 | /* If we have no interval timer running start it */ |
- | |
| 640 | if (this.myInterval == null) |
- | |
| 641 | { |
- | |
| 642 | var self = this; |
- | |
| 643 | - | ||
| 644 | /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */ |
- | |
| 645 | this.myInterval = new Interval(function() { self.timerUpdate() }, 5000); |
- | |
| 646 | } |
- | |
| 647 | - | ||
| 648 | this.myInterval.start(); |
- | |
| 649 | 635 | ||
| 650 | this.timerUpdate(); |
636 | this.timerUpdate(); |
| 651 | } |
637 | } |
| 652 | } |
638 | } |
| 653 | Display.prototype.setLEDtoCalendar = function() |
639 | Display.prototype.setLEDtoCalendar = function() |