Esempio n. 1
0
        public static TEventType GetEvent <TEventType>() where TEventType : EventBase, new()
        {
            if (eventAggregator == null)
            {
                eventAggregator = new Prism.Events.EventAggregator();
            }

            return(eventAggregator.GetEvent <TEventType>());
        }
Esempio n. 2
0
 public void Start(object args)
 {
     if (null != args)
     {
         //customInfo = (MTMCustInfo)args;
         // to do 数据绑定
         healthDTO = (MTMHealthCollectDTO)args;
         Prism.Events.EventAggregator eventAggragator = ServiceLocator.Current.GetInstance <EventAggregator>();
         eventAggragator.GetEvent <WebSocketEvent>().Subscribe(OnWebSocketEvent);
     }
 }
Esempio n. 3
0
        private void ReadCommandBase(string endpoint, List <TestPattern> testPatterns)
        {
            var variables = _readCommandBase_CreateTestVariables(testPatterns);

            var application = _readCommandBase_CreateApplication(endpoint);

            using (var s = TestServer.TestServer.StartServer(application, variables))
            {
                _readCommandBase_ServerInit(s, testPatterns);

                var ea  = new Prism.Events.EventAggregator();
                var msg = "";

                ea.GetEvent <Jupiter.Events.ErrorNotificationEvent>()
                .Subscribe(x => msg = x.Message);

                var c          = new Client(ea);
                var references = new OPCUAReference(c, null, ea);
                var ota        = new Jupiter.Models.OneTimeAccessModel(c, c);
                ota.EventAggregator = ea;
                var nodegrid = new Jupiter.Models.NodeInfoDataGridModel(c, c);
                var nodetree = new Jupiter.Models.NodeTreeModel(c, references, null, ota);
                nodetree.EventAggregator = ea;

                c.EventAggregator
                .GetEvent <Jupiter.Events.NowLoadingEvent>()
                .Subscribe((x) =>
                {
                    var first = x.ServerList.First();

                    x.Client.BrowseSecurityList(first);

                    for (int i = 0; i < first.Endpoints.Count; i++)
                    {
                        if (first.Endpoints[i].SecurityMode.ToString().EndsWith("None"))
                        {
                            Console.WriteLine(first.Endpoints[i].SecurityMode);
                            x.SelectedIndex       = i;
                            x.SelectedServerIndex = 0;
                            x.Result = true;
                            break;
                        }
                    }
                });

                c.CreateSession(endpoint).Wait();
                foreach (OPCUAReference ch in references.Children)
                {
                    if (ch.DisplayName != "TestData")
                    {
                        continue;
                    }

                    nodetree.UpdateVariableNodeListCommand.Execute(ch);
                    foreach (VariableInfo vn in nodetree.VariableNodes)
                    {
                        nodetree.AddToReadWriteCommand.Execute(new List <VariableInfo>()
                        {
                            vn
                        });
                    }
                }
                ;
                ota.ReadCommand.Execute(null);
                Assert.AreEqual(msg, "");
                Assert.AreEqual(ota.OneTimeAccessItems.Count, testPatterns.Count);
                for (int i = 0; i < testPatterns.Count; i++)
                {
                    var got  = ((VariableInfo)ota.OneTimeAccessItems[i]).Value.ToString();
                    var want = testPatterns[i].Value.ToString();
                    Assert.AreEqual(got, want);
                }
            }
        }