|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.prosysopc.ua.server.ServiceHandler
com.prosysopc.ua.server.AttributeServiceHandler
public class AttributeServiceHandler
A basic implementation of a node attribute value provider. The class handles all service calls in the OPC UA Attribute Service Set by making sure that valid responses are sent for each service, even when they are not implemented. To implement the services you should override the methods that actually handle the calls, i.e. readAttribute, writeAttribute, historyReadAttribute, historyUpdateAttribute. These handle individual requests per single attribute. Alternatively, you can override the "higher-level" functions that handle complete requests. By default these loop through the individual requests.
| Field Summary | |
|---|---|
protected static org.slf4j.Logger |
logger
|
| Fields inherited from class com.prosysopc.ua.server.ServiceHandler |
|---|
stringTable |
| Constructor Summary | |
|---|---|
AttributeServiceHandler(SessionManager sessionManager,
NodeManagerTable nodeManagerTable)
|
|
| Method Summary | |
|---|---|
protected org.slf4j.Logger |
getLogger()
|
int |
getMaxNodesPerHistoryReadData()
|
int |
getMaxNodesPerHistoryReadEvents()
|
int |
getMaxNodesPerHistoryUpdateData()
|
int |
getMaxNodesPerHistoryUpdateEvents()
|
int |
getMaxNodesPerRead()
|
int |
getMaxNodesPerWrite()
|
protected void |
historyRead(ServiceContext serviceContext,
org.opcfoundation.ua.core.HistoryReadRequest request,
org.opcfoundation.ua.core.HistoryReadResponse response)
Handle the onHistoryRead service call. |
protected void |
historyUpdate(ServiceContext serviceContext,
org.opcfoundation.ua.core.HistoryUpdateRequest request,
org.opcfoundation.ua.core.HistoryUpdateResponse response)
Handle the onHistoryUpdate service call. |
void |
onHistoryRead(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.HistoryReadRequest,org.opcfoundation.ua.core.HistoryReadResponse> req)
|
void |
onHistoryUpdate(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.HistoryUpdateRequest,org.opcfoundation.ua.core.HistoryUpdateResponse> req)
|
void |
onRead(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.ReadRequest,org.opcfoundation.ua.core.ReadResponse> req)
|
void |
onWrite(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.WriteRequest,org.opcfoundation.ua.core.WriteResponse> req)
|
protected void |
read(ServiceContext serviceContext,
org.opcfoundation.ua.core.ReadRequest request,
org.opcfoundation.ua.core.ReadResponse response)
Handle the onRead service call. |
protected void |
readAttribute(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
org.opcfoundation.ua.builtintypes.DataValue dataValue)
Read the value of a single node attribute. |
protected HistoryResult |
readNodeHistory(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
HistoryContinuationPoint continuationPoint,
org.opcfoundation.ua.core.HistoryReadDetails details,
int aggregateIndex)
Read history of a single node. |
protected void |
releaseHistoryContinuationPoint(ServiceContext serviceContext,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.ByteString continuationPoint)
|
void |
setMaxNodesPerHistoryReadData(int maxNodesPerHistoryReadData)
Safety limit for the maximum request size for history reads (data). |
void |
setMaxNodesPerHistoryReadEvents(int maxNodesPerHistoryReadEvents)
Safety limit for the maximum request size for history reads (events). |
void |
setMaxNodesPerHistoryUpdateData(int maxNodesPerHistoryUpdateData)
Safety limit for the maximum request size for history updates containing data updates. |
void |
setMaxNodesPerHistoryUpdateEvents(int maxNodesPerHistoryUpdateEvents)
Safety limit for the maximum request size for history updates containing event updates. |
void |
setMaxNodesPerRead(int maxNodesPerRead)
Safety limit for the maximum request size for reads. |
void |
setMaxNodesPerWrite(int maxNodesPerWrite)
Safety limit for the maximum request size for writes. |
protected void |
updateNodeHistory(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.core.HistoryUpdateDetails details,
org.opcfoundation.ua.core.HistoryUpdateResult historyUpdateResult)
|
protected void |
write(ServiceContext serviceContext,
org.opcfoundation.ua.core.WriteRequest request,
org.opcfoundation.ua.core.WriteResponse response)
Handle the onWrite service call. |
protected boolean |
writeAttribute(ServiceContext serviceContext,
Object operationContext,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
org.opcfoundation.ua.builtintypes.DataValue value)
Write the value of a single node attribute. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.slf4j.Logger logger
| Constructor Detail |
|---|
public AttributeServiceHandler(SessionManager sessionManager,
NodeManagerTable nodeManagerTable)
| Method Detail |
|---|
public int getMaxNodesPerHistoryReadData()
setMaxNodesPerHistoryReadData(int)public int getMaxNodesPerHistoryReadEvents()
setMaxNodesPerHistoryReadEvents(int)public int getMaxNodesPerHistoryUpdateData()
setMaxNodesPerHistoryUpdateData(int)public int getMaxNodesPerHistoryUpdateEvents()
setMaxNodesPerHistoryUpdateEvents(int)public int getMaxNodesPerRead()
setMaxNodesPerRead(int)public int getMaxNodesPerWrite()
setMaxNodesPerWrite(int)
public final void onHistoryRead(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.HistoryReadRequest,org.opcfoundation.ua.core.HistoryReadResponse> req)
throws org.opcfoundation.ua.common.ServiceFaultException
onHistoryRead in interface org.opcfoundation.ua.core.AttributeServiceSetHandlerorg.opcfoundation.ua.common.ServiceFaultException
public final void onHistoryUpdate(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.HistoryUpdateRequest,org.opcfoundation.ua.core.HistoryUpdateResponse> req)
throws org.opcfoundation.ua.common.ServiceFaultException
onHistoryUpdate in interface org.opcfoundation.ua.core.AttributeServiceSetHandlerorg.opcfoundation.ua.common.ServiceFaultException
public final void onRead(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.ReadRequest,org.opcfoundation.ua.core.ReadResponse> req)
throws org.opcfoundation.ua.common.ServiceFaultException
onRead in interface org.opcfoundation.ua.core.AttributeServiceSetHandlerorg.opcfoundation.ua.common.ServiceFaultException
public final void onWrite(org.opcfoundation.ua.transport.endpoint.EndpointServiceRequest<org.opcfoundation.ua.core.WriteRequest,org.opcfoundation.ua.core.WriteResponse> req)
throws org.opcfoundation.ua.common.ServiceFaultException
onWrite in interface org.opcfoundation.ua.core.AttributeServiceSetHandlerorg.opcfoundation.ua.common.ServiceFaultExceptionpublic void setMaxNodesPerHistoryReadData(int maxNodesPerHistoryReadData)
If the value is 0 or negative, the limit is not used. In this case, the
ServiceHandler#setMaxOperationsPerRequest() is used to limit the request size.
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerHistoryReadData - the maxNodesPerHistoryReadData to setpublic void setMaxNodesPerHistoryReadEvents(int maxNodesPerHistoryReadEvents)
If the value is 0 or negative, the limit is not used. In this case, the
ServiceHandler#setMaxOperationsPerRequest() is used to limit the request size.
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerHistoryReadEvents - the maxNodesPerHistoryReadEvents to setpublic void setMaxNodesPerHistoryUpdateData(int maxNodesPerHistoryUpdateData)
If the value is 0 or negative, the limit is not used. In this case, the
ServiceHandler#setMaxOperationsPerRequest() is used to limit the request size.
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerHistoryUpdateData - the maxNodesPerHistoryUpdateData to setpublic void setMaxNodesPerHistoryUpdateEvents(int maxNodesPerHistoryUpdateEvents)
If the value is 0 or negative, the limit is not used. In this case, the
ServiceHandler#setMaxOperationsPerRequest() is used to limit the request size.
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerHistoryUpdateEvents - the maxNodesPerHistoryUpdateData to setpublic void setMaxNodesPerRead(int maxNodesPerRead)
If the value is 0 or negative, the limit is not used. In this case, the
ServiceHandler#setMaxOperationsPerRequest() is used to limit the request size.
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerRead - the maxNodesPerRead to setpublic void setMaxNodesPerWrite(int maxNodesPerWrite)
The value is reflected to ServerCapabilities/OperationLimits.
maxNodesPerWrite - the maxNodesPerWrite to setprotected org.slf4j.Logger getLogger()
getLogger in class ServiceHandler
protected void historyRead(ServiceContext serviceContext,
org.opcfoundation.ua.core.HistoryReadRequest request,
org.opcfoundation.ua.core.HistoryReadResponse response)
throws ServiceException
serviceContext - The serviceContext of the client connection used to call this service.request - The request message.response - The response message. Fill in here the results. Make sure that for each node a
new DataValue object is created and initialized with current timestamps. The actual data
is read in readAttribute, which may return DiagnosticInfo, when necessary.
ServiceException - When the request is invalid or the call fails for some other reason.
The following error StatusCodes are expected: Bad_NothingToDo, Bad_TooManyOperations,
Bad_MaxAgeInvalid, Bad_TimestampsToReturnInvalid
protected void historyUpdate(ServiceContext serviceContext,
org.opcfoundation.ua.core.HistoryUpdateRequest request,
org.opcfoundation.ua.core.HistoryUpdateResponse response)
throws ServiceException
serviceContext - The serviceContext of the client connection used to call this service.request - The request message.response - The response message. Fill in here the results. Make sure that for each node a
new DataValue object is created and initialized with current timestamps. The actual data
is read in readAttribute, which may return DiagnosticInfo, when necessary.
ServiceException - When the request is invalid or the call fails for some other reason.
The following error StatusCodes are expected: Bad_NothingToDo, Bad_TooManyOperations,
Bad_MaxAgeInvalid, Bad_TimestampsToReturnInvalid
protected void read(ServiceContext serviceContext,
org.opcfoundation.ua.core.ReadRequest request,
org.opcfoundation.ua.core.ReadResponse response)
throws ServiceException
serviceContext - The serviceContext of the client connection used to call this service.request - The request message.response - The response message. Fill in here the results. Make sure that for each node a
new DataValue object is created and initialized with current timestamps. The actual data
is read in readAttribute, which may return DiagnosticInfo, when necessary.
ServiceException - When the request is invalid or the call fails for some other reason.
The following error StatusCodes are expected: Bad_NothingToDo, Bad_TooManyOperations,
Bad_MaxAgeInvalid, Bad_TimestampsToReturnInvalid
protected void readAttribute(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
org.opcfoundation.ua.builtintypes.DateTime minTimestamp,
org.opcfoundation.ua.builtintypes.DataValue dataValue)
throws StatusException
serviceContext - The serviceContext of the client connection used to call this service.dataset - the possible dataset prepared in beginRead(com.prosysopc.ua.server.ServiceContext, java.util.Map, org.opcfoundation.ua.core.ReadValueId[], org.opcfoundation.ua.core.TimestampsToReturn, org.opcfoundation.ua.builtintypes.DateTime, org.opcfoundation.ua.builtintypes.DataValue[], org.opcfoundation.ua.builtintypes.DiagnosticInfo[]) nodeId - The node to read.attributeId - The attribute to read.indexRange - The requested index range for an array value. May be null.timestampsToReturn - Which timestamps were requested by the client.minTimestamp - Minimum value of the ServerTimestamp of the value to be read. If there is
no value available that is new enough already available (in the server cache), the
server should attempt to read a new value from the actual data source, instead of using
the cached value. If a new value cannot be read, the best value available is returned.
If minTimestamp == DateTime.MAX_VALUE a new value should be read from the source.dataValue - The data value to return. Set Value, and for Value attribute also StatusCode
and the Timestamps.
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid,
Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData,
Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotReadable,
Bad_UserAccessDenied
protected HistoryResult readNodeHistory(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.core.TimestampsToReturn timestampsToReturn,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
HistoryContinuationPoint continuationPoint,
org.opcfoundation.ua.core.HistoryReadDetails details,
int aggregateIndex)
throws StatusException
serviceContext - dataset - the possible dataset prepared in beginHistoryRead(com.prosysopc.ua.server.ServiceContext, java.util.Map, org.opcfoundation.ua.core.HistoryReadDetails, org.opcfoundation.ua.core.HistoryReadValueId[], com.prosysopc.ua.server.HistoryContinuationPoint[], org.opcfoundation.ua.core.TimestampsToReturn, com.prosysopc.ua.server.HistoryResult[]) timestampsToReturn - nodeId - indexRange - continuationPoint - details - aggregateIndex - the aggregate that should be used from the AggregateType array in
ReadProcessedDetails (if such is provided)
StatusException - If the read fails. Expected result codes: Bad_NodeIdInvalid,
Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_DataEncodingInvalid,
Bad_DataEncodingUnsupported, Bad_ContinuationPointInvalid, Bad_UserAccessDenied
protected void releaseHistoryContinuationPoint(ServiceContext serviceContext,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.ByteString continuationPoint)
throws StatusException
serviceContext - nodeId - continuationPoint -
StatusException
protected void updateNodeHistory(ServiceContext serviceContext,
Object dataset,
org.opcfoundation.ua.core.HistoryUpdateDetails details,
org.opcfoundation.ua.core.HistoryUpdateResult historyUpdateResult)
throws StatusException
serviceContext - dataset - details - historyUpdateResult -
ServiceException
StatusException
protected void write(ServiceContext serviceContext,
org.opcfoundation.ua.core.WriteRequest request,
org.opcfoundation.ua.core.WriteResponse response)
throws ServiceException
serviceContext - The serviceContext of the client connection used to call this service.request - The request message.response - The response message. Fill in here the result codes. Make sure that for each
node a new StatusCode object is created and initialized to StatusCode.Good. The actual
data is written in writeAttribute, which may return DiagnosticInfo, when necessary.
ServiceException - When the request is invalid or the call fails for some other reason.
The following error StatusCodes are expected: Bad_NothingToDo, Bad_TooManyOperations,
Bad_MaxAgeInvalid, Bad_TimestampsToReturnInvalid
protected boolean writeAttribute(ServiceContext serviceContext,
Object operationContext,
org.opcfoundation.ua.builtintypes.NodeId nodeId,
org.opcfoundation.ua.builtintypes.UnsignedInteger attributeId,
org.opcfoundation.ua.utils.NumericRange indexRange,
org.opcfoundation.ua.builtintypes.DataValue value)
throws StatusException
serviceContext - The serviceContext of the client connection used to call this service.operationContext - nodeId - The node to write.attributeId - The attribute to write.indexRange - The index range to set for an array value. May be null.dataValue - The data value to write.
StatusException - If the write fails. Expected result codes: Bad_NodeIdInvalid,
Bad_NodeIdUnknown, Bad_AttributeIdInvalid, Bad_IndexRangeInvalid, Bad_IndexRangeNoData,
Bad_DataEncodingInvalid, Bad_DataEncodingUnsupported, Bad_NotWriteable,
Bad_UserAccessDenied, Bad_OutOfRange, Bad_TypeMismatch, Bad_WriteNotSupported
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||