예제 #1
0
        private static void OnUpdateEvent(object sender, EventArgs e)
        {
            ScadaStorageProxy proxy = ScadaProxyFactory.Instance().ScadaStorageProxy();
            ScadaUpdateEvent  ev    = new ScadaUpdateEvent()
            {
                Points = new List <ScadaPointDto>()
            };

            var all      = proxy.GetModel().Values.ToList();
            var analogs  = all.Where(x => x.RegisterType == RegisterType.ANALOG_INPUT || x.RegisterType == RegisterType.ANALOG_OUTPUT).Cast <AnalogPoint>().ToList();
            var binaries = all.Where(x => x.RegisterType == RegisterType.BINARY_INPUT || x.RegisterType == RegisterType.BINARY_OUTPUT).Cast <DiscretePoint>().ToList();

            ev.Points.AddRange(Mapper.MapCollection <AnalogPoint, ScadaPointDto>(analogs));
            ev.Points.AddRange(Mapper.MapCollection <DiscretePoint, ScadaPointDto>(binaries));

            DomUpdateEvent dom = new DomUpdateEvent()
            {
                DomData = proxy.GetDomModel()
            };

            try
            {
                instace.Publish(ev).ConfigureAwait(false).GetAwaiter().GetResult();
                instace.Publish(dom).ConfigureAwait(false).GetAwaiter().GetResult();
            }
            catch (Exception ex) { }
        }
예제 #2
0
 internal void Update(object sender, DomUpdateEvent e)
 {
     App.Current.Dispatcher.Invoke((System.Action) delegate
     {
         TimeStamp = DateTime.Now.ToString();
         TableData = new ObservableCollection <SwitchingEquipmentDto>();
         foreach (var item in e.DomData)
         {
             TableData.Add(Mapper.Map <SwitchingEquipmentDto>(item));
         }
     });
 }
예제 #3
0
        private void DoWork()
        {
            while (executionFlag)
            {
                DomUpdateEvent dom = new DomUpdateEvent()
                {
                    DomData = ScadaProxyFactory.Instance().DOMProxy().GetAll().ToSwitchingEquipment()
                };
                HistoryUpdateEvent history = new HistoryUpdateEvent()
                {
                    History = ScadaProxyFactory.Instance().HistoryProxy().GetAll()
                };
                HistoryGraphicalEvent graph = new HistoryGraphicalEvent()
                {
                    Graph = ScadaProxyFactory.Instance().HistoryProxy().GetGraph()
                };
                ScadaUpdateEvent ev = new ScadaUpdateEvent()
                {
                    Points = new List <SCADA.Common.DataModel.ScadaPointDto>()
                };
                var all      = ScadaProxyFactory.Instance().ScadaStorageProxy().GetModel().Values.ToList();
                var analogs  = all.Where(x => x.RegisterType == RegisterType.ANALOG_INPUT || x.RegisterType == RegisterType.ANALOG_OUTPUT).Cast <AnalogPoint>().ToList();
                var binaries = all.Where(x => x.RegisterType == RegisterType.BINARY_INPUT || x.RegisterType == RegisterType.BINARY_OUTPUT).Cast <DiscretePoint>().ToList();
                ev.Points.AddRange(Mapper.MapCollection <AnalogPoint, ScadaPointDto>(analogs));
                ev.Points.AddRange(Mapper.MapCollection <DiscretePoint, ScadaPointDto>(binaries));
                if (ev.Points.Count > 0)
                {
                    endpoint.Publish(ev).ConfigureAwait(false);
                }
                if (dom.DomData.Count > 0)
                {
                    endpoint.Publish(dom).ConfigureAwait(false);
                }
                if (history.History.Count > 0)
                {
                    endpoint.Publish(history).ConfigureAwait(false);
                }
                endpoint.Publish(graph).ConfigureAwait(false);

                Thread.Sleep(GetConfigTime());
            }
        }
예제 #4
0
 public Task Handle(DomUpdateEvent message, IMessageHandlerContext context)
 {
     domUpdate.Invoke(this, message);
     return(Task.CompletedTask);
 }
예제 #5
0
        private void Update()
        {
            var            domService     = new DomServiceProxy(ConfigurationReader.ReadValue(Context, "Settings", "Dom"));
            var            historyService = new HistoryServiceProxy(ConfigurationReader.ReadValue(Context, "Settings", "History"));
            var            storageService = new ScadaStorageProxy(ConfigurationReader.ReadValue(Context, "Settings", "Storage"));
            var            domData        = domService.GetAll().GetAwaiter().GetResult();
            DomUpdateEvent dom            = new DomUpdateEvent()
            {
                DomData = domData.ToSwitchingEquipment()
            };
            HistoryUpdateEvent history = new HistoryUpdateEvent()
            {
                History = historyService.GetAll().GetAwaiter().GetResult()
            };
            HistoryGraphicalEvent graph = new HistoryGraphicalEvent()
            {
                Graph = historyService.GetGraph().GetAwaiter().GetResult()
            };
            ScadaUpdateEvent ev = new ScadaUpdateEvent()
            {
                Points = new List <SCADA.Common.DataModel.ScadaPointDto>()
            };

            var all      = (storageService.GetModel().GetAwaiter().GetResult()).Values.ToList();
            var analogs  = all.Where(x => x.RegisterType == RegisterType.ANALOG_INPUT || x.RegisterType == RegisterType.ANALOG_OUTPUT).Cast <AnalogPoint>().ToList();
            var binaries = all.Where(x => x.RegisterType == RegisterType.BINARY_INPUT || x.RegisterType == RegisterType.BINARY_OUTPUT).Cast <DiscretePoint>().ToList();

            ev.Points.AddRange(Mapper.MapCollection <AnalogPoint, ScadaPointDto>(analogs));
            ev.Points.AddRange(Mapper.MapCollection <DiscretePoint, ScadaPointDto>(binaries));

            Subscription subs      = new Subscription();
            Publisher    publisher = new Publisher(subs.Topic, subs.ConnectionString);

            if (ev.Points.Count > 0)
            {
                publisher.SendMessage(new PubSubMessage()
                {
                    ContentType = ContentType.SCADA_UPDATE,
                    Sender      = Sender.SCADA,
                    Content     = JsonTool.Serialize <ScadaUpdateEvent>(ev)
                }).ConfigureAwait(false);
            }
            if (dom.DomData.Count > 0)
            {
                publisher.SendMessage(new PubSubMessage()
                {
                    ContentType = ContentType.SCADA_DOM,
                    Sender      = Sender.SCADA,
                    Content     = JsonTool.Serialize <DomUpdateEvent>(dom)
                }).ConfigureAwait(false);
            }
            if (history.History.Count > 0)
            {
                publisher.SendMessage(new PubSubMessage()
                {
                    ContentType = ContentType.SCADA_HISTORY,
                    Sender      = Sender.SCADA,
                    Content     = JsonTool.Serialize <HistoryUpdateEvent>(history)
                }).ConfigureAwait(false);
            }
            publisher.SendMessage(new PubSubMessage()
            {
                ContentType = ContentType.SCADA_HISTORY_GRAPH,
                Sender      = Sender.SCADA,
                Content     = JsonTool.Serialize <HistoryGraphicalEvent>(graph)
            }).ConfigureAwait(false);
        }