示例#1
0
 public CachedControlPair(LightControlPair light)
 {
     this.Properties      = light.Properties.DeepClone();
     this.PowerState      = light.PowerState;
     this.AppControlState = light.AppControlState;
     this.NetworkLight    = new AppLightState(light.NetworkLight);
     this.ExpectedLight   = light.ExpectedLight.DeepClone();
     if (light.Transition != null)
     {
         this.Transition = light.Transition.DeepClone();
     }
     this.ResetOccurred = light.ResetOccurred;
 }
示例#2
0
        public static void LogRefresh <T>(this ILogger <T> logger, CachedControlPair stale, LightControlPair refreshed)
        {
            if (stale.PowerState == refreshed.PowerState &&
                stale.AppControlState == refreshed.AppControlState &&
                stale.ResetOccurred == refreshed.ResetOccurred)
            {
                return;
            }
            var refreshMessage = $"Refreshed light | ID: {refreshed.Properties.Id} Name: {refreshed.Properties.Name}";

            if (stale.PowerState != refreshed.PowerState)
            {
                refreshMessage += $" | Power state changed from {stale.PowerState} to {refreshed.PowerState}";
            }
            if (stale.AppControlState != refreshed.AppControlState)
            {
                refreshMessage += $" | Control state changed from {stale.AppControlState} to {refreshed.AppControlState}";
            }
            if (refreshed.ResetOccurred != refreshed.ResetOccurred)
            {
                refreshMessage += refreshed.ResetOccurred ? $" | Light reset." : $" | Reset scheduled.";
            }
            logger.LogDebug(stale.ToString());
            logger.LogDebug(refreshed.ToString());
            logger.LogInformation(refreshMessage);
        }