Class MeasurementDeviceBaseClass
java.lang.Object
neqsim.util.NamedBaseClass
neqsim.process.measurementdevice.MeasurementDeviceBaseClass
- All Implemented Interfaces:
Serializable, MeasurementDeviceInterface, ProcessElementInterface, NamedInterface
- Direct Known Subclasses:
CompressorMonitor, FireDetector, FlowInducedVibrationAnalyser, GasDetector, LevelTransmitter, OilLevelTransmitter, PushButton, SevereSlugAnalyser, StreamMeasurementDeviceBaseClass, WaterLevelTransmitter
public abstract class MeasurementDeviceBaseClass
extends NamedBaseClass
implements MeasurementDeviceInterface
Base implementation for measurement devices supplying values to controllers and process
equipment. The class offers unit handling as well as configurable Gaussian noise and discrete
sample delay to mimic realistic transmitter behaviour.
- Version:
- $Id: $Id
- Author:
- ESOL
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AlarmConfigprivate final AlarmStateprivate booleanprivate doubleprivate Stringprivate intprivate doubleprivate doubleprivate SensorFaultTypeprivate doubleprivate booleanprivate doublePrevious filtered value used by the first-order filter.private doubleFirst-order filter time constant in seconds (0 = disabled).private booleanprivate booleanprivate doubleprivate doubleprivate doubleprivate doubleprivate Stringprivate OnlineSignalprivate Randomprivate static final longSerialization version UID.private Stringprivate InstrumentTagRoleprotected StringFields inherited from class NamedBaseClass
name -
Constructor Summary
ConstructorsConstructorDescriptionMeasurementDeviceBaseClass(String name, String unit) Constructor for MeasurementDeviceBaseClass. -
Method Summary
Modifier and TypeMethodDescriptionacknowledgeAlarm(double time) Acknowledges the currently active alarm if one exists.private doubleapplyFault(double rawValue) Apply a sensor fault to the raw measurement value.protected doubleapplySignalModifiers(double rawValue) Apply configured noise, delay and sensor fault to a raw measurement value.voidRemove any active sensor fault and return to normal operation.voiddisplayResult.booleandoConditionAnalysis.evaluateAlarm(double measuredValue, double dt, double time) Evaluates the alarm state using the supplied measurement value.Returns the alarm configuration, ornullif alarms are disabled.Returns the mutable alarm state for the device.doubleGetter for the fieldconditionAnalysisMaxDeviation.Getter for the fieldconditionAnalysisMessage.intGet the configured delay in number of samples.doubleGet the parameter associated with the currently active sensor fault.Get the currently active sensor fault type.doubleReturns the field data value received from the external data source.doubleGets the configured first-order filter time constant.doublegetMaximumValue.doublegetMeasuredPercentValue.doublegetMeasuredValue(String unit) Get Measured value in specified unit.doublegetMinimumValue.doubleGet the configured noise standard deviation.doubleGetter for the fieldonlineMeasurementValue.getOnlineSignal.getTag()Returns the instrument tag identifier used for field data integration.Returns the role of this instrument in a digital-twin or field data integration context.getUnit()getUnit.booleanReturns whether a field data value has been set.booleanReturns whether the alarm on this measurement point is currently shelved.booleanisLogging.booleanisOnlineSignal.voidrunConditionAnalysis.voidsetAlarmConfig(AlarmConfig alarmConfig) Associates an alarm configuration with the measurement device.voidsetConditionAnalysis(boolean conditionMonitor) Setter for the fieldconditionAnalysis.voidsetConditionAnalysisMaxDeviation(double conditionAnalysisMaxDeviation) Setter for the fieldconditionAnalysisMaxDeviation.voidsetDelaySteps(int delaySteps) Configure discrete delay in number of samples.voidsetFault(SensorFaultType type, double parameter) Inject a sensor fault into this measurement device.voidsetFieldValue(double value) Sets the field data value received from the external data source.voidsetFirstOrderTimeConstant(double timeConstant) Sets the first-order filter time constant for smoothing measurement readings.voidsetIsOnlineSignal(boolean isOnlineSignal, String plantName, String transmitterame) Setter for the fieldisOnlineSignal.voidsetLogging(boolean logging) setLogging.voidsetMaximumValue(double maximumValue) setMaximumValue.voidsetMinimumValue(double minimumValue) setMinimumValue.voidsetNoiseStdDev(double noiseStdDev) Set Gaussian noise standard deviation for the measurement.voidsetOnlineMeasurementValue(double value, String unit) Setter for the fieldonlineMeasurementValue.voidsetOnlineSignal(OnlineSignal onlineSignal) Setter for the fieldonlineSignal.voidsetQualityCheckMessage(String conditionAnalysisMessage) setQualityCheckMessage.voidsetRandomSeed(long seed) Set the random seed used for noise generation to achieve deterministic measurements when required.voidSets the instrument tag identifier for field data integration.voidsetTagRole(InstrumentTagRole role) Sets the role of this instrument for field data integration.voidsetUnit.voidshelveAlarm(String reason) Shelves (suppresses) the alarm on this measurement point indefinitely.voidshelveAlarm(String reason, double expiryTime) Shelves (suppresses) the alarm on this measurement point until the given simulation time.voidRemoves the alarm shelve, resuming normal alarm evaluation.Methods inherited from class NamedBaseClass
getName, getTagNumber, setName, setTagNumberMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface MeasurementDeviceInterface
applyFieldValue, equals, getDeviation, getMeasuredValue, getOnlineValue, getRelativeDeviation, hashCodeMethods inherited from interface NamedInterface
getName, getTagName, getTagNumber, setName, setTagName, setTagNumber
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerialization version UID.- See Also:
-
unit
-
maximumValue
private double maximumValue -
minimumValue
private double minimumValue -
logging
private boolean logging -
onlineSignal
-
isOnlineSignal
private boolean isOnlineSignal -
onlineMeasurementValue
private double onlineMeasurementValue -
onlineMeasurementValueUnit
-
delayBuffer
-
delaySteps
private int delaySteps -
noiseStdDev
private double noiseStdDev -
random
-
firstOrderTimeConstant
private double firstOrderTimeConstantFirst-order filter time constant in seconds (0 = disabled). -
filteredPreviousValue
private double filteredPreviousValuePrevious filtered value used by the first-order filter. -
conditionAnalysis
private boolean conditionAnalysis -
conditionAnalysisMessage
-
conditionAnalysisMaxDeviation
private double conditionAnalysisMaxDeviation -
faultType
-
faultParameter
private double faultParameter -
faultAccumulator
private double faultAccumulator -
alarmConfig
-
alarmState
-
tag
-
tagRole
-
fieldValue
private double fieldValue -
fieldValueSet
private boolean fieldValueSet
-
-
Constructor Details
-
MeasurementDeviceBaseClass
-
-
Method Details
-
getOnlineSignal
getOnlineSignal.
- Specified by:
getOnlineSignalin interfaceMeasurementDeviceInterface- Returns:
- a
OnlineSignalobject
-
setOnlineSignal
Setter for the field
onlineSignal.- Parameters:
onlineSignal- the onlineSignal to set
-
isOnlineSignal
public boolean isOnlineSignal()isOnlineSignal.
- Specified by:
isOnlineSignalin interfaceMeasurementDeviceInterface- Returns:
- a boolean
-
setIsOnlineSignal
-
getUnit
getUnit.
- Specified by:
getUnitin interfaceMeasurementDeviceInterface- Returns:
- a
Stringobject
-
setUnit
setUnit.
- Specified by:
setUnitin interfaceMeasurementDeviceInterface- Parameters:
unit- aStringobject
-
getMaximumValue
public double getMaximumValue()getMaximumValue.
- Specified by:
getMaximumValuein interfaceMeasurementDeviceInterface- Returns:
- a double
-
setMaximumValue
public void setMaximumValue(double maximumValue) setMaximumValue.
- Specified by:
setMaximumValuein interfaceMeasurementDeviceInterface- Parameters:
maximumValue- a double
-
getMinimumValue
public double getMinimumValue()getMinimumValue.
- Specified by:
getMinimumValuein interfaceMeasurementDeviceInterface- Returns:
- a double
-
setMinimumValue
public void setMinimumValue(double minimumValue) setMinimumValue.
- Specified by:
setMinimumValuein interfaceMeasurementDeviceInterface- Parameters:
minimumValue- a double
-
getMeasuredPercentValue
public double getMeasuredPercentValue()getMeasuredPercentValue.
- Specified by:
getMeasuredPercentValuein interfaceMeasurementDeviceInterface- Returns:
- a double
-
isLogging
public boolean isLogging()isLogging.
- Specified by:
isLoggingin interfaceMeasurementDeviceInterface- Returns:
- a boolean
-
setLogging
public void setLogging(boolean logging) setLogging.
- Specified by:
setLoggingin interfaceMeasurementDeviceInterface- Parameters:
logging- a boolean
-
getMeasuredValue
Get Measured value in specified unit.
- Specified by:
getMeasuredValuein interfaceMeasurementDeviceInterface- Parameters:
unit- aStringobject- Returns:
- a double
-
setAlarmConfig
Description copied from interface:MeasurementDeviceInterfaceAssociates an alarm configuration with the measurement device.- Specified by:
setAlarmConfigin interfaceMeasurementDeviceInterface- Parameters:
alarmConfig- configuration to apply, ornullto disable alarms
-
getAlarmConfig
Description copied from interface:MeasurementDeviceInterfaceReturns the alarm configuration, ornullif alarms are disabled.- Specified by:
getAlarmConfigin interfaceMeasurementDeviceInterface- Returns:
- alarm configuration
-
getAlarmState
Description copied from interface:MeasurementDeviceInterfaceReturns the mutable alarm state for the device.- Specified by:
getAlarmStatein interfaceMeasurementDeviceInterface- Returns:
- alarm state
-
evaluateAlarm
Description copied from interface:MeasurementDeviceInterfaceEvaluates the alarm state using the supplied measurement value.- Specified by:
evaluateAlarmin interfaceMeasurementDeviceInterface- Parameters:
measuredValue- measured valuedt- simulation time steptime- current simulation time- Returns:
- events generated during the evaluation
-
acknowledgeAlarm
Description copied from interface:MeasurementDeviceInterfaceAcknowledges the currently active alarm if one exists.- Specified by:
acknowledgeAlarmin interfaceMeasurementDeviceInterface- Parameters:
time- simulation time of the acknowledgement- Returns:
- acknowledgement event, or
nullif nothing was acknowledged
-
shelveAlarm
Shelves (suppresses) the alarm on this measurement point indefinitely. While shelved, alarm evaluations continue to track the value but no events are generated.- Parameters:
reason- operator-provided reason for shelving
-
shelveAlarm
Shelves (suppresses) the alarm on this measurement point until the given simulation time.- Parameters:
reason- operator-provided reason for shelvingexpiryTime- simulation time when shelving expires
-
unshelveAlarm
public void unshelveAlarm()Removes the alarm shelve, resuming normal alarm evaluation. -
isAlarmShelved
public boolean isAlarmShelved()Returns whether the alarm on this measurement point is currently shelved.- Returns:
trueif shelved
-
applySignalModifiers
protected double applySignalModifiers(double rawValue) Apply configured noise, delay and sensor fault to a raw measurement value.- Parameters:
rawValue- unmodified measurement value- Returns:
- value after noise, fault injection and delay are applied
-
setNoiseStdDev
public void setNoiseStdDev(double noiseStdDev) Set Gaussian noise standard deviation for the measurement.- Parameters:
noiseStdDev- standard deviation of measurement noise
-
getNoiseStdDev
public double getNoiseStdDev()Get the configured noise standard deviation.- Returns:
- noise standard deviation
-
setFirstOrderTimeConstant
public void setFirstOrderTimeConstant(double timeConstant) Sets the first-order filter time constant for smoothing measurement readings. A value of 0 (the default) disables the filter. Typical transmitter time constants range from 0.5 to 10 seconds.- Parameters:
timeConstant- time constant in seconds (0 = disabled)
-
getFirstOrderTimeConstant
public double getFirstOrderTimeConstant()Gets the configured first-order filter time constant.- Returns:
- time constant in seconds (0 = disabled)
-
setDelaySteps
public void setDelaySteps(int delaySteps) Configure discrete delay in number of samples.- Parameters:
delaySteps- number of samples delay
-
getDelaySteps
public int getDelaySteps()Get the configured delay in number of samples.- Returns:
- number of delayed samples
-
setRandomSeed
public void setRandomSeed(long seed) Set the random seed used for noise generation to achieve deterministic measurements when required.- Parameters:
seed- random seed
-
getTag
Returns the instrument tag identifier used for field data integration. The tag maps this instrument to a signal in the plant historian or data source (e.g. "PT-101", "TT-201").- Specified by:
getTagin interfaceMeasurementDeviceInterface- Returns:
- tag string, or empty string if not set
-
setTag
Sets the instrument tag identifier for field data integration.- Specified by:
setTagin interfaceMeasurementDeviceInterface- Parameters:
tag- tag string mapping to a plant historian signal
-
getTagRole
Returns the role of this instrument in a digital-twin or field data integration context.- Specified by:
getTagRolein interfaceMeasurementDeviceInterface- Returns:
- the tag role, defaulting to
InstrumentTagRole.VIRTUAL
-
setTagRole
Sets the role of this instrument for field data integration.- Specified by:
setTagRolein interfaceMeasurementDeviceInterface- Parameters:
role- the tag role to assign
-
getFieldValue
public double getFieldValue()Returns the field data value received from the external data source. Only meaningful forInstrumentTagRole.INPUTandInstrumentTagRole.BENCHMARKroles.- Specified by:
getFieldValuein interfaceMeasurementDeviceInterface- Returns:
- the field value, or
Double.NaNif not set
-
setFieldValue
public void setFieldValue(double value) Sets the field data value received from the external data source.- Specified by:
setFieldValuein interfaceMeasurementDeviceInterface- Parameters:
value- the field measurement value
-
hasFieldValue
public boolean hasFieldValue()Returns whether a field data value has been set.- Specified by:
hasFieldValuein interfaceMeasurementDeviceInterface- Returns:
- true if a field value is available
-
displayResult
public void displayResult()displayResult.
- Specified by:
displayResultin interfaceMeasurementDeviceInterface
-
setOnlineMeasurementValue
-
getOnlineMeasurementValue
public double getOnlineMeasurementValue()Getter for the field
onlineMeasurementValue.- Returns:
- a double
-
doConditionAnalysis
public boolean doConditionAnalysis()doConditionAnalysis.
- Returns:
- a boolean
-
applyFault
private double applyFault(double rawValue) Apply a sensor fault to the raw measurement value. The fault transformation depends on the currently configuredSensorFaultType.- Parameters:
rawValue- true process measurement before fault injection- Returns:
- measurement value after fault transformation
-
setFault
Inject a sensor fault into this measurement device. While a fault is active, the measured value will be transformed according to the specified fault type and parameter.- Parameters:
type- the type of sensor fault to injectparameter- fault-specific parameter (e.g. stuck value, drift rate, bias)
-
clearFault
public void clearFault()Remove any active sensor fault and return to normal operation. -
getFaultType
Get the currently active sensor fault type.- Returns:
- the active fault type, or
SensorFaultType.NONEif no fault is injected
-
getFaultParameter
public double getFaultParameter()Get the parameter associated with the currently active sensor fault.- Returns:
- the fault parameter value
-
setConditionAnalysis
public void setConditionAnalysis(boolean conditionMonitor) Setter for the field
conditionAnalysis.- Parameters:
conditionMonitor- a boolean
-
runConditionAnalysis
public void runConditionAnalysis()runConditionAnalysis.
-
getConditionAnalysisMessage
-
setQualityCheckMessage
-
getConditionAnalysisMaxDeviation
public double getConditionAnalysisMaxDeviation()Getter for the field
conditionAnalysisMaxDeviation.- Returns:
- a double
-
setConditionAnalysisMaxDeviation
public void setConditionAnalysisMaxDeviation(double conditionAnalysisMaxDeviation) Setter for the field
conditionAnalysisMaxDeviation.- Parameters:
conditionAnalysisMaxDeviation- a double
-