/// <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) { m_rPackNum++; data = null; myStatistic.IncStTxFrameCounter(); if ((m_errorfrequency > 0) && (m_rPackNum % (ulong)m_errorfrequency == 0)) { myStatistic.IncStRxFragmentedCounter(); myStatistic.RxDataBlock(false); return(AL_ReadData_Result.ALRes_DatTransferErrr); } data = (IReadValue)pool.GetEmptyISesDBuffer(); // Processes.Timer.Wait(Processes.Timer.TInOneSecond/4); ((NULL_message)data).SetBlockDescription(station, block); ((NULL_message)data).ReadFromDB(); bool success = true; if (CommunicationThroughCommunicationLayer) { success = SendReceive(); } if (success) { myStatistic.IncStRxFrameCounter(); } myStatistic.RxDataBlock(success); return(AL_ReadData_Result.ALRes_Success); } }
/// <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); } } }