Beispiel #1
0
 /// <summary>
 /// Reads process data from the selected location and device resources.
 /// </summary>
 /// <param name="pBlock"><see cref="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="IReadValue"/> containing the requested data.</param>
 /// <param name="pRetries">Number of retries to get data.</param>
 /// <returns>Result of the operation</returns>
 public AL_ReadData_Result ReadData(IBlockDescription pBlock, int pStation, out IReadValue pData, byte pRetries)
 {
     pData = null;
     try
     {
         return(mDataProvider.ReadData(pBlock, pStation, out pData, pRetries));
     }
     catch (Exception ex)
     {
         if ((pData != null) && !pData.InPool)
         {
             pData.ReturnEmptyEnvelope();
         }
         pData = null;
         TraceException(ex, 46);
         return(AL_ReadData_Result.ALRes_DatTransferErrr);
     }
 }
 /// <summary>
 /// Read Data
 /// </summary>
 /// <param name="block">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)
     {
         InterFrameStopwatch.Reset();
         InterFrameStopwatch.Start();
         m_rPackNum++;
         data = null;
         bool TransmissionIsOK = true;
         data = (IReadValue)pool.GetEmptyISesDBuffer();
         //informacja ze dziala transmitter:
         ((Message)data).TransmitterON(station);
         //Timer.Wait( Timer.TInOneSecond );
         ((Message)data).SetBlockDescription(station, block);
         ((Message)data).ReadFromDB();
         myStatistic.IncStTxFrameCounter();
         myStatistic.IncStRxFrameCounter();
         myStatistic.TimeCharGapAdd(1);
         myStatistic.TimeMaxResponseDelayAdd(InterFrameStopwatch.ElapsedMilliseconds);
         ((Message)data).TransmitterOFF(station);
         if (m_errorfrequency > 0 && (m_rPackNum % (100 / (ulong)m_errorfrequency)) == 0)
         {
             TransmissionIsOK = false;
         }
         if (TransmissionIsOK && ((Message)data).TestCommunication(station))
         {
             myStatistic.RxDataBlock(true);
             return(AL_ReadData_Result.ALRes_Success);
         }
         else
         {
             myStatistic.RxDataBlock(false);
             data.ReturnEmptyEnvelope();
             data = null;
             return(AL_ReadData_Result.ALRes_DatTransferErrr);
         }
     }
 }