// Return the incremented value for a ValueQT private int IncrementItemValue(MyDaAddressSpaceElement item) { // get actual value ValueQT itemValue = null; item.GetCacheValue(ref itemValue); Type dataType = itemValue.Data.GetType(); object newValue = null; if (dataType == typeof(bool)) { newValue = !(bool)itemValue.Data; } if (dataType == typeof(Byte)) { newValue = (Byte)((Byte)itemValue.Data + m_increment); } if (dataType == typeof(SByte)) { newValue = (SByte)((SByte)itemValue.Data + m_increment); } if (dataType == typeof(UInt16)) { newValue = (UInt16)((UInt16)itemValue.Data + m_increment); } if (dataType == typeof(Int16)) { newValue = (Int16)((Int16)itemValue.Data + m_increment); } if (dataType == typeof(UInt32)) { newValue = (UInt32)((UInt32)itemValue.Data + m_increment); } if (dataType == typeof(Int32)) { newValue = (Int32)((Int32)itemValue.Data + m_increment); } if (dataType == typeof(UInt64)) { newValue = (UInt64)((UInt64)itemValue.Data + m_increment); } if (dataType == typeof(Int64)) { newValue = (Int64)((Int64)itemValue.Data + m_increment); } if (dataType == typeof(Single)) { newValue = (Single)((Single)itemValue.Data + m_increment); } if (dataType == typeof(Double)) { newValue = (Double)((Double)itemValue.Data + m_increment); } // apply new value return(item.ValueChanged(new ValueQT(newValue, EnumQuality.GOOD, DateTime.Now))); }