/// <summary>
 /// Read Data
 /// </summary>
 /// <param name="block">Data block description to be read</param>
 /// <param name="station">Address of the remote station connected to the common field bus. –1 if not applicable.
 /// </param>
 /// <param name="data">The buffer with the requested data.</param>
 /// <param name="retries">Number of retries to get data.</param>
 /// <returns>Result of the operation</returns>
 AL_ReadData_Result IApplicationLayerMaster.ReadData(IBlockDescription block, int station, out IReadValue data, byte retries)
 {
     lock (this)
     {
         rPackNum++;
         data = null;
         data = (IReadValue)pool.GetEmptyISesDBuffer();
         System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
         ((NULL_message)data).SetBlockDescription(station, block);
         ((NULL_message)data).ReadFromDB();
         myStatistic.IncStTxFrameCounter();
         myStatistic.IncStRxFrameCounter();
         myStatistic.RxDataBlock(true);
         return(AL_ReadData_Result.ALRes_Success);
     }
 }
        /// <summary>
        /// Reads process data from the selected location and device resources.
        /// </summary>
        /// <param name="pBlock"><see cref="T:CAS.Lib.CommonBus.ApplicationLayer.IBlockDescription" /> selecting the resource containing the data block to be read.</param>
        /// <param name="pStation">Address of the remote station connected to the common field bus. –1 if not applicable.</param>
        /// <param name="pData">The buffer <see cref="T:CAS.Lib.CommonBus.ApplicationLayer.IReadValue" /> containing the requested data.</param>
        /// <param name="pRetries">Number of retries to get data.</param>
        /// <returns>Result of the operation</returns>
        /// <exception cref="System.ArgumentOutOfRangeException"></exception>
        public AL_ReadData_Result ReadData(IBlockDescription pBlock, int pStation, out IReadValue pData, byte pRetries)
        {
            pData = null;
            if (pBlock.dataType != 0)
            {
                TraceSource.TraceMessage(TraceEventType.Error, 149, $"Wrong dataType: {pBlock.dataType}; only data type = 0 is expected");
                m_statistic.IncStRxInvalid();
            }
            if (!Connected)
            {
                TraceSource.TraceMessage(TraceEventType.Verbose, 165, $"ReadData failed because it is not connected; retries/limit={m_RetryCount}/{this.m_TextReaderProtocolParameters.MaxNumberOfRetries}.");
                return(AL_ReadData_Result.ALRes_DisInd);
            }
            m_statistic.IncStTxFrameCounter();
            IDataEntity _copy      = Interlocked.Exchange <IDataEntity>(ref m_Fifo, m_Fifo);
            bool        _retResult = _copy != null;

            m_statistic.RxDataBlock(_retResult);
            if (!_retResult)
            {
                m_statistic.IncStRxNoResponseCounter();
                TraceSource.TraceMessage(TraceEventType.Information, 186, $"ReadData failed; retries/limit={m_RetryCount}/{this.m_TextReaderProtocolParameters.MaxNumberOfRetries}.");
                return(AL_ReadData_Result.ALRes_DatTransferErrr);
            }
            m_statistic.IncStRxFrameCounter();
            pData = new ReadDataEntity(_copy, pBlock);
            TraceSource.TraceMessage(TraceEventType.Verbose, 191, $"ReadData succeeded for [{pStation}/{pBlock.startAddress}]");
            return(AL_ReadData_Result.ALRes_Success);
        }