Esempio n. 1
0
 internal void Close()
 {
     _status = false;
     _clientRs.TerminaSocket();
     _serverLog.Closed();
     _clientRs  = null;
     _isBusyLog = false;
     _fileLog   = null;
     _serverLog = null;
 }
Esempio n. 2
0
        private void EnviaSolicitud()
        {
            _dataRecived = false;
            _countTime   = 0;

            SetRegisterAddress();

            if (_esSocket)
            {
                _status = _clientRs.BinaryWriter(_dsf.ToBytes());

                //if (_muestraDatosConsola)
                //{
                //    Console.WriteLine("BinaryWriter");
                //    _dsf.ToBytes().ToList().ForEach(item => Console.Write(string.Format("{0:X} ", item)));
                //    Console.WriteLine();
                //}
            }
            else
            {
                _status = _serialPortInterface.Send(_dsf.ToBytes());
            }

            while (!_dataRecived && _countTime < _timeOut)
            {
                Thread.Sleep(1);
                _countTime++;
            }

            if (_countTime >= _timeOut)
            {
                Console.WriteLine("Medidor Timeout");
                _cuentaTimeOut++;
                if (_cuentaTimeOut >= _maxTimeOut)
                {
                    _clientRs.TerminaSocket();
                    _clientRs.IniciarSocket();
                }
            }
            else
            {
                _cuentaTimeOut = 0;
                PrintStatus(true);
            }
        }