示例#1
0
 public void InterfaceEnable(string domain)
 {
     try
     {
         switch (domain)
         {
         case Domains.HomeAutomation_ZWave:
             var zwaveInterface = (GetInterface(Domains.HomeAutomation_ZWave) as MIG.Interfaces.HomeAutomation.ZWave);
             if (zwaveController != null)
             {
                 zwaveController.DiscoveryEvent -= zwaveController_DiscoveryEvent;
             }
             zwaveInterface.SetPortName(systemConfiguration.GetInterfaceOption(
                 Domains.HomeAutomation_ZWave,
                 "Port"
             ).Value.Replace(
                 "|",
                 "/"
             ));
             zwaveInterface.Connect();
             zwaveController = zwaveInterface.ZWaveController;
             if (zwaveController != null)
             {
                 zwaveController.DiscoveryEvent += zwaveController_DiscoveryEvent;
             }
     //                    LoadModules();
     //                        RefreshModules(domain, true);
             break;
         case Domains.HomeAutomation_X10:
             var x10Interface = (GetInterface(Domains.HomeAutomation_X10) as MIG.Interfaces.HomeAutomation.X10);
             x10Interface.SetPortName(systemConfiguration.GetInterfaceOption(
                 Domains.HomeAutomation_X10,
                 "Port"
             ).Value.Replace(
                 "|",
                 "/"
             ));
             x10Interface.SetHouseCodes(systemConfiguration.GetInterfaceOption(
                 Domains.HomeAutomation_X10,
                 "HouseCodes"
             ).Value);
             x10Interface.Connect();
             x10Controller = x10Interface.X10Controller;
     //                    LoadModules();
             RefreshModules(domain, true);
             break;
         case Domains.HomeAutomation_W800RF:
             var w800rfInterface = (GetInterface(Domains.HomeAutomation_W800RF) as MIG.Interfaces.HomeAutomation.W800RF);
             w800rfInterface.SetPortName(systemConfiguration.GetInterfaceOption(
                 Domains.HomeAutomation_W800RF,
                 "Port"
             ).Value);
             w800rfInterface.Connect();
     //                    LoadModules();
             RefreshModules(domain, true);
             break;
         case Domains.EmbeddedSystems_Weeco4mGPIO:
             var weeco4mInterface = (GetInterface(Domains.EmbeddedSystems_Weeco4mGPIO) as MIG.Interfaces.EmbeddedSystems.Weeco4mGPIO);
             weeco4mInterface.SetInputPin(uint.Parse(systemConfiguration.GetInterfaceOption(
                 Domains.EmbeddedSystems_Weeco4mGPIO,
                 "InputPin"
             ).Value));
             weeco4mInterface.SetPulsePerWatt(double.Parse(systemConfiguration.GetInterfaceOption(
                 Domains.EmbeddedSystems_Weeco4mGPIO,
                 "PulsePerWatt"
             ).Value));
             weeco4mInterface.Connect();
             RefreshModules(domain, true);
             break;
         default:
             GetInterface(domain).Connect();
             RefreshModules(domain, true);
             break;
         }
     }
     catch (Exception ex)
     {
         HomeGenieService.LogEvent(
             Domains.HomeAutomation_HomeGenie,
             "InterfaceEnable()",
             ex.Message,
             "Exception.StackTrace",
             ex.StackTrace
         );
     }
 }
示例#2
0
 public void InterfaceDisable(string domain)
 {
     try
     {
         switch (domain)
         {
         case Domains.HomeAutomation_ZWave:
             GetInterface(domain).Disconnect();
             if (zwaveController != null)
             {
                 zwaveController.DiscoveryEvent -= zwaveController_DiscoveryEvent;
             }
             zwaveController = null;
             break;
         case Domains.HomeAutomation_X10:
             GetInterface(domain).Disconnect();
             x10Controller = null;
             break;
         default:
             GetInterface(domain).Disconnect();
             break;
         }
         RefreshModules(domain, true);
     }
     catch (Exception ex)
     {
         HomeGenieService.LogEvent(
             Domains.HomeAutomation_HomeGenie,
             "InterfaceDisable()",
             ex.Message,
             "Exception.StackTrace",
             ex.StackTrace
         );
     }
 }