Gasworks, redux.

The majority of what I spent my time on this weekend was finishing up some outstanding contract work that desperately needed to be completed. The project in particular is called ‘Gasworks’, for Energy Operations Management (EOM). They are a privately-owned natural gas transmission line company. What this means is, let’s say you have some property that has natural gas deposits. You’ve drilled, and there is actually natural gas there. That’s great, but what do you do now? That is where EOM comes in. They build and manage pipelines from natural gas wells to the market, either by connecting to a utilities transmission line, or directly to a customer (Normally a power plant or refinery).

EOM has a SCADA system that monitors their real-time natural gas flow rates and pressures throughout all the pipelines they manage. Gasworks is a web application that ties into EOM’s SCADA system, and offers up that real-time data to EOM’s customers. I designed the original Gasworks back in 2005, and have been updating and revising it ever since. Most recently, they were due for a complete overhaul. They needed a better design, better mobile/tablet support, and a robust administration section, where their staff could add Locations and Data points to the system, as well as manage customer logins and permissions.

I utilized the CodeIgniter MVC Framework for the site, using their default css for the administration side, and using jQuery Mobile for the customer side. I made a significant change this time around. All the data a customer sees when they log in is pulled from XML (generated via CodeIgniter). The main page is generated with jQuery, based on the XML. It’s pretty fast, and lets customers refresh their page without a total page reload. It also added the capability to have customers pull their XML, and integrate it into their own SCADA systems.

On to the screenshots! I can’t really show the administration half, since the data is confidential.

The XML data that is generated via CodeIgniter
The main view the customer sees when they log in. Systems and locations are all dependent on user permissions.
Systems expand to show locations within. Notice how it relates to the generated XML
When user clicks on specific location, they see realtime charts. Layout different depending on device used. Mobile users will have charts vertical for spacing issues.

And for those who are interested, here is an example of some of the js I wrote. This is the js function I use to parse the XML and print out the main view of Gasworks.

function parseXml(xml)
{
	var html='\n';
	html+='\t<div data-role="collapsible-set" data-theme="a" data-content-theme="a">\n';
 
	$(xml).find("system").each(function() {
		html+='\t<div data-role="collapsible">\n';
		html+='\t\t<h3>'+$(this).attr('name')+'</h3>\n\n';			
 
		html+='\t\t<ul data-role="listview" data-inset="true">\n';
		$(this).children('location').each(function() {
			var location_html='';
			var latest_poll=new Date('January 1, 2000'););
			var a_or_b=true;
			$(this).children('tag').each(function() {
 
				if($(this).attr('date'))
				{
					date_string = $(this).attr('date');
					var this_date = new Date(date_string.replace(/-/g,'/'));
					if(latest_poll<this_date) latest_poll=this_date;
				}
 
				if(a_or_b)
				{
					location_html+='\t\t\t<li data-icon="false">\n\t\t\t<div class="ui-grid-a">\n\t\t\t\t<div class="ui-block-a">';
					if($(this).attr('label')=='none') location_html+=$(this).attr('value')+' '+$(this).attr('type');
					else location_html+=$(this).attr('label')+' ';
					location_html+='</div>\n';
					a_or_b=false;						
				}
				else
				{
					location_html+='\t\t\t\t<div class="ui-block-b">';
					if($(this).attr('label')=='none') location_html+=$(this).attr('value')+' '+$(this).attr('type');
					else location_html+=$(this).attr('label')+' '+$(this).attr('value')+' '+$(this).attr('type');
					location_html+='</div></div>\n\t\t\t</li>\n';
					a_or_b=true;
				}									
 
			});
			if(!a_or_b) location_html+='\t\t\t\t<div class="ui-block-b"></div></div>\n\t\t\t</li>\n';
			if(latest_poll.getMinutes()<10) var minutes='0'+latest_poll.getMinutes();
			else var minutes=latest_poll.getMinutes();
 
			var the_time=latest_poll.getHours()+':'+minutes+' '+(latest_poll.getMonth()+1)+'/'+latest_poll.getDate();
 
			html+="\t\t\t<li data-theme=\"b\"><a href=\"http://gasworks.gasbiz.com/bambino/index.php/main/location/"+$(this).attr('id')+"\">"+$(this).attr('name')+'<span class="ui-li-count">'+the_time+'</span></a></li>\n';
			html+=location_html;
 
		});
		html+='\t\t</ul> <!-- end location -->\n';
 
		html+='\t</div> <!-- end system -->\n';
 
	});
	html+='\t</div> <!-- end collapsible-set -->\n';
 
	$('#loading').hide();
	$('#accordion_content').text('');
	$('#accordion_content').append(html).trigger('create');
 
	$('#accordion_content').show();
}

I’m proud of how this came out. It helped me become very familiar with the jQuerymobile framework, and definitely leveled up my XML manipulation skills.

Leave a Reply

Your email address will not be published. Required fields are marked *