@@ -5383,96 +5383,64 @@ void Attribute::log_quality()
53835383 dev = tg->get_device_by_name (d_name);
53845384 }
53855385
5386- //
5387- // Log something if the new quality is different than the old one
5388- //
5386+ const bool has_quality_changed = quality != old_quality;
5387+ const bool has_alarm_changed = alarm != old_alarm;
5388+ const bool is_alarm_set = alarm. any ();
53895389
5390- if (quality != old_quality )
5390+ if (has_quality_changed )
53915391 {
5392- if (alarm. any () == false )
5392+ if (! is_alarm_set )
53935393 {
5394-
5395- //
5396- // No alarm detected
5397- //
5398-
5399- switch (quality)
5394+ switch (quality)
54005395 {
5401- case ATTR_INVALID:
5402- DEV_ERROR_STREAM (dev) << " INVALID quality for attribute " << get_name () << std::endl;
5403- break ;
5396+ case ATTR_INVALID:
5397+ DEV_ERROR_STREAM (dev) << " INVALID quality for attribute " << name << std::endl;
5398+ break ;
54045399
5405- case ATTR_CHANGING:
5406- DEV_INFO_STREAM (dev) << " CHANGING quality for attribute " << get_name () << std::endl;
5407- break ;
5400+ case ATTR_CHANGING:
5401+ DEV_INFO_STREAM (dev) << " CHANGING quality for attribute " << name << std::endl;
5402+ break ;
54085403
5409- case ATTR_VALID:
5410- DEV_INFO_STREAM (dev) << " INFO quality for attribute " << get_name () << std::endl;
5411- break ;
5404+ case ATTR_VALID:
5405+ DEV_INFO_STREAM (dev) << " INFO quality for attribute " << name << std::endl;
5406+ break ;
54125407
5413- default :
5414- break ;
5408+ default :
5409+ break ;
54155410 }
54165411 }
54175412 else
54185413 {
5419-
5420- //
5421- // Different log according to which alarm is set
5422- //
5423-
5424- if (alarm[min_level] == true )
5425- {
5426- DEV_ERROR_STREAM (dev) << " MIN ALARM for attribute " << get_name () << std::endl;
5427- }
5428- else if (alarm[max_level] == true )
5429- {
5430- DEV_ERROR_STREAM (dev) << " MAX ALARM for attribute " << get_name () << std::endl;
5431- }
5432- else if (alarm[rds] == true )
5433- {
5434- DEV_WARN_STREAM (dev) << " RDS (Read Different Set) ALARM for attribute " << get_name () << std::endl;
5435- }
5436- else if (alarm[min_warn] == true )
5437- {
5438- DEV_WARN_STREAM (dev) << " MIN WARNING for attribute " << get_name () << std::endl;
5439- }
5440- else if (alarm[max_warn] == true )
5441- {
5442- DEV_WARN_STREAM (dev) << " MAX WARNING for attribute " << get_name () << std::endl;
5443- }
5414+ log_alarm_quality ();
54445415 }
54455416 }
5446- else
5417+ else if (has_alarm_changed)
54475418 {
5419+ log_alarm_quality ();
5420+ }
5421+ }
54485422
5449- //
5450- // The quality is the same but may be the alarm has changed
5451- //
5452-
5453- if (alarm != old_alarm)
5454- {
5455- if (alarm[min_level] == true )
5456- {
5457- DEV_ERROR_STREAM (dev) << " MIN ALARM for attribute " << get_name () << std::endl;
5458- }
5459- else if (alarm[max_level] == true )
5460- {
5461- DEV_ERROR_STREAM (dev) << " MAX ALARM for attribute " << get_name () << std::endl;
5462- }
5463- else if (alarm[rds] == true )
5464- {
5465- DEV_WARN_STREAM (dev) << " RDS (Read Different Set) ALARM for attribute " << get_name () << std::endl;
5466- }
5467- else if (alarm[min_warn] == true )
5468- {
5469- DEV_WARN_STREAM (dev) << " MIN WARNING for attribute " << get_name () << std::endl;
5470- }
5471- else if (alarm[max_warn] == true )
5472- {
5473- DEV_WARN_STREAM (dev) << " MAX WARNING for attribute " << get_name () << std::endl;
5474- }
5475- }
5423+ void Attribute::log_alarm_quality () const
5424+ {
5425+ if (alarm[min_level])
5426+ {
5427+ DEV_ERROR_STREAM (dev) << " MIN ALARM for attribute " << name << std::endl;
5428+ }
5429+ else if (alarm[max_level])
5430+ {
5431+ DEV_ERROR_STREAM (dev) << " MAX ALARM for attribute " << name << std::endl;
5432+ }
5433+ else if (alarm[rds])
5434+ {
5435+ DEV_WARN_STREAM (dev) << " RDS (Read Different Set) ALARM for attribute " << name << std::endl;
5436+ }
5437+ else if (alarm[min_warn])
5438+ {
5439+ DEV_WARN_STREAM (dev) << " MIN WARNING for attribute " << name << std::endl;
5440+ }
5441+ else if (alarm[max_warn])
5442+ {
5443+ DEV_WARN_STREAM (dev) << " MAX WARNING for attribute " << name << std::endl;
54765444 }
54775445}
54785446
0 commit comments