Example #1
0
        private void NotifyInternalBufferOverflowEvent()
        {
            InternalBufferOverflowException exception = new InternalBufferOverflowException(SR.GetString("FSW_BufferOverflow", new object[] { this.directory }));
            ErrorEventArgs e = new ErrorEventArgs(exception);

            this.OnError(e);
        }
Example #2
0
        /// <devdoc>
        ///     Raises the event to each handler in the list.
        /// </devdoc>
        /// <internalonly/>
        private void NotifyInternalBufferOverflowEvent()
        {
            InternalBufferOverflowException ex = new InternalBufferOverflowException(SR.GetString(SR.FSW_BufferOverflow, directory));

            ErrorEventArgs errevent = new ErrorEventArgs(ex);

            OnError(errevent);
        }
        /// <devdoc>
        ///     Raises the event to each handler in the list.
        /// </devdoc>
        /// <internalonly/>
        private void NotifyInternalBufferOverflowEvent() {
            InternalBufferOverflowException ex = new InternalBufferOverflowException(SR.GetString(SR.FSW_BufferOverflow, directory));

            ErrorEventArgs errevent = new ErrorEventArgs(ex);

            OnError(errevent);
        }
Example #4
0
        /// <summary>
        /// Fügt dem Empfangspuffer Datenbytes hinzu
        /// </summary>
        /// <param name="rBytes">Datenbytes, die angefügt werden sollen</param>
        /// <exception cref="InternalBufferOverflowException">InternalBufferOverflowException, wird geworfen, wenn Buffer überläuft</exception>
        public void AddBytes(byte[] rBytes)
        {
            accessControl.WaitOne();
            for(int i=0; i<rBytes.Length; i++) // Der reihe nach hinzufügen
            {
                if(addByteInternal(rBytes[i]) != 0) // sollte beispielsweise der Buffer überlaufen, Exception raus, eigtl. kann hier eh nur ein bufferoverflow ausschlaggebend sein
                {
                    InternalBufferOverflowException ex = new InternalBufferOverflowException(EDOLLHandler.GetLastError() + "Datapointer: " + this.dptr.ToString());
                    accessControl.Release();
                    throw ex;
                }
            }
            // wenn ich bis hierher gekommen bin, gabs keinen Fehler...

            availableSema = accessControl.Release();

            if(ByteReceived != null)
            {
                ByteReceived(this, EventArgs.Empty); // Fire Events (if there are any)
            }
        }
Example #5
0
        ///<summary>
        /// Fügt ein Byte hinten an den Buffer an (an die Stelle, auf die der Datenpointer vorher zeigte)
        /// </summary>
        /// <param name="pByte">Anzuhängendes Byte</param>
        /// <returns>
        /// <list type="bullet">
        /// <item>0 bei Erfolg (<see cref="EDOLLHandler">EDOLL-Code</see>)</item>
        /// <item>-201 wenn Buffer voll (Byte wurde nicht geschrieben) (<see cref="EDOLLHandler">EDOLL-Code</see>)</item>
        /// </list>
        /// </returns>
        /// <example>
        /// Beispieloperationen mit dem Buffer
        /// <para><img src="tbl_img/receiveBufferExample.jpg" /></para>
        /// <code> 
        /// public static void receiveBufferExample()
        /// {
        /// 	receiveBuffer testBuffer = new receiveBuffer();
        /// 
        ///		testBuffer.AddByte((byte)'a');
        ///     testBuffer.AddByte((byte)'b');
        ///     testBuffer.AddByte((byte)'c');
        /// 
        ///     stdOut.Debug("Dataptr now: " + testBuffer.DataPtr.ToString());     // printet 3
        /// 	stdOut.Debug("Buffer content: " + testBuffer.ToString());// Zeigt Hexwerte im Buffer an
        ///  
        ///     testBuffer.FreeBytes(0,1); // markiert 'a' und 'b' zum Löschen
        ///            
        ///     stdOut.Info("a und b marked for erasing");
        ///     stdOut.Debug("Dataptr now: " + testBuffer.DataPtr.ToString());     // liefert 3, wurde ja erst markiert
        ///                            
        ///     testBuffer.Flush();
        ///            
        ///     stdOut.Info("buffer flushed...");
        ///     stdOut.Debug("Dataptr now: " + testBuffer.DataPtr.ToString());     // liefert 1, 'c' wurde ganz nach vorne gerutscht
        ///     stdOut.Debug("Buffer content: " + testBuffer.ToString());// Zeigt Hexwerte im Buffer an
        /// 
        ///     testBuffer.Clear(); // Buffer wieder ausleeren
        ///            
        ///     stdOut.Info("buffer cleared");
        ///     stdOut.Debug("Dataptr now: " + testBuffer.DataPtr.ToString());     // liefert 0
        /// }
        /// </code>
        /// </example>>
        // TODO: EXCEPTION dokumentieren
        public int AddByte(byte pByte)
        {
            int tmpError;

            accessControl.WaitOne();
            tmpError = addByteInternal(pByte);

            if(tmpError == 0)
            {
                accessControl.Release();
                if(ByteReceived != null)
                {
                    ByteReceived(this, EventArgs.Empty); // Call Events (if there are any)
                }

                return(0); // EDOLL no Error
            }
            else
            {

                EDOLLHandler.Error(tmpError); // Buffer overflow...
                InternalBufferOverflowException ex = new InternalBufferOverflowException(EDOLLHandler.GetLastError() + "Datapointer: " + this.dptr.ToString());
                accessControl.Release();
                throw ex;
            }
        }