@@ -243,7 +243,7 @@ void CScheduler::ReloadSchedules()
243
243
}
244
244
245
245
// Add Setpoint Timers
246
- result = m_sql.safe_query (" SELECT T1.DeviceRowID, T1.Time, T1.Type, T1.Temperature, T1.Days, T2.Name, T1.[Date] FROM SetpointTimers as T1, DeviceStatus as T2 WHERE ((T1.Active == 1) AND (T1.TimerPlan == %d) AND (T2.ID == T1.DeviceRowID)) ORDER BY T1.ID" ,
246
+ result = m_sql.safe_query (" SELECT T1.DeviceRowID, T1.Time, T1.Type, T1.Temperature, T1.Days, T2.Name, T1.[Date], T1.MDay, T1.Month, T1.Occurence FROM SetpointTimers as T1, DeviceStatus as T2 WHERE ((T1.Active == 1) AND (T1.TimerPlan == %d) AND (T2.ID == T1.DeviceRowID)) ORDER BY T1.ID" ,
247
247
m_sql.m_ActiveTimerPlan );
248
248
if (result.size () > 0 )
249
249
{
@@ -257,6 +257,9 @@ void CScheduler::ReloadSchedules()
257
257
titem.bEnabled = true ;
258
258
titem.bIsScene = false ;
259
259
titem.bIsThermostat = true ;
260
+ titem.MDay = 0 ;
261
+ titem.Month = 0 ;
262
+ titem.Occurence = 0 ;
260
263
261
264
std::stringstream s_str (sd[0 ]);
262
265
s_str >> titem.RowID ;
@@ -272,6 +275,38 @@ void CScheduler::ReloadSchedules()
272
275
titem.startMonth = (unsigned char )atoi (sdate.substr (5 , 2 ).c_str ());
273
276
titem.startDay = (unsigned char )atoi (sdate.substr (8 , 2 ).c_str ());
274
277
}
278
+ else if (timerType == TTYPE_MONTHLY)
279
+ {
280
+ std::string smday = sd[7 ];
281
+ if (smday == " 0" )
282
+ continue ; // invalid
283
+ titem.MDay = atoi (smday.c_str ());
284
+ }
285
+ else if (timerType == TTYPE_MONTHLY_WD)
286
+ {
287
+ std::string socc = sd[9 ];
288
+ if (socc == " 0" )
289
+ continue ; // invalid
290
+ titem.Occurence = atoi (socc.c_str ());
291
+ }
292
+ else if (timerType == TTYPE_YEARLY)
293
+ {
294
+ std::string smday = sd[7 ];
295
+ std::string smonth = sd[8 ];
296
+ if ((smday == " 0" ) || (smonth == " 0" ))
297
+ continue ; // invalid
298
+ titem.MDay = atoi (smday.c_str ());
299
+ titem.Month = atoi (smonth.c_str ());
300
+ }
301
+ else if (timerType == TTYPE_YEARLY_WD)
302
+ {
303
+ std::string smonth = sd[8 ];
304
+ std::string socc = sd[9 ];
305
+ if ((smonth == " 0" ) || (socc == " 0" ))
306
+ continue ; // invalid
307
+ titem.Month = atoi (smonth.c_str ());
308
+ titem.Occurence = atoi (socc.c_str ());
309
+ }
275
310
276
311
titem.startHour = (unsigned char )atoi (sd[1 ].substr (0 , 2 ).c_str ());
277
312
titem.startMin = (unsigned char )atoi (sd[1 ].substr (3 , 2 ).c_str ());
@@ -1234,11 +1269,11 @@ namespace http {
1234
1269
if (idx == 0 )
1235
1270
return ;
1236
1271
root[" status" ] = " OK" ;
1237
- root[" title" ] = " Timers " ;
1272
+ root[" title" ] = " SetpointTimers " ;
1238
1273
char szTmp[50 ];
1239
1274
1240
1275
std::vector<std::vector<std::string> > result;
1241
- result = m_sql.safe_query (" SELECT ID, Active, [Date], Time, Type, Temperature, Days FROM SetpointTimers WHERE (DeviceRowID=%llu) AND (TimerPlan==%d) ORDER BY ID" ,
1276
+ result = m_sql.safe_query (" SELECT ID, Active, [Date], Time, Type, Temperature, Days, MDay, Month, Occurence FROM SetpointTimers WHERE (DeviceRowID=%llu) AND (TimerPlan==%d) ORDER BY ID" ,
1242
1277
idx, m_sql.m_ActiveTimerPlan );
1243
1278
if (result.size () > 0 )
1244
1279
{
@@ -1268,6 +1303,9 @@ namespace http {
1268
1303
root[" result" ][ii][" Type" ] = iTimerType;
1269
1304
root[" result" ][ii][" Temperature" ] = atof (sd[5 ].c_str ());
1270
1305
root[" result" ][ii][" Days" ] = atoi (sd[6 ].c_str ());
1306
+ root[" result" ][ii][" MDay" ] = atoi (sd[7 ].c_str ());
1307
+ root[" result" ][ii][" Month" ] = atoi (sd[8 ].c_str ());
1308
+ root[" result" ][ii][" Occurence" ] = atoi (sd[9 ].c_str ());
1271
1309
ii++;
1272
1310
}
1273
1311
}
@@ -1288,6 +1326,9 @@ namespace http {
1288
1326
std::string smin = request::findValue (&req, " min" );
1289
1327
std::string stvalue = request::findValue (&req, " tvalue" );
1290
1328
std::string sdays = request::findValue (&req, " days" );
1329
+ std::string smday = " 0" ;
1330
+ std::string smonth = " 0" ;
1331
+ std::string soccurence = " 0" ;
1291
1332
if (
1292
1333
(idx == " " ) ||
1293
1334
(active == " " ) ||
@@ -1316,22 +1357,50 @@ namespace http {
1316
1357
Year = atoi (sdate.substr (6 , 4 ).c_str ());
1317
1358
}
1318
1359
}
1360
+ else if (iTimerType == TTYPE_MONTHLY)
1361
+ {
1362
+ smday = request::findValue (&req, " mday" );
1363
+ if (smday == " " ) return ;
1364
+ }
1365
+ else if (iTimerType == TTYPE_MONTHLY_WD)
1366
+ {
1367
+ soccurence = request::findValue (&req, " occurence" );
1368
+ if (soccurence == " " ) return ;
1369
+ }
1370
+ else if (iTimerType == TTYPE_YEARLY)
1371
+ {
1372
+ smday = request::findValue (&req, " mday" );
1373
+ smonth = request::findValue (&req, " month" );
1374
+ if ((smday == " " ) || (smonth == " " )) return ;
1375
+ }
1376
+ else if (iTimerType == TTYPE_YEARLY_WD)
1377
+ {
1378
+ smonth = request::findValue (&req, " month" );
1379
+ soccurence = request::findValue (&req, " occurence" );
1380
+ if ((smonth == " " ) || (soccurence == " " )) return ;
1381
+ }
1319
1382
1320
1383
unsigned char hour = atoi (shour.c_str ());
1321
1384
unsigned char min = atoi (smin.c_str ());
1322
1385
int days = atoi (sdays.c_str ());
1323
1386
float temperature = static_cast <float >(atof (stvalue.c_str ()));
1387
+ int mday = atoi (smday.c_str ());
1388
+ int month = atoi (smonth.c_str ());
1389
+ int occurence = atoi (soccurence.c_str ());
1324
1390
root[" status" ] = " OK" ;
1325
1391
root[" title" ] = " AddSetpointTimer" ;
1326
1392
m_sql.safe_query (
1327
- " INSERT INTO SetpointTimers (Active, DeviceRowID, [Date], Time, Type, Temperature, Days, TimerPlan) VALUES (%d,'%q','%04d-%02d-%02d','%02d:%02d',%d,%.1f,%d,%d)" ,
1393
+ " INSERT INTO SetpointTimers (Active, DeviceRowID, [Date], Time, Type, Temperature, Days, MDay, Month, Occurence, TimerPlan) VALUES (%d,'%q','%04d-%02d-%02d','%02d:%02d',%d,%.1f,%d,%d,%d ,%d,%d)" ,
1328
1394
(active == " true" ) ? 1 : 0 ,
1329
1395
idx.c_str (),
1330
1396
Year, Month, Day,
1331
1397
hour, min,
1332
1398
iTimerType,
1333
1399
temperature,
1334
1400
days,
1401
+ mday,
1402
+ month,
1403
+ occurence,
1335
1404
m_sql.m_ActiveTimerPlan
1336
1405
);
1337
1406
m_mainworker.m_scheduler .ReloadSchedules ();
@@ -1353,6 +1422,9 @@ namespace http {
1353
1422
std::string smin = request::findValue (&req, " min" );
1354
1423
std::string stvalue = request::findValue (&req, " tvalue" );
1355
1424
std::string sdays = request::findValue (&req, " days" );
1425
+ std::string smday = " 0" ;
1426
+ std::string smonth = " 0" ;
1427
+ std::string soccurence = " 0" ;
1356
1428
if (
1357
1429
(idx == " " ) ||
1358
1430
(active == " " ) ||
@@ -1381,21 +1453,49 @@ namespace http {
1381
1453
Year = atoi (sdate.substr (6 , 4 ).c_str ());
1382
1454
}
1383
1455
}
1456
+ else if (iTimerType == TTYPE_MONTHLY)
1457
+ {
1458
+ smday = request::findValue (&req, " mday" );
1459
+ if (smday == " " ) return ;
1460
+ }
1461
+ else if (iTimerType == TTYPE_MONTHLY_WD)
1462
+ {
1463
+ soccurence = request::findValue (&req, " occurence" );
1464
+ if (soccurence == " " ) return ;
1465
+ }
1466
+ else if (iTimerType == TTYPE_YEARLY)
1467
+ {
1468
+ smday = request::findValue (&req, " mday" );
1469
+ smonth = request::findValue (&req, " month" );
1470
+ if ((smday == " " ) || (smonth == " " )) return ;
1471
+ }
1472
+ else if (iTimerType == TTYPE_YEARLY_WD)
1473
+ {
1474
+ smonth = request::findValue (&req, " month" );
1475
+ soccurence = request::findValue (&req, " occurence" );
1476
+ if ((smonth == " " ) || (soccurence == " " )) return ;
1477
+ }
1384
1478
1385
1479
unsigned char hour = atoi (shour.c_str ());
1386
1480
unsigned char min = atoi (smin.c_str ());
1387
1481
int days = atoi (sdays.c_str ());
1388
1482
float tempvalue = static_cast <float >(atof (stvalue.c_str ()));
1483
+ int mday = atoi (smday.c_str ());
1484
+ int month = atoi (smonth.c_str ());
1485
+ int occurence = atoi (soccurence.c_str ());
1389
1486
root[" status" ] = " OK" ;
1390
1487
root[" title" ] = " UpdateSetpointTimer" ;
1391
1488
m_sql.safe_query (
1392
- " UPDATE SetpointTimers SET Active=%d, [Date]='%04d-%02d-%02d', Time='%02d:%02d', Type=%d, Temperature=%.1f, Days=%d WHERE (ID == '%q')" ,
1489
+ " UPDATE SetpointTimers SET Active=%d, [Date]='%04d-%02d-%02d', Time='%02d:%02d', Type=%d, Temperature=%.1f, Days=%d, MDay=%d, Month=%d, Occurence=%d WHERE (ID == '%q')" ,
1393
1490
(active == " true" ) ? 1 : 0 ,
1394
1491
Year, Month, Day,
1395
1492
hour, min,
1396
1493
iTimerType,
1397
1494
tempvalue,
1398
1495
days,
1496
+ mday,
1497
+ month,
1498
+ occurence,
1399
1499
idx.c_str ()
1400
1500
);
1401
1501
m_mainworker.m_scheduler .ReloadSchedules ();
0 commit comments