/// <summary> /// Initializes the object with default values. /// </summary> public Subscription(Cache cache, Server server, SubscriptionState state) { if (server == null) throw new ArgumentNullException("server"); if (state == null) throw new ArgumentNullException("state"); m_cache = cache; m_server = server; m_state = new SubscriptionState(); m_state.Active = false; // set the initial state. ModifyState((int)StateMask.All, state); }
/// <summary> /// Initializes the object with its item id and device. /// </summary> public SubscriptionItem(string itemID, Cache cache) { if (itemID == null) throw new ArgumentNullException("itemID"); if (cache == null) throw new ArgumentNullException("cache"); m_itemID = itemID; m_cache = cache; m_euType = (euType)m_cache.ReadProperty(m_itemID, Property.EUTYPE); if (m_euType == euType.analog) { m_maxValue = (double)m_cache.ReadProperty(m_itemID, Property.HIGHEU); m_minValue = (double)m_cache.ReadProperty(m_itemID, Property.LOWEU); } }
/// <summary> /// Initializes the devices accessed by the server. Creates the device simulator by default. /// </summary> protected virtual void InitializesDevices(Cache cache) { lock (typeof(Server)) { if (TheDevice == null) { TheDevice = new Device(); TheDevice.Initialize(cache); } } }
/// <summary> /// Initializes a server instance after it is created. /// </summary> public virtual void Initialize(bool supportsCOM) { lock (this) { // initialize the cache. if (TheCache == null) { TheCache = new Cache(supportsCOM); TheCache.Initialize(); } m_cache = TheCache; m_cache.AddRef(); // get the default locale. SetLocale(m_cache.SupportedLocales[0]); // initialize all devices (sub-classes may define custom devices). InitializesDevices(m_cache); } }