Beispiel #1
0
        public void testHandleData_shouldReceiveGlobalNotification()
        {
            GlobalUpdate        globalUpdate  = null;
            DeviceUpdate        deviceUpdate  = null;
            List <Camera>       cameras       = null;
            List <Thermostat>   thermostats   = null;
            List <SmokeCOAlarm> smokeCOAlarms = null;
            List <Structure>    structures    = null;
            Metadata            metadata      = null;

            var notifier = new Notifier();

            notifier.GlobalUpdated       += (sender, args) => { globalUpdate = args.Data; };
            notifier.DeviceUpdated       += (sender, args) => { deviceUpdate = args.Data; };
            notifier.CameraUpdated       += (sender, args) => { cameras = args.Data; };
            notifier.ThermostatUpdated   += (sender, args) => { thermostats = args.Data; };
            notifier.SmokeCOAlarmUpdated += (sender, args) => { smokeCOAlarms = args.Data; };
            notifier.StructureUpdated    += (sender, args) => { structures = args.Data; };
            notifier.MetadataUpdated     += (sender, args) => { metadata = args.Data; };

            notifier.HandleData(new GlobalUpdate(
                                    thermostats: new List <Thermostat>(),
                                    smokeCOAlarms: new List <SmokeCOAlarm>(),
                                    cameras: new List <Camera>(),
                                    structures: new List <Structure>(),
                                    metadata: new Metadata()));

            Assert.IsNotNull(globalUpdate);
            Assert.IsNotNull(deviceUpdate);
            Assert.IsNotNull(cameras);
            Assert.IsNotNull(thermostats);
            Assert.IsNotNull(smokeCOAlarms);
            Assert.IsNotNull(structures);
            Assert.IsNotNull(metadata);
        }
    void GlobalInit()
    {
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
#if UNITY_STANDALONE_WIN
        DllTest.GetProcessWnd();
#endif
        try
        {
            //全局的初始化
            LogMgr.GlobalInit();
            Utility.GlobalInit();
            RuntimeInfo.GlobalInit();
            SDKMgr.Instance.GlobalPreInit();

            Resolution.GlobalInit();
            StringTable.GlobalInit();
            SceneObjMgr.Instance.GlobalInit();
            ResManager.Instance.GlobalInit();   //Res需要在SDKMgr的前面。
            //ReportException.Instance.GlobalInit();
            SDKMgr.Instance.GlobalInit();
            ServerSetting.GlobalInit();

            GlobalUpdate.GlobalInit();
            NetCmdMapping.GlobalInit();
            LogicManager.Instance.GlobalInit();
            UICamera.onPress = OnPress;
            Utility.GlobalInit();
        }
        catch (System.Exception e)
        {
            ReportException.Instance.AddException(e.ToString());
        }
    }
Beispiel #3
0
 public void HandleData(GlobalUpdate eventData)
 {
     GlobalUpdated?.Invoke(this, new NestGlobalEventArgs(eventData));
     DeviceUpdated?.Invoke(this, new NestDeviceEventArgs(eventData.Devices));
     StructureUpdated?.Invoke(this, new NestStructureEventArgs(eventData.Structures));
     ThermostatUpdated?.Invoke(this, new NestThermostatEventArgs(eventData.Thermostats));
     CameraUpdated?.Invoke(this, new NestCameraEventArgs(eventData.Cameras));
     SmokeCOAlarmUpdated?.Invoke(this, new NestSmokeCOAlarmEventArgs(eventData.SmokeCOAlarms));
     MetadataUpdated?.Invoke(this, new NestMetadataEventArgs(eventData.Metadata));
 }
Beispiel #4
0
 public void Update(float delta)
 {
     GlobalUpdate.PreUpdate(delta);
     if (m_LogicData != null)
     {
         m_LogicData.LogicObj.Update(delta);
         m_LogicData.LogicUIObj.Update(delta);
     }
     GlobalUpdate.LateUpdate(delta);
     if (m_LogicData != null)
     {
         CheckAction();
     }
 }
