@@ -119,6 +119,8 @@ MultiFun::MultiFun(const int ID, const std::string &IPAddress, const unsigned sh
119
119
120
120
m_isSensorExists[0 ] = false ;
121
121
m_isSensorExists[1 ] = false ;
122
+ m_isWeatherWork[0 ] = false ;
123
+ m_isWeatherWork[1 ] = false ;
122
124
}
123
125
124
126
MultiFun::~MultiFun ()
@@ -240,7 +242,8 @@ bool MultiFun::WriteToHardware(const char *pdata, const unsigned char length)
240
242
241
243
float temp = therm->temp ;
242
244
243
- if (therm->id2 == 0x1F || therm->id2 == 0x20 )
245
+ if ((therm->id2 == 0x1F || therm->id2 == 0x20 ) ||
246
+ ((therm->id2 == 0x1C || therm->id2 == 0x1D ) && m_isWeatherWork[therm->id2 - 0x1C ]))
244
247
{
245
248
temp = temp * 5 ;
246
249
temp = (int )temp | 0x8000 ;
@@ -346,7 +349,7 @@ void MultiFun::GetTemperatures()
346
349
347
350
if ((temp > -39 ) && (temp < 1000 ))
348
351
{
349
- SendTempSensor (i, - 1 , temp, sensors[i].name );
352
+ SendTempSensor (i, 255 , temp, sensors[i].name );
350
353
}
351
354
if ((i == 1 ) || (i == 2 ))
352
355
{
@@ -400,17 +403,17 @@ void MultiFun::GetRegisters(bool firstTime)
400
403
{
401
404
if (((*it).first & value) && !((*it).first & m_LastAlarms))
402
405
{
403
- SendTextSensor (1 , 0 , - 1 , (*it).second , " Alarms" );
406
+ SendTextSensor (1 , 0 , 255 , (*it).second , " Alarms" );
404
407
}
405
408
else
406
409
if (!((*it).first & value) && ((*it).first & m_LastAlarms))
407
410
{
408
- SendTextSensor (1 , 0 , - 1 , " End - " + (*it).second , " Alarms" );
411
+ SendTextSensor (1 , 0 , 255 , " End - " + (*it).second , " Alarms" );
409
412
}
410
413
}
411
414
if (((bool )m_LastAlarms != bool (value)) || firstTime)
412
415
{
413
- SendAlertSensor (0 , - 1 , value ? 4 : 1 , " Alarm" );
416
+ SendAlertSensor (0 , 255 , value ? 4 : 1 , " Alarm" );
414
417
}
415
418
m_LastAlarms = value;
416
419
break ;
@@ -422,17 +425,17 @@ void MultiFun::GetRegisters(bool firstTime)
422
425
{
423
426
if (((*it).first & value) && !((*it).first & m_LastWarnings))
424
427
{
425
- SendTextSensor (1 , 1 , - 1 , (*it).second , " Warnings" );
428
+ SendTextSensor (1 , 1 , 255 , (*it).second , " Warnings" );
426
429
}
427
430
else
428
431
if (!((*it).first & value) && ((*it).first & m_LastWarnings))
429
432
{
430
- SendTextSensor (1 , 1 , - 1 , " End - " + (*it).second , " Warnings" );
433
+ SendTextSensor (1 , 1 , 255 , " End - " + (*it).second , " Warnings" );
431
434
}
432
435
}
433
436
if (((bool )m_LastWarnings != bool (value)) || firstTime)
434
437
{
435
- SendAlertSensor (1 , - 1 , value ? 3 : 1 , " Warning" );
438
+ SendAlertSensor (1 , 255 , value ? 3 : 1 , " Warning" );
436
439
}
437
440
m_LastWarnings = value;
438
441
break ;
@@ -444,18 +447,18 @@ void MultiFun::GetRegisters(bool firstTime)
444
447
{
445
448
if (((*it).first & value) && !((*it).first & m_LastDevices))
446
449
{
447
- SendGeneralSwitchSensor (2 , - 1 , true , (*it).second .c_str (), (*it).first );
450
+ SendGeneralSwitchSensor (2 , 255 , true , (*it).second .c_str (), (*it).first );
448
451
}
449
452
else
450
453
if (!((*it).first & value) && ((*it).first & m_LastDevices))
451
454
{
452
- SendGeneralSwitchSensor (2 , - 1 , false , (*it).second .c_str (), (*it).first );
455
+ SendGeneralSwitchSensor (2 , 255 , false , (*it).second .c_str (), (*it).first );
453
456
}
454
457
}
455
458
m_LastDevices = value;
456
459
457
460
float level = (value & 0xFC00 ) >> 10 ;
458
- SendPercentageSensor (2 , 1 , - 1 , level, " BLOWER POWER" );
461
+ SendPercentageSensor (2 , 1 , 255 , level, " BLOWER POWER" );
459
462
break ;
460
463
}
461
464
case 0x03 :
@@ -465,18 +468,18 @@ void MultiFun::GetRegisters(bool firstTime)
465
468
{
466
469
if (((*it).first & value) && !((*it).first & m_LastState))
467
470
{
468
- SendTextSensor (3 , 1 , - 1 , (*it).second , " State" );
471
+ SendTextSensor (3 , 1 , 255 , (*it).second , " State" );
469
472
}
470
473
else
471
474
if (!((*it).first & value) && ((*it).first & m_LastState))
472
475
{
473
- SendTextSensor (3 , 1 , - 1 , " End - " + (*it).second , " State" );
476
+ SendTextSensor (3 , 1 , 255 , " End - " + (*it).second , " State" );
474
477
}
475
478
}
476
479
m_LastState = value;
477
480
478
481
float level = (value & 0xFC00 ) >> 10 ;
479
- SendPercentageSensor (3 , 1 , - 1 , level, " Fuel Level" );
482
+ SendPercentageSensor (3 , 1 , 255 , level, " Fuel Level" );
480
483
break ;
481
484
}
482
485
@@ -491,6 +494,7 @@ void MultiFun::GetRegisters(bool firstTime)
491
494
{
492
495
temp = (value & 0x0FFF ) * 0.2 ;
493
496
}
497
+ m_isWeatherWork[i - 0x1C ] = (value & 0x8000 ) == 0x8000 ;
494
498
SendSetPointSensor (i, 1 , 1 , temp, name);
495
499
break ;
496
500
}
@@ -514,7 +518,7 @@ void MultiFun::GetRegisters(bool firstTime)
514
518
}
515
519
else
516
520
{
517
- // SendGeneralSwitchSensor(i, -1 , value, name, 1); // TODO - send level (dimmer)
521
+ // SendGeneralSwitchSensor(i, 255 , value, name, 1); // TODO - send level (dimmer)
518
522
}
519
523
break ;
520
524
}
@@ -526,12 +530,12 @@ void MultiFun::GetRegisters(bool firstTime)
526
530
{
527
531
if (((*it).first & value) && !((*it).first & m_LastQuickAccess))
528
532
{
529
- SendGeneralSwitchSensor (0x21 , - 1 , true , (*it).second .c_str (), (*it).first );
533
+ SendGeneralSwitchSensor (0x21 , 255 , true , (*it).second .c_str (), (*it).first );
530
534
}
531
535
else
532
536
if ((!((*it).first & value) && ((*it).first & m_LastQuickAccess)) || firstTime)
533
537
{
534
- SendGeneralSwitchSensor (0x21 , - 1 , false , (*it).second .c_str (), (*it).first );
538
+ SendGeneralSwitchSensor (0x21 , 255 , false , (*it).second .c_str (), (*it).first );
535
539
}
536
540
}
537
541
m_LastQuickAccess = value;
@@ -625,7 +629,7 @@ int MultiFun::SendCommand(const unsigned char* cmd, const unsigned int cmdLength
625
629
{
626
630
if (databuffer[8 ] >= 1 && databuffer[8 ] <= 4 )
627
631
{
628
- _log.Log (LOG_ERROR, " MultiFun: Receive error (%s)" , errors[databuffer[8 ]].c_str ());
632
+ _log.Log (LOG_ERROR, " MultiFun: Receive error (%s)" , errors[databuffer[8 ] - 1 ].c_str ());
629
633
}
630
634
else
631
635
{
0 commit comments