Skip to end of metadata
Go to start of metadata

In the process of writing a module, you will likely encounter certain situations multiple times, including situations that have been faced many times by the developers on Ignition as well. For these very common cases, it's useful to be aware of various helpful "utility" classes that exist in the platform that can help.

Gateway

TypeUtilities

  The necessity of coercing values to a certain type is extremely common. The TypeUtilities class is extremely useful, and supports a large number of coercion scenarios. It goes far beyond basic casting, and can translate between many different types intelligently. For example, it can convert an enum to integer through the invocation of , first looking for a getIntValue() function on the enum, and then using the ordinal position, and vice-versa.  

DBUtilities

  Provides several methods for easily closing connections, statements, result sets, etc. without having to perform all of the normal fault checking. For example, this common code:

DBUtilities makes life easier!
 
Connection con;
try{
	con = openConnection();
	//...database stuff and error handling...
} finally { 
	if(con!=null){
		try {
			con.close();
		} catch(Exception ignore) {
			//Not used;
		}
	}
}

becomes a cleaner:

try{
	con = openConnection();
	//...database stuff and error handling...
	} finally {
		DBUtilities.close(con);
}

 

CloneUtil

  Provides several different ways to clone objects, and a simple method that will detect which to use.

CRCUtil

  Makes it easy to calculate the CRC of an arbitrary collection of objects, including a byte array.

FormatUtil

  Provides function for formatting values into strings. In particular, has a number of functions for displaying durations and timing based messages.

GatewayUtils

  Most of the functions in this class are only used by the Ignition platform, but there are some useful general-purpose functions for working with directories and manipulating files.

HexUtils

  Tools for converting to and from hex strings into bytes.

SecurityUtils

  Provides capabilities for encryption, decryption, and hashing.

 

 

 

  • No labels