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

fixed Typos; added averaged values

parent 9f4c0567
......@@ -10,7 +10,7 @@ VAR
Pressure1,
Brightness1,
LightDirection1,
Precipation1,
Precipitation1,
WindSpeed2,
WindDirection2,
......@@ -19,7 +19,7 @@ VAR
Pressure2,
Brightness2,
LightDirection2,
Precipation2,
Precipitation2,
WindSpeed,
WindDirection,
TemperatureDome,
......@@ -27,10 +27,16 @@ VAR
WindEvent,
HumidityEvent,
PrecepationEvent: FB_Eventlog;
PrecipitationEvent: FB_Eventlog;
WindAverage,
PrecepationAverage: FB_TimeAverage;
PrecipitationAverage,
HumidityAverage,
TemperatureAverage: FB_TimeAverage;
avg_wind, max_wind: REAL;
stage: UINT := 0;
influx: FB_influxdb;
influxmeasurement: STRING;
influxdbtimer: TON;
END_VAR
]]></Declaration>
<Implementation>
......@@ -42,7 +48,7 @@ Humidity1 := F_YREAL(GVL_Environment.rawHumidity1, 0, 32767, 0.0, 100.0); /
Pressure1 := F_YREAL(GVL_Environment.rawPressure1, 0, 32767, 300.0, 800.0); // mBar 300...1100? 800..1060?
Brightness1 := F_YREAL(GVL_Environment.rawBrightness1, 0, 32767, 1.0, 150000.0); // Lux
LightDirection1 := F_YREAL(GVL_Environment.rawLightDirection1, 0, 32767, 0.0, 360.0); // °
Precipation1 := F_YREAL(GVL_Environment.rawPrecipation1, 0, 32767, 0.001, 100.0); // mm/h
Precipitation1 := F_YREAL(GVL_Environment.rawPrecipation1, 0, 32767, 0.001, 100.0); // mm/h
WindSpeed2 := F_YREAL(GVL_Environment.rawWindSpeed2, 0, 32767, 0.0, 60.0); // m/s
WindDirection2 := F_YREAL(GVL_Environment.rawWindDirection2, 0, 32767, 0.0, 360.0); // °
......@@ -51,7 +57,7 @@ Humidity2 := F_YREAL(GVL_Environment.rawHumidity2, 0, 32767, 0.0, 100.0); /
Pressure2 := F_YREAL(GVL_Environment.rawPressure2, 0, 32767, 800.0, 1060.0); // mBar
Brightness2 := F_YREAL(GVL_Environment.rawBrightness2, 0, 32767, 1.0, 150000.0); // Lux
LightDirection2 := F_YREAL(GVL_Environment.rawLightDirection2, 0, 32767, 0.0, 360.0); // °
Precipation2 := F_YREAL(GVL_Environment.rawPrecipation2, 0, 32767, 0.001, 100.0); // mm/h
Precipitation2 := F_YREAL(GVL_Environment.rawPrecipation2, 0, 32767, 0.001, 100.0); // mm/h
IF WindSpeed1 > WindSpeed2 THEN
WindSpeed := WindSpeed1;
......@@ -66,7 +72,10 @@ TemperatureDome := F_YREAL(GVL_Environment.rawTemperatureDome, 0, 32767, -30.0,
HumidityDome := F_YREAL(GVL_Environment.rawHumidityDome, 0, 32767, 0.0, 100.0); // %
WindAverage(IN := WindSpeed, PT := T#5M, AVG => avg_wind, MAXAVG => max_wind);
PrecepationAverage(IN := MAX(Precipation1, Precipation2), PT := T#2M);
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);
WindEvent( Trigger := avg_wind > 10.0,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Wind Speed: %s',
......@@ -74,20 +83,43 @@ WindEvent( Trigger := avg_wind > 10.0,
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
HumidityEvent( Trigger := MAX(Humidity1, Humidity2) > 80.0,
HumidityEvent( Trigger := HumidityAverage.AVG> 80.0,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Humidity: %s',
OnMessage := LREAL_TO_STRING( MAX(Humidity1, Humidity2)),
OnMessage := LREAL_TO_STRING( HumidityAverage.AVG),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
PrecepationEvent( Trigger := PrecepationAverage.AVG > 0.3,
PrecipitationEvent( Trigger := PrecipitationAverage.AVG > 0.3,
Level := ADSLOG_MSGTYPE_WARN,
FormatString := 'Precepation: %s',
OnMessage := LREAL_TO_STRING( MAX(Precipation1, Precipation2)),
OnMessage := LREAL_TO_STRING( PrecipitationAverage.AVG),
OffMessage := 'OK',
OffLevel := ADSLOG_MSGTYPE_HINT);
]]></ST>
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>
</Implementation>
<LineIds Name="ConvertEnvironment">
<LineId Id="3" Count="0" />
......@@ -110,8 +142,25 @@ PrecepationEvent( Trigger := PrecepationAverage.AVG > 0.3,
<LineId Id="68" Count="0" />
<LineId Id="71" Count="1" />
<LineId Id="230" Count="1" />
<LineId Id="143" Count="20" />
<LineId Id="143" Count="0" />
<LineId Id="293" Count="0" />
<LineId Id="297" 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>
</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