void OutputEndpointStateChanged(object sender, StateChangedEventArgs eventArgs) { Console.WriteLine(eventArgs.Endpoint.Name + " is changed to " + eventArgs.Endpoint.CurrentState); //Find the HardwareEndpointID's corresponding to the endpoint where the state has changed. //Locate the HardwareEndpoint and ask the mapper for the corresponding state to put on the stack. //put it on the stack and "There will be light!". Maybe we should be talking in messages here. //To accomodate for dimmers and stuff //Locate hardware endpoint var hwe = CouplingInformation.EndpointCouples.First(c => c.Item1 == eventArgs.Endpoint.Name).Item2; //ask it for some control messages var controlMessages = hwe.Mapper.GetControllMessagesForEndpointState(eventArgs.Endpoint.CurrentState, hwe); foreach (var controlMessage in controlMessages) { Thread.Sleep(controlMessage.WaitTime); controlMessage.Enter(); } }
public void InvokeStateChanged(StateChangedEventArgs e) { var handler = StateChanged; if (handler != null) handler(this, e); }