public void Send(CompanyCommand command, params string[] parameters)
        {
            _semaphore.WaitOne();

            _serialPort.Write(command.GetFullCommand(parameters));

            _semaphore.Release(1);
        }
        public void Send(CompanyCommand command, params string[] parameters)
        {
            RequestSemaphore();

            _tcpClient.Client.Send(Encoding.UTF8.GetBytes(command.GetFullCommand(parameters)));

            ReleaseSemaphore();
        }
        public string SendAndReceive(CompanyCommand command, params string[] parameters)
        {
            _semaphore.WaitOne();

            _serialPort.Write(command.GetFullCommand(parameters));
            var result = _serialPort.ReadLine();

            _semaphore.Release(1);

            return result;
        }
        public string SendAndReceive(CompanyCommand command, params string[] parameters)
        {
            RequestSemaphore();

            _tcpClient.Client.Send(Encoding.UTF8.GetBytes(command.GetFullCommand(parameters)));
            var resultBytes = new byte[command.ExpectedResultSize];
            _tcpClient.Client.Receive(resultBytes);
            var result = Encoding.UTF8.GetString(resultBytes).Replace("\0", string.Empty);

            ReleaseSemaphore();

            return result;
        }