# Example 5. Computed Schedule[LINK]

Many models have schedule inputs that could be used to control the object, but creating the schedules it is too cumbersome. We need to ask, Can we use the EMS to dynamically calculate a schedule?

## EMS Design Discussion[LINK]

As an example, we will take the model from example 1 and use the EMS to replicate the heating and cooling zone temperature setpoint schedules. The input object Schedule:Constant has been set up to be available as an actuator. We then add EnergyManagementSystem:Actuator objects that set these actuators up as Erl variables.

To devise an Erl program to compute the schedule, we need to use the built-in variables that describe time and day. The built-in variable Hour will provide information about the time of day; DayOfWeek will provide information about whether it is the weekend or a weekday.

## EMS Input Objects[LINK]

Example EMS input for computing a schedule for heating and cooling setpoints follows and are contained in the example file called “EMSCustomSchedule.idf.”

Schedule:Constant,
CLGSETP_SCH,
Temperature,
24.0;

EnergyManagementSystem:Actuator,
myCLGSETP_SCH_Override,
CLGSETP_SCH,Schedule:Constant,Schedule Value;

EnergyManagementSystem:ProgramCallingManager,
My Setpoint Schedule Calculator Example,
BeginTimestepBeforePredictor,
MyComputedCoolingSetpointProg,
MyComputedHeatingSetpointProg;

EnergyManagementSystem:Program,
MyComputedCoolingSetpointProg,
IF (DayOfWeek = = 1),
Set myCLGSETP_SCH_Override = 30.0  ,
ELSEIF (Holiday = = 3.0) && (DayOfMonth = = 21) && (Month = = 1),  !winter design day
Set myCLGSETP_SCH_Override = 30.0 ,
ELSEIF HOUR < 6       ,
Set myCLGSETP_SCH_Override = 30.0  ,
ELSEIF (Hour > = 6) && (Hour < 22)  && (DayOfWeek > = 2) && (DayOfWeek < = 6) ,
Set myCLGSETP_SCH_Override = 24.0  ,
ELSEIF (Hour > = 6) && (hour < 18) && (DayOfWeek = = 7)
Set myCLGSETP_SCH_Override = 24.0  ,
ELSEIF (Hour > = 6) && (hour > = 18) && (DayOfWeek = = 7)
Set myCLGSETP_SCH_Override = 30.0  ,
ELSEIF (Hour > = 22)                   ,
Set myCLGSETP_SCH_Override = 30.0  ,
ENDIF;

Schedule:Constant,
HTGSETP_SCH,
Temperature,
21.0;

EnergyManagementSystem:Actuator,
myHTGSETP_SCH,
HTGSETP_SCH,Schedule:Constant,Schedule Value;

EnergyManagementSystem:Program,
MyComputedHeatingSetpointProg,
Set locHour = Hour, ! echo out for debug
Set locDay = DayOfWeek, ! echo out for debug
Set locHol = Holiday,  ! echo out for debug
IF (DayOfWeek = = 1),
Set myHTGSETP_SCH = 15.6  ,
ELSEIF (Holiday = = 3.0) && (DayOfYear = = 21),  !winter design day
Set myHTGSETP_SCH = 21.0 ,
ELSEIF HOUR < 5       ,
Set myHTGSETP_SCH = 15.6  ,
ELSEIF (Hour > = 5) && (Hour < 19)  && (DayOfWeek > = 2) && (DayOfWeek < = 6) ,
Set myHTGSETP_SCH = 21.0  ,
ELSEIF (Hour > = 6) && (hour < 17) && (DayOfWeek = = 7),
Set myHTGSETP_SCH = 21.0  ,
ELSEIF (Hour > = 6) && (hour < = 17) && (DayOfWeek = = 7) ,
Set myHTGSETP_SCH = 15.6   ,
ELSEIF (Hour > = 19)          ,
Set myHTGSETP_SCH = 15.6   ,
ENDIF;