Exemplo n.º 1
0
 void Send(string cmd)
 {
     try
     {
         stream.WriteLine(cmd);
         var response = stream.ReadLine();
         if (response != "ok")
         {
             throw new HardwareException(DeviceType.Generator, ErrorCode.CommunicationError, "Communication error", "");
         }
     }
     catch (IOException)
     {
         throw new HardwareException(DeviceType.Generator, ErrorCode.CommunicationError, "Communication error", "Connect the generator");
     }
     catch (TimeoutException)
     {
         throw new HardwareException(DeviceType.Generator, ErrorCode.CommunicationError, "Communication error", "Switch the generator on");
     }
 }