package com.powerdata.openpa.psse;

import com.powerdata.openpa.tools.BaseObject;

public abstract class PsseModel
{
	public static PsseModel Open(String uri) throws PsseModelException
	{
		String[] tok = uri.split(":", 1);
		switch(tok[0].toLowerCase())
		{
			case "pssecsv": 
				String dpath = tok[1].split("=")[1];
				return new com.powerdata.openpa.psse.csv.PsseModelIn(dpath);
			default:
				throw new PsseModelException("URI not supported: "+uri);
		}
	}
	
	protected PsseModelLog _log = new PsseModelLog()
	{
		@Override
		public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
		{
			String objclass = obj.getClass().getSimpleName();
			String objnm = obj.getDebugName();
			String objid = obj.getObjectID();
			((severity == LogSev.Error) ? System.err : System.out)
				.format("%s %s %s[%s] %s\n", objclass, objnm, objid, msg);
		}
	};
	
	public PsseModel() {} 
	public PsseModel(PsseModelLog log) {_log = log;} 
	
//	/** find a Bus by ID (moved to InputList)*/ 
//	public BusIn getBus(String id) throws PsseModelException {return getBuses().get(id);}
	
	public abstract ImpCorrTblList getImpCorrTables() throws PsseModelException;
	public abstract AreaList getAreas() throws PsseModelException;
	public abstract OwnerList getOwners() throws PsseModelException;
	public abstract ZoneList getZones() throws PsseModelException;
	
	
	public void log(LogSev severity, BaseObject obj, String msg) throws PsseModelException
	{
		_log.log(severity, obj, msg);
	}
	
}	



@@ -138,13 +138,20 @@
 odel
+In
  Open
+Input
 (Str
@@ -320,16 +320,16 @@
 =%22)%5B1%5D;%0A
-
 %09%09%09%09retu
@@ -464,16 +464,378 @@
 ;%0A%09%09%7D%0A%09%7D
+%0A%0A%09public static PsseModelOut OpenOut(String uri) throws PsseModelException%0A%09%7B%0A%09%09String%5B%5D tok = uri.split(%22:%22, 1);%0A%09%09switch(tok%5B0%5D.toLowerCase())%0A%09%09%7B%0A//%09%09%09case %22pssecsv%22: %0A//%09%09%09%09String dpath = tok%5B1%5D.split(%22=%22)%5B1%5D;%0A//%09%09%09%09return new com.powerdata.openpa.psse.csv.PsseModelOut(dpath);%0A%09%09%09default:%0A%09%09%09%09throw new PsseModelException(%22URI not supported: %22+uri);%0A%09%09%7D%0A%09%7D
 %0A%09%0A%09prot

add static open calls