SCRIPT FOR VMC DEVICES
INTRODUCTION
This scrpt will set the value coming from a set point considered as a Max temperature and set inside a info component, that will be taken and considered in a function. At the same time the hour of the max temperature will be recorded in turn inside an another info that will be considered to activate the VMC the next day at the hour that has been recorded to set the Machine at the specific max temperature.
SCRIPT EXPLANATION
VARIABLES
First lets create the variables for the elements that we are going to use inside the Functions.
var setpoint: This first variable is the one that will contain the value of the component set point, so set with the component ID 13;
var tempmax: This second Variable will take care about the value of the first info component that contain’s the max temperature that the set point reaches with the component ID 12;
var time: This third variable will contain the hour of the day with the component ID 14;
var enable: This fourth variable will allow the user to enable or disable the function at his desires, with the component ID 16;
var reset: This fifth variable will allow the user to reset the recorded time at his desires, with the component ID 17;
SCRIPTS EXECUTION
FIRST FUNCTION
Function setpointchanged(): This function will record the current value of the set point and the current value of the time. Both these variables will be processed in the second part of the function, the if will consider that, if the current max temperature is minor of the current value of the set point the temperature will be set to the info component that corrispond to the variable temp_max.
There are other variable in this function, these other variable are set to get the time that will be considered as the time that is set to the info 12 to save the hour when the temp_max reaches its peak.
Function’s variable
var d = new date(); This variable will get the date from the 1 jannuary form 1970.
var t = d.getTime(): This variable get the live time of your current position.
var minutes = d.getMinutes(): This variable the live minutes of your position.
var hour = d.getthours(): This variable the live hour of your position.
setValue(time,hour+”:”+minutes): This “setValue” funciton will set the current time inside the info component ID 12 eahter known as var time.
SECOND FUNCTION
Function checkTime(): This function will get the current system time and the current Temp_max, these two values will be set to the setpoint and to the info component of the max temperature with ID 13.
Function’s variable
var d = new date(); This variable will get the date from the 1 jannuary form 1970.
var t = d.getTime(): This variable get the live time of your current position.
var minutes = d.getMinutes(): This variable the live minutes of your position.
var hour = d.getthours(): This variable the live hour of your position.
var maxTime = getValueAsString(time): This variable will record the current maxTime value as text.
var currentTempMax = getValueAsDouble(temp_Max): This variable will record the current value written with decimal from inside the variable called temp_max.
setValue(setpoint, currentTempMax): This setValue will set the values to the setpoint and the temperautre to the variable currentTempMax.
THIRD FUNCTION
Function resetChanged(): This function if needed will reset the time set in the max time variable, this is linked to the variable called “var reset”, this function as said will reset the time of the maxTime set.
Function’s variable
var currentSetPoint = getValueAsDouble(setpoint): This variable will get the current value of the setpoint component with decimals.
var d = new date(); This variable will get the date from the 1 jannuary form 1970.
var t = d.getTime(): This variable get the live time of your current position.
var minutes = d.getMinutes(): This variable the live minutes of your position.
var hour = d.getthours(): This variable the live hour of your position.
setValue(time,hour+”:”+minutes): This “setValue” funciton will set the current time inside the info component ID 12 eahter known as var time.
SET TRIGGERS
setTrigger(setpoint,”setpointchanged”): This action will execute the setpointchanged function to the component setpoint.
setTriggerEdge(reset,”on”,”resetChanged”): This action will execute the reset of the time component once the pulse component is pressed allowing the record of another time value.
setInterval(10,”checkTime”): This action will add an interval of 10 seconds to the checkTime function.