예제 #1
0
        /// <summary>
        /// The main processing loop.
        /// </summary>
        public void Process()
        {
            LogUtil.EnableMemoryLog();
            try
            {
                string serviceProgram             = "Inter Operability Testing Service";
                byte   serviceProgramMajorVersion = 0;
                byte   serviceProgramMinorVersion = 1;
                string serviceAddress             = "0.0.0.0";
                int    serviceHubPort             = MxpConstants.DefaultHubPort + 2;
                int    serviceServerPort          = MxpConstants.DefaultServerPort + 2;
                string serviceAssetCacheUrl       = "http://test.assetcache.one";

                Guid   bubbleOneId              = new Guid("539DFA16-5B52-4c9f-9A09-AD746520873E");
                string bubbleOneName            = "IOT Bubble 1";
                float  bubbleOneRange           = 100;
                float  bubbleOnePerceptionRange = 110;

                CloudService cloudService = new CloudService(serviceAssetCacheUrl, serviceAddress, serviceHubPort, serviceServerPort, serviceProgram, serviceProgramMajorVersion, serviceProgramMinorVersion);

                CloudBubble bubbleOne = new CloudBubble(bubbleOneId, bubbleOneName, bubbleOneRange, bubbleOnePerceptionRange);

                this.testAssessor.RegisterEventHandlers(bubbleOne);

                bubbleOne.ParticipantDisconnected += OnParticipantDisconnected;

                cloudService.AddBubble(bubbleOne);

                cloudService.Startup(true);

                while (DateTime.Now.Subtract(startTime) < IotServiceLifeSpan && !isCompleted)
                {
                    cloudService.Process();
                    testSuiteState.ReferenceServerLog = LogUtil.GetMemoryLog();
                    Thread.Sleep(10);
                }

                cloudService.Shutdown();
            }
            finally
            {
                lock (threadLock)
                {
                    serviceController = null;
                }
                testSuiteState.ReferenceServerLog = LogUtil.GetMemoryLog();
                LogUtil.DisableMemoryLog();
            }
        }
예제 #2
0
 /// <summary>
 /// Returns service controller or null if it is already reserved.
 /// Service controller is automatically released when test time ends.
 /// </summary>
 /// <param name="testSuiteState">Test suite state of the session reserving the controller.</param>
 /// <returns></returns>
 public static IotServiceController ReserveServiceController(TestSuiteState testSuiteState)
 {
     lock (threadLock)
     {
         if (serviceController != null)
         {
             // Service controller is already existing and reserved by someone else.
             return(null);
         }
         else
         {
             serviceController = new IotServiceController(testSuiteState);
             return(serviceController);
         }
     }
 }