How to calculate temperature on/off constants Please consider the following as pseudo code for my question
    double K1 = 50.0 / 300; // Warm up, 5 min, 20 - 70. Subject to change.
    double K2 = -50.0 / 120; // Cool down, 2 min, 20 - 70. Subject to change.

    double T = 20;
    const int ON_TIME = 7; // seconds. this must be calculated
    const int OFF_TIME = 2; // seconds. this must be calculated
    int onCounter = ON_TIME;
    int offCounter = 0;
    for (int t = 0; t < 1800; t++)
    {
        if (onCounter > 0)
        {
            onCounter--;
            T += K1;
        }
        else if(offCounter == 0)
        {
            onCounter = ON_TIME;
            // switch relay off here
        }

        if (offCounter > 0)
        {
            T += K2;
            offCounter--;
        }
        else if(onCounter == 0)
        {
            offCounter = OFF_TIME;
            // switch relay on here
        }
        Console.WriteLine("t: {0}, T: {1:F2}", t, T);
    }

What this function does is simulation of oven temperature during 30 minutes(Tt) linearly up to 70C. Of course it doesn't work as expected. The input parameters are two linear slopes.


*

*Oven temperature will increase from 20C to 70C during 5 minutes (Tw)

*Oven will cool down from 70C to 20C during 2 minutes (Tc)

*The step should be 1C (Ts)


So the function will control relay, which will either turn on the oven or turn off. 
I have tried to just search those ON/OFF_TIME constans but it looks like I need more serious approach.
The question is - how to calculate ON_TIME and OFF_TIME? 
 A: Usually your steps would be time, not temperature.  In that case, ON_TIME should be the number of time steps in 5 minutes.  If your time step is 1 second, ON_TIME should be 300.  Similarly OFF_TIME would be 120.  Then I would expect you to increment T by the timestep, not by K1 or K2.  You never use temperature, all you care about is the expected time to get from low to high.
Added:  it sounded like the oven was constantly cycling between the hot and cold limits.  Now it sounds like you want to stay at one level, more common in ovens.  If you assume that the heating and cooling is linear (and you don't have any better data) and you want to hold accuracy of Ts, you can afford to be on for Ts/warming rate  and off for Ts/cooling rate.  With the constants you give that would be on $\frac {1C}{10\ C/min}=\frac 1{10} min =  6 sec$  With the faster cooling time, the off time will be $\frac 52$ times less or $2.4 sec$.  You can divide by your timestep to get the number of cycles on and off.  If the timestep is 0.2 sec, it would be $30$ cycles on, $12$ cycles off.  The problem with this is that the temperature will tend to walk away if your constants are not right.  That is why one usually measures the temperature and switches the relay in response to the measurement instead of forecasting the behavior.
