29 extern int debug; |
29 extern int debug; |
30 extern sys_config Config; |
30 extern sys_config Config; |
31 |
31 |
32 int SIM_hlt_value = 0; |
32 int SIM_hlt_value = 0; |
33 int SIM_mlt_value = 0; |
33 int SIM_mlt_value = 0; |
|
34 int SIM_cooler = FALSE; |
34 |
35 |
35 |
36 |
36 #ifdef HAVE_WIRINGPI_H |
37 #ifdef HAVE_WIRINGPI_H |
37 PI_THREAD (my_simulator_loop) |
38 PI_THREAD (my_simulator_loop) |
38 #else |
39 #else |
78 */ |
79 */ |
79 Config.simulator->hlt_heater_state = SIM_hlt_value; |
80 Config.simulator->hlt_heater_state = SIM_hlt_value; |
80 if (SIM_hlt_value) { |
81 if (SIM_hlt_value) { |
81 Config.simulator->hlt_heater_temp += (250 - Config.simulator->hlt_heater_temp) / 2000; |
82 Config.simulator->hlt_heater_temp += (250 - Config.simulator->hlt_heater_temp) / 2000; |
82 } else { |
83 } else { |
83 Config.simulator->hlt_heater_temp -= (Config.simulator->hlt_heater_temp - Config.simulator->hlt_temperature) / 1000; |
84 Config.simulator->hlt_heater_temp -= (Config.simulator->hlt_heater_temp - Config.simulator->hlt_temperature) / 500; |
84 } |
85 } |
85 Config.simulator->mlt_heater_state = SIM_mlt_value; |
86 Config.simulator->mlt_heater_state = SIM_mlt_value; |
86 if (SIM_mlt_value) { |
87 if (SIM_mlt_value) { |
87 Config.simulator->mlt_heater_temp += (250 - Config.simulator->mlt_heater_temp) / 2000; |
88 Config.simulator->mlt_heater_temp += (250 - Config.simulator->mlt_heater_temp) / 2000; |
88 } else { |
89 } else { |
89 Config.simulator->mlt_heater_temp -= (Config.simulator->mlt_heater_temp - Config.simulator->mlt_temperature) / 1000; |
90 Config.simulator->mlt_heater_temp -= (Config.simulator->mlt_heater_temp - Config.simulator->mlt_temperature) / 500; |
|
91 } |
|
92 |
|
93 /* |
|
94 * If cooling, bring down the MLT temperature. Assume 14 degrees coolwater. |
|
95 */ |
|
96 if (SIM_cooler) { |
|
97 Config.simulator->mlt_temperature -= (Config.simulator->mlt_temperature - 14) / (250 * Config.simulator->hlt_heater_volume); |
90 } |
98 } |
91 |
99 |
92 /* |
100 /* |
93 * Shift the liquid temperature towards the heating elements temperature, |
101 * Shift the liquid temperature towards the heating elements temperature, |
94 * but never higher then 100 degrees celcius. |
102 * but never higher then 100 degrees celcius. |
106 last = now; |
114 last = now; |
107 /* |
115 /* |
108 * Each second |
116 * Each second |
109 */ |
117 */ |
110 if (debug) |
118 if (debug) |
111 fprintf(stdout, "HLT temp=%f plate=%f val=%d MLT temp=%f plate=%f val=%d Room %.1f loops=%d\n", |
119 fprintf(stdout, "HLT temp=%f plate=%f val=%d MLT temp=%f plate=%f val=%d Room %.1f loops=%d cool=%s\n", |
112 Config.simulator->hlt_temperature, Config.simulator->hlt_heater_temp, Config.simulator->hlt_heater_state, |
120 Config.simulator->hlt_temperature, Config.simulator->hlt_heater_temp, Config.simulator->hlt_heater_state, |
113 Config.simulator->mlt_temperature, Config.simulator->mlt_heater_temp, Config.simulator->mlt_heater_state, |
121 Config.simulator->mlt_temperature, Config.simulator->mlt_heater_temp, Config.simulator->mlt_heater_state, |
114 Config.simulator->room_temperature, loops); |
122 Config.simulator->room_temperature, loops, SIM_cooler ? "Yes":"No"); |
115 loops = 0; |
123 loops = 0; |
116 } |
124 } |
117 usleep(50000); |
125 usleep(50000); |
118 } |
126 } |
119 |
127 |