mirror of
https://github.com/eddyem/tsys01.git
synced 2026-02-01 04:45:05 +03:00
fix reinit bug in netdaemon
This commit is contained in:
parent
7344a6a332
commit
f640702946
4
src/netdaemon/scripts/acc
Normal file
4
src/netdaemon/scripts/acc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
HTTP/1.1 200 OK
|
||||||
|
Access-Control-Allow-Origin: *
|
||||||
|
Content-type: text/html
|
||||||
|
|
||||||
11
src/netdaemon/scripts/runSpeedCtrl
Executable file
11
src/netdaemon/scripts/runSpeedCtrl
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
NewVal=$((cat /home/eddy/bin/acc; /home/eddy/bin/SEWcontrol) | nc -w0 -lp 8080 | grep GET)
|
||||||
|
E=$(echo $NewVal | sed 's|.*setspeed=\([0-9\.]\+\).*|\1|' | grep "^[0-9]*[.]*[0-9]*$")
|
||||||
|
#'
|
||||||
|
if [ "x$E" != "x" ]; then
|
||||||
|
#echo "SPEED=$E"
|
||||||
|
(( E > 299 )) && (( E < 1301 )) && /home/eddy/bin/SEWcontrol -s $E || /home/eddy/bin/SEWcontrol -0
|
||||||
|
fi
|
||||||
|
done
|
||||||
5
src/netdaemon/scripts/rundaemons
Executable file
5
src/netdaemon/scripts/rundaemons
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
/home/eddy/bin/serialsock -d /dev/ttyUSB0 -l /tmp/serv.log &
|
||||||
|
sleep 1
|
||||||
|
/home/eddy/bin/netdaemon -g -s /tmp/www/ -N /home/eddy/tempadj.txt /tmp/netdaemon.log &
|
||||||
|
/home/eddy/bin/runSpeedCtrl &
|
||||||
@ -402,8 +402,7 @@ static void daemon_(int sock){
|
|||||||
tgot = dtime();
|
tgot = dtime();
|
||||||
process_T(); // get new temperatures & throw out bad results
|
process_T(); // get new temperatures & throw out bad results
|
||||||
for(i = 0; i <= NCTRLR_MAX; ++i){ // scan over controllers
|
for(i = 0; i <= NCTRLR_MAX; ++i){ // scan over controllers
|
||||||
int N, p;
|
for(int N = 0; N <= NCHANNEL_MAX; ++N) for(int p = 0; p < 2; ++p){
|
||||||
for(N = 0; N <= NCHANNEL_MAX; ++N) for(p = 0; p < 2; ++p){
|
|
||||||
double T = t_last[p][N][i];
|
double T = t_last[p][N][i];
|
||||||
char **buf;
|
char **buf;
|
||||||
size_t *len;
|
size_t *len;
|
||||||
|
|||||||
@ -233,7 +233,10 @@ int poll_sensors(int N){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
if(N && ngot < MIN_SENSORS_AMOUNT){ // too little sensors for mirror controller
|
||||||
|
send_cmd(N, CMD_REINIT_SENSORS); // reinit sensors
|
||||||
|
}
|
||||||
|
return ngot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -270,6 +273,7 @@ int check_sensors(){
|
|||||||
++found;
|
++found;
|
||||||
green(_("Found controller #%d\n"), i);
|
green(_("Found controller #%d\n"), i);
|
||||||
LOGMSG("Found controller #%d", i);
|
LOGMSG("Found controller #%d", i);
|
||||||
|
send_cmd(i, CMD_LOWSPEED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,8 @@
|
|||||||
#define WAIT_TMOUT (0.5)
|
#define WAIT_TMOUT (0.5)
|
||||||
// Main controller polling timeout - 1 second
|
// Main controller polling timeout - 1 second
|
||||||
#define POLLING_TMOUT (1.0)
|
#define POLLING_TMOUT (1.0)
|
||||||
// Thermal polling timeout: 1.5 seconds
|
// Thermal polling timeout: 3 seconds
|
||||||
#define T_POLLING_TMOUT (1.5)
|
#define T_POLLING_TMOUT (3)
|
||||||
// T measurement time interval - 30 seconds
|
// T measurement time interval - 30 seconds
|
||||||
#define T_INTERVAL (30.0)
|
#define T_INTERVAL (30.0)
|
||||||
// interval (in seconds) to remove too old measurements (if sensor not available now)
|
// interval (in seconds) to remove too old measurements (if sensor not available now)
|
||||||
@ -39,13 +39,18 @@
|
|||||||
// amount of measurement to plot mean graphs
|
// amount of measurement to plot mean graphs
|
||||||
#define GRAPHS_AMOUNT (15)
|
#define GRAPHS_AMOUNT (15)
|
||||||
|
|
||||||
|
// minimal amount of working sensors for one controller (if less - call "reinit" command)
|
||||||
|
#define MIN_SENSORS_AMOUNT (6)
|
||||||
|
|
||||||
// Protocol
|
// Protocol
|
||||||
#define CMD_SENSORS_OFF 'F'
|
#define CMD_SENSORS_OFF 'F'
|
||||||
#define CMD_SENSORS_OFF_LOCAL 'f'
|
#define CMD_SENSORS_OFF_LOCAL 'f'
|
||||||
|
#define CMD_REINIT_SENSORS 'I'
|
||||||
#define CMD_VOLTAGE 'K'
|
#define CMD_VOLTAGE 'K'
|
||||||
#define CMD_PING 'P'
|
#define CMD_PING 'P'
|
||||||
#define CMD_MEASURE_T 'T'
|
#define CMD_MEASURE_T 'T'
|
||||||
#define CMD_MEASURE_LOCAL 't'
|
#define CMD_MEASURE_LOCAL 't'
|
||||||
|
#define CMD_LOWSPEED 'V'
|
||||||
#define ANS_PONG "PONG"
|
#define ANS_PONG "PONG"
|
||||||
|
|
||||||
extern time_t tmeasured[2][NCHANNEL_MAX+1][NCTRLR_MAX+1];
|
extern time_t tmeasured[2][NCHANNEL_MAX+1][NCTRLR_MAX+1];
|
||||||
|
|||||||
74
src/netdaemon/www/fans.html
Normal file
74
src/netdaemon/www/fans.html
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="ASCII">
|
||||||
|
<title>BTA primary mirror fans control</title>
|
||||||
|
<script>
|
||||||
|
var refrtime = 2000;
|
||||||
|
var starttime = new Date().getTime(); // UNIX time in milliseconds
|
||||||
|
var T;
|
||||||
|
//console.log("T=" + starttime);
|
||||||
|
refresh();
|
||||||
|
function $(x){
|
||||||
|
return document.getElementById(x);
|
||||||
|
}
|
||||||
|
function callback(resp){
|
||||||
|
//console.log("Response: " + resp);
|
||||||
|
const urlParams = new URLSearchParams(resp);
|
||||||
|
//console.log("Speed=" + urlParams.get('SPEED') + ", Current=" + urlParams.get('CURRENT'));
|
||||||
|
$("curval").innerText = urlParams.get('CURRENT');
|
||||||
|
$("spdval").innerText = urlParams.get('SPEED');
|
||||||
|
delete urlParams;
|
||||||
|
}
|
||||||
|
function refresh(){
|
||||||
|
// stop refreshing after 5 minutes
|
||||||
|
var d = new Date;
|
||||||
|
if(d.getTime() - starttime > 300000){
|
||||||
|
delete d;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//console.log("diff: " + (d.getTime() - starttime)/1000);
|
||||||
|
delete d;
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.onload = function(){callback(xhr.response);};
|
||||||
|
xhr.open("POST", "http://mirtemp.sao.ru:8080/");
|
||||||
|
xhr.send();
|
||||||
|
T = setTimeout(refresh, refrtime);
|
||||||
|
}
|
||||||
|
function setspeed(val){
|
||||||
|
let xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", "http://mirtemp.sao.ru:8080/setspeed=" + val);
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
function setspeeda(){
|
||||||
|
setspeed($("setspeed").value);
|
||||||
|
}
|
||||||
|
function chkrad(){
|
||||||
|
var rad = document.getElementsByName('rs');
|
||||||
|
for(var i=0; i < rad.length; ++i){
|
||||||
|
if(rad[i].checked){
|
||||||
|
//console.log("checked: " + rad[i].value);
|
||||||
|
setspeed(rad[i].value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
New speed: <input id="setspeed" type="number" step="1" min="300" max="1300" value="500">
|
||||||
|
<button onclick="setspeeda();">Set</button>
|
||||||
|
<button onclick="setspeed(0);">Stop</button>
|
||||||
|
</p><p>
|
||||||
|
Set speed: <input type="radio" id="lowspd" name="rs" value="300"><label for="lowspd">Low</label>
|
||||||
|
<input type="radio" id="midspd" name="rs" value="800"><label for="midspd">Mid</label>
|
||||||
|
<input type="radio" id="highspd" name="rs" value="1300"><label for="highspd">High</label>
|
||||||
|
<input type="radio" id="stop" name="rs" checked value="0"><label for="stop">Stop</label>
|
||||||
|
<button onclick="chkrad();">Set</button><br>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Current: <span id="curval"></span> A. Speed: <span id="spdval"></span> rpm.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user