source: branches/FACT++_scripts_refactoring/closed_lid_ratescan.js

Last change on this file was 18220, checked in by dneise, 9 years ago
Don't know what these modifications are for, but they are really old. so I check them in.
File size: 3.6 KB
Line 
1voltageOff = function()
2{
3 var state = dim.state("BIAS_CONTROL").name;
4
5 if (state=="Disconnected")
6 {
7 console.out(" Voltage off: bias crate disconnected!");
8 return;
9 }
10
11 // check of feedback has to be switched on
12 var isOn = state=="VoltageOn" || state=="Ramping";
13 if (isOn)
14 {
15 dim.log("Switching voltage off.");
16
17 if (dim.state("FTM_CONTROL").name=="TriggerOn")
18 {
19 dim.send("FTM_CONTROL/STOP_TRIGGER");
20 dim.wait("FTM_CONTROL", "Valid", 3000);
21 }
22
23 // Supress the possibility that the bias control is
24 // ramping and will reject the command to switch the
25 // voltage off
26 //dim.send("FEEDBACK/STOP");
27 //dim.wait("FEEDBACK", "Calibrated", 3000);
28
29 // Make sure we are not in Ramping anymore
30 //dim.wait("BIAS_CONTROL", "VoltageOn", 3000);
31
32 // Switch voltage off
33 dim.send("BIAS_CONTROL/SET_ZERO_VOLTAGE");
34 }
35
36 dim.wait("BIAS_CONTROL", "VoltageOff", 60000); // FIXME: 30000?
37 dim.wait("FEEDBACK", "Calibrated", 3000);
38
39 // FEEDBACK stays in CurrentCtrl when Voltage is off but output enabled
40 // dim.wait("FEEDBACK", "CurrentCtrlIdle", 1000);
41
42 if (isOn)
43 dim.log("Voltage off.");
44}
45
46waitForVoltageOn = function()
47{
48 // Avoid output if condition is already fulfilled
49 dim.log("Waiting for voltage to be stable.");
50
51 function func()
52 {
53 if (this.ok==true)
54 return true;
55 }
56
57 var now = new Date();
58
59 this.last = undefined;
60 this.ok = false;
61 v8.timeout(4*60000, func, this); // FIMXE: Remove 4!
62 this.ok = undefined;
63
64 dim.log("Voltage On(?)");
65
66 //if (irq)
67 //dim.log("Waiting for stable voltage interrupted.");
68 //else
69 //dim.log("Voltage stable within limits");
70}
71
72
73voltageOn = function(ov)
74{
75 if (isNaN(ov))
76 ov = 1.1;
77
78 if (this.ov!=ov && dim.state("FEEDBACK").name=="InProgress") // FIXME: Warning, OnStandby, Critical if (ov<this.ov)
79 {
80 dim.log("Stoping feedback.");
81 if (dim.state("FTM_CONTROL").name=="TriggerOn")
82 {
83 dim.send("FTM_CONTROL/STOP_TRIGGER");
84 dim.wait("FTM_CONTROL", "Valid", 3000);
85 }
86
87 dim.send("FEEDBACK/STOP");
88 dim.wait("FEEDBACK", "Calibrated", 3000);
89
90 // Make sure we are not in Ramping anymore
91 dim.wait("BIAS_CONTROL", "VoltageOn", 3000);
92 }
93
94 var isOff = dim.state("FEEDBACK").name=="Calibrated";
95 if (isOff)
96 {
97 dim.log("Switching voltage to Uov="+ov+"V.");
98
99 dim.send("FEEDBACK/START", ov);
100
101 // FIXME: We could miss "InProgress" if it immediately changes to "Warning"
102 // Maybe a dim.timeout state>8 ?
103 dim.wait("FEEDBACK", "InProgress", 45000);
104
105 this.ov = ov;
106 }
107
108 // Wait until voltage on
109 dim.wait("BIAS_CONTROL", "VoltageOn", 60000); // FIXME: 30000?
110}
111
112 dim.log("STARTING SCRIPT closed_lid_ratescan");
113
114// dim.log("Sending Voltage On");
115// voltageOn();
116 v8.sleep(10000);
117
118 var tm = new Date();
119
120 dim.log("Starting ratescan.");
121
122 // Start rate scan
123 //dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 200, 900, 20);
124 dim.send("RATE_SCAN/START_THRESHOLD_SCAN", 100, 900, 10);
125
126 // PAUSE
127 dim.log("PAUSE 10s");
128 v8.sleep(10000);
129 dim.log("Start Ratescan");
130
131 // Lets wait if the ratescan really starts... this might take a few
132 dim.wait("RATE_SCAN", "InProgress", 10000);
133 //dim.wait("RATE_SCAN", "Connected", 2700000);
134 dim.wait("RATE_SCAN", "Connected", 3500000);
135
136 dim.log("Ratescan done");
137
138
139// voltageOff();
140
141 dim.log("Task finished [RATESCAN]");
142 console.out("");
143
Note: See TracBrowser for help on using the repository browser.