/// <summary> /// This function gets message from the remote unit. /// </summary> /// <param name="Rxmsg">Received message</param> /// <param name="Txmsg">Transmited message, information about this frmae could be necessary to properly init received frame. /// </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 GetMessage(out Message Rxmsg, Message Txmsg) { Rxmsg = m_Pool.GetEmptyISesDBuffer(); Rxmsg.ResetContent(); Rxmsg.userDataLength = Rxmsg.userBuffLength; ushort received = 0; bool receiving = true; byte lastChar; while (receiving) { switch (GetICommunicationLayer.GetChar(out lastChar, 0)) { case TGetCharRes.Success: if (!Rxmsg.WriteByte(lastChar)) { EventLogMonitor.WriteToEventLogError("Response frame is too long. The data cannot be longer than " + Rxmsg.userBuffLength + " characters", 92); return(AL_ReadData_Result.ALRes_DatTransferErrr); } received++; break; default: receiving = false; break; } } if (Rxmsg.offset == 0) { return(AL_ReadData_Result.ALRes_DatTransferErrr); } Rxmsg.userDataLength = received; return(AL_ReadData_Result.ALRes_Success); } //GetMessage
/// <summary> /// Constructor for the HTTP on Soap Formatter server /// </summary> /// <param name="portNumber">TCP port number that this server is listening on</param> public HTTPSoapServer(int portNumber) { try { IDictionary formatterProps = new Hashtable(); formatterProps["includeVersions"] = false; formatterProps["strictBinding"] = false; SoapServerFormatterSinkProvider ftProvider = new SoapServerFormatterSinkProvider(formatterProps, null); //SoapServerFormatterSinkProvider ftProvider = new SoapServerFormatterSinkProvider(); ftProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; ftProvider.Next = new System.Runtime.Remoting.MetadataServices.SdlChannelSinkProvider(); m_Channel = new HttpServerChannel(null, portNumber, ftProvider); EventLogMonitor.WriteToEventLogInfo("HTTPServerChannel, port:" + portNumber.ToString() + "..created", (int)Error.DataPorter_Servers); } catch (Exception ex) { EventLogMonitor.WriteToEventLogError("HTTPServerChannel not started, exception:" + ex.Message, (int)Error.DataPorter_Servers); } }
/// <summary> /// Initializes a new instance of the <see cref="ProtocolHubConfiguration"/> class. /// </summary> /// <param name="ConfigurationFilename">The configuration filename.</param> /// <param name="open_readonly">if set to <c>true</c> file is opened as read only.</param> public ProtocolHubConfiguration(string ConfigurationFilename, bool open_readonly) { filename = ConfigurationFilename; try { configuration = new ComunicationNet(); this.configuration.BeginInit(); this.configuration.DataSetName = "ComunicationNet"; this.configuration.Locale = new System.Globalization.CultureInfo("en-US"); this.configuration.EndInit(); XML2DataSetIO.readXMLFile(configuration, filename, open_readonly); } catch (System.IO.IOException ioex) { EventLogMonitor.WriteToEventLogError("Problem with CommServer configuration file:" + ioex.Message, (int)Error.CommServer_Configuration); } catch (Exception ex) { string _path = Environment.CurrentDirectory; EventLogMonitor.WriteToEventLogError($"Problem with CommServer XML configuration file : {filename} - in directory: {_path } error: {ex.ToString()}", (int)Error.CommServer_Configuration); } }