Rev 1237 | Rev 1239 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1237 | Rev 1238 | ||
|---|---|---|---|
| Line 99... | Line 99... | ||
| 99 | { |
99 | { |
| 100 | log(this.myName + ":" + this.myId + "> Failed to initialize, Name-config missing from config.\n"); |
100 | log(this.myName + ":" + this.myId + "> Failed to initialize, Name-config missing from config.\n"); |
| 101 | return; |
101 | return; |
| 102 | } |
102 | } |
| 103 | this.shortName = this.myInitialArguments["ShortName"]; |
103 | this.shortName = this.myInitialArguments["ShortName"]; |
| - | 104 | ||
| - | 105 | /* Start interval timer for sending timestamp to network. Arguments are the callback function and time in milliseconds |
|
| - | 106 | used to make sure an eth-node gets its init packet */ |
|
| - | 107 | this.myInterval = new Interval(function() { self.sendTimeStamp() }, 10000); |
|
| 104 | 108 | ||
| 105 | this.screenSaverCnt = 0; |
109 | this.screenSaverCnt = 0; |
| 106 | this.mainScreenCnt = 0; |
110 | this.mainScreenCnt = 0; |
| 107 | this.exchangeUpdateCnt = exchangeUpdateTimeout-10; |
111 | this.exchangeUpdateCnt = exchangeUpdateTimeout-10; |
| 108 | 112 | ||
| Line 363... | Line 367... | ||
| 363 | { |
367 | { |
| 364 | //FIXME: constraints? |
368 | //FIXME: constraints? |
| 365 | if (this.bookFromTime.getHours() < 23) |
369 | if (this.bookFromTime.getHours() < 23) |
| 366 | { |
370 | { |
| 367 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() + bookingIncrease); |
371 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() + bookingIncrease); |
| 368 | } |
372 | } |
| 369 | } |
373 | } |
| 370 | 374 | ||
| 371 | Display.prototype.decBookTimeFrom = function() |
375 | Display.prototype.decBookTimeFrom = function() |
| 372 | { |
376 | { |
| 373 | //FIXME: constraints? |
377 | //FIXME: constraints? |
| 374 | var now = new Date(); |
378 | var now = new Date(); |
| 375 | if (this.bookFromTime.getHours() >= now.getHours()) |
379 | if (this.bookFromTime.getHours() >= now.getHours()) |
| 376 | { |
380 | { |
| 377 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() - bookingIncrease); |
381 | this.bookFromTime.setMinutes(this.bookFromTime.getMinutes() - bookingIncrease); |
| 378 | } |
382 | } |
| 379 | } |
383 | } |
| 380 | 384 | ||
| 381 | Display.prototype.setBookTimeFrom = function() |
385 | Display.prototype.setBookTimeFrom = function() |
| 382 | { |
386 | { |
| 383 | this.currentMenuItem.displayData[1] = " <"+this.bookFromTime.getTimeShortFormated()+"> "; |
387 | this.currentMenuItem.displayData[1] = " <"+this.bookFromTime.getTimeShortFormated()+"> "; |
| 384 | } |
388 | } |
| 385 | 389 | ||
| 386 | Display.prototype.setBookTimeTo = function() |
390 | Display.prototype.setBookTimeTo = function() |
| 387 | { |
391 | { |
| 388 | this.currentMenuItem.displayData[1] = " <"+this.bookToTime.getTimeShortFormated()+"> "; |
392 | this.currentMenuItem.displayData[1] = " <"+this.bookToTime.getTimeShortFormated()+"> "; |
| 389 | } |
393 | } |
| 390 | 394 | ||
| 391 | Display.prototype.chooseBookTimeTo = function() |
395 | Display.prototype.chooseBookTimeTo = function() |
| 392 | { |
396 | { |
| 393 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - <" |
397 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - <" |
| 394 | +this.bookToTime.getTimeShortFormated()+"> "; |
398 | +this.bookToTime.getTimeShortFormated()+"> "; |
| 395 | } |
399 | } |
| 396 | 400 | ||
| 397 | Display.prototype.chooseBookTimeFrom = function() |
401 | Display.prototype.chooseBookTimeFrom = function() |
| 398 | { |
402 | { |
| 399 | this.currentMenuItem.displayData[0] = " <"+this.bookFromTime.getTimeShortFormated()+"> - " |
403 | this.currentMenuItem.displayData[0] = " <"+this.bookFromTime.getTimeShortFormated()+"> - " |
| 400 | +this.bookToTime.getTimeShortFormated()+" "; |
404 | +this.bookToTime.getTimeShortFormated()+" "; |
| 401 | } |
405 | } |
| 402 | 406 | ||
| 403 | Display.prototype.setBookTime = function() |
407 | Display.prototype.setBookTime = function() |
| 404 | { |
408 | { |
| 405 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - " |
409 | this.currentMenuItem.displayData[0] = " "+this.bookFromTime.getTimeShortFormated()+" - " |
| 406 | +this.bookToTime.getTimeShortFormated()+" "; |
410 | +this.bookToTime.getTimeShortFormated()+" "; |
| 407 | } |
411 | } |
| 408 | 412 | ||
| 409 | Display.prototype.updateStatusMenuItem = function() |
413 | Display.prototype.updateStatusMenuItem = function() |
| Line 432... | Line 436... | ||
| 432 | //log("callback: "+shortname+" \n"); |
436 | //log("callback: "+shortname+" \n"); |
| 433 | if (shortname == this.shortName) |
437 | if (shortname == this.shortName) |
| 434 | { |
438 | { |
| 435 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
439 | //FIXME check if data contains error tag and error message, print to log and keep previous data? |
| 436 | if (data.error) |
440 | if (data.error) |
| 437 | { |
441 | { |
| 438 | log("Display: got this error from exchange.php: " + data.error + "\n"); |
442 | log("Display: got this error from exchange.php: " + data.error + "\n"); |
| 439 | } |
443 | } |
| 440 | else |
444 | else |
| 441 | { |
445 | { |
| 442 | this.exchangeData = data; |
446 | this.exchangeData = data; |
| 443 | this.createCalendarMenu(); |
447 | this.createCalendarMenu(); |
| 444 | } |
448 | } |
| 445 | } |
449 | } |
| 446 | } |
450 | } |
| 447 | 451 | ||
| 448 | /* this function parses calendar data from exchange-script and creates a menu */ |
452 | /* this function parses calendar data from exchange-script and creates a menu */ |
| 449 | Display.prototype.createCalendarMenu = function() |
453 | Display.prototype.createCalendarMenu = function() |
| 450 | { |
454 | { |
| 451 | /* This is used for function declarations like the callbacks below */ |
455 | /* This is used for function declarations like the callbacks below */ |
| Line 490... | Line 494... | ||
| 490 | 494 | ||
| 491 | } |
495 | } |
| 492 | /* to link in the newly created menuitems with exchangeinformation the display must be showing |
496 | /* to link in the newly created menuitems with exchangeinformation the display must be showing |
| 493 | either the statusmenu or the bookingmenu */ |
497 | either the statusmenu or the bookingmenu */ |
| 494 | if (this.currentMenuItem == this.statusMenuItem || this.currentMenuItem == this.bookMenuItem || this.currentMenuItem == this.bookResultMenuItem) |
498 | if (this.currentMenuItem == this.statusMenuItem || this.currentMenuItem == this.bookMenuItem || this.currentMenuItem == this.bookResultMenuItem) |
| 495 | { |
499 | { |
| 496 | /* if there is one or more exchangemenuitems */ |
500 | /* if there is one or more exchangemenuitems */ |
| 497 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
501 | if (this.exchangeCalendarFirstMenuItem && this.exchangeCalendarLastMenuItem) |
| 498 | { |
502 | { |
| 499 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
503 | this.statusMenuItem.setNextItem(this.exchangeCalendarFirstMenuItem); |
| 500 | this.bookMenuItem.setPrevItem(this.exchangeCalendarLastMenuItem); |
504 | this.bookMenuItem.setPrevItem(this.exchangeCalendarLastMenuItem); |
| 501 | } |
505 | } |
| 502 | /* if not then link statusmenu to bookingmenu */ |
506 | /* if not then link statusmenu to bookingmenu */ |
| 503 | else |
507 | else |
| 504 | { |
508 | { |
| 505 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
509 | this.statusMenuItem.setNextItem(this.bookMenuItem); |
| 506 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
510 | this.bookMenuItem.setPrevItem(this.statusMenuItem); |
| 507 | } |
511 | } |
| 508 | } |
512 | } |
| 509 | } |
513 | } |
| 510 | } |
514 | } |
| 511 | 515 | ||
| 512 | Display.prototype.replaceAumlauts = function(intext) |
516 | Display.prototype.replaceAumlauts = function(intext) |
| 513 | { |
517 | { |
| 514 | intext = intext.replace(/Å/, String.fromCharCode(1)); |
518 | intext = intext.replace(/Å/, String.fromCharCode(1)); |
| 515 | intext = intext.replace(/å/, String.fromCharCode(0)); |
519 | intext = intext.replace(/å/, String.fromCharCode(0)); |
| 516 | intext = intext.replace(/Ä/, String.fromCharCode(2)); |
520 | intext = intext.replace(/Ä/, String.fromCharCode(2)); |
| Line 521... | Line 525... | ||
| 521 | //intext = intext.replace(/,/, "."); |
525 | //intext = intext.replace(/,/, "."); |
| 522 | return intext; |
526 | return intext; |
| 523 | } |
527 | } |
| 524 | 528 | ||
| 525 | Display.prototype.softPwmOnline = function() |
529 | Display.prototype.softPwmOnline = function() |
| 526 | { |
530 | { |
| 527 | } |
531 | } |
| 528 | 532 | ||
| 529 | Display.prototype.rotaryOnline = function() |
533 | Display.prototype.rotaryOnline = function() |
| 530 | { |
534 | { |
| 531 | } |
535 | } |
| 532 | 536 | ||
| 533 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
537 | Display.prototype.rotaryPosUpdate = function(SwitchId) |
| 534 | { |
538 | { |
| 535 | this.screenSaverCnt = 0; |
539 | this.screenSaverCnt = 0; |
| 536 | this.mainScreenCnt = 0; |
540 | this.mainScreenCnt = 0; |
| 537 | for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++) |
541 | for (var i = 0; i < this.myRotaryService.getSteps(SwitchId); i++) |
| 538 | { |
542 | { |
| 539 | if (this.myRotaryService.getDirection(SwitchId) == "Clockwise") |
543 | if (this.myRotaryService.getDirection(SwitchId) == "Clockwise") |
| 540 | { |
544 | { |
| 541 | if (this.currentMenuItem.doRight) |
545 | if (this.currentMenuItem.doRight) |
| 542 | { |
546 | { |
| 543 | this.currentMenuItem.doRight(); |
547 | this.currentMenuItem.doRight(); |
| 544 | } |
548 | } |
| 545 | } |
549 | } |
| 546 | else |
550 | else |
| 547 | { |
551 | { |
| 548 | if (this.currentMenuItem.doLeft) |
552 | if (this.currentMenuItem.doLeft) |
| 549 | { |
553 | { |
| 550 | this.currentMenuItem.doLeft(); |
554 | this.currentMenuItem.doLeft(); |
| 551 | } |
555 | } |
| 552 | } |
556 | } |
| 553 | } |
557 | } |
| 554 | 558 | ||
| 555 | this.updateDisplay(); |
559 | this.updateDisplay(); |
| 556 | } |
560 | } |
| 557 | 561 | ||
| Line 564... | Line 568... | ||
| 564 | if (this.currentMenuItem.doPress) |
568 | if (this.currentMenuItem.doPress) |
| 565 | { |
569 | { |
| 566 | this.currentMenuItem.doPress(); |
570 | this.currentMenuItem.doPress(); |
| 567 | } |
571 | } |
| 568 | this.updateDisplay(); |
572 | this.updateDisplay(); |
| 569 | } |
573 | } |
| 570 | } |
574 | } |
| 571 | 575 | ||
| 572 | Display.prototype.updateDisplay = function() |
576 | Display.prototype.updateDisplay = function() |
| 573 | { |
577 | { |
| 574 | /* see if the current menuitem wants to update itself */ |
578 | /* see if the current menuitem wants to update itself */ |
| 575 | if (this.currentMenuItem.doUpdate) |
579 | if (this.currentMenuItem.doUpdate) |
| 576 | { |
580 | { |
| 577 | this.currentMenuItem.doUpdate(); |
581 | this.currentMenuItem.doUpdate(); |
| 578 | } |
582 | } |
| 579 | 583 | ||
| 580 | /* Clear the LCD screen */ |
584 | /* Clear the LCD screen */ |
| 581 | //this.myLCDService.clearScreen(); |
585 | //this.myLCDService.clearScreen(); |
| 582 | 586 | ||
| 583 | /* send the data for the current menuitem to display */ |
587 | /* send the data for the current menuitem to display */ |
| 584 | for (var i = 0; i < this.currentMenuItem.displayData.length; i++) |
588 | for (var i = 0; i < this.currentMenuItem.displayData.length; i++) |
| 585 | { |
589 | { |
| 586 | this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]); |
590 | this.myLCDService.printText(0, i, this.currentMenuItem.displayData[i]); |
| 587 | } |
591 | } |
| 588 | 592 | ||
| 589 | } |
593 | } |
| 590 | 594 | ||
| 591 | Display.prototype.lcdCenterText = function(text) |
595 | Display.prototype.lcdCenterText = function(text) |
| 592 | { |
596 | { |
| Line 607... | Line 611... | ||
| 607 | this.myInterval.stop(); |
611 | this.myInterval.stop(); |
| 608 | } |
612 | } |
| 609 | } |
613 | } |
| 610 | 614 | ||
| 611 | Display.prototype.lcdOnline = function() |
615 | Display.prototype.lcdOnline = function() |
| 612 | { |
616 | { |
| 613 | /* If service is not online do nothing */ |
617 | /* If service is not online do nothing */ |
| 614 | if (this.myLCDService.isOnline()) |
618 | if (this.myLCDService.isOnline()) |
| 615 | { |
619 | { |
| 616 | /* Clear the LCD screen */ |
620 | /* Clear the LCD screen */ |
| 617 | this.myLCDService.clearScreen(); |
621 | this.myLCDService.clearScreen(); |
| 618 | /* Set backlight to max */ |
622 | /* Set backlight to max */ |
| 619 | this.myLCDService.setBacklight(255); |
623 | this.myLCDService.setBacklight(255); |
| 620 | 624 | ||
| 621 | /* If we have no interval timer running start it */ |
625 | /* If we have no interval timer running start it */ |
| 622 | if (this.myInterval == null) |
626 | if (this.myInterval == null) |
| 623 | { |
627 | { |
| 624 | var self = this; |
628 | var self = this; |
| 625 | 629 | ||
| 626 | /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */ |
630 | /* Start interval timer for our printout. Arguments are the callback function and time in milliseconds */ |
| 627 | this.myInterval = new Interval(function() { self.timerUpdate() }, 5000); |
631 | this.myInterval = new Interval(function() { self.timerUpdate() }, 5000); |
| 628 | } |
632 | } |
| 629 | 633 | ||
| 630 | this.myInterval.start(); |
634 | this.myInterval.start(); |
| 631 | 635 | ||
| 632 | this.timerUpdate(); |
636 | this.timerUpdate(); |
| 633 | } |
637 | } |
| 634 | } |
638 | } |
| 635 | 639 | ||
| 636 | Display.prototype.setLED = function(red, green, blue) |
640 | Display.prototype.setLED = function(red, green, blue) |
| 637 | { |
641 | { |
| - | 642 | ||
| - | 643 | } |
|
| - | 644 | ||
| - | 645 | Display.prototype.sendTimeStamp = function() |
|
| - | 646 | { |
|
| - | 647 | var canMessage = new CanNMTMessage("nmt", "Time"); |
|
| - | 648 | canMessage.send(); |
|
| 638 | 649 | ||
| 639 | } |
650 | } |
| 640 | 651 | ||
| 641 | Display.prototype.timerUpdate = function() |
652 | Display.prototype.timerUpdate = function() |
| 642 | { |
653 | { |