io.stepfunc.dnp3.EventBufferConfig Maven / Gradle / Ivy
// This library is provided under the terms of a non-commercial license.
//
// Please refer to the source repository for details:
//
// https://github.com/stepfunc/dnp3/blob/master/LICENSE.txt
//
// Please contact Step Function I/O if you are interested in commercial license:
//
// [email protected]
package io.stepfunc.dnp3;
import org.joou.*;
/**
* Maximum number of events for each type
*
* A value of zero means that events will not be buffered for that type.
*/
public final class EventBufferConfig
{
/**
* Maximum number of Binary Input events (g2)
*/
public UShort maxBinary;
/**
* Maximum number of Double-Bit Binary Input events (g4)
*/
public UShort maxDoubleBitBinary;
/**
* Maximum number of Binary Output Status events (g11)
*/
public UShort maxBinaryOutputStatus;
/**
* Maximum number of Counter events (g22)
*/
public UShort maxCounter;
/**
* Maximum number of Frozen Counter events (g23)
*/
public UShort maxFrozenCounter;
/**
* Maximum number of Analog Input events (g32)
*/
public UShort maxAnalog;
/**
* Maximum number of Analog Output Status events (g42)
*/
public UShort maxAnalogOutputStatus;
/**
* Maximum number of Octet String events (g111)
*/
public UShort maxOctetString;
/**
* Maximum number of Binary Input events (g2)
*/
public EventBufferConfig withMaxBinary(UShort value)
{
this.maxBinary = value;
return this;
}
/**
* Maximum number of Double-Bit Binary Input events (g4)
*/
public EventBufferConfig withMaxDoubleBitBinary(UShort value)
{
this.maxDoubleBitBinary = value;
return this;
}
/**
* Maximum number of Binary Output Status events (g11)
*/
public EventBufferConfig withMaxBinaryOutputStatus(UShort value)
{
this.maxBinaryOutputStatus = value;
return this;
}
/**
* Maximum number of Counter events (g22)
*/
public EventBufferConfig withMaxCounter(UShort value)
{
this.maxCounter = value;
return this;
}
/**
* Maximum number of Frozen Counter events (g23)
*/
public EventBufferConfig withMaxFrozenCounter(UShort value)
{
this.maxFrozenCounter = value;
return this;
}
/**
* Maximum number of Analog Input events (g32)
*/
public EventBufferConfig withMaxAnalog(UShort value)
{
this.maxAnalog = value;
return this;
}
/**
* Maximum number of Analog Output Status events (g42)
*/
public EventBufferConfig withMaxAnalogOutputStatus(UShort value)
{
this.maxAnalogOutputStatus = value;
return this;
}
/**
* Maximum number of Octet String events (g111)
*/
public EventBufferConfig withMaxOctetString(UShort value)
{
this.maxOctetString = value;
return this;
}
/**
* Fully construct {@link EventBufferConfig} specifying the value of each field
*
* @param maxBinary Maximum number of Binary Input events (g2)
* @param maxDoubleBitBinary Maximum number of Double-Bit Binary Input events (g4)
* @param maxBinaryOutputStatus Maximum number of Binary Output Status events (g11)
* @param maxCounter Maximum number of Counter events (g22)
* @param maxFrozenCounter Maximum number of Frozen Counter events (g23)
* @param maxAnalog Maximum number of Analog Input events (g32)
* @param maxAnalogOutputStatus Maximum number of Analog Output Status events (g42)
* @param maxOctetString Maximum number of Octet String events (g111)
*/
public EventBufferConfig(UShort maxBinary, UShort maxDoubleBitBinary, UShort maxBinaryOutputStatus, UShort maxCounter, UShort maxFrozenCounter, UShort maxAnalog, UShort maxAnalogOutputStatus, UShort maxOctetString)
{
this.maxBinary = maxBinary;
this.maxDoubleBitBinary = maxDoubleBitBinary;
this.maxBinaryOutputStatus = maxBinaryOutputStatus;
this.maxCounter = maxCounter;
this.maxFrozenCounter = maxFrozenCounter;
this.maxAnalog = maxAnalog;
this.maxAnalogOutputStatus = maxAnalogOutputStatus;
this.maxOctetString = maxOctetString;
}
/**
* Create a configuration where no events are buffered.
*
* Values are initialized to:
*
* - {@link EventBufferConfig#maxBinary} : 0
* - {@link EventBufferConfig#maxDoubleBitBinary} : 0
* - {@link EventBufferConfig#maxBinaryOutputStatus} : 0
* - {@link EventBufferConfig#maxCounter} : 0
* - {@link EventBufferConfig#maxFrozenCounter} : 0
* - {@link EventBufferConfig#maxAnalog} : 0
* - {@link EventBufferConfig#maxAnalogOutputStatus} : 0
* - {@link EventBufferConfig#maxOctetString} : 0
*
*
* @return Initialized {@link EventBufferConfig} instance
*/
public static EventBufferConfig noEvents()
{
return new EventBufferConfig(UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0), UShort.valueOf(0));
}
void _assertFieldsNotNull()
{
java.util.Objects.requireNonNull(maxBinary, "maxBinary cannot be null");
java.util.Objects.requireNonNull(maxDoubleBitBinary, "maxDoubleBitBinary cannot be null");
java.util.Objects.requireNonNull(maxBinaryOutputStatus, "maxBinaryOutputStatus cannot be null");
java.util.Objects.requireNonNull(maxCounter, "maxCounter cannot be null");
java.util.Objects.requireNonNull(maxFrozenCounter, "maxFrozenCounter cannot be null");
java.util.Objects.requireNonNull(maxAnalog, "maxAnalog cannot be null");
java.util.Objects.requireNonNull(maxAnalogOutputStatus, "maxAnalogOutputStatus cannot be null");
java.util.Objects.requireNonNull(maxOctetString, "maxOctetString cannot be null");
}
}