Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Neural Dot Net Pt 3 The Adaline Network

, 23 Oct 2003
A neural network library in C#.
neural_dot_net_2002.zip
Neural Dot Net 2002
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
App.ico
BackpropagationWorkingFile.wrk
Lin2Var.trn
Neural Dot Net 2002.exe
Neural Net Library.dll
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
SharpUtils.pdb
equations.Bak
Neural Dot Net 2002.csproj.user
Neural Net Library
bin
Debug
Neural Net Library.csproj.user
Neural Net Library.suo
obj
Debug
Neural Net Library.projdata
temp
TempPE
SharpUtils
bin
Debug
obj
Debug
SharpUtils.projdata
temp
TempPE
SharpUtils.csproj.user
SharpUtils.suo
neural_network_first_release.zip
Neural Network First release
3e5b39da.jpg
3e5b3ee8.jpg
3e65d686.jpg
3e65d687.jpg
Adaline.png
AdalineOneOptions.png
AdalineTwoOptions.jpg
AdalineWordClassDiagram.png
Adalinewordpattern.png
Addwordtoadalinetwofile.png
Backpropagationclasses.png
BackPropagationOneDiagram.png
backpropagationoneoptions.png
BackPropagationWordDiagram.png
BackPropagationWordOptions.png
BackPropagationWordPattern.png
Basic.png
BasicLinkWorks.png
BasicNetworkTester Overview.png
BasicNeuronComponent.png
changedBasicClassDiagram.png
equationTest.jpg
equationwithbias.jpg
function.jpg
Generating a given File.png
Inside Adaline Transition Function.png
Inside Self Organizing network run.png
Inside The Adaline Run Function Plus Bias.png
Inside The Adaline Run Function.png
learn For the self organizing network.png
Learning For the Backpropagation Network.png
LogViewer
LogViewer.csproj.user
Neural Net Library
Adaline.png
Adalinewordpattern.png
BackPropagation.emf
Basic.png
librarytobackprop.png
Neural Net Library.csproj.user
Pattern.png
Thumbs.db
Neural Net Test
App.ico
bin
Debug
AdalineWordFile.dat
adalinewordWorkingFile.wrk
adword.trn
AxInterop.SHDocVw.dll
BackpropagationWorkingFile.wrk
Interop.SHDocVw.dll
Lin2Var.trn
LogViewer.dll
Neural Net Library.dll
Neural Net Test.exe
SelfOrganizingNetworkOne.trn
SelfOrganizingNetworkOne.wrk
SelfOrganizingNetworkOneTest.tst
SharpUtils.dll
Neural Net Test.csproj.user
NeuralNetTesterPackages.png
Pattern.png
SelfOrganizingNetworkDiagram.png
SelfOrganizingNetworkOneClasses.png
selfOrganizingnetworkoneoptions.png
SelfOrganizingNetworkTwoOptions.png
selforganizingnetworkword.png
Setting Options For a Given Network.png
SharpUtils
SharpUtils.csproj.user
Testing a Given Network.png
Thumbs.db
Train Network Interaction.png
Training a given Network.png
TransferEq.jpg
TransferFunctionlogic.jpg
Transferfunctionwithbias.jpg

using System;
using System.Diagnostics;
using System.ComponentModel;


/// SharpUtils is nothing more than a namespace to store 
/// useful classes
namespace SharpUtils
{
	/// <summary>
	/// Summary description for SimpleEventLog.
	/// </summary>
	public class SimpleEventLog : EventLog
	{
		/// as can't tell if there is an error or how to return it 
		/// set up a simple error reporting system
	  
		private string strError;
		private bool bError = false;

		/// <summary>
		/// get or set the error string
		/// </summary>
		public string Error
		{
			get
			{
				return strError;
			}
			set
			{
				strError = value;
			}
		}

		/// <summary>
		/// check if there has been an error
		/// </summary>
		public bool IsError
		{
			get
			{
				return bError;
			}
			set
			{
				bError = value;
			}
		}

