Created
December 27, 2010 13:46
-
-
Save juanplopes/756145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Returns -1 in BalancaResponse.Peso if there was an error and the error message. | |
/// </summary> | |
/// <returns></returns> | |
public BalancaResponse GetWeight() | |
{ | |
BalancaResponse response = new BalancaResponse(); | |
response.Peso = -1d; | |
Double peso = this.AbrePorta(); | |
if (peso == 0d) | |
response.Message = "Não foi possível abri a porta " + Enum.GetName(typeof(Balanca.Port), _port); | |
else | |
{ | |
peso = this.LePeso(); | |
if (peso == -9999) | |
response.Message = "Erro generico de comunicacao - caracteres nao numericos recebidos."; | |
else if (peso == -9997) | |
response.Message = "Nao conseguiu abrir a comunicacao com a porta serial."; | |
else if (peso == -9996) | |
response.Message = "Tempo de 2 segundos esgotado (time out)."; | |
else | |
response.Peso = peso; | |
this.FechaPorta(); | |
} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment