protected override ServiceResult WriteValueAttribute(
ISystemContext context,
NumericRange indexRange,
object value,
StatusCode statusCode,
DateTime sourceTimestamp)
{
ServiceResult result = null;
if ((WriteMask & AttributeWriteMask.ValueForVariableType) == 0)
{
return StatusCodes.BadNotWritable;
}
// ensure the source timestamp has a valid value.
if (sourceTimestamp == DateTime.MinValue)
{
sourceTimestamp = DateTime.UtcNow;
}
// index range writes not supported.
if (indexRange != NumericRange.Empty)
{
return StatusCodes.BadIndexRangeInvalid;
}
// verify data type.
TypeInfo typeInfo = TypeInfo.IsInstanceOfDataType(
value,
m_dataType,
m_valueRank,
context.NamespaceUris,
context.TypeTable);
if (typeInfo == null || typeInfo == TypeInfo.Unknown)
{
return StatusCodes.BadTypeMismatch;
}
// check for simple write value handler.
if (OnSimpleWriteValue != null)
{
result = OnSimpleWriteValue(
context,
this,
ref value);
if (ServiceResult.IsBad(result))
{
return result;
}
}
// update cached values.
Value = value;
return ServiceResult.Good;
}
#endregion