private ServiceResult OnWriteAnalog( ISystemContext context, NodeState node, NumericRange indexRange, QualifiedName dataEncoding, ref object value, ref StatusCode statusCode, ref DateTime timestamp) { AnalogItemState variable = node as AnalogItemState; // verify data type. Opc.Ua.TypeInfo typeInfo = Opc.Ua.TypeInfo.IsInstanceOfDataType( value, variable.DataType, variable.ValueRank, context.NamespaceUris, context.TypeTable); if (typeInfo == null || typeInfo == Opc.Ua.TypeInfo.Unknown) { return StatusCodes.BadTypeMismatch; } // check index range. if (variable.ValueRank >= 0) { if (indexRange != NumericRange.Empty) { object target = variable.Value; ServiceResult result = indexRange.UpdateRange(ref target, value); if (ServiceResult.IsBad(result)) { return result; } value = target; } } // check instrument range. else { if (indexRange != NumericRange.Empty) { return StatusCodes.BadIndexRangeInvalid; } double number = Convert.ToDouble(value); if (variable.InstrumentRange != null && (number < variable.InstrumentRange.Value.Low || number > variable.InstrumentRange.Value.High)) { return StatusCodes.BadOutOfRange; } } return ServiceResult.Good; }