public void SubscribeToTagChange(int publishingInterval, string tagName, object clientHandle, TagValueChanged callback) { lock (this.syncRoot) { this.baseClient.SubscribeToTagChange(publishingInterval, tagName, clientHandle, callback); } }
public void SubscribeToTagChange(int publishingInterval, string tagName, object clientHandle, TagValueChanged callback) { if (!this.callbacks.ContainsKey(tagName)) { this.callbacks.Add(tagName, new List<Action>()); } this.callbacks[tagName].Add(() => { callback(tagName, clientHandle, this.currentValues[tagName]); }); }
public void SubscribeToTagChange(int publishingInterval, string tagName, object clientHandle, TagValueChanged callback) { throw new NotImplementedException(); //if (!this.subscriptions.ContainsKey(publishingInterval)) //{ // this.subscriptions.Add(publishingInterval, this.opcClient.AddSubscription(publishingInterval)); //} //object serverHandle; //var eventKey = Guid.NewGuid(); //this.subscriptions[publishingInterval].AddDataMonitoredItem( // new NodeId(tagName), // clientHandle, // (o, dv) => // { // if (!StatusCode.IsGood(dv.StatusCode)) // { // // ignore all not good changes // return; // } // lock (this.eventValues) // { // // First Event occurance of every tag should be ignored // if (!this.eventValues.ContainsKey(eventKey)) // { // this.eventValues.Add(eventKey, dv.Value); // return; // } // var previousValue = this.eventValues[eventKey]; // var currentValue = dv.Value; // // Raise event only if values are truly different // if (Equals(previousValue, currentValue)) // { // return; // } // this.eventValues[eventKey] = dv.Value; // } // callback(o, dv.Value); // }, // (uint)publishingInterval, // out serverHandle); }
private void _socket_MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args) { using (DataReader reader = args.GetDataReader()) { reader.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8; try { string message = reader.ReadString(reader.UnconsumedBufferLength); TagValueChanged?.Invoke(this, JsonConvert.DeserializeObject <Tag>(message)); } catch (Exception ex) { LogService.AddEntry(this.GetType().Name, ex); } } }