|
Last change
on this file since 18374 was 18223, checked in by dneise, 10 years ago |
|
made library and function from script with side-effects. function is called in Startup.js now.
|
|
File size:
1.9 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | if (!("CheckFTU" in this)){
|
|---|
| 4 | var CheckFTU = {
|
|---|
| 5 | checkFTU : function(){
|
|---|
| 6 | console.out("Checking FTU: start");
|
|---|
| 7 |
|
|---|
| 8 | var service_ftm = new Subscription("FTM_CONTROL/FTU_LIST");
|
|---|
| 9 |
|
|---|
| 10 | // Make sure that we receive a 'Yes, we are connected and names are available' event
|
|---|
| 11 | service_ftm.get(5000);
|
|---|
| 12 |
|
|---|
| 13 | // Check for all FTUs to be connected when the next event arrives
|
|---|
| 14 | service_ftm.onchange = function(event)
|
|---|
| 15 | {
|
|---|
| 16 | var ping = event.obj['Ping'];
|
|---|
| 17 | for (var i=0; i<40; i++)
|
|---|
| 18 | {
|
|---|
| 19 | if (ping[i]==1)
|
|---|
| 20 | continue;
|
|---|
| 21 |
|
|---|
| 22 | var str = "";
|
|---|
| 23 | for (var h=0; h<4; h++)
|
|---|
| 24 | {
|
|---|
| 25 | for (var w=0; w<10; w++)
|
|---|
| 26 | str += ping[h*10+w];
|
|---|
| 27 | if (h!=3)
|
|---|
| 28 | str += '|';
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | console.out(str)
|
|---|
| 32 |
|
|---|
| 33 | console.out("Problems in the FTU communication found.");
|
|---|
| 34 | console.out("Send command to disable all FTUs.");
|
|---|
| 35 | console.out(" => Crate reset needed.");
|
|---|
| 36 |
|
|---|
| 37 | dim.send("FTM_CONTROL/ENABLE_FTU", -1, false);
|
|---|
| 38 | throw new Error("CrateReset[FTU]");
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | // Signal success by closing the connection
|
|---|
| 42 | service_ftm.close();
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | // Send ping (request FTU status)
|
|---|
| 46 | dim.send("FTM_CONTROL/PING");
|
|---|
| 47 |
|
|---|
| 48 | // Wait for 1 second for the answer
|
|---|
| 49 | var timeout = new Thread(3000, function(){ if (service_ftm.isOpen) throw new Error("Could not check that all FTUs are ok within 3s."); });
|
|---|
| 50 | while (service_ftm.isOpen)
|
|---|
| 51 | v8.sleep();
|
|---|
| 52 |
|
|---|
| 53 | console.out("Checking FTU: done");
|
|---|
| 54 | console.out("");
|
|---|
| 55 | },
|
|---|
| 56 | };
|
|---|
| 57 | }
|
|---|
| 58 | else{
|
|---|
| 59 | console.out("multiple include of 'CheckFTU.js'");
|
|---|
| 60 | } |
|---|
Note:
See
TracBrowser
for help on using the repository browser.