示例#1
0
        public void UpdatePrimaryDataSubscription(string filterExpression)
        {
            ClearMeasurements();

            m_dataSubscriptionInfo.FilterExpression = filterExpression;
            DataSubscription.UnsynchronizedSubscribe(m_dataSubscriptionInfo);
        }
示例#2
0
        /// <summary>
        /// Fetch all the attributes and subscribe according to the filter
        /// </summary>
        public void SubscribeAttributes()
        {
            //just in case we are resubscribing, clear everything
            _d.Invoke(() => FilteredAttributes.Clear());
            Attributes.Clear();
            DataReferenceSource r = new DataReferenceSource(
                Name + "._Attributes[]",
                Name,
                (i) =>
            {
                //we need to start this on a new thread otherwise we can't make other calls to the RuntimeDataClient
                string[] attributes = (string[])i.VTQ.Value.Array;
                if (attributes == null)
                {
                    return;
                }
                new Thread(() =>
                {
                    Thread.CurrentThread.IsBackground = true;
                    DealWithNewAttributes(attributes.ToList <string>());
                }).Start();
            }
                );

            //just in case
            if (DataSubscription != null)
            {
                DataSubscription.Subscribe(new DataReferenceSource[] { r });
            }
        }
示例#3
0
        private void _datasubscriptionMonitor_Notification(object sender, PostgreSQLListener <DataSubscription> .PostgreSQLNotification notifyEvent)
        {
            string           changeType = notifyEvent.Notification.operation;
            DataSubscription sub        = notifyEvent.Notification.row;

            SubscriptionChangeNotification(changeType, sub);
        }
示例#4
0
 public void Unsubscribe()
 {
     try
     {
         //var result = Items.Select(i => i.DataReference).ToArray();
         DataSubscription.UnsubscribeAll();
         Items.Clear();
         _d.Invoke(() => FilteredAttributes.Clear());
     }
     catch { }
 }
示例#5
0
        /// <summary>
        /// Sort the list of strings and convert it into Attribute objects
        /// </summary>
        /// <param name="attributes">The value of an objects _Attributes[] attribute</param>
        private void DealWithNewAttributes(List <string> attributes)
        {
            //unsubscribe all previous subscriptions
            DataSubscription.UnsubscribeAll();
            attributes.Sort();
            Dictionary <string, List <string> > uniqueAttributes = new Dictionary <string, List <string> >();
            string        previous    = "zoogabooga";//I bet nobody will call an attribute this
            List <string> currentList = new List <string>();

            for (int i = 0; i < attributes.Count; i++)
            {
                if (attributes[i].StartsWith(previous))
                {
                    currentList.Add(attributes[i]);
                }
                else
                {
                    currentList = new List <string>();
                    uniqueAttributes.Add(attributes[i], currentList);
                    previous = attributes[i];
                }
            }
            foreach (var kvp in uniqueAttributes)
            {
                Attribute a = new Attribute(kvp.Key, kvp.Value, this);
                Attributes.Add(a);
                a.PropertyChanged += Attribute_PropertyChanged;
            }
            //Filter the attributes on the GUI dispatcher
            _d.Invoke(() =>
            {
                FilteredAttributes.Clear();
                var results = from i in Attributes where (i.Flags & FilterOptions) != 0 select i;
                FilteredAttributes.AddRange(results);
            });

            //subscribe all the filtered Attributes DataItems
            foreach (var a in FilteredAttributes)
            {
                Items.AddRange(a.DataItems);
            }

            var dataSources = new List <DataReferenceSource>();

            foreach (var dataItem in Items)
            {
                dataSources.Add(
                    new DataReferenceSource(
                        dataItem.ReferenceString,
                        dataItem.OwningObject,
                        (d) =>
                {
                    dataItem.DataReference = d;
                    dataItem.DataValue     = d.VTQ.Value.RawValue;
                    dataItem.StatusSetting = d.VTQ.QualityStatus.StatusSetting;
                    dataItem.MxQuality     = d.VTQ.QualityStatus.MxQuality;
                    dataItem.OpcUaQuality  = d.VTQ.QualityStatus.OPCUAQuality;
                    dataItem.Timestamp     = d.VTQ.Timestamp;
                }));
            }
            DataSubscription.Subscribe(dataSources.ToArray());
        }
示例#6
0
 private void DataSubscriptionConnectionTerminated(object sender, EventArgs e)
 {
     DataSubscription.Start();
     LogStatusMessage("Connection to publisher was terminated for primary data subscription, restarting connection cycle...");
 }
示例#7
0
        public void MetaSignalCommand(MetaSignal signal)
        {
            string connString = new ConnectionStringParser <SettingAttribute>().ComposeConnectionString(signal);

            DataSubscription.SendServerCommand((ServerCommand)ECAServerCommand.MetaSignal, connString);
        }
示例#8
0
 public void TerminateSubscriptions()
 {
     DataSubscription.Unsubscribe();
     StatisticSubscription.Unsubscribe();
 }