public void SetMemento(XElement profileElement) { Id = Guid.Parse(profileElement.GetAttributeString("id")); Name = profileElement.GetAttributeString("name"); Decay = profileElement.GetAttributeUint("decay"); HasRestrictedHours = profileElement.GetAttributeBoolean("restrictedhours"); StartTime = profileElement.GetAttributeUint("starttime"); EndTime = profileElement.GetAttributeUint("endtime"); foreach (var stateElement in profileElement.Elements("state")) { var state = new ProfileState { BuildState = stateElement.GetAttributeEnum("name", BuildState.Unknown), Green = stateElement.GetAttributeBoolean("green"), Yellow = stateElement.GetAttributeBoolean("yellow"), Red = stateElement.GetAttributeBoolean("red"), Flash = stateElement.GetAttributeBoolean("flash"), Buzzer = stateElement.GetAttributeBoolean("buzzer") }; States.Add(state); } }
private void SetColorBasedOnProfile(ProfileState profileState, Color color, DateTimeOffset timeStamp) { Log.Information("=> DelcomDevice.SetColorBasedOnProfile"); var isColorTurnedOn = color == Color.Green && profileState.Green || color == Color.Yellow && profileState.Yellow || color == Color.Red && profileState.Red; if (isColorTurnedOn) { var intensity = GetColorIntensity(color, timeStamp); if (profileState.Flash) { Log.Information("Flashing '{0}' at intensity '{1}'", color.Name, intensity); PhysicalDevice.Flash(color, intensity); } else { Log.Information("Turning on '{0}' at intensity '{1}'", color.Name, intensity); PhysicalDevice.TurnOn(color, intensity); } } else { Log.Information("Turning off '{0}'", color.Name); PhysicalDevice.TurnOff(color); } }