File indexing completed on 2025-08-02 08:21:01
0001 <!DOCTYPE html>
0002 <head>
0003 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
0004
0005 <title>RCDAQ Controls</title>
0006
0007 <style>
0008 body {
0009 font-family: sans-serif;
0010 }
0011
0012
0013 table {
0014 width: 50%;
0015 height: 30px;
0016 cellpadding: 8;
0017 border-spacing: 0px;
0018 border-collapse: collapse;
0019 }
0020
0021 td {
0022 width: 100%;
0023 height: 30px;
0024 border: 2px solid #bbbbbb;
0025 text-align:center;
0026 vertical-align:middle;
0027 }
0028
0029 input {
0030 width: 99%;
0031 height: 30px;
0032 background-color: #33CCCC;
0033 font-size: 100%;
0034
0035 }
0036
0037 .bold {
0038 font-weight: bold;
0039 }
0040
0041
0042 .RunActiveStatus {
0043 color: red;
0044 background-color: #F5D88B;
0045 font-weight: bold;
0046 }
0047
0048 .RunInActiveStatus {
0049 color: blue;
0050 background-color: #CCCCCC;
0051 }
0052
0053 .ServerDeadStatus {
0054 color: white;
0055 background-color: #F93D5C;
0056 }
0057
0058
0059
0060 .LoggingActive {
0061 color: black;
0062 background-color: #F5D88B;
0063 }
0064 .LoggingInActive {
0065 color: black;
0066 background-color: #CCCCCC;
0067 }
0068
0069 .ButtonActive {
0070 color: black;
0071 background-color: #33CCCC;
0072 }
0073 .ButtonInActive {
0074 color: black;
0075 background-color: #666666;
0076 }
0077
0078
0079 </style>
0080
0081
0082 <script>
0083
0084 var debug = false;
0085 var webSocket;
0086
0087 // global flags
0088 var ServerWasDeadFlag = false;
0089 var OpenDisabledFlag = false;
0090
0091 // color definitions
0092
0093 var StandardColor = "#cccc00";
0094 var StatusColor = "#bbbb00";
0095 var StandardColor2 = "#00CC99";
0096 var BorderColor = "#CCCC99";
0097 var ButtonBgColor = "#33CCCC";
0098
0099
0100 var RunInactiveColor = "#CCCCCC";
0101 var RunActiveColor = "#F5D88B"; // orange-ish
0102
0103 var LoggingDisabledColor = "#CCCCCC";
0104 var LoggingEnabledColor = RunActiveColor;
0105
0106 var ServerDeadColor = "#F93D5C";
0107 var ButtonInactiveColor = "#666666";
0108
0109 var RunCommand = "daq_begin";
0110 var OpenCommand = "daq_open";
0111
0112 function init()
0113 {
0114 if ( debug) {console.log('starting init');}
0115 // we are recursively calling this function.
0116 // This stopMe tells this round not to proceed.
0117 var stopMe = false;
0118
0119 webSocket = new WebSocket("ws://"+location.host);
0120
0121 webSocket.onerror = function(e) {
0122 e.preventDefault();
0123 }
0124
0125
0126 webSocket.onopen = function(e) {
0127 if ( debug) {console.log('Websocket opened - sending initial update request');}
0128 webSocket.send("initial_update");
0129 }
0130
0131
0132 webSocket.onclose = function(event) {
0133 if ( debug) { console.log('Websocket closed'); };
0134 delete webSocket;
0135 stopMe = true;
0136
0137 ServerWasDeadFlag = true;
0138
0139 document.getElementById("Status").className = "ServerDeadStatus";
0140 document.getElementById("Status").textContent="RCDAQ not running";
0141 document.getElementById("Logging").className='LoggingInActive';
0142 document.getElementById("OpenButton").className='ButtonInActive';
0143 document.getElementById("BeginButton").className='ButtonInActive';
0144
0145 document.getElementById("RunNr").textContent="n/a";
0146 document.getElementById("Events").textContent="n/a";
0147 document.getElementById("Volume").textContent="n/a";
0148 document.getElementById("Logging").textContent=" ";
0149
0150 retryTimer = setTimeout(init, 2500);
0151 }
0152 if ( stopMe) return;
0153
0154 webSocket.onmessage = wsReceive;
0155
0156
0157 }
0158
0159 function wsReceive(e)
0160 {
0161 if ( debug) { console.log('Websocket received ' + e.data); }
0162 full_parse(e.data);
0163
0164 }
0165
0166 function full_parse(j)
0167 {
0168
0169 if ( j.length == 0)
0170 {
0171 return;
0172 }
0173
0174
0175 var o = JSON.parse(j);
0176
0177 list = Object.keys(o);
0178 var i;
0179 for ( i = 0; i < list.length; i++)
0180 {
0181 if ( list[i] == "OpenFlag")
0182 {
0183 if ( o[list[i]] > 0 )
0184 {
0185 document.getElementById("OpenButton").value = "Close";
0186 document.getElementById("Logging").className='LoggingActive';
0187 OpenCommand = "daq_close";
0188 }
0189 else
0190 {
0191 document.getElementById("OpenButton").value = "Open";
0192 document.getElementById("Logging").className='LoggingInActive';
0193 OpenCommand = "daq_open";
0194 }
0195 }
0196 else if ( list[i] == "RunFlag")
0197 {
0198 document.getElementById("BeginButton").className='ButtonActive';
0199
0200 if ( o[list[i]] == 1 )
0201 {
0202 // we dim the open/close button since it's going inactive
0203 document.getElementById("OpenButton").className='ButtonInActive';
0204 // we re-color the status field
0205 document.getElementById("Status").className='RunActiveStatus';
0206
0207 // and we change the text to "end"
0208 document.getElementById("BeginButton").value = "End";
0209 RunCommand = "daq_end";
0210 }
0211 else
0212 {
0213 // we un-dim the open/close button since it's active again
0214 document.getElementById("OpenButton").className='ButtonActive';
0215 // we re-color the status field
0216 document.getElementById("Status").className='RunInActiveStatus';
0217 // and we change the text to "Begin"
0218 document.getElementById("BeginButton").value = "Begin";
0219 RunCommand = "daq_begin";
0220 }
0221 }
0222
0223 if ( document.getElementById(list[i]) )
0224 {
0225 document.getElementById(list[i]).textContent=o[list[i]];
0226 }
0227 }
0228 }
0229
0230 function initial_update()
0231 {
0232 var uri = "initial_update";
0233 var xhttp = new XMLHttpRequest();
0234 xhttp.onreadystatechange = function()
0235 {
0236 if (xhttp.readyState == 4 && xhttp.status == 200)
0237 {
0238 //console.log(" response " + xhttp.responseText);
0239 full_parse(xhttp.responseText);
0240 }
0241 };
0242
0243
0244 xhttp.open("get", uri, true);
0245 xhttp.send();
0246 }
0247
0248
0249
0250 function OpenHandler()
0251 {
0252
0253 webSocket.send(OpenCommand);
0254 }
0255
0256 function RunHandler()
0257 {
0258
0259 webSocket.send(RunCommand);
0260
0261 }
0262
0263 // document.addEventListener("DOMContentLoaded", function() {
0264 // init();
0265 // });
0266
0267
0268 </script>
0269 </head>
0270
0271 <body>
0272
0273
0274 <TABLE>
0275
0276 <tr>
0277 <td colspan="2" style="background-color: #cccc00; height:45px;font-size:140%;">RCDAQ Control</td>
0278 </tr>
0279 <tr>
0280 <td id="Name" colspan="2" style="background-color: #bbbb00; height:18px;font-size:80%;"> </td>
0281 </tr>
0282
0283 <tr>
0284 <td id="Status" colspan="2" class="RunInActiveStatus"> </td>
0285 </tr>
0286
0287 <tr>
0288 <td colspan="1" style="background-color: #00cc99; width:50%">Run:
0289 <td id="RunNr" style="background-color: #00cc99;" ></td>
0290 </tr>
0291
0292 <tr>
0293 <td colspan="1" style="background-color: #00cc99; width:50%">Events:
0294 <td id="Events" style="background-color: #00cc99;" ></td>
0295 </tr>
0296
0297 <tr>
0298 <td colspan="1" style="background-color:#00cc99; width:50%">Volume:
0299 <td id="Volume" style="background-color: #00cc99;" >0 MB</td>
0300 </tr>
0301
0302 <tr>
0303 <td id="Logging" colspan="2" class="LoggingInActive" ></td>
0304 </tr>
0305
0306
0307 <tr>
0308 <td colspan="2" style="background-color:#33bbbb";> <input type="button" value="Open" onClick="OpenHandler()" class="ButtonActive" id="OpenButton"></td>
0309 </tr>
0310
0311 <tr>
0312 <td colspan="2" style="background-color:#33bbbb";> <input type="button" value="Begin" onClick="RunHandler()" class="ButtonActive" id="BeginButton"></td>
0313 </tr>
0314
0315
0316 </table>
0317
0318 <script>
0319 window.onload = init;
0320 </script>
0321
0322
0323 </body>