INGEAR.NET.Logix

 

Controller.ErrorCode Property

Returns numeric error value the Controller's most recent operations

[Visual Basic]
NotOverridable Public ReadOnly Property ErrorCode As Integer _
    Implements IController.ErrorCode
[C#]
public int ErrorCode {get;}

Property Value

Numeric error code value: ResultCode or CIP Errors class for possible list of errors.

Implements

IController.ErrorCode

Remarks

ErrorCodes with a value of 100xxx (e.g. 10057) are Windows Sockets errors and not listed in the ResultCode constants.  

Example

VB
Try
  ' ************************************
  ' * initialize controller class
  Dim MyPLC as New Logix.Controller()
  ' ************************************
  ' * set IP Address
  MyPLC.IPAddress = "192.168.1.31"
  ' ************************************
  ' * connect to PLC
  MyPLC.Connect()
  ' ************************************
  ' * check for errors
  If MyPLC.Error = ResultCode.E_SUCCESS Then
    Console.WriteLine("Connect Success")
  Else  
    Console.WriteLine(MyPLC.ErrorString)
  End If  
Catch ex As System.Exception
  Console.WriteLine(ex.Message)
End Try
  
C#
try
{
  ///////////////////////////////////////
  // initialize controller class
  Logix.Controller MyPLC = new Logix.Controller()
  ///////////////////////////////////////
  // set IP Address
  MyPLC.IPAddress = "192.168.1.31"
  ///////////////////////////////////////
  // connect to plc
  MyPLC.Connect();
  ///////////////////////////////////////
  // check for error
  if (ResultCode.E_SUCCESS != MyPLC.ErrorCode)
    Console.WriteLine(MyPLC.ErrorString);
}
catch(System.Exception ex)
{
  Console.WriteLine(ex.Message);
}      

See Also

Controller Class | Logix Namespace | ErrorString