public DDS238(bool muestraDatosConsola, string ip, int puerto, bool esSocket, bool escribeArchivoLog, string path) { _ip = ip; _puerto = puerto; _path = path; _esSocket = esSocket; _escribeArchivoLog = escribeArchivoLog; _muestraDatosConsola = muestraDatosConsola; if (_escribeArchivoLog) { string log = string.Format(@"log_meter_{0}.txt", DateTime.Now.ToString("yyyyMMdd")); log = Path.Combine(_path, log); _fileLog = System.IO.File.AppendText(log); _fileLog.AutoFlush = true; _fileLog.WriteLine(DateTime.Now); } _clientRs = new SuperSocketClient(ip, puerto); _clientRs.InputData += clientRs_InputData; _clientRs.Disconnect += _clientRs_Disconnect; _clientRs.Connect += _clientRs_Connect; _status = _clientRs.IniciarSocket(); while (!_status) { Thread.Sleep(10); } _threadStart = new ThreadStart(Tarea); _thread = new Thread(_threadStart); _thread.Start(); }
//--------------------------------------------------------------------- void _onSocketError(object rec, SocketErrorEventArgs args) { mSocket = null; if (OnSocketError != null) { OnSocketError(this, args); } }
//--------------------------------------------------------------------- public RpcSessionSuperSocket(EntityMgr entity_mgr) { mEntityMgr = entity_mgr; mSocket = new SuperSocketClient(); mSocket.OnSocketReceive += _onSocketReceive; mSocket.OnSocketConnected += _onSocketConnected; mSocket.OnSocketClosed += _onSocketClosed; mSocket.OnSocketError += _onSocketError; }
//--------------------------------------------------------------------- void _onSocketClosed(object client, EventArgs args) { mSocket = null; if (OnSocketClosed != null) { OnSocketClosed(this, args); } }
//--------------------------------------------------------------------- public EntityRpcSessionSuperSocketC(EntityMgr entity_mgr) { mEntityMgr = entity_mgr; mSocket = new SuperSocketClient(); mSocket.OnSocketReceive += _onSocketReceive; mSocket.OnSocketConnected += _onSocketConnected; mSocket.OnSocketClosed += _onSocketClosed; mSocket.OnSocketError += _onSocketError; }
internal void Close() { _status = false; _clientRs.TerminaSocket(); _serverLog.Closed(); _clientRs = null; _isBusyLog = false; _fileLog = null; _serverLog = null; }
public DDS238(bool muestraDatosConsola, SerialPortInterface serial, string ip, int puerto, bool esSocket, bool escribeArchivoLog) { _esSocket = esSocket; _escribeArchivoLog = escribeArchivoLog; _dsf = new SendFrameFormat(0x01, FunctionCode.ReadHoldingRegisters); if (serial != null) { _serialPortInterface = serial; } if (!esSocket) { //string trm = string.Format("trm_{0}.txt", DateTime.Now.ToString("yyyyMMdd")); //_t = System.IO.File.AppendText(trm); _status = _serialPortInterface.Open(); _serialPortInterface.DataReceived += Sp_DataReceived; } else { _clientRs = new SuperSocketClient(ip, puerto); _clientRs.InputData += clientRs_InputData; _status = _clientRs.IniciarSocket(); } _muestraDatosConsola = muestraDatosConsola; _timer.Interval = 1000; _timer.Elapsed += Tarea; _timer.Enabled = true; _serverLog.InputData += _serverLog_InputData; _serverLog.Init(123); if (_escribeArchivoLog) { string log = string.Format(@"log\log_meter_{0}.txt", DateTime.Now.ToString("yyyyMMdd")); _f = System.IO.File.AppendText(log); } }