		/// <summary>
		/// One argument constructor
		/// Creates the eventlog specified if necassary
		/// </summary>
		/// <param name="eventLogName"></param>
		public SimpleEventLog( string eventLogName )
		{
			if( EventLog.SourceExists( eventLogName ) == false )
			{
				/// create the event log on the current computer
				try
				{
					EventLog.CreateEventSource( eventLogName, eventLogName );
				}
				catch( ArgumentException )
				{
					IsError = true;
					Error = "The string passed to CreateEventSource is null";
				}
				catch( Exception )
				{
					IsError = true;
					Error = "The system could not open the registry key for " + eventLogName;
				}
			}
			else
			{
				Source = eventLogName;
			}
		}


		/// <summary>
		/// Second constructor takes two parameters 
		/// Note the use of the contrustor intialiser that calls the one argument
		/// constructor first
		/// The second parameter gives the option to clear the event log on start up
		/// </summary>
		/// <param name="eventLogName"></param>
		/// <param name="clear"></param>
		public SimpleEventLog( string eventLogName, bool clear ) : this( eventLogName )
		{
			if( clear == true )
			{
				ClearSimpleEventLog();
			}
		}


		/// <summary>
		/// Write an entry into the log
		/// </summary>
		/// <param name="entry">Text to be written to the log</param>
		/// <returns>false on error</returns>
		private bool WriteSimpleEntry( string entry, EventLogEntryType eventType )
		{
			IsError = false;
			try
			{
				WriteEntry( entry, eventType );
			}
			catch( ArgumentException argExp )
			{
				IsError = true;
				Error = "Argument exception is " + argExp.Message;
			}
			catch( InvalidOperationException )
			{
				IsError = true;
				Error = "You do not have write permission for the event log";
			}
			catch( Win32Exception winExp )
			{
				IsError = true;
				Error = "Win32Exception is " + winExp.Message;
			}
			catch( SystemException )
			{
				IsError = true;
				Error = "The event log could not be notified to start recieing events";
			}
			catch( Exception )
			{
				IsError = true;
				Error = "The registry entry for the log could not be opened on the remote computer";
			}


			if( IsError == true )
				return false;
			else
				return true;
		}



		/// <summary>
		/// Write an information entry into the event log
		/// </summary>
		/// <param name="information">Information to be written to the event log</param>
		/// <returns>true if written to the event log</returns>
		public bool WriteInformation( string information )
		{
			return WriteSimpleEntry( information, EventLogEntryType.Information );
		}

		/// <summary>
		/// Write a warning to the current event log
		/// </summary>
		/// <param name="warning">warning to be written to the event log</param>
		/// <returns>true on success</returns>
		public bool WriteWarning( string warning )
		{
			return WriteSimpleEntry( warning, EventLogEntryType.Warning );
		}

		/// <summary>
		/// Write an error to the current event log
		/// </summary>
		/// <param name="error">error to be written to the event log</param>
		/// <returns>true on success</returns>
		public bool WriteError( string error )
		{
			return WriteSimpleEntry( error, EventLogEntryType.Error );
		}


		/// <summary>
		/// clear all the data out of the current event log
		/// </summary>
		/// <returns>false on error </returns>
		public bool ClearSimpleEventLog()
		{
			IsError = false;
			try
			{
				Clear();
			}
			catch( Win32Exception winExp )
			{
				IsError = true;
				Error = "Win 32 Exception " + winExp.Message;
			}
			catch( ArgumentException )
			{
				IsError = true;
				Error = "The log name is empty";
			}
			catch( Exception )
			{
				IsError = true;
				Error = "The log could not be opened";
			}

			if( IsError == true )
				return false;
			else
				return true;
		}


		/// <summary>
		/// Remove the current event log and source from the system
		/// </summary>
		/// <param name="eventLogName">Name of the event log to be deleted</param>
		/// <returns>false if error</returns>
		public bool DeleteSimpleEventLog()
		{
			IsError = false;

			try
			{
				EventLog.Delete( Source );
			}
			catch( ArgumentException )
			{
				IsError = true;
				Error = "Event Log Name is null";
			}
			catch( SystemException sysExp )
			{
				IsError = true;
				Error = "System Exception " + sysExp;
			}

			if( IsError == true )
				return false;
			else
				return true;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

pseudonym67

United Kingdom United Kingdom
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 24 Oct 2003
Article Copyright 2003 by pseudonym67
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid