Exemple #1
0
        internal AdsSymbolLoader(IAdsConnection connection, SymbolLoaderSettings settings, IAccessorRawValue accessor, ISession session, SymbolUploadInfo symbolsInfo)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }
            if (accessor == null)
            {
                throw new ArgumentNullException("accessor");
            }
            if (symbolsInfo == null)
            {
                throw new ArgumentNullException("symbolsInfo");
            }
            ISymbolFactory symbolFactory = null;

            this._connection       = connection;
            this._symbolUploadInfo = symbolsInfo;
            symbolFactory          = (settings.SymbolsLoadMode != SymbolsLoadMode.DynamicTree) ? ((ISymbolFactory) new TwinCAT.Ads.TypeSystem.SymbolFactory(settings.NonCachedArrayElements)) : ((ISymbolFactory) new DynamicSymbolFactory(new TwinCAT.Ads.TypeSystem.SymbolFactory(settings.NonCachedArrayElements), settings.NonCachedArrayElements));
            this._settings         = settings;
            AdsBinder binder = new AdsBinder(this._connection.Address, this, symbolFactory, this.UseVirtualInstances);

            this._symbolFactorServices = new SymbolFactoryServices(binder, symbolFactory, accessor, session);
            symbolFactory.Initialize(this._symbolFactorServices);
            this._rootNamespace = this._connection.Address.ToString();
            this._namespaces    = new NamespaceCollection();
        }
Exemple #2
0
 internal Symbol(AdsSymbolEntry entry, ISymbol parent, ISymbolFactoryServices factoryServices)
 {
     this.accessRights = SymbolAccessRights.All;
     if (entry == null)
     {
         throw new ArgumentNullException("entry");
     }
     if (factoryServices == null)
     {
         throw new ArgumentNullException("factoryServices");
     }
     this.factoryServices  = factoryServices;
     this.indexGroup       = entry.indexGroup;
     this.indexOffset      = entry.indexOffset;
     base.comment          = entry.comment;
     base.dataTypeId       = (AdsDatatypeId)entry.dataType;
     base.category         = DataTypeCategory.Unknown;
     this.parent           = parent;
     base.instanceName     = this.getInstanceName(entry.name);
     this.instancePath     = this.getInstancePath(entry.name);
     base.size             = (int)entry.size;
     base.typeName         = entry.type;
     base.resolvedDataType = null;
     base.flags            = entry.flags;
     if (entry.attributeCount > 0)
     {
         base.attributes = new TypeAttributeCollection(entry.attributes);
     }
 }
Exemple #3
0
 private Symbol(uint indexGroup, uint indexOffset, ISymbol parent, IDataType type, string instanceName, string instancePath, ISymbolFactoryServices factoryServices)
 {
     this.accessRights = SymbolAccessRights.All;
     if (factoryServices == null)
     {
         throw new ArgumentNullException("factoryServices");
     }
     if (string.IsNullOrEmpty(instanceName))
     {
         throw new ArgumentOutOfRangeException("instanceName");
     }
     this.factoryServices = factoryServices;
     this.parent          = parent;
     if (parent != null)
     {
         base.Bind(((IBinderProvider)parent).Binder);
     }
     this.indexGroup  = indexGroup;
     this.indexOffset = indexOffset;
     if (type != null)
     {
         base.dataTypeId = ((DataType)type).DataTypeId;
         base.category   = type.Category;
     }
     base.instanceName = instanceName;
     this.instancePath = instancePath;
     if (string.IsNullOrEmpty(this.instancePath))
     {
         if (parent == null)
         {
             this.instancePath = instanceName;
         }
         else if (type.IsPointer)
         {
             this.instancePath = parent.InstancePath + "." + instanceName;
         }
         else if (!parent.IsPointer)
         {
             this.instancePath = !parent.IsReference ? (parent.InstancePath + "." + instanceName) : parent.InstancePath;
         }
         else
         {
             base.instanceName = parent.InstanceName + "^";
             this.instancePath = parent.InstancePath + "^";
         }
     }
     base.SetContextMask(0);
     if (parent != null)
     {
         base.SetContextMask(((IContextMaskProvider)parent).ContextMask);
     }
     if (type != null)
     {
         base.flags    = DataTypeFlagConverter.Convert(((DataType)type).Flags);
         base.size     = type.Size;
         base.typeName = type.Name;
     }
     base.resolvedDataType = type;
 }
Exemple #4
0
 public void Initialize(ISymbolFactoryServices services)
 {
     if (services == null)
     {
         throw new ArgumentNullException("services");
     }
     this.services    = services;
     this.initialized = true;
 }
