Exemplo n.º 1
0
        private UaValue BuildInnerComplex(string description, int length, bool generateSchema)
        {
            if (length == 1)
            {
                return(BuildJsonForObject(description, generateSchema));
            }

            var     jArray = new JArray();
            UaValue uaVal  = new UaValue();

            for (int i = 0; i < length; i++)
            {
                uaVal = BuildJsonForObject(description, generateSchema);
                jArray.Insert(i, uaVal.Value);
            }

            var jSchema = (generateSchema) ? DataTypeSchemaGenerator.GenerateSchemaForArray(new[] { length }, uaVal.Schema) : null;

            return(new UaValue(jArray, jSchema));
        }
Exemplo n.º 2
0
        private void OnMonitorNotification(MonitoredItem monitoreditem, MonitoredItemNotificationEventArgs e)
        {
            VariableNode varNode = (VariableNode)monitoreditem.Subscription.Session.ReadNode(monitoreditem.StartNodeId);

            foreach (var value in monitoreditem.DequeueValues())
            {
                Console.WriteLine("Got a value");
                var     typeManager = new DataTypeManager(monitoreditem.Subscription.Session);
                UaValue opcvalue    = typeManager.GetUaValue(varNode, value, false);

                dynamic monitorInfoPair;

                lock (_monitorPublishInfo)
                {
                    monitorInfoPair = _monitorPublishInfo
                                      .SelectMany(pair => pair.Value, (parent, child) => new { ServerUrl = parent.Key, Info = child })
                                      .First(couple => couple.Info.Subscription == monitoreditem.Subscription);
                }

                var message = $"[TOPIC: {monitorInfoPair.Info.Topic}]  \t ({monitoreditem.DisplayName}): {opcvalue.Value}";
                monitorInfoPair.Info.Forward(message);
                Console.WriteLine(message);
            }
        }