Пример #1
0
 private void _virtualmeterloop()
 {
     while (_vmrunning)
     {
         try
         {
             foreach (Module module in _homegenie.Modules)
             {
                 ModuleParameter parameter = null;
                 parameter = module.Properties.Find(delegate(ModuleParameter mp) { return(mp.Name == ModuleParameters.MODPAR_VIRTUALMETER_WATTS); });
                 if (parameter == null)
                 {
                     continue;
                 }
                 else
                 {
                     double vmwatts = 0;
                     //
                     try
                     {
                         vmwatts = double.Parse(parameter.Value.Replace(",", "."), System.Globalization.CultureInfo.InvariantCulture);
                         if (vmwatts > 0)
                         {
                             parameter = module.Properties.Find(delegate(ModuleParameter mp) { return(mp.Name == ModuleParameters.MODPAR_STATUS_LEVEL); });
                             double level = double.Parse(parameter.Value.Replace(",", "."), System.Globalization.CultureInfo.InvariantCulture);
                             //
                             //_homegenie.migservice_InterfacePropertyChangedAction(new InterfacePropertyChangedAction() { Domain = module.Domain, SourceId = module.Address, SourceType = module.Description, Path = Globals.MODPAR_STATUS_LEVEL, Value = level.ToString() });
                             _homegenie.migservice_InterfacePropertyChanged(new InterfacePropertyChangedAction()
                             {
                                 Domain = module.Domain, SourceId = module.Address, SourceType = module.Description, Path = ModuleParameters.MODPAR_METER_WATTS, Value = level == 0 ? "0" : (vmwatts * level).ToString(/* System.Globalization.CultureInfo.InvariantCulture */)
                             });
                             //
                             Thread.Sleep(100);
                         }
                     }
                     catch { }
                 }
             }
         }
         catch { } // TODO: this should use locking instead of try cactch
         //
         Thread.Sleep(30000);
     }
 }