| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var service_ftm = new Subscription("FTM_CONTROL/FTU_LIST");
|
|---|
| 4 |
|
|---|
| 5 | // Make sure that we receive a 'Yes, we are connected' event
|
|---|
| 6 | service_ftm.get(5000);
|
|---|
| 7 |
|
|---|
| 8 | // Wait for the format string to be available
|
|---|
| 9 | // FIXME: Timeout
|
|---|
| 10 | while (!dim.send("FTM_CONTROL"))
|
|---|
| 11 | v8.sleep();
|
|---|
| 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 | console.out("Problems in the FTU communication found.");
|
|---|
| 23 | console.out("Send command to disable all FTUs.");
|
|---|
| 24 | console.out(" => Power cycle needed.");
|
|---|
| 25 |
|
|---|
| 26 | dim.send("FTM_CONTOL/ENABLE_FTU", -1, false);
|
|---|
| 27 | throw new Error("CrateReset[FTU]");
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | // Signal success by closing the connection
|
|---|
| 31 | service_ftm.close();
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | // Send ping (request FTU status)
|
|---|
| 35 | dim.send("FTM_CONTROL/PING");
|
|---|
| 36 |
|
|---|
| 37 | // Wait for 1 second for the answer
|
|---|
| 38 | var timeout = new Thread(1000, function(){ if (service_ftm.isOpen) throw new Error(""); });
|
|---|
| 39 | while (service_ftm.isOpen)
|
|---|
| 40 | v8.sleep();
|
|---|
| 41 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.