Graddagsberäkning
Detaljer
- Typ
- Program
- Upplaggd av
- Jens Marklund, Abelko Innovation
- Version
- 1
- Uppdaterad
- 2016-08-10
- Skapad
- 2016-08-10
- Kategori
- Allmän automation, Energioptimering, Värme
- Visningar
- 3500
Beskrivning
Beräknar graddagar för Ultra
Bruksanvisning
Skapa en scriptmall i Ultran och klistra in detta script.
Juridisk information
Alla skript tillhandahålls i befintligt skick och all användning sker på eget ansvar. Felaktig använding kan leda till skadad eller förstörd utrustning.
Skript kod
APPLICATION DegDays
INPUTS
OutdoorTemp;
OUTPUTS
CHANNELS
DegDaysJan; % set as persistent
DegDaysFeb; % set as persistent
DegDaysMar; % set as persistent
DegDaysApr; % set as persistent
DegDaysMay; % set as persistent
DegDaysJun; % set as persistent
DegDaysJul; % set as persistent
DegDaysAug; % set as persistent
DegDaysSep; % set as persistent
DegDaysOct; % set as persistent
DegDaysNov; % set as persistent
DegDaysDec; % set as persistent
CurrentDayTempSum; % set as persistent
CurrentDaySampleSum; % set as persistent
CurrentMonthDegDays; % set as persistent
LastDayAvgTemp; % set as persistent, used for logging
CurrentDayAvgTemp; % used for viewing the current value on a summary page
LastSavedDay; % set as persistent
LastSavedMonth; % set as persistent
CurrentMonth; % set as persistent
CurrentLimit; % set as persistent
ALARMGROUPS
CURVES
CALENDARS
PARAMETERS
LimitType; % 0=Use LimitAll, 1=One limit per month
LimitAllYear;
LimitJan;
LimitFeb;
LimitMar;
LimitApr;
LimitMay;
LimitJun;
LimitJul;
LimitAug;
LimitSep;
LimitOct;
LimitNov;
LimitDec;
CONSTANTS
LimitType_ONELIMIT = 0;
LimitType_ONEPERMONTH = 1;
SUBAPPLICATIONS
%
% Saves the calculated degdays.
%
SUBROUTINE UpdateMonthTable
VAR
FirstRun;
BUFFER
BEGIN
IF CurrentMonth = 1 THEN DegDaysJan <- CurrentMonthDegDays;
ELSIF CurrentMonth = 2 THEN DegDaysFeb <- CurrentMonthDegDays;
ELSIF CurrentMonth = 3 THEN DegDaysMar <- CurrentMonthDegDays;
ELSIF CurrentMonth = 4 THEN DegDaysApr <- CurrentMonthDegDays;
ELSIF CurrentMonth = 5 THEN DegDaysMay <- CurrentMonthDegDays;
ELSIF CurrentMonth = 6 THEN DegDaysJun <- CurrentMonthDegDays;
ELSIF CurrentMonth = 7 THEN DegDaysJul <- CurrentMonthDegDays;
ELSIF CurrentMonth = 8 THEN DegDaysAug <- CurrentMonthDegDays;
ELSIF CurrentMonth = 9 THEN DegDaysSep <- CurrentMonthDegDays;
ELSIF CurrentMonth = 10 THEN DegDaysOct <- CurrentMonthDegDays;
ELSIF CurrentMonth = 11 THEN DegDaysNov <- CurrentMonthDegDays;
ELSIF CurrentMonth = 12 THEN DegDaysDec <- CurrentMonthDegDays;
ENDIF;
END;
%
% Sets the current limit
%
SUBROUTINE SetCurrentLimit
VAR
FirstRun;
BUFFER
BEGIN
IF LimitType = LimitType_ONELIMIT THEN
CurrentLimit <- LimitAllYear;
ELSE
IF CurrentMonth = 1 THEN CurrentLimit <- LimitJan;
ELSIF CurrentMonth = 2 THEN CurrentLimit <- LimitFeb;
ELSIF CurrentMonth = 3 THEN CurrentLimit <- LimitMar;
ELSIF CurrentMonth = 4 THEN CurrentLimit <- LimitApr;
ELSIF CurrentMonth = 5 THEN CurrentLimit <- LimitMay;
ELSIF CurrentMonth = 6 THEN CurrentLimit <- LimitJun;
ELSIF CurrentMonth = 7 THEN CurrentLimit <- LimitJul;
ELSIF CurrentMonth = 8 THEN CurrentLimit <- LimitAug;
ELSIF CurrentMonth = 9 THEN CurrentLimit <- LimitSep;
ELSIF CurrentMonth = 10 THEN CurrentLimit <- LimitOct;
ELSIF CurrentMonth = 11 THEN CurrentLimit <- LimitNov;
ELSIF CurrentMonth = 12 THEN CurrentLimit <- LimitDec;
ENDIF;
ENDIF;
END;
%
% Main routine.
%
ROUTINE Main
VAR
FirstRun;
BUFFER
BEGIN
% If started for the first time we need to
% set some start values.
IF FirstRun = 0 THEN
IF LastSavedDay = 0 THEN
LastSavedDay <- TIME_DAY;
ENDIF;
IF LastSavedMonth = 0 THEN
LastSavedMonth <- TIME_MONTH;
ENDIF;
IF CurrentMonth = 0 THEN
CurrentMonth <- TIME_MONTH;
ENDIF;
FirstRun := 1;
ENDIF;
CALL(SetCurrentLimit);
% Calculate current days values.
CurrentDayTempSum <- CurrentDayTempSum + OutdoorTemp;
CurrentDaySampleSum <- CurrentDaySampleSum + 1;
CurrentDayAvgTemp <- CurrentDayTempSum/CurrentDaySampleSum;
% New day since we last saved current months value.
IF LastSavedDay <> TIME_DAY THEN
LastDayAvgTemp <- CurrentDayTempSum/CurrentDaySampleSum;
% If the last days avg temp is below the current limit add
% the last days contribution.
IF LastDayAvgTemp <= CurrentLimit THEN
CurrentMonthDegDays <- CurrentMonthDegDays + (CurrentLimit-LastDayAvgTemp);
ENDIF;
CurrentDayTempSum <- 0;
CurrentDaySampleSum <- 0;
LastSavedDay <- TIME_DAY;
ENDIF;
% New month, time to save last months value.
IF LastSavedMonth <> TIME_MONTH THEN
CALL(UpdateMonthTable);
LastSavedMonth <- TIME_MONTH;
CurrentMonthDegDays <- 0;
ENDIF;
CurrentMonth <- TIME_MONTH;
END;
END APPLICATION;
INPUTS
OutdoorTemp;
OUTPUTS
CHANNELS
DegDaysJan; % set as persistent
DegDaysFeb; % set as persistent
DegDaysMar; % set as persistent
DegDaysApr; % set as persistent
DegDaysMay; % set as persistent
DegDaysJun; % set as persistent
DegDaysJul; % set as persistent
DegDaysAug; % set as persistent
DegDaysSep; % set as persistent
DegDaysOct; % set as persistent
DegDaysNov; % set as persistent
DegDaysDec; % set as persistent
CurrentDayTempSum; % set as persistent
CurrentDaySampleSum; % set as persistent
CurrentMonthDegDays; % set as persistent
LastDayAvgTemp; % set as persistent, used for logging
CurrentDayAvgTemp; % used for viewing the current value on a summary page
LastSavedDay; % set as persistent
LastSavedMonth; % set as persistent
CurrentMonth; % set as persistent
CurrentLimit; % set as persistent
ALARMGROUPS
CURVES
CALENDARS
PARAMETERS
LimitType; % 0=Use LimitAll, 1=One limit per month
LimitAllYear;
LimitJan;
LimitFeb;
LimitMar;
LimitApr;
LimitMay;
LimitJun;
LimitJul;
LimitAug;
LimitSep;
LimitOct;
LimitNov;
LimitDec;
CONSTANTS
LimitType_ONELIMIT = 0;
LimitType_ONEPERMONTH = 1;
SUBAPPLICATIONS
%
% Saves the calculated degdays.
%
SUBROUTINE UpdateMonthTable
VAR
FirstRun;
BUFFER
BEGIN
IF CurrentMonth = 1 THEN DegDaysJan <- CurrentMonthDegDays;
ELSIF CurrentMonth = 2 THEN DegDaysFeb <- CurrentMonthDegDays;
ELSIF CurrentMonth = 3 THEN DegDaysMar <- CurrentMonthDegDays;
ELSIF CurrentMonth = 4 THEN DegDaysApr <- CurrentMonthDegDays;
ELSIF CurrentMonth = 5 THEN DegDaysMay <- CurrentMonthDegDays;
ELSIF CurrentMonth = 6 THEN DegDaysJun <- CurrentMonthDegDays;
ELSIF CurrentMonth = 7 THEN DegDaysJul <- CurrentMonthDegDays;
ELSIF CurrentMonth = 8 THEN DegDaysAug <- CurrentMonthDegDays;
ELSIF CurrentMonth = 9 THEN DegDaysSep <- CurrentMonthDegDays;
ELSIF CurrentMonth = 10 THEN DegDaysOct <- CurrentMonthDegDays;
ELSIF CurrentMonth = 11 THEN DegDaysNov <- CurrentMonthDegDays;
ELSIF CurrentMonth = 12 THEN DegDaysDec <- CurrentMonthDegDays;
ENDIF;
END;
%
% Sets the current limit
%
SUBROUTINE SetCurrentLimit
VAR
FirstRun;
BUFFER
BEGIN
IF LimitType = LimitType_ONELIMIT THEN
CurrentLimit <- LimitAllYear;
ELSE
IF CurrentMonth = 1 THEN CurrentLimit <- LimitJan;
ELSIF CurrentMonth = 2 THEN CurrentLimit <- LimitFeb;
ELSIF CurrentMonth = 3 THEN CurrentLimit <- LimitMar;
ELSIF CurrentMonth = 4 THEN CurrentLimit <- LimitApr;
ELSIF CurrentMonth = 5 THEN CurrentLimit <- LimitMay;
ELSIF CurrentMonth = 6 THEN CurrentLimit <- LimitJun;
ELSIF CurrentMonth = 7 THEN CurrentLimit <- LimitJul;
ELSIF CurrentMonth = 8 THEN CurrentLimit <- LimitAug;
ELSIF CurrentMonth = 9 THEN CurrentLimit <- LimitSep;
ELSIF CurrentMonth = 10 THEN CurrentLimit <- LimitOct;
ELSIF CurrentMonth = 11 THEN CurrentLimit <- LimitNov;
ELSIF CurrentMonth = 12 THEN CurrentLimit <- LimitDec;
ENDIF;
ENDIF;
END;
%
% Main routine.
%
ROUTINE Main
VAR
FirstRun;
BUFFER
BEGIN
% If started for the first time we need to
% set some start values.
IF FirstRun = 0 THEN
IF LastSavedDay = 0 THEN
LastSavedDay <- TIME_DAY;
ENDIF;
IF LastSavedMonth = 0 THEN
LastSavedMonth <- TIME_MONTH;
ENDIF;
IF CurrentMonth = 0 THEN
CurrentMonth <- TIME_MONTH;
ENDIF;
FirstRun := 1;
ENDIF;
CALL(SetCurrentLimit);
% Calculate current days values.
CurrentDayTempSum <- CurrentDayTempSum + OutdoorTemp;
CurrentDaySampleSum <- CurrentDaySampleSum + 1;
CurrentDayAvgTemp <- CurrentDayTempSum/CurrentDaySampleSum;
% New day since we last saved current months value.
IF LastSavedDay <> TIME_DAY THEN
LastDayAvgTemp <- CurrentDayTempSum/CurrentDaySampleSum;
% If the last days avg temp is below the current limit add
% the last days contribution.
IF LastDayAvgTemp <= CurrentLimit THEN
CurrentMonthDegDays <- CurrentMonthDegDays + (CurrentLimit-LastDayAvgTemp);
ENDIF;
CurrentDayTempSum <- 0;
CurrentDaySampleSum <- 0;
LastSavedDay <- TIME_DAY;
ENDIF;
% New month, time to save last months value.
IF LastSavedMonth <> TIME_MONTH THEN
CALL(UpdateMonthTable);
LastSavedMonth <- TIME_MONTH;
CurrentMonthDegDays <- 0;
ENDIF;
CurrentMonth <- TIME_MONTH;
END;
END APPLICATION;
Användarnas noteringar
Du måste vara inloggad för att göra en notering. Bli medlem eller logga in. Vi använder en moderator som godkänner noteringarna innan de visas.