Exemple #5
0
 internal Symbol(AdsSymbolEntry entry, IDataType type, ISymbol parent, ISymbolFactoryServices factoryServices) : this(entry, parent, factoryServices)
 {
     base.category         = type.Category;
     base.resolvedDataType = type;
     if ((base.attributes != null) && (base.attributes.Count >= 2))
     {
         ISubRangeType subRange = null;
         if (TryParseSubRange(type, base.attributes, factoryServices.Binder, out subRange))
         {
             base.category         = subRange.Category;
             base.resolvedDataType = subRange;
         }
     }
 }
Exemple #6
0
        internal Symbol(int[] indices, bool oversampleElement, ISymbol parent)
        {
            this.accessRights = SymbolAccessRights.All;
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            this.factoryServices = ((ISymbolFactoryServicesProvider)parent).FactoryServices;
            this.parent          = parent;
            base.Bind(((IBinderProvider)parent).Binder);
            string    str  = string.Empty;
            ArrayType type = (ArrayType)((DataType)parent.DataType).ResolveType(DataTypeResolveStrategy.AliasReference);

            type.CheckIndices(indices, oversampleElement);
            str = !oversampleElement?ArrayIndexConverter.IndicesToString(indices) : ArrayIndexConverter.OversamplingSubElementToString(type.Dimensions.ElementCount);

            base.instanceName = parent.InstanceName + str;
            this.instancePath = parent.InstancePath + str;
            DataType elementType = (DataType)type.ElementType;

            base.resolvedDataType = elementType;
            base.flags            = this.getSymbolFlags(parent, elementType);
            if (base.resolvedDataType != null)
            {
                base.size       = base.resolvedDataType.Size;
                base.dataTypeId = ((DataType)base.resolvedDataType).DataTypeId;
                base.category   = base.resolvedDataType.Category;
                base.typeName   = base.resolvedDataType.Name;
            }
            else
            {
                base.size       = !base.IsBitType ? type.ElementSize : 1;
                base.dataTypeId = type.ElementTypeId;
                base.category   = DataTypeCategory.Unknown;
                base.typeName   = type.ElementTypeName;
            }
            if (!oversampleElement)
            {
                this.calcAccess(parent, elementType, ArrayType.GetElementOffset(indices, (IArrayType)((DataType)parent.DataType).ResolveType(DataTypeResolveStrategy.AliasReference)), base.flags, elementType.Flags, out this.indexGroup, out this.indexOffset);
            }
            else
            {
                this.indexGroup  = 0xf019;
                this.indexOffset = 0;
            }
            base.SetContextMask(((IContextMaskProvider)parent).ContextMask);
            DataTypeCategory category = base.category;
        }
Exemple #7
0
        internal Symbol(Member member, ISymbol parent)
        {
            this.accessRights = SymbolAccessRights.All;
            if (member == null)
            {
                throw new ArgumentNullException("member");
            }
            if (parent == null)
            {
                throw new ArgumentNullException("parent");
            }
            this.factoryServices = ((ISymbolFactoryServicesProvider)parent).FactoryServices;
            this.parent          = parent;
            base.Bind(((IBinderProvider)parent).Binder);
            string instanceName = member.InstanceName;

            base.instanceName     = instanceName;
            this.instancePath     = parent.InstancePath + "." + instanceName;
            base.resolvedDataType = (DataType)member.DataType;
            base.flags            = this.getSymbolFlags(parent, member);
            this._memberFlags     = member.MemberFlags;
            this.staticAddress    = parent.IsStatic || this._memberFlags.HasFlag(AdsDataTypeFlags.None | AdsDataTypeFlags.Static);
            base.attributes       = (member.Attributes.Count <= 0) ? null : new TypeAttributeCollection(member.Attributes);
            base.comment          = member.Comment;
            if (base.resolvedDataType != null)
            {
                base.size       = base.resolvedDataType.Size;
                base.dataTypeId = ((DataType)base.resolvedDataType).DataTypeId;
                base.category   = base.resolvedDataType.Category;
                base.typeName   = base.resolvedDataType.Name;
            }
            else
            {
                base.size       = member.Size;
                base.dataTypeId = member.DataTypeId;
                base.category   = member.Category;
                base.typeName   = member.TypeName;
            }
            this.calcAccess(parent, member, out this.indexGroup, out this.indexOffset);
            base.SetContextMask(((IContextMaskProvider)parent).ContextMask);
            DataTypeCategory category = base.category;
        }
