コード例 #1
0
        public void ConfiguredStart()
        {

            guiService.ConfiguredStart();

            //initialize the scout helper; needed for scouts that rely on upnp discovery
            ScoutHelper.Init(logger);

            //start the configured scouts. starting scouts before modules.
            foreach (var sInfo in config.GetAllScouts())
            {
                StartScout(sInfo);
            }

            //start the heartbeat service (directly writes to cloud)
            if (Settings.HeartbeatServiceMode != "Off")
            {
                InitHeartbeatService();
            }

            //config updater
            if(this.configLookup==null)
            {
                ConfigUpdater configLookup = null;
                LoadConfig loadNewConfig = this.LoadConfigFromDir;

                configLookup = new ConfigUpdater(null, logger, Settings.ConfigLookupFrequency, loadNewConfig, this);
                this.configLookup = configLookup;
                if (this.configLookup != null)
                {
                    this.configLookup.setConfig(this.config);
                }

            }

            // start the authentication service
            {
                authenticationService = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                authenticationServiceHost = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, authenticationService);
                authenticationServiceHost.Open();
            }

            InitHomeService();

            if (Settings.RunningMode.Equals("standard"))
            {
                InitAutoStartModules();
            }
            else
            #region developers' running modes
            {
                if (Settings.RunningMode.Equals("unittesting"))
                {

                    // don't start any modules, we just need a module-less platform to initialize the module (app/device)
                    // being unit tested
                }
                else if (Settings.RunningMode.Equals("ratul"))
                {
                    //StartModule(new ModuleInfo("axiscamdriver", "DriverAxisCamera", "DriverAxisCamera", null, false, "192.168.0.198", "root", "homeos"));
                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));
                    
                    StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "HomeOS.Hub.Drivers.WebCam", null, false, @"Microsoft® LifeCam VX-7000"));
                    StartModule(new ModuleInfo("AppCam", "AppCamera", "HomeOS.Hub.Apps.SmartCam", null, false));

                    //string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    //string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    //StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));                   

                    //StartModule(new ModuleInfo("HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera for HomeOSGadgeteerDevice_WindowCamera_MicrosoftResearch_65355695098562951548", "DriverGadgetCamera", "HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera", null, false, "192.168.0.197"));

                    //StartModule(new ModuleInfo("zwavezensys", "DriverZwaveZensys", "HomeOS.Hub.Drivers.ZwaveZensys_4_55", null, false));
                    //StartModule(new ModuleInfo("switchapp", "AppSwitch", "HomeOS.Hub.Apps.Switch", null, false));

                    //StartModule(new ModuleInfo("alerts", "AppAlerts", "HomeOS.Hub.Apps.Alerts", null, false));

                    //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", ""));

                    //StartModule(new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null));
                    //StartModule(new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null));
                }
                else if (Settings.RunningMode.Equals("rayman"))
                {
                    ModuleInfo d = new ModuleInfo("HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", null, false,"foo", "8000", "1" );
                    StartModule(d);

                    /*
                    HomeOS.Hub.Platform.Authentication.AuthenticationService auth = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this);
                    System.ServiceModel.ServiceHost s = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, auth);
                    s.Open();


                    ModuleInfo app = new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null);
                    StartModule(app);
                    ModuleInfo app1 = new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null);
                    StartModule(app1);
                    
                    HomeOS.Hub.Common.TokenHandler.SafeTokenHandler t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    string s1 = t.GenerateToken("helloworlergwergwergwergwergwegrwegewgewrgwergwregwgwgd"); 
                    logger.Log("Encryting helloworld: "+s1);
                    t = null;
                    t = new Common.TokenHandler.SafeTokenHandler("randomsalt");
                    logger.Log("decrypting token: " + t.ProcessToken(s1).Name);*/


                    //    DateTime t = policyEngine.AllowAccess("*","AppDummy1", "jeff");
                    //    logger.Log(">>>>>>>>>>> " + t.ToString()+ "  , " + DateTime.Now);


                    // Dont touch my running mode
                    /*
                     AddInToken t =  null ; 
                         foreach (AddInToken token in allAddinTokens)
                         {
                             if (token.Name.Equals("HomeOS.Hub.Drivers.Dummy") )
                             {
                                 t = token ; 
                             }
                         }
                         VModule a = t.Activate<VModule>(AddInSecurityLevel.FullTrust);
                      ModuleInfo info = new ModuleInfo("friendlyName", "moduleName", "moduleName", null, false, null);
                         AddInController aic = AddInController.GetAddInController(a);
                         a.Initialize(this, logger,info, 0);
                         SafeThread moduleThread = new SafeThread(delegate() { a.Start(); },"", logger);
                         moduleThread.Start();
                         System.Threading.Thread.Sleep(1 * 11 * 1000);
                         aic.Shutdown();
                    

                     ModuleInfo[] app = new ModuleInfo[100];
                     int i;
                     for (i = 0; i < 30; i++)
                     {
                         app[i] = new ModuleInfo("AppDummy"+i.ToString(), "AppDummy"+i.ToString(), "HomeOS.Hub.Apps.Dummy", null, false, null);
                         StartModule(app[i]);
                     }
            

                 

                     ModuleInfo[] driver = new ModuleInfo[3000]; 
                     int j;
                     for (j = 0; j <30; j++)
                     {
                         driver[j] = new ModuleInfo("DriverDummy"+j.ToString(), "DriverDummy"+j.ToString(), "HomeOS.Hub.Drivers.Dummy", null, false, null);
                         StartModule(driver[j]);
                     }
            
                     System.Threading.Thread.Sleep(1 * 20 * 1000);
                    
                     
                     for (j = 29; j >=0; j--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(driver[j])).Key.Secret());

                     }
                     for (i = 29;i >= 1; i--)
                     {
                         StopModule(runningModules.First(x => x.Value.Equals(app[j])).Key.Secret());

                     }
          */


                }
                else if (Settings.RunningMode.Equals("chunte"))
                {
                    //StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "logitech"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "192.168.0.196", "admin", "whoareyou?"));
                    //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "172.31.42.177", "admin", ""));
                    string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                    string video2 = "c:\\img\\DSCN7066_test1.avi";
                    StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                    StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                    //StartModule(new ModuleInfo("cameraapp", "AppCamera", "AppCamera", null, false));

                    string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                    string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                    StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                }
                else if (Settings.RunningMode.Contains("khurshed"))
                {
                    if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "HomeOS.Hub.Apps.SmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_notifications"))
                    {
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_webcam"))
                    {
                        StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000"));
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_foscam"))
                    {
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", ""));
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                    else if (Settings.RunningMode.Equals("khurshed_test_tracking_videoloading"))
                    {
                        string video1 = "c:\\img\\cam2_20120821165455_test1.avi";
                        string video2 = "c:\\img\\DSCN7066_test1.avi";
                        StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1));
                        StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2));
                        string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt";
                        string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt";
                        StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2));
                    }
                }
                else if (Settings.RunningMode.Equals("jamie"))
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(new XmlTextReader(@"C:\homeos\LightSettings.xml"));

                    XmlNode xmlData = xmlDoc.SelectSingleNode("data");
                    string strLightsIP = xmlData.SelectSingleNode("lightsIP").InnerText;
                    string strLightsUser = xmlData.SelectSingleNode("lightsUser").InnerText;
                    string strfoscamIP = xmlData.SelectSingleNode("foscamIP").InnerText;
                    string strfoscamUser = xmlData.SelectSingleNode("foscamUser").InnerText;
                    string strLightCount = xmlData.SelectSingleNode("light_count").InnerText;

                    StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, strfoscamIP, strfoscamUser, ""));
                    StartModule(new ModuleInfo("huedriver1", "HueBridge", "HomeOS.Hub.Drivers.HueBridge", null, false, strLightsIP, strLightsUser, strLightCount));
                    StartModule(new ModuleInfo("LightsHome1", "LightsHome", "HomeOS.Hub.Apps.LightsHome", null, false));
                }
                else if (Settings.RunningMode.Equals("sarah"))
                {
                    //Sarah to fill in the right device id
                    StartModule(new ModuleInfo("couchdriver", "DriverCouch", "HomeOS.Hub.Drivers.GadgetCouch", null, false, ".."));
                    StartModule(new ModuleInfo("couchapp", "EmotoCouch", "HomeOS.Hub.Apps.EmotoCouch", null, false));
                }
                else if (Settings.RunningMode.Equals("erin"))
                {
                    //app startup needed since it's not in the install repository
                    StartModule(new ModuleInfo("AppDoorjamb", "AppDoorjamb", "HomeOS.Hub.Apps.Doorjamb", null, false));
                }
                else
                {
                    throw new Exception("Unknown running mode: " + Settings.RunningMode);
                }

                //we ran using a non-standard running mode
                //make sure that the modules we ran are entered in the config, so that we can keep it consistent
                //otherwise, a service (port) will get added without its exporting module
                lock (this)
                {
                    foreach (ModuleInfo moduleInfo in runningModules.Values)
                    {
                        if (moduleInfo.GetManifest() == null)
                            moduleInfo.SetManifest(new Manifest());

                        config.AddModuleIfMissing(moduleInfo);
                    }
                }

            }
            #endregion


            if (String.IsNullOrEmpty(Settings.WifiSsid))
                logger.Log("Warning: WiFi credentials are not configured");

            if (!Settings.StayOffline)
            {
                //start checking for the uniqueness of home id on a separate thread
                SafeThread uniqueHomeIdCheck = new SafeThread(delegate()
                {
                    heartbeatService.CanIClaimHomeId(Utils.HardwareId, Settings.HomeId, UniqueHomeIdCheckCompleted);
                }, "UniqueHomeIdCheck", logger);

                uniqueHomeIdCheck.Start();
            }
        }
コード例 #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if(guiService!=null)
                    guiService.Dispose();
                
                if(infoService!=null)
                    infoService.Dispose();
                
                if (heartbeatService != null)
                    heartbeatService.Dispose();

                if (discoveryHelperService != null)
                    discoveryHelperService.Dispose();

                if (authenticationServiceHost != null)
                    authenticationServiceHost.Close();

                if (authenticationService != null)
                    authenticationService = null; 
               
            }
        }