Commit 29df2079 authored by Jörg Weingrill's avatar Jörg Weingrill
Browse files

data pump for influxdb

parent 928b46ae
......@@ -27,10 +27,15 @@ VAR
Temperature2Event,
Temperature3Event: FB_Eventlog;
HTMLLog: FB_HTMLFile;
HTMLTimer: TON;
HTMLTimer,
influxdbtimer: TON;
influx: FB_influxdb;
influxmeasurements: STRING;
pressurestring,
temperaturestring,
coldheadstring: STRING(255);
coldheadstring,
setpointstring: STRING(255);
influxstage : UINT;
END_VAR
VAR CONSTANT
heater_max : LREAL := 16384.0;
......@@ -54,6 +59,22 @@ 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;
heater_mode := E_ThermoMode.heater_simple;
ELSIF avg_pressure < 5E-5 THEN
dewar_setpoint := -110.0;
heater_mode := E_ThermoMode.heater_pid;
END_IF
IF avg_temperature > 40.0 THEN
heater_mode := E_ThermoMode.heater_off;
END_IF
IF dewar_setpoint > 0.0 THEN
heater_mode := E_ThermoMode.heater_simple;
END_IF
CASE heater_mode OF
E_ThermoMode.heater_off:
heater_value := 0;
......@@ -113,10 +134,28 @@ HTMLTimer(IN := TRUE AND NOT HTMLTimer.Q, PT := T#1M);
pressurestring := CONCAT('Dewar Pressure$T', LREAL_TO_FMTESTR(avg_pressure, 2, TRUE));
temperaturestring := CONCAT('<br>$NDewar Temperature$T', LREAL_TO_FMTSTR(avg_temperature ,2, TRUE));
coldheadstring := CONCAT('<br>$NCold Head$T', LREAL_TO_FMTSTR(dewar_temperature1, 2, TRUE));
setpointstring := CONCAT('<br>$NDewar Setpoint$T', LREAL_TO_FMTSTR(dewar_setpoint, 2, TRUE));
HTMLLog(Trigger := HTMLTimer.Q,
sPathName := 'C:\inetpub\wwwroot\thermocontrol.html',
sHeader := 'ThermoControl',
sBody := CONCAT(CONCAT(pressurestring, temperaturestring),coldheadstring));]]></ST>
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">
<LineId Id="5" Count="0" />
......@@ -132,6 +171,13 @@ HTMLLog(Trigger := HTMLTimer.Q,
<LineId Id="165" Count="1" />
<LineId Id="254" Count="0" />
<LineId Id="89" Count="0" />
<LineId Id="530" Count="2" />
<LineId Id="538" Count="0" />
<LineId Id="534" Count="0" />
<LineId Id="536" Count="1" />
<LineId Id="533" Count="0" />
<LineId Id="365" Count="3" />
<LineId Id="372" Count="3" />
<LineId Id="255" Count="0" />
<LineId Id="90" Count="1" />
<LineId Id="110" Count="0" />
......@@ -159,8 +205,18 @@ HTMLLog(Trigger := HTMLTimer.Q,
<LineId Id="287" Count="0" />
<LineId Id="62" Count="0" />
<LineId Id="294" Count="1" />
<LineId Id="330" Count="0" />
<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>
</TcPlcObject>
\ No newline at end of file
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