Exemplo n.º 1
0
        internal static List <TheOPCSensorSubscription> GetHostThingOPCProperties(TheThing tHostThing, TheThing tProviderThing)
        {
            string prefix      = "OPCUA";
            var    legacyProps = tHostThing.GetPropertiesMetaStartingWith(prefix, true);

            if (legacyProps.Any())
            {
                foreach (var prop in legacyProps)
                {
                    if (ParseOpcUaMetaString(prop.cdeM, out var propKind, out var nodeIdName, out var serverId, out var changeTrigger, out var deadBandValue, out var structTypeInfo, out var historyStartTime, out var eventFilter))
                    {
                        if (serverId == tProviderThing.ID)
                        {
                            // TODO log migration start
                            var opcSubscriptionInfo = new TheOPCSensorSubscription
                            {
                                SampleRate     = (int)prop.cdeEXP,
                                SensorId       = nodeIdName,
                                ChangeTrigger  = changeTrigger,
                                DeadbandValue  = deadBandValue,
                                EventInfo      = eventFilter,
                                StructTypeInfo = structTypeInfo,
                                //HistoryStartTime = historyStartTime, // TODO
                            };

                            var providerInfo = new cdeP.TheProviderInfo(tProviderThing, opcSubscriptionInfo);
                            prop.SetSensorProviderInfo(providerInfo);
                            prop.cdeM = null;
                            // TODO Log migration finish
                        }
                        else
                        {
                            // tag from a different opc client
                        }
                    }
                    else
                    {
                        // Log migration error
                    }
                }