Exemplo n.º 1
0
        public Tag Convert(object inObj)
        {
            OpcTag opcTag  = inObj as OpcTag;
            string tagName = opcTag.Id.Split('=').Last();
            Dictionary <string, object> fields = new Dictionary <string, object>()
            {
                { "TagQuality", opcTag.TagQuality }, { "TagType", opcTag.TagType }
            };
            Tag tag = new Tag(tagName, fields);

            tag.SetTimestamp(opcTag.Timestamp);
            tag.SetDataPoint <string>(tagName, opcTag.TagValue);
            return(tag);
        }
Exemplo n.º 2
0
 public void Subscription_DataChanged(Subscription subscription, DataChangedEventArgs e)
 {
     foreach (DataChange change in e.DataChanges)
     {
         string timeStamp    = ((change.Value.SourceTimestamp != DateTime.MinValue) ? change.Value.SourceTimestamp : change.Value.ServerTimestamp).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss.fff");
         string typeInfo     = change.Value.WrappedValue.TypeInfo.ToString();
         string wrappedValue = change.Value.WrappedValue.ToString();
         //string tagName = change.MonitoredItem.NodeId.Identifier.ToString();
         string tagName = change.MonitoredItem.NodeId.ToString();
         WriteLog(string.Format("{{tagName: \"{0}\", timeStamp: \"{1}\", typeInfo: \"{2}\", wrappedValue: {3}}}", tagName, timeStamp, typeInfo, wrappedValue));
         //write the changed state to the state manager.
         OpcTag opcGeneratedTag = new OpcTag()
         {
             Id = tagName, TagType = typeInfo, TagQuality = "0", TagValue = wrappedValue, Timestamp = DateTime.Parse(timeStamp)
         };
         Tag tag = _opcTagConverter.Convert(opcGeneratedTag);
         _tagStateManager.UpdateTag <string>(tag.Name, tag.GetTimestamp(), wrappedValue, tag.Other);
     }
 }