Exemple #1
0
        private void OnWriteAnyValue(object managedValue, int timeout)
        {
            DateTime time;

            if (!this.HasValue)
            {
                throw new CannotAccessVirtualSymbolException(this);
            }
            IAccessorValueAny valueAccessor = this.ValueAccessor as IAccessorValueAny;

            if (valueAccessor == null)
            {
                throw new ValueAccessorException($"Accessor '{this.ValueAccessor}' doesn't support IValueAnyAccessor", this.ValueAccessor);
            }
            int num = 0;
            IAccessorConnection connection = valueAccessor as IAccessorConnection;

            if ((timeout >= 0) && (connection != null))
            {
                using (new AdsTimeoutSetter(connection.Connection, timeout))
                {
                    num = valueAccessor.TryWriteAnyValue(this, managedValue, out time);
                    goto TR_0004;
                }
            }
            num = valueAccessor.TryWriteAnyValue(this, managedValue, out time);
TR_0004:
            if (num != 0)
            {
                throw new SymbolException($"Cannot write (any) of Symbol '{this.InstancePath}'! Error: {num}", this);
            }
        }
Exemple #2
0
        private void OnWriteAnyValue(object managedValue)
        {
            DateTime time;

            if (!this.HasValue)
            {
                throw new CannotAccessVirtualSymbolException(this);
            }
            IAccessorValueAny valueAccessor = this.ValueAccessor as IAccessorValueAny;

            if (valueAccessor == null)
            {
                throw new ValueAccessorException($"Accessor '{this.ValueAccessor}' doesn't support IValueAnyAccessor", this.ValueAccessor);
            }
            int num = valueAccessor.TryWriteAnyValue(this, managedValue, out time);

            if (num != 0)
            {
                throw new SymbolException($"Cannot write (any) of Symbol '{this.InstancePath}'! Error: {num}", this);
            }
        }