Subversion Repositories heating

Rev

Rev 54 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 54 Rev 55
Line 229... Line 229...
229
 
229
 
230
				if (evaluateTemp(akt->rnum, tmp))		// Should we start heating?
230
				if (evaluateTemp(akt->rnum, tmp))		// Should we start heating?
231
					startHeat(akt->rnum);				// yes
231
					startHeat(akt->rnum);				// yes
232
				else									// Or should we stop heating
232
				else									// Or should we stop heating
233
					stopHeat(akt->rnum);				// yes
233
					stopHeat(akt->rnum);				// yes
-
 
234
 
-
 
235
				if (isHeating())						// As long as there is a room who need heating, this function returns true.
-
 
236
					controlHeat(0, true);
-
 
237
				else
-
 
238
					controlHeat(0, false);
234
			}
239
			}
235
 
240
 
236
			akt = akt->next;
241
			akt = akt->next;
237
		}
242
		}
238
 
243
 
Line 257... Line 262...
257
}
262
}
258
 
263
 
259
void heating::controlHeat (int room, bool stst)
264
void heating::controlHeat (int room, bool stst)
260
{
265
{
261
HCONF *akt = HeatConf;
266
HCONF *akt = HeatConf;
262
int pin;
267
int pin, gpio;
263
 
268
 
264
	while (akt)
269
	if (room > 0)
265
	{
270
	{
-
 
271
		while (akt)
-
 
272
		{
266
		if (akt->rnum == room)
273
			if (akt->rnum == room)
267
			break;
274
				break;
268
 
275
 
269
		akt = akt->next;
276
			akt = akt->next;
270
	}
277
		}
271
 
278
 
272
	if (!akt)
279
		if (!akt)
273
	{
280
		{
274
		syslog(LOG_WARNING, "controlHeat: Room %d not found!", room);
281
			syslog(LOG_WARNING, "controlHeat: Room %d not found!", room);
275
		return;
282
			return;
276
	}
283
		}
277
 
284
 
278
	if (akt->valve != stst)
285
		if (akt->valve != stst)
279
	{
286
		{
280
		if (Configure.debug)
287
			if (Configure.debug)
281
			syslog(LOG_DEBUG, "Heating for room %d switched %s", room, (stst) ? "ON" : "OFF");
288
				syslog(LOG_DEBUG, "Heating for room %d switched %s", room, (stst) ? "ON" : "OFF");
282
 
289
 
283
		string h = "HEATING:";
290
			string h = "HEATING:";
284
		h.append(itostring(room) + ":");
291
			h.append(itostring(room) + ":");
285
		h.append((stst)? "ON;" : "OFF;");
292
			h.append((stst)? "ON;" : "OFF;");
286
		answer(h);
293
			answer(h);
-
 
294
		}
-
 
295
 
-
 
296
		gpio = akt->gpio;
287
	}
297
	}
-
 
298
	else if (heatIO <= 0)
-
 
299
		return;
-
 
300
	else
-
 
301
		gpio = heatIO;
288
 
302
 
289
	switch (akt->gpio)
303
	switch (gpio)
290
	{
304
	{
291
		case 1: pin = PIN1; break;
305
		case 1: pin = PIN1; break;
292
		case 2: pin = PIN2; break;
306
		case 2: pin = PIN2; break;
293
		case 3: pin = PIN3; break;
307
		case 3: pin = PIN3; break;
294
		case 4: pin = PIN4; break;
308
		case 4: pin = PIN4; break;
Line 299... Line 313...
299
		case 9: pin = PIN9; break;
313
		case 9: pin = PIN9; break;
300
		default:
314
		default:
301
			return;
315
			return;
302
	}
316
	}
303
 
317
 
-
 
318
	if (room && akt)
304
	akt->valve = stst;
319
		akt->valve = stst;
305
	// Enable the GPIO pin to start heating
320
	// Enable the GPIO pin to start heating
306
	if (!bcmInitialized)
321
	if (!bcmInitialized)
307
		return;
322
		return;
308
 
323
 
309
	// Set the pin to be an output
324
	// Set the pin to be an output
Line 796... Line 811...
796
			onoff = ToBool(hv1);
811
			onoff = ToBool(hv1);
797
 
812
 
798
		if (!compcase(hv0, "OutSensor") && cs == GLOBAL)
813
		if (!compcase(hv0, "OutSensor") && cs == GLOBAL)
799
			outSensor = atoi(hv1);
814
			outSensor = atoi(hv1);
800
 
815
 
-
 
816
		if (!compcase(hv0, "HeatIO") && cs == GLOBAL)
-
 
817
			heatIO = atoi(hv1);
-
 
818
 
801
		if (cs == ROOM)
819
		if (cs == ROOM)
802
		{
820
		{
803
			if (!compcase(hv0, "soll"))
821
			if (!compcase(hv0, "soll"))
804
				akt->soll = atoi(hv1);
822
				akt->soll = atoi(hv1);
805
 
823
 
Line 849... Line 867...
849
 
867
 
850
		akt = akt->next;
868
		akt = akt->next;
851
	}
869
	}
852
 
870
 
853
	cfile.close ();
871
	cfile.close ();
-
 
872
 
-
 
873
	if (heatIO <= 0)
-
 
874
		syslog (LOG_DAEMON, "Missing the GPIO number to start and stop the heating! This heat control will not work!");
-
 
875
 
854
	return true;
876
	return true;
855
}
877
}
856
 
878
 
857
 
879
 
858
bool heating::buildDB()
880
bool heating::buildDB()
Line 1178... Line 1200...
1178
	rm++;
1200
	rm++;
1179
	akt->rnum = rm;
1201
	akt->rnum = rm;
1180
	return akt;
1202
	return akt;
1181
}
1203
}
1182
 
1204
 
-
 
1205
/*
-
 
1206
 * This function checks if there is a room where heating is requested.
-
 
1207
 * If only one room requests heating, it returns true. This means, that
-
 
1208
 * the therme, the heating, should start.
-
 
1209
 * Otherwise it should stop heating.
-
 
1210
 * This will work only, if there's a GPIO pin defined for the heating!
-
 
1211
 * Beside this the function checks whether the defined GPIO pin is
-
 
1212
 * unique. If not, it always returns false.
-
 
1213
 */
-
 
1214
bool heating::isHeating()
-
 
1215
{
-
 
1216
HCONF *akt = HeatConf;
-
 
1217
 
-
 
1218
	if (heatIO <= 0)
-
 
1219
		return false;
-
 
1220
 
-
 
1221
	// Make sure the defined GPIO pin for the heating is unique.
-
 
1222
	while (akt)
-
 
1223
	{
-
 
1224
		if (akt->gpio == heatIO)
-
 
1225
			return false;
-
 
1226
 
-
 
1227
		akt = akt->next;
-
 
1228
	}
-
 
1229
 
-
 
1230
	// Find out if there is a room who requested heating.
-
 
1231
	akt = HeatConf;
-
 
1232
 
-
 
1233
	while (akt)
-
 
1234
	{
-
 
1235
		if (akt->valve)
-
 
1236
			return true;
-
 
1237
 
-
 
1238
		akt = akt->next;
-
 
1239
	}
-
 
1240
 
-
 
1241
	return false;
-
 
1242
}
-
 
1243
 
1183
heating::HTABLE* heating::appendHTable(HCONF *ht)
1244
heating::HTABLE* heating::appendHTable(HCONF *ht)
1184
{
1245
{
1185
HTABLE *akt, *p;
1246
HTABLE *akt, *p;
1186
 
1247
 
1187
	akt = new HTABLE;
1248
	akt = new HTABLE;