} //GetMessage /// <summary> /// Transmit message to the remote unit. /// </summary> /// <param name="Txmsg">Message to be transmitted</param> /// <returns> /// ALRes_Success: /// Operation accomplished successfully /// ALRes_DisInd: /// Disconnect indication – connection has been shut down remotely or lost because of /// communication error. Data is unavailable /// </returns> protected override AL_ReadData_Result TransmitMessage(MBUS_message Txmsg) { Flush(((MBUS_ProtocolParameters)GetProtocolParameters).InterframeGapSpan); GetIProtocolParent.IncStTxFrameCounter(); switch (GetICommunicationLayer.FrameEndSignal(Txmsg)) { case TFrameEndSignalRes.Success: break; case TFrameEndSignalRes.DisInd: return(AL_ReadData_Result.ALRes_DisInd); } return(AL_ReadData_Result.ALRes_Success); }
/// <summary> /// Transmit message to the remote unit. /// </summary> /// <param name="toSendMessage">Message to be transmitted</param> /// <returns> /// ALRes_Success: Operation accomplished successfully /// ALRes_DatTransferErrr: Data transfer is imposible because of a communication error – loss of /// communication with a station /// ALRes_DisInd: Disconnect indication – connection has been shut down remotely or lost because of /// communication error. Data is unavailable /// </returns> protected override AL_ReadData_Result TransmitMessage(FrameStateMachine toSendMessage) { FrameStateMachine preparedToSend = m_Pool.GetEmptyISesDBuffer(); //tworzymy nowego message'a do wyslania- bedzie on zawieral dodatkowo bajty sumy kontrolna i wstawione znaki preparedToSend.PrepareFrameToBeSend(toSendMessage); switch (GetICommunicationLayer.FrameEndSignal(preparedToSend)) { case TFrameEndSignalRes.Success: GetIProtocolParent.IncStTxFrameCounter(); //uzupelniamy statystyki break; case TFrameEndSignalRes.DisInd: return(AL_ReadData_Result.ALRes_DisInd); } preparedToSend.ReturnEmptyEnvelope(); return(AL_ReadData_Result.ALRes_Success); }
/// <summary> /// Transmit message to the remote unit. /// </summary> /// <param name="message">Message to be transmitted</param> /// <returns> /// ALRes_Success: /// Operation accomplished successfully /// ALRes_DisInd: /// Disconnect indication – connection has been shut down remotely or lost because of /// communication error. Data is unavailable /// </returns> protected override AL_ReadData_Result TransmitMessage(ModBusMessage message) { try { Flush(((ModBus_ProtocolParameters)GetProtocolParameters).Timeout35Span); //flush may throw DisconnectException } catch (DisconnectException ex) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Information, 130, $"ModBusProtocol.TransmitMessage.Flush: exception has been caught {ex.Message}"); return(AL_ReadData_Result.ALRes_DisInd); } GetIProtocolParent.IncStTxFrameCounter(); switch (GetICommunicationLayer.FrameEndSignal(message)) { case TFrameEndSignalRes.Success: break; case TFrameEndSignalRes.DisInd: return(AL_ReadData_Result.ALRes_DisInd); } return(AL_ReadData_Result.ALRes_Success); }