/// <summary> /// Initializes the communication interface. /// This object can then be passed to the Command objects like MeBasicCmd. /// </summary> /// <param name="phyCom">Physical connection.</param> public MeComQuerySet(IMeComPhy phyCom) { this.phyCom = phyCom; meFrame = new MeComFrame(phyCom, statistics); Random rand = new Random(); sequenceNr = Convert.ToUInt16(rand.Next(65535)); threadIdOfCreator = Thread.CurrentThread.ManagedThreadId; }
/// <summary> /// Changes the physical connection interface for this communication object. /// </summary> /// <param name="phyCom"></param> /// <exception cref="NotSupportedException">when a different thread then the creator of this object /// tries to change the physical interface.</exception> public void ChangePhyCom(IMeComPhy phyCom) { lock (lockObj) { if (Thread.CurrentThread.ManagedThreadId != threadIdOfCreator) { throw new NotSupportedException("Only the creator thread can change the physical interface!"); } this.phyCom = phyCom; meFrame = new MeComFrame(this.phyCom, statistics); } }
/// <summary> /// Saves the needed interface internally for further use. /// </summary> /// <param name="inPhyCom">Interface to the physical interface.</param> /// <param name="statistics">Reference to the Statistics module.</param> public MeComFrame(IMeComPhy inPhyCom, Statistics statistics) { PhyCom = inPhyCom; this.statistics = statistics; }