Commit 8ebbed61 authored by Jörg Weingrill's avatar Jörg Weingrill
Browse files

remove influxdb connector

parent e8a36a38
......@@ -23,7 +23,11 @@ VAR
WindSpeed,
WindDirection,
TemperatureDome,
HumidityDome: REAL;
HumidityDome,
Dust1, Dust2,
CryoSupport,
CryoReturn,
CryoDifference: REAL;
WindEvent,
HumidityEvent,
......@@ -31,12 +35,13 @@ VAR
WindAverage,
PrecipitationAverage,
HumidityAverage,
TemperatureAverage: FB_TimeAverage;
TemperatureAverage,
Dust11Average,
Dust12Average,
Dust21Average,
Dust22Average,
DustAverage: FB_TimeAverage;
avg_wind, max_wind: REAL;
stage: UINT := 0;
influx: FB_influxdb;
influxmeasurement: STRING;
influxdbtimer: TON;
END_VAR
]]></Declaration>
<Implementation>
......@@ -71,11 +76,22 @@ END_IF
TemperatureDome := F_YREAL(GVL_Environment.rawTemperatureDome, 0, 32767, -30.0, 70.0); // °C
HumidityDome := F_YREAL(GVL_Environment.rawHumidityDome, 0, 32767, 0.0, 100.0); // %
CryoSupport := F_YREAL(GVL_Environment.rawCryoSupport, 0, 32767, 0.0, 25.0); //bar
CryoReturn := F_YREAL(GVL_Environment.rawCryoReturn, 0, 32767, 0.0, 25.0); //bar
CryoDifference := CryoSupport - CryoReturn;
WindAverage(IN := WindSpeed, PT := T#5M, AVG => avg_wind, MAXAVG => max_wind);
PrecipitationAverage(IN := MAX(Precipitation1, Precipitation2), PT := T#2M);
HumidityAverage(IN := MAX(Humidity1, Humidity2), PT := T#2M);
TemperatureAverage(IN := 0.5*Temperature1 + 0.5*Temperature2, PT := T#5M);
Dust11Average(IN := 1.0 - BOOL_TO_REAL(GVL_Environment.rawDust11), PT := T#30S);
Dust12Average(IN := 1.0 - BOOL_TO_REAL(GVL_Environment.rawDust12), PT := T#30S);
Dust21Average(IN := 1.0 - BOOL_TO_REAL(GVL_Environment.rawDust21), PT := T#30S);
Dust22Average(IN := 1.0 - BOOL_TO_REAL(GVL_Environment.rawDust22), PT := T#30S);
Dust1 := 10.0 * MAX(Dust11Average.AVG, Dust21Average.AVG); //mg/m³
Dust2 := 10.0 * MAX(Dust12Average.AVG, Dust22Average.AVG); //mg/m³
DustAverage(IN := 0.5*Dust1 + 0.5*Dust2, PT := T#5M);
WindEvent( Trigger := avg_wind > 10.0,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Wind Speed: %s',
......@@ -96,30 +112,7 @@ PrecipitationEvent( Trigger := PrecipitationAverage.AVG > 0.3,
OnMessage := LREAL_TO_STRING( PrecipitationAverage.AVG),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
influxdbtimer(IN := TRUE AND NOT influxdbtimer.Q, PT := T#6S);
IF influxdbtimer.q THEN
stage := (stage + 1) MOD 11;
END_IF
CASE stage OF
0: influxmeasurement := CONCAT('dome_temperature=', LREAL_TO_STRING(TemperatureDome));
1: influxmeasurement := CONCAT('dome_humidity=', LREAL_TO_STRING(HumidityDome));
2: influxmeasurement := CONCAT('windspeed=', LREAL_TO_STRING(WindSpeed));
3: influxmeasurement := CONCAT('temperature=', LREAL_TO_STRING(TemperatureAverage.AVG));
4: influxmeasurement := CONCAT('humidity=', LREAL_TO_STRING( HumidityAverage.AVG));
5: influxmeasurement := CONCAT('pressure=', LREAL_TO_STRING(Pressure1));
6: influxmeasurement := CONCAT('brightness=', LREAL_TO_STRING(Brightness1));
7: influxmeasurement := CONCAT('winddirection=', LREAL_TO_STRING(WindDirection));
8: influxmeasurement := CONCAT('lightdirection=', LREAL_TO_STRING(LightDirection1));
9: influxmeasurement := CONCAT('precipitation=', LREAL_TO_STRING(PrecipitationAverage.AVG));
10: influxmeasurement := CONCAT('windmax=', LREAL_TO_STRING(max_wind));
ELSE
influxmeasurement := '';
END_CASE
influx(Trigger := influxdbtimer.q,
table := 'environment',
measurements := influxmeasurement,
timeout := T#6S);]]></ST>
]]></ST>
</Implementation>
<LineIds Name="ConvertEnvironment">
<LineId Id="3" Count="0" />
......@@ -141,25 +134,18 @@ influx(Trigger := influxdbtimer.q,
<LineId Id="194" Count="0" />
<LineId Id="68" Count="0" />
<LineId Id="71" Count="1" />
<LineId Id="351" Count="2" />
<LineId Id="355" Count="0" />
<LineId Id="230" Count="1" />
<LineId Id="143" Count="0" />
<LineId Id="293" Count="0" />
<LineId Id="297" Count="0" />
<LineId Id="341" Count="1" />
<LineId Id="344" Count="2" />
<LineId Id="343" Count="0" />
<LineId Id="348" Count="0" />
<LineId Id="296" Count="0" />
<LineId Id="144" Count="19" />
<LineId Id="267" Count="0" />
<LineId Id="270" Count="0" />
<LineId Id="273" Count="4" />
<LineId Id="279" Count="2" />
<LineId Id="294" Count="0" />
<LineId Id="282" Count="0" />
<LineId Id="286" Count="1" />
<LineId Id="289" Count="2" />
<LineId Id="283" Count="0" />
<LineId Id="285" Count="0" />
<LineId Id="278" Count="0" />
<LineId Id="271" Count="1" />
<LineId Id="2" Count="0" />
<LineId Id="299" Count="0" />
</LineIds>
</POU>
......
......@@ -27,15 +27,11 @@ VAR
Temperature2Event,
Temperature3Event: FB_Eventlog;
HTMLLog: FB_HTMLFile;
HTMLTimer,
influxdbtimer: TON;
influx: FB_influxdb;
influxmeasurements: STRING;
HTMLTimer: TON;
pressurestring,
temperaturestring,
coldheadstring,
setpointstring: STRING(255);
influxstage : UINT;
END_VAR
VAR CONSTANT
heater_max : LREAL := 16384.0;
......@@ -60,14 +56,18 @@ fbTimeAverage(IN := 0.5*dewar_temperature2 + 0.5*dewar_temperature3,
fbDewarpressure(IN := dewar_pressure, PT := T#30S, AVG => avg_pressure);
IF avg_pressure > 1E-4 THEN
dewar_setpoint := 30.0;
dewar_setpoint := 20.0;
heater_mode := E_ThermoMode.heater_simple;
ELSIF avg_pressure < 5E-5 THEN
ELSIF avg_pressure < 5E-5 THEN // we don't need any heater, we are still cooling down
dewar_setpoint := -110.0;
heater_mode := E_ThermoMode.heater_off;
END_IF
IF avg_temperature < -100.0 THEN // we are in target range of the PID loop
heater_mode := E_ThermoMode.heater_pid;
END_IF
IF avg_temperature > 40.0 THEN
IF avg_temperature > 25.0 THEN
heater_mode := E_ThermoMode.heater_off;
END_IF
......@@ -75,6 +75,16 @@ IF dewar_setpoint > 0.0 THEN
heater_mode := E_ThermoMode.heater_simple;
END_IF
fbPIRegler(fSetpointValue := dewar_setpoint,
fActualValue := avg_temperature,
bReset := heater_mode <> E_ThermoMode.heater_pid,
fCtrlCycleTime := 1.0, //0.002,
fKp := 6169.1542,
fTn := 310.0,
fTv := 4.5,
fCtrlOutput => pid_output,
nErrorStatus => PIDError);
CASE heater_mode OF
E_ThermoMode.heater_off:
heater_value := 0;
......@@ -87,14 +97,6 @@ CASE heater_mode OF
heater_value := 0.0;
END_IF
E_ThermoMode.heater_pid:
fbPIRegler(fSetpointValue := dewar_setpoint,
fActualValue := avg_temperature,
fCtrlCycleTime := 0.002,
fKp := 6169.1542,
fTn := 310.0,
fTv := 4.5,
fCtrlOutput => pid_output,
nErrorStatus => PIDError);
heater_value := pid_output;
END_CASE
......@@ -139,22 +141,6 @@ HTMLLog(Trigger := HTMLTimer.Q,
sPathName := 'C:\inetpub\wwwroot\thermocontrol.html',
sHeader := 'ThermoControl',
sBody := CONCAT(CONCAT(CONCAT(pressurestring, temperaturestring),coldheadstring),setpointstring));
CASE influxstage OF
0: influxmeasurements := CONCAT('dewar_pressure=', LREAL_TO_FMTESTR(avg_pressure, 5, TRUE));
1: influxmeasurements := CONCAT('dewar_temperature=', LREAL_TO_FMTSTR(avg_temperature ,3, TRUE));
2: influxmeasurements := CONCAT('cold_head=', LREAL_TO_FMTSTR(dewar_temperature1, 3, TRUE));
3: influxmeasurements := CONCAT('setpoint=', LREAL_TO_FMTSTR(dewar_setpoint, 3, TRUE));
ELSE
influxmeasurements := '';
END_CASE
IF influxdbtimer.Q THEN
influxstage := (influxstage + 1) MOD 4;
END_IF
influxdbtimer(IN := TRUE AND NOT influxdbtimer.Q, PT := T#15S);
influx(Trigger := influxdbtimer.q,
table := 'thermocontrol',
measurements := influxmeasurements);
]]></ST>
</Implementation>
<LineIds Name="ThermoControl">
......@@ -176,8 +162,13 @@ influx(Trigger := influxdbtimer.q,
<LineId Id="534" Count="0" />
<LineId Id="536" Count="1" />
<LineId Id="533" Count="0" />
<LineId Id="591" Count="0" />
<LineId Id="590" Count="0" />
<LineId Id="592" Count="1" />
<LineId Id="365" Count="3" />
<LineId Id="372" Count="3" />
<LineId Id="579" Count="0" />
<LineId Id="581" Count="8" />
<LineId Id="255" Count="0" />
<LineId Id="90" Count="1" />
<LineId Id="110" Count="0" />
......@@ -186,7 +177,6 @@ influx(Trigger := influxdbtimer.q,
<LineId Id="99" Count="0" />
<LineId Id="105" Count="4" />
<LineId Id="104" Count="0" />
<LineId Id="155" Count="7" />
<LineId Id="93" Count="0" />
<LineId Id="92" Count="0" />
<LineId Id="64" Count="0" />
......@@ -207,15 +197,6 @@ influx(Trigger := influxdbtimer.q,
<LineId Id="294" Count="1" />
<LineId Id="370" Count="1" />
<LineId Id="288" Count="3" />
<LineId Id="479" Count="1" />
<LineId Id="482" Count="2" />
<LineId Id="486" Count="1" />
<LineId Id="481" Count="0" />
<LineId Id="488" Count="2" />
<LineId Id="420" Count="0" />
<LineId Id="414" Count="0" />
<LineId Id="418" Count="1" />
<LineId Id="435" Count="0" />
<LineId Id="431" Count="0" />
</LineIds>
</POU>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment