package com.powerdata.openpa.tools.psmfmt;

import com.powerdata.openpa.PAModel;
import com.powerdata.openpa.PAModelException;
import com.powerdata.openpa.TransformerList;
import com.powerdata.openpa.tools.psmfmt.ExportOpenPA.StringWrap;

public class CaseTransformerWindingOPA extends ExportOpenPA<TransformerList>
{

	CaseTransformerWindingOPA(PAModel m) throws PAModelException
	{
		super(m.getTransformers(), CaseTransformerWinding.values().length);
		assign(TransformerWinding.ID, new StringWrap(i -> _list.getID(i)+"_wnd"));
		assign(CaseTransformerWinding.FromMW, i -> String.valueOf(_list.getFromP(i)));
		assign(CaseTransformerWinding.FromMVAr, i -> String.valueOf(_list.getFromQ(i)));
		assign(CaseTransformerWinding.ToMW, i -> String.valueOf(_list.getToP(i)));
		assign(CaseTransformerWinding.ToMVAr, i -> String.valueOf(_list.getToQ(i)));
	}

	@Override
	protected String getPsmFmtName()
	{
		return "PsmCase" + PsmCaseFmtObject.TransformerWinding.toString();
	}
}

@@ -37,16 +37,234 @@
 smfmt;%0A%0A
+import java.io.BufferedWriter;%0Aimport java.io.File;%0Aimport java.io.FileWriter;%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport com.powerdata.openpa.ACBranch;%0Aimport com.powerdata.openpa.ACBranchListIfc;%0A
 import c
@@ -366,25 +366,26 @@
 .openpa.
-Transform
+PhaseShift
 erList;%0A
@@ -416,44 +416,23 @@
 npa.
-tools.psmfmt.ExportOpenPA.StringWrap
+TransformerList
 ;%0A%0Ap
@@ -515,141 +515,572 @@
 %7B%0A%0A%09
-CaseTransformerWindingOPA(PAModel m) throws PAModelException%0A%09%7B%0A%09%09super(m.getTransformers(), CaseTransformerWinding.values().length);
+@Override%0A%09protected String getPsmFmtName()%0A%09%7B%0A%09%09return %22PsmCase%22 + PsmCaseFmtObject.TransformerWinding.toString();%0A%09%7D%0A%09%0A%09int _ntx, _nps;%0A%09FmtInfo%5B%5D _txi;%0A%09public CaseTransformerWindingOPA(PAModel m) throws PAModelException%0A%09%7B%0A%09%09super(null, TransformerWinding.values().length);%0A%09%09TransformerList tlist = m.getTransformers();%0A%09%09PhaseShifterList plist = m.getPhaseShifters();%0A%09%09_ntx = tlist.size();%0A%09%09_nps = plist.size();%0A%09%09assign(tlist);%0A%09%09_txi = _finfo.clone();%0A%09%09assign(plist);%0A%09%7D%0A%0A%09void assign(ACBranchListIfc%3C? extends ACBranch%3E list) throws PAModelException%0A%09%7B
 %0A%09%09a
@@ -1128,17 +1128,16 @@
 ap(i -%3E 
-_
 list.get
@@ -1204,33 +1204,32 @@
  String.valueOf(
-_
 list.getFromP(i)
@@ -1286,33 +1286,32 @@
  String.valueOf(
-_
 list.getFromQ(i)
@@ -1364,33 +1364,32 @@
  String.valueOf(
-_
 list.getToP(i)))
@@ -1450,17 +1450,16 @@
 valueOf(
-_
 list.get
@@ -1488,114 +1488,292 @@
 de%0A%09
-protected String getPsmFmtName()%0A%09%7B%0A%09%09return %22PsmCase%22 + PsmCaseFmtObject.TransformerWinding.toString
+void export(File outputdir) throws PAModelException, IOException%0A%09%7B%0A%09%09PrintWriter pw = new PrintWriter(new BufferedWriter(%0A%09%09%09new FileWriter(new File(outputdir, getPsmFmtName()+%22.csv%22))));%0A%09%09printHeader(pw);%0A%09%09printData(pw, _txi, _ntx);%0A%09%09printData(pw, _finfo, _nps);%0A%09%09pw.close
 ();%0A%09%7D%0A
+%0A
 %7D%0A

add missing phase shifter data to transformer winding case CSV file