source: branches/fscctrl_safety_limits/scripts/CheckFTU.js@ 18801

Last change on this file since 18801 was 16794, checked in by tbretz, 11 years ago
output some information so that it is aparent which FTU gives the problem.
File size: 1.2 KB
Line 
1'use strict';
2
3var service_ftm = new Subscription("FTM_CONTROL/FTU_LIST");
4
5// Make sure that we receive a 'Yes, we are connected and names are available' event
6service_ftm.get(5000);
7
8// Check for all FTUs to be connected when the next event arrives
9service_ftm.onchange = function(event)
10{
11 var ping = event.obj['Ping'];
12 for (var i=0; i<40; i++)
13 {
14 if (ping[i]==1)
15 continue;
16
17 var str = "";
18 for (var h=0; h<4; h++)
19 {
20 for (var w=0; w<10; w++)
21 str += ping[h*10+w];
22 if (h!=3)
23 str += '|';
24 }
25
26 console.out(str)
27
28 console.out("Problems in the FTU communication found.");
29 console.out("Send command to disable all FTUs.");
30 console.out(" => Crate reset needed.");
31
32 dim.send("FTM_CONTROL/ENABLE_FTU", -1, false);
33 throw new Error("CrateReset[FTU]");
34 }
35
36 // Signal success by closing the connection
37 service_ftm.close();
38}
39
40// Send ping (request FTU status)
41dim.send("FTM_CONTROL/PING");
42
43// Wait for 1 second for the answer
44var timeout = new Thread(3000, function(){ if (service_ftm.isOpen) throw new Error("Could not check that all FTUs are ok within 3s."); });
45while (service_ftm.isOpen)
46 v8.sleep();
47
Note: See TracBrowser for help on using the repository browser.