ReadValue() public method

Returns a new value for the variable.
public ReadValue ( BaseVariableState variable ) : object
variable BaseVariableState
return object
Ejemplo n.º 1
0
        /// <summary>
        /// Generates a new value each time the value is read.
        /// </summary>
        private ServiceResult DoDeviceRead(
            ISystemContext context,
            NodeState node,
            NumericRange indexRange,
            QualifiedName dataEncoding,
            ref object value,
            ref StatusCode statusCode,
            ref DateTime timestamp)
        {
            BaseVariableState variable = node as BaseVariableState;

            if (variable == null)
            {
                return(ServiceResult.Good);
            }

            if (!SimulationActive.Value)
            {
                return(ServiceResult.Good);
            }

            TestDataSystem system = context.SystemHandle as TestDataSystem;

            if (system == null)
            {
                return(StatusCodes.BadOutOfService);
            }

            try
            {
                value = system.ReadValue(variable);

                statusCode = StatusCodes.Good;
                timestamp  = DateTime.UtcNow;

                ServiceResult error = BaseVariableState.ApplyIndexRangeAndDataEncoding(
                    context,
                    indexRange,
                    dataEncoding,
                    ref value);

                if (ServiceResult.IsBad(error))
                {
                    statusCode = error.StatusCode;
                }

                return(ServiceResult.Good);
            }
            catch (Exception e)
            {
                return(new ServiceResult(e));
            }
        }
 /// <summary>
 /// Generates a new value for the variable.
 /// </summary>
 protected void GenerateValue(TestDataSystem system, BaseVariableState variable)
 {
     variable.Value      = system.ReadValue(variable);
     variable.Timestamp  = DateTime.UtcNow;
     variable.StatusCode = StatusCodes.Good;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates a new value for the variable.
 /// </summary>
 protected void GenerateValue(TestDataSystem system, BaseVariableState variable)
 {
     variable.Value = system.ReadValue(variable);
     variable.Timestamp = DateTime.UtcNow;
     variable.StatusCode = StatusCodes.Good;
 }