Beispiel #5
0
        public void testNestGlobalUpdate_shouldReturnSameObjectInGetters()
        {
            var testThermos     = new List <Thermostat>();
            var testSmokeAlarms = new List <SmokeCOAlarm>();
            var testCams        = new List <Camera>();
            var testStructures  = new List <Structure>();
            var testMetadata    = new Metadata();

            var update = new GlobalUpdate(testThermos, testSmokeAlarms, testCams,
                                          testStructures, testMetadata);

            Assert.AreSame(testThermos, update.Thermostats);
            Assert.AreSame(testSmokeAlarms, update.SmokeCOAlarms);
            Assert.AreSame(testCams, update.Cameras);
            Assert.AreSame(testStructures, update.Structures);
            Assert.AreSame(testMetadata, update.Metadata);
        }
Beispiel #6
0
    void ActiveLogic(LogicRuntimeData ld)
    {
        GlobalUpdate.OnLogicChange();
        CloseLogic();
        if (ld.Type != LogicType.LOGIC_UPDATE)
        {
            SceneMain.Instance.StartInnerCoroutine(AsyncLoadRes(ld));
            return;
        }
        m_LogicData = ld;
        if (ResType.GlobalRes == ld.LogicRes)
        {
            if (!ResManager.Instance.BeginLoadRes(ResType.GlobalRes, true) ||
                !ResManager.Instance.BeginLoadRes(ResType.FishRes, false) ||
                !ResManager.Instance.BeginLoadRes(ResType.PathRes, true) ||
                !ResManager.Instance.BeginLoadRes(ResType.ExtraRes, true))
            {
                NativeInterface.ShowMsgAndExit("res_load_err", 200);
                return;
            }
        }
        else if (ld.LogicRes != ResType.MAX)
        {
            if (!ResManager.Instance.BeginLoadRes(m_LogicData.LogicRes, true))
            {
                NativeInterface.ShowMsgAndExit("res_load_err", 203);
                return;
            }
        }
        bool bRet = m_LogicData.LogicObj.Init(m_LogicData.LogicUIObj, m_Params);

        bRet    &= m_LogicData.LogicUIObj.Init(m_LogicData.LogicObj, m_Params);
        m_Params = null;
        if (!bRet)
        {
            //逻辑和UI初始化失败
            NativeInterface.ShowMsgAndExit("res_load_err", 202);
            return;
        }

        ResManager.Instance.EndLoadRes();
    }
Beispiel #7
0
        public void testMap_shouldParseStructureEventWithPathNode()
        {
            var handler = new DummyEventHandler();
            var mapper  = new ObjectModelMapper(handler);

            string json = LoadString(TEST_GLOBAL_UPDATE_JSON_NEW);

            mapper.Map(new StreamingEvent("put", json));
            Assert.IsNull(handler.error);
            Assert.IsFalse(handler.authRevokedEvent);
            GlobalUpdate eventData = handler.updateEvent;

            Assert.IsNotNull(eventData);
            Assert.IsNotNull(eventData.Devices);
            Assert.IsNotNull(eventData.Metadata);
            Assert.IsNotNull(eventData.Structures);
            Assert.IsNotNull(eventData.Devices.Cameras);
            Assert.IsNotNull(eventData.Devices.SmokeCOAlarms);
            Assert.IsNotNull(eventData.Devices.Thermostats);
            Assert.AreEqual(eventData.Devices.Cameras.Count, 1);
            Assert.AreEqual(eventData.Devices.SmokeCOAlarms.Count, 1);
            Assert.AreEqual(eventData.Devices.Thermostats.Count, 1);
        }
Beispiel #8
0
 private void Update()
 {
     GlobalUpdate?.Invoke();
 }
 public MessageHandler()
 {
     allInputs[0] = new GlobalUpdate();
 }
Beispiel #10
0
 public void HandleData(GlobalUpdate eventData)
 {
     updateEvent = eventData;
 }
Beispiel #11
0
 /// <summary>
 /// Called when an update occurs on any device, structure or metadata object.
 /// </summary>
 /// <param name="update">a <see cref="GlobalUpdate"/> object containing all values at the time of the update.</param>
 public NestGlobalEventArgs(GlobalUpdate update)
 {
     this.Data = update;
 }