Ejemplo n.º 1
0
        public AdsErrorCode TryCreateHandles(out ISumHandleCollection handles)
        {
            IList <SumDataEntity> list = this.CreateSumEntityInfos();

            handles = null;
            AdsErrorCode[] returnCodes = null;
            IList <byte[]> readData    = null;

            int[]        readDataSizes = null;
            AdsErrorCode code          = base.Execute(null, out readData, out readDataSizes, out returnCodes);

            if (code == AdsErrorCode.NoError)
            {
                handles = new SumHandleList();
                for (int i = 0; i < list.Count; i++)
                {
                    uint notificationHandle = 0;
                    if (returnCodes[i] == AdsErrorCode.NoError)
                    {
                        notificationHandle = BitConverter.ToUInt32(readData[i], 0);
                    }
                    handles.Add(new SumNotificationHandleEntry(this._variableHandles[i], notificationHandle, returnCodes[i]));
                }
            }
            return(code);
        }
Ejemplo n.º 2
0
        public AdsErrorCode TryCreateHandles(out ISumHandleCollection handles)
        {
            IList <SumDataEntity> sumEntities = this.CreateSumEntityInfos();

            handles = null;
            AdsErrorCode[] returnCodes = null;
            List <byte[]>  writeData   = new List <byte[]>();
            IList <byte[]> readData    = null;

            foreach (InstancePathSumEntity entity in sumEntities)
            {
                writeData.Add(entity.GetWriteBytes());
            }
            base.innerCommand = new SumReadWrite(this._connection, sumEntities, TwinCAT.Ads.SumCommand.SumCommand.SumAccessMode.AquireHandleByName);
            AdsErrorCode code = base.innerCommand.TryReadWriteRaw(writeData, out readData, out returnCodes);

            if (code == AdsErrorCode.NoError)
            {
                handles = new SumHandleList();
                for (int i = 0; i < sumEntities.Count; i++)
                {
                    uint handle = 0;
                    if (returnCodes[i] == AdsErrorCode.NoError)
                    {
                        handle = BitConverter.ToUInt32(readData[i], 0);
                    }
                    handles.Add(new SumHandleInstancePathEntry(this._instancePaths[i], handle, returnCodes[i]));
                }
            }
            return(code);
        }
Ejemplo n.º 3
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         AdsErrorCode[] returnCodes  = null;
         uint[]         validHandles = this.handleDict.ValidHandles;
         AdsErrorCode   code         = new SumReleaseHandles(this.connection, validHandles).TryReleaseHandles(out returnCodes);
         this.handleDict = null;
     }
 }
Ejemplo n.º 4
0
        public AdsErrorCode TryCreateHandles(out uint[] handles, out AdsErrorCode[] returnCodes)
        {
            ISumHandleCollection handles2 = null;
            AdsErrorCode         code     = this.TryCreateHandles(out handles2);

            returnCodes = new AdsErrorCode[handles2.Count];
            handles     = new uint[handles2.Count];
            for (int i = 0; i < handles2.Count; i++)
            {
                handles[i]     = handles2[i].Handle;
                returnCodes[i] = handles2[i].ErrorCode;
            }
            return(code);
        }