io.stepfunc.rodbus.WriteResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rodbus Show documentation
Show all versions of rodbus Show documentation
Safe and fast Modbus library
// This library is provided under the terms of a non-commercial license.
//
// Please refer to the source repository for details:
//
// https://github.com/stepfunc/rodbus/blob/master/LICENSE.txt
//
// Please contact Step Function I/O if you are interested in commercial license:
//
// [email protected]
package io.stepfunc.rodbus;
import org.joou.*;
/**
* Result struct describing if an operation was successful or not. Exception codes are returned to the client
*/
public final class WriteResult
{
/**
* true if the operation was successful, false otherwise. Error details found in the exception field.
*/
public boolean success;
/**
* exception enumeration. If undefined, look at the raw value
*/
public ModbusException exception;
/**
* Raw exception value when 'exception' field is Undefined
*/
public UByte rawException;
/**
* Initialize {@link WriteResult} to default values
*
* @param success true if the operation was successful, false otherwise. Error details found in the exception field.
* @param exception exception enumeration. If undefined, look at the raw value
* @param rawException Raw exception value when 'exception' field is Undefined
*/
public WriteResult(boolean success, ModbusException exception, UByte rawException)
{
this.success = success;
this.exception = exception;
this.rawException = rawException;
}
/**
* initialize a WriteResult to indicate a successful write operation
*
* @return WriteResult initialized to indicate a successful write operation
*/
public static WriteResult createSuccess()
{
return NativeFunctions.write_result_success();
}
/**
* initialize a WriteResult to indicate a successful write operation
*
* @param exception Exception code to include in the result
* @return WriteResult initialized to indicate a successful write operation
*/
public static WriteResult createException(ModbusException exception)
{
return NativeFunctions.write_result_exception(exception);
}
/**
* initialize a WriteResult to indicate a successful write operation
*
* @param rawException Raw Exception code to include in the result
* @return WriteResult initialized to indicate a successful write operation
*/
public static WriteResult createRawException(UByte rawException)
{
return NativeFunctions.write_result_raw_exception(rawException);
}
}