Exemple #8
0
        public static void ParseSymbols(AdsStream symbolStream, Encoding encoding, ISymbolFactoryServices factoryServices)
        {
            if (symbolStream == null)
            {
                throw new ArgumentNullException("symbolStream");
            }
            if (factoryServices == null)
            {
                throw new ArgumentNullException("factoryServices");
            }
            AdsBinaryReader symbolReader = new AdsBinaryReader(symbolStream);

            symbolStream.Position = 0L;
            while (symbolStream.Position < symbolStream.Length)
            {
                ISymbol symbol = ParseSymbol(symbolReader, encoding, factoryServices);
                if (symbol != null)
                {
                    factoryServices.Binder.Bind((IHierarchicalSymbol)symbol);
                }
            }
        }
Exemple #9
0
 internal PointerInstance(AdsSymbolEntry entry, IPointerType type, ISymbol parent, ISymbolFactoryServices factoryServices) : base(entry, type, parent, factoryServices)
 {
     base.category = DataTypeCategory.Pointer;
 }
Exemple #10
0
 public void Initialize(ISymbolFactoryServices services)
 {
     this.inner.Initialize(services);
 }
Exemple #11
0
 internal ArrayInstance(AdsSymbolEntry entry, IArrayType type, ISymbol parent, ISymbolFactoryServices factoryServices) : base(entry, type, parent, factoryServices)
 {
     base.category = DataTypeCategory.Array;
 }
 internal RpcStructInstance(AdsSymbolEntry entry, RpcStructType structRpcCallable, ISymbol parent, ISymbolFactoryServices services) : base(entry, structRpcCallable, parent, services)
 {
 }
Exemple #13
0
 internal UnionInstance(AdsSymbolEntry entry, IUnionType type, ISymbol parent, ISymbolFactoryServices factoryServices) : base(entry, type, parent, factoryServices)
 {
     base.category = DataTypeCategory.Union;
 }
Exemple #14
0
 protected StructInstance(string instanceName, ISymbol parent, int fieldOffset, ISymbolFactoryServices factoryServices) : base(instanceName, parent, factoryServices)
 {
     base.category = DataTypeCategory.Struct;
 }
 internal VirtualStructInstance(string instanceName, string instancePath, ISymbol parent, ISymbolFactoryServices services) : base(instanceName, instancePath, services)
 {
     this._virtualMembers = new SymbolCollection(InstanceCollectionMode.Names);
     base.category        = DataTypeCategory.Struct;
 }
Exemple #16
0
 internal Symbol(string instanceName, ISymbol parent, ISymbolFactoryServices factoryServices) : this(0, 0, parent, null, instanceName, null, factoryServices)
 {
     DataTypeCategory category = base.category;
 }
Exemple #17
0
 internal Symbol(string instanceName, string instancePath, ISymbolFactoryServices factoryServices) : this(0, 0, null, null, instanceName, instancePath, factoryServices)
 {
     DataTypeCategory category = base.category;
 }
Exemple #18
0
 protected StructInstance(string instanceName, string instancePath, ISymbolFactoryServices factoryServices) : base(instanceName, instancePath, factoryServices)
 {
     base.category = DataTypeCategory.Struct;
 }
Exemple #19
0
        internal Symbol(ISymbol parent, IDataType type, string instanceName, int fieldOffset, ISymbolFactoryServices factoryServices) : this(0, 0, parent, type, instanceName, null, factoryServices)
        {
            DataType type2 = (DataType)type;

            this.calcAccess(parent, (DataType)type, fieldOffset, DataTypeFlagConverter.Convert(type2.Flags), type2.Flags, out this.indexGroup, out this.indexOffset);
            DataTypeCategory category = base.category;
        }
Exemple #20
0
 internal StructInstance(AdsSymbolEntry entry, IStructType type, ISymbol parent, ISymbolFactoryServices factoryServices) : base(entry, type, parent, factoryServices)
 {
     base.category = DataTypeCategory.Struct;
 }
Exemple #21
0
 internal UnionInstance(string instanceName, ISymbol parent, ISymbolFactoryServices factoryServices) : base(instanceName, parent, factoryServices)
 {
     base.category = DataTypeCategory.Union;
 }
Exemple #22
0
 internal ReferenceInstance(AdsSymbolEntry entry, IReferenceType type, ISymbol parent, ISymbolFactoryServices factoryServices) : base(entry, type, parent, factoryServices)
 {
     base.category = DataTypeCategory.Reference;
 }
Exemple #23
0
        private static ISymbol ParseSymbol(AdsBinaryReader symbolReader, Encoding encoding, ISymbolFactoryServices factoryServices)
        {
            AdsSymbolEntry entry = new AdsSymbolEntry(-1L, encoding, symbolReader);

            return(factoryServices.SymbolFactory.CreateInstance(entry, null));
        }