public NetHelper SignalModuleEvent(string hgaddress, ModuleHelper m, ModuleParameter p) { string eventrouteurl = "http://" + hgaddress + "/api/HomeAutomation.HomeGenie/Interconnection/Events.Push/" + _homegenie.GetHttpServicePort(); // propagate event to remote hg endpoint this.WebService(eventrouteurl) .Put(JsonConvert.SerializeObject(new ModuleEvent(m.SelectedModules[0], p))) .CallAsync(); return(this); }
//TODO: add autodoc comment (HG Event forwarding) public NetHelper SignalModuleEvent(string hgAddress, ModuleHelper module, ModuleParameter parameter) { string eventRouteUrl = "http://" + hgAddress + "/api/HomeAutomation.HomeGenie/Interconnection/Events.Push/" + homegenie.GetHttpServicePort(); // propagate event to remote hg endpoint this.WebService(eventRouteUrl) .Put(JsonConvert.SerializeObject( new ModuleEvent(module.SelectedModules[0], parameter), new JsonSerializerSettings() { Culture = System.Globalization.CultureInfo.InvariantCulture } )) .CallAsync(); return(this); }
// TODO: add autodoc comment (HG Event forwarding) public NetHelper SignalModuleEvent(string hgAddress, ModuleHelper module, ModuleParameter parameter) { var eventRouteUrl = "http://" + hgAddress + "/api/" + Domains.HomeAutomation_HomeGenie + "/Interconnection/Events.Push/" + _homegenie.GetHttpServicePort(); // propagate event to remote hg endpoint Utility.RunAsyncTask(() => { WebService(eventRouteUrl) .Put(JsonConvert.SerializeObject(new ModuleEvent(module.Instance, parameter), new JsonSerializerSettings() { Culture = System.Globalization.CultureInfo.InvariantCulture })) .Call(); }); return(this); }
public ProgramHelper RaiseEvent(ModuleHelper module, string parameter, string value, string description) { MIG.InterfacePropertyChangedAction mact = new MIG.InterfacePropertyChangedAction(); mact.Domain = module.Instance.Domain; mact.Path = parameter; mact.Value = value; mact.SourceId = module.Instance.Address; mact.SourceType = "Virtual Module"; try { _homegenie.SignalModulePropertyChange(this, module.Instance, mact); } catch (Exception ex) { HomeGenieService.LogEvent(_programmodule.Domain, _programmodule.Address, ex.Message, "Exception.StackTrace", ex.StackTrace); } return(this); }
public void RoutePropertyChangedEvent(object eventData) { var moduleEvent = (RoutedEvent)eventData; var moduleHelper = new Scripting.ModuleHelper(hgService, moduleEvent.Module); for (int p = 0; p < Programs.Count; p++) { var program = Programs[p]; if (program == null || !program.IsEnabled || !isEngineEnabled) { continue; } if ((moduleEvent.Sender == null || !moduleEvent.Sender.Equals(program))) { try { program.Engine.RoutedEventAck.Set(); if (program.Engine.ModuleChangedHandler != null && moduleEvent.Parameter != null) // && proceed) { var param = moduleEvent.Parameter.DeepClone(); bool handled = !program.Engine.ModuleChangedHandler(moduleHelper, param); if (handled) { // stop routing event if "false" is returned MigService.Log.Debug("Event propagation halted by automation program '{0}' ({1}) (Name={2})", program.Name, program.Address, param.Name); break; } } } catch (Exception ex) { HomeGenieService.LogError( program.Domain, program.Address.ToString(), ex.Message, "Exception.StackTrace", ex.StackTrace ); } } } }
/// <summary> /// Raise a module parameter event and set the parameter with the specified value. /// </summary> /// <returns>ProgramHelper.</returns> /// <param name="module">The module source of this event.</param> /// <param name="parameter">Parameter name.</param> /// <param name="value">The new parameter value to set.</param> /// <param name="description">Event description.</param> public ProgramHelper RaiseEvent(ModuleHelper sourceModule, string parameter, string value, string description) { try { var actionEvent = new MIG.InterfacePropertyChangedAction(); actionEvent.Domain = sourceModule.Instance.Domain; actionEvent.Path = parameter; actionEvent.Value = value; actionEvent.SourceId = sourceModule.Instance.Address; actionEvent.SourceType = "Virtual Module"; homegenie.SignalModulePropertyChange(this, sourceModule.Instance, actionEvent); } catch (Exception ex) { HomeGenieService.LogEvent( programModule.Domain, programModule.Address, ex.Message, "Exception.StackTrace", ex.StackTrace ); } return(this); }
/// <summary> /// Raise a module parameter event and set the parameter with the specified value. /// </summary> /// <returns>ProgramHelper.</returns> /// <param name="module">The module source of this event.</param> /// <param name="parameter">Parameter name.</param> /// <param name="value">The new parameter value to set.</param> /// <param name="description">Event description.</param> public ProgramHelper RaiseEvent(ModuleHelper sourceModule, string parameter, string value, string description) { try { var actionEvent = homegenie.MigService.GetEvent( sourceModule.Instance.Domain, sourceModule.Instance.Address, description, parameter, value ); homegenie.RaiseEvent(myProgramId, actionEvent); } catch (Exception ex) { HomeGenieService.LogError( programModule.Domain, programModule.Address, ex.Message, "Exception.StackTrace", ex.StackTrace ); } return this; }
public ProgramHelper RaiseEvent(ModuleHelper module, string parameter, string value, string description) { try { var actionEvent = new MIG.InterfacePropertyChangedAction(); actionEvent.Domain = module.Instance.Domain; actionEvent.Path = parameter; actionEvent.Value = value; actionEvent.SourceId = module.Instance.Address; actionEvent.SourceType = "Virtual Module"; homegenie.SignalModulePropertyChange(this, module.Instance, actionEvent); } catch (Exception ex) { HomeGenieService.LogEvent(programModule.Domain, programModule.Address, ex.Message, "Exception.StackTrace", ex.StackTrace); } return this; }
//TODO: add autodoc comment (HG Event forwarding) public NetHelper SignalModuleEvent(string hgAddress, ModuleHelper module, ModuleParameter parameter) { string eventRouteUrl = "http://" + hgAddress + "/api/" + Domains.HomeAutomation_HomeGenie + "/Interconnection/Events.Push/" + homegenie.GetHttpServicePort(); // propagate event to remote hg endpoint Utility.RunAsyncTask(() => { this.WebService(eventRouteUrl) .Put(JsonConvert.SerializeObject(new ModuleEvent(module.SelectedModules[0], parameter), new JsonSerializerSettings(){ Culture = System.Globalization.CultureInfo.InvariantCulture })) .Call(); }); return this; }
public void RouteModuleEvent(HomeGenie.Automation.ProgramManager.RoutedEvent eventData) { if (moduleUpdateHandler != null) { var module = new ModuleHelper(homegenie, eventData.Module); var parameter = eventData.Parameter; var callback = new WaitCallback((state) => { try { homegenie.MigService.RaiseEvent( this, Domains.HomeAutomation_HomeGenie, SourceModule.Scheduler, "Scheduler Routed Event", Properties.SchedulerModuleUpdateStart, schedulerItem.Name); moduleUpdateHandler(module, parameter); homegenie.MigService.RaiseEvent( this, Domains.HomeAutomation_HomeGenie, SourceModule.Scheduler, "Scheduler Routed Event", Properties.SchedulerModuleUpdateEnd, schedulerItem.Name); } catch (Exception e) { homegenie.MigService.RaiseEvent( this, Domains.HomeAutomation_HomeGenie, SourceModule.Scheduler, e.Message.Replace('\n', ' ').Replace('\r', ' '), Properties.SchedulerError, schedulerItem.Name); } }); ThreadPool.QueueUserWorkItem(callback); } }
public NetHelper SignalModuleEvent(string hgAddress, ModuleHelper module, ModuleParameter parameter) { string eventRouteUrl = "http://" + hgAddress + "/api/HomeAutomation.HomeGenie/Interconnection/Events.Push/" + homegenie.GetHttpServicePort(); // propagate event to remote hg endpoint this.WebService(eventRouteUrl) .Put(JsonConvert.SerializeObject(new ModuleEvent(module.SelectedModules[0], parameter))) .CallAsync(); return this; }