Changeset 17012 for trunk/FACT++
- Timestamp:
- 08/19/13 12:56:27 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/scripts/doCrateReset.js
r16875 r17012 12 12 include('scripts/CheckStates.js'); 13 13 14 var crate =14 var crates = 15 15 [ 16 16 $['camera']=='true' || $['crate0']=='true', … … 20 20 ]; 21 21 22 var camera = $['camera']=='true';22 include('scripts/crateReset.js'); 23 23 24 var cnt = 0; 25 for (var i=0; i<4; i++) 26 if (crate[i]) 27 cnt++; 28 29 if (cnt==0) 30 { 31 console.out("No crate to reset."); 32 exit(); 33 } 34 35 console.out("Checking availability of servers..."); 36 37 var table = 38 [ 39 [ "MCP" ], 40 [ "FTM_CONTROL" ], 41 [ "FAD_CONTROL" ], 42 ]; 43 if (!checkStates(table, 3000)) 44 throw new Error("Either MCP, FTM_CONTROL or FAD_CONTROL not online."); 45 46 // No data taking should be in progress 47 // Trigger must be switched off 48 49 checkSend(["MCP", "FAD_CONTROL", "FTM_CONTROL" ]); 50 51 52 var mcp = dim.state("MCP"); 53 if (mcp.name=="TriggerOn" || mcp.state=="TakingData") 54 dim.send("MCP/STOP"); 55 if (mcp.name.substr(0,7)=="kConfig") 56 dim.send("MCP/RESET"); 57 if (dim.state("FTM_CONTROL").name=="TriggerOn") 58 dim.send("FTM_CONTROL/STOP_TRIGGER"); 59 60 /* 61 var table = 62 [ 63 [ "MCP", [ "Idle", "Connected" ]], 64 [ "FTM_CONTROL", [ "Idle" ] ], 65 ]; 66 checkStates(table); 67 */ 68 69 //dim.send("FTM_CONTROL/RESET_CONFIGURE"); 70 //dim.send("FTM_CONTROL/STOP_TRIGGER"); 71 72 //if (dim.state("FAD_CONTROL").name=="RunInProgress") 73 // dim.send("FAD_CONTROL/CLOSE_OPEN_FILES"); 74 75 //if (fadstate=="Configuring1" || fadstate=="Configuring2" || fadstate=="Configured") 76 // dim.send("FAD_CONTROL/RESET_CONFIGURE"); 77 //v8.timeout(5000, function() { if (dim.state("FAD_CONTROL").index<5) return true; }); 78 79 console.out("Checking status of servers..."); 80 81 var table = 82 [ 83 [ "MCP", [ "Idle", "Connected" ]], 84 [ "FTM_CONTROL", [ "Valid" ] ], 85 [ "FAD_CONTROL", [ "Disengaged", "Disconnected", "Connecting", "Connected" ] ], 86 ]; 87 if (!checkStates(table)) 88 throw new Error("Either MCP, FTM_CONTROL or FAD_CONTROL not in a state in which it ought to be."); 89 90 // FTUs must be switched off 91 92 console.out("Disable FTUs..."); 93 94 //checkSend(["FTM_CONTROL"]); 95 dim.send("FTM_CONTROL/ENABLE_FTU", -1, false); 96 v8.sleep(1000); 97 98 // Boards in the crates must be disconnected 99 100 //checkSend(["FAD_CONTROL"]); 101 102 if (dim.state("FAD_CONTROL").name=="Connecting" || dim.state("FAD_CONTROL").name=="Connected") 103 for (var i=0; i<10; i++) 104 { 105 for (var j=0; j<4; j++) 106 if (crate[j]) 107 { 108 console.out("Sending DISCONNECT "+(j*10+i)); 109 dim.send("FAD_CONTROL/DISCONNECT", j*10+i); 110 } 111 } 112 113 v8.sleep(2000); 114 if (!checkStates([[ "FAD_CONTROL", [ "Disengaged", "Disconnected", "Connected" ] ]])) 115 throw new Error("FAD_CONTROL neither Disengaged, Disconnected not Connected."); 116 117 118 // Reset crates 119 120 if (camera) 121 dim.send("FTM_CONTROL/RESET_CAMERA"); 122 else 123 { 124 for (var i=0; i<4; i++) 125 if (crate[i]) 126 { 127 console.out("Sending RESET_CRATE "+i); 128 dim.send("FTM_CONTROL/RESET_CRATE", i); 129 } 130 } 131 132 // We have to wait a bit 133 134 v8.sleep(3200); 135 136 // Reconnect all boards 137 138 if (dim.state("FAD_CONTROL").name=="Disengaged") 139 { 140 dim.send("Waiting 38s for crates to finish reset."); 141 v8.sleep(38000); 142 dim.send("FAD_CONTROL", "START"); 143 } 144 else 145 for (var i=0; i<10; i++) 146 { 147 v8.sleep(3200); 148 for (var j=0; j<4; j++) 149 if (crate[j]) 150 { 151 console.out("Sending CONNECT "+(j*10+i)); 152 dim.send("FAD_CONTROL/CONNECT", j*10+i); 153 } 154 } 155 156 157 // Reconnect all FTUs 158 159 console.out("Enable FTUs..."); 160 161 v8.sleep(1000); 162 dim.send("FTM_CONTROL/ENABLE_FTU", -1, true); 163 v8.sleep(3000); 164 dim.send("FTM_CONTROL/PING"); 165 v8.sleep(1000); 166 167 dim.wait("FAD_CONTROL", "Connected", 3000); 168 169 // Done 170 171 console.out("Crate reset finished."); 24 crateReset(crates);
Note:
See TracChangeset
for help on using the changeset viewer.