private void MigService_InterfacePropertyChanged(InterfacePropertyChangedAction propertyChangedAction) { // TODO: route event to MIG.ProtocolAdapters if (InterfacePropertyChanged != null) { InterfacePropertyChanged(propertyChangedAction); } }
internal void RaiseProgramModuleEvent(ProgramBlock program, string property, string value) { var programModule = homegenie.Modules.Find(m => m.Domain == Domains.HomeAutomation_HomeGenie_Automation && m.Address == program.Address.ToString()); if (programModule != null) { var actionEvent = new MIG.InterfacePropertyChangedAction(); actionEvent.Domain = programModule.Domain; actionEvent.Path = property; actionEvent.Value = value; actionEvent.SourceId = programModule.Address; actionEvent.SourceType = "Automation Program"; Utility.ModuleParameterSet(programModule, property, value); homegenie.SignalModulePropertyChange(this, programModule, actionEvent); } }
public void SignalModulePropertyChange(object sender, Module module, InterfacePropertyChangedAction propertyChangedAction) { // ROUTE THE EVENT TO AUTOMATION PROGRAMS, BEFORE COMMITTING THE CHANGE if (masterControlProgram != null) { ModuleParameter tempParam = new ModuleParameter() { Name = propertyChangedAction.Path, Value = propertyChangedAction.Value.ToString() }; RoutedEvent eventData = new RoutedEvent() { Sender = sender, Module = module, Parameter = tempParam }; RouteParameterBeforeChangeEvent(eventData); // If the value has been manipulated by an automation program // so the event has to be updated as well if (tempParam.Value != propertyChangedAction.Value.ToString()) { HomeGenieService.LogEvent(Domains.HomeAutomation_HomeGenie, "ModuleParameterIsChanging(...)", "Parameter value manipulated by automation program", tempParam.Name, propertyChangedAction.Value.ToString() + " => " + tempParam.Value); propertyChangedAction.Value = tempParam.Value; } } ModuleParameter parameter = null; try { // Lookup for the existing module parameter parameter = Utility.ModuleParameterGet(module, propertyChangedAction.Path); if (parameter == null) { module.Properties.Add(new ModuleParameter() { Name = propertyChangedAction.Path, Value = propertyChangedAction.Value.ToString() }); parameter = Utility.ModuleParameterGet(module, propertyChangedAction.Path); } else { parameter.Value = propertyChangedAction.Value.ToString(); } } catch (Exception ex) { //HomeGenieService.LogEvent(Domains.HomeAutomation_HomeGenie, "SignalModulePropertyChange(...)", ex.Message, "Exception.StackTrace", ex.StackTrace); } string eventValue = (propertyChangedAction.Value.GetType() == typeof(String) ? propertyChangedAction.Value.ToString() : JsonConvert.SerializeObject(propertyChangedAction.Value)); LogBroadcastEvent( propertyChangedAction.Domain, propertyChangedAction.SourceId, propertyChangedAction.SourceType, propertyChangedAction.Path, eventValue ); // ROUTE EVENT TO LISTENING AutomationPrograms if (masterControlProgram != null) { RoutedEvent eventData = new RoutedEvent() { Sender = sender, Module = module, Parameter = parameter }; //RouteParameterChangedEvent(eventData); ThreadPool.QueueUserWorkItem(new WaitCallback(RouteParameterChangedEvent), eventData); } }
// called by interfaces, when a device changes internal void migService_InterfacePropertyChanged(InterfacePropertyChangedAction propertyChangedAction) { // look for module associated to this event Module module = null; try { module = Modules.Find(delegate(Module o) { return o.Domain == propertyChangedAction.Domain && o.Address == propertyChangedAction.SourceId; }); } catch { } // if (module != null && propertyChangedAction.Path != "") { // clear RoutingNode property since the event was locally generated //if (module.RoutingNode != "") //{ // module.RoutingNode = ""; //} // we found associated module in HomeGenie.Modules SignalModulePropertyChange(migService, module, propertyChangedAction); } else { if (propertyChangedAction.Domain == Domains.MigService_Interfaces) { modules_RefreshInterface(GetInterface(propertyChangedAction.SourceId)); } LogBroadcastEvent( propertyChangedAction.Domain, propertyChangedAction.SourceId, propertyChangedAction.SourceType, propertyChangedAction.Path, propertyChangedAction.Value != null ? propertyChangedAction.Value.ToString() : "" ); } }
public void SignalModulePropertyChange( object sender, Module module, InterfacePropertyChangedAction propertyChangedAction ) { // update module parameter value ModuleParameter parameter = null; try { parameter = Utility.ModuleParameterGet(module, propertyChangedAction.Path); if (parameter == null) { module.Properties.Add(new ModuleParameter() { Name = propertyChangedAction.Path, Value = propertyChangedAction.Value.ToString() }); } else { parameter.Value = propertyChangedAction.Value.ToString(); } } catch { // HomeGenieService.LogEvent(Domains.HomeAutomation_HomeGenie, "SignalModulePropertyChange(...)", ex.Message, "Exception.StackTrace", ex.StackTrace); } // LogBroadcastEvent( propertyChangedAction.Domain, propertyChangedAction.SourceId, propertyChangedAction.SourceType, propertyChangedAction.Path, JsonConvert.SerializeObject(propertyChangedAction.Value) ); // ///// ROUTE EVENT TO LISTENING AutomationPrograms if (masterControlProgram != null) { RoutedEvent eventData = new RoutedEvent() { Sender = sender, Module = module, Parameter = parameter }; ThreadPool.QueueUserWorkItem(new WaitCallback(RouteParameterChangedEvent), eventData); } }
// called by interfaces, when a device changes internal void migService_InterfacePropertyChanged(InterfacePropertyChangedAction propertyChangedAction) { // look for module associated to this event Module module = null; try { module = Modules.Find(delegate(Module o) { return o.Domain == propertyChangedAction.Domain && o.Address == propertyChangedAction.SourceId; }); } catch { } // if (module != null && propertyChangedAction.Path != "") { // clear RoutingNode property since the event was locally generated //if (module.RoutingNode != "") //{ // module.RoutingNode = ""; //} // we found associated module in HomeGenie.Modules #region z-wave specific stuff if (propertyChangedAction.SourceType == "ZWave Node") { if (propertyChangedAction.Path == Properties.ZWAVENODE_MANUFACTURERSPECIFIC) { ManufacturerSpecific zwavemanufacturerspecs = (ManufacturerSpecific)propertyChangedAction.Value; propertyChangedAction.Value = zwavemanufacturerspecs.ManufacturerId + ":" + zwavemanufacturerspecs.TypeId + ":" + zwavemanufacturerspecs.ProductId; //TODO: deprecate the following line UpdateZWaveNodeDeviceHandler(byte.Parse(propertyChangedAction.SourceId), module); } } #endregion z-wave specific stuff SignalModulePropertyChange(migService, module, propertyChangedAction); } else { // There is no source module in Modules for this event. modules_RefreshMisc(); } }