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); } }
protected virtual void OnWriteRawValue(byte[] value, int timeout) { DateTime time; if (!this.HasValue) { throw new CannotAccessVirtualSymbolException(this); } IAccessorConnection valueAccessor = this.ValueAccessor as IAccessorConnection; int num = 0; if ((timeout >= 0) && (valueAccessor != null)) { using (new AdsTimeoutSetter(valueAccessor.Connection, timeout)) { num = this.ValueAccessor.TryWriteValue(this, value, 0, out time); goto TR_0003; } } num = this.ValueAccessor.TryWriteValue(this, value, 0, out time); TR_0003: if (num != 0) { throw new SymbolException($"Cannot write RawValue of Symbol '{this.InstancePath}'! Error: {num}", this); } }
protected virtual byte[] OnReadRawValue(int timeout) { DateTime time; if (!this.HasValue) { return(null); } byte[] buffer = null; int num = 0; IAccessorConnection valueAccessor = this.ValueAccessor as IAccessorConnection; if ((timeout >= 0) && (valueAccessor != null)) { using (new AdsTimeoutSetter(valueAccessor.Connection, timeout)) { num = this.ValueAccessor.TryReadValue(this, out buffer, out time); goto TR_0003; } } num = this.ValueAccessor.TryReadValue(this, out buffer, out time); TR_0003: if (num != 0) { throw new SymbolException($"Cannot read RawValue of Symbol '{this.InstancePath}'! Error: {num}", this); } return(buffer); }
protected virtual object OnReadValue(int timeout) { DateTime time; if (!this.HasValue) { throw new CannotAccessVirtualSymbolException(this); } IAccessorValue valueAccessor = (IAccessorValue)this.ValueAccessor; IAccessorConnection connection = valueAccessor as IAccessorConnection; if ((timeout >= 0) && (connection != null)) { using (new AdsTimeoutSetter(connection.Connection, timeout)) { return(valueAccessor.ReadValue(this, out time)); } } return(valueAccessor.ReadValue(this, out time)); }
protected virtual void OnWriteValue(object value, int timeout) { DateTime time; if (!this.HasValue) { throw new CannotAccessVirtualSymbolException(this); } IAccessorValue valueAccessor = (IAccessorValue)this.ValueAccessor; IAccessorConnection connection = valueAccessor as IAccessorConnection; if ((timeout >= 0) && (connection != null)) { using (new AdsTimeoutSetter(connection.Connection, timeout)) { valueAccessor.WriteValue(this, value, out time); return; } } valueAccessor.WriteValue(this, value, out time); }