Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scenario;
- import cbList.open.OpenFileAllCSV;
- import com.mxgraph.model.mxCell;
- import com.mxgraph.model.mxICell;
- import elecNetwork.view.GraphEditor;
- import elecNetwork.view.logic.EShedding;
- import elecNetwork.view.logic.Logic;
- import elecNetwork.view.logic.LogicLine;
- import elecNetwork.view.logic.Mode;
- import elecNetwork.view.logic.SLogic;
- import elecNetwork.view.logic.open.OpenFileQLE;
- import java.awt.Rectangle;
- import java.util.ArrayList;
- import java.util.Hashtable;
- import java.util.List;
- import javax.swing.JFrame;
- import javax.swing.JScrollPane;
- import javax.swing.JTable;
- import main.MainWindow;
- import scenario.export.ExportDocument;
- public class Calculation extends JFrame
- {
- private static final long serialVersionUID = 1L;
- public String componentType;
- public String sourceName;
- public String cellName;
- public mxICell mxcell;
- public mxICell mxedge;
- public mxICell cellSource;
- public mxICell edgeSource;
- public mxICell nextCell;
- public Hashtable<String, String> linkName;
- public Hashtable<String, String> linkContactor;
- public Hashtable<String, String> linkSource;
- public List<mxICell[]> cellWait;
- //liste du tableau des charges
- public LoadTable loadModele;
- //liste des liens entre composants
- public LinkTable linkModele;
- public String[] listNull;
- public static JTable loadTable;
- public static JTable loadTableLink;
- public List<String> busbarList;
- public int ligneCpt = 0;
- public static ExportDocument InProgressDocument;
- public static int selection;
- public static List<Double[]> consumption;
- //valeurs par defaut pour precision des consommations et amperage, et facteur de puissance
- public static int loadPrecisionCalculation=10;
- public static int powerFactorPrecisionCalculation=10;
- public static List<JTable> ataListTable;
- public Calculation(int selectionEntry)
- {
- //nombre de configuration
- selection=selectionEntry;
- this.linkName = new Hashtable<String,String>();
- this.linkContactor = new Hashtable<String,String>();
- this.linkSource = new Hashtable<String,String>();
- this.cellWait = new ArrayList<mxICell[]>();
- this.loadModele = new LoadTable();
- this.linkModele = new LinkTable();
- loadTable = new JTable(this.loadModele);
- loadTable.getColumnModel().getColumn(0).setPreferredWidth(187);
- JScrollPane paneLoadTable = new JScrollPane(loadTable);
- loadTable.setAutoResizeMode(0);
- ataListTable = new ArrayList<JTable>();
- for(int i=0;i<ScenarioPage.selectedPhase.length;i++)
- ataListTable.add(new JTable(new AtaTable()));
- loadTableLink = new JTable(this.linkModele);
- if (GraphEditor.allEdges.length != 0)
- {
- for (int i = 0; i < GraphEditor.allEdges.length; i++)
- {
- MainWindow.scenario.revalidate();
- ScenarioPage.progressbar.setIndeterminate(false);
- ScenarioPage.task.ProgressBar(i+1, GraphEditor.allEdges.length);
- //recherche des sources d'alimentation puis s'il s'agit d'une source ou d'une cible lors du cablage
- if (((((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("RAT")) ||
- (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("generateur")) ||
- (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("externalpower")) ||
- (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("battery"))) &&
- (componentCondition(((mxCell)GraphEditor.allEdges[i]).getSource().getParent())))
- {
- this.cellSource = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
- this.sourceName = (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getValue().toString() + "#" + ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId() + "§");
- this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
- this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
- process(1);
- }
- else if (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("groundservicing"))
- {
- if ((((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().indexOf(";") != -1) && (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().indexOf(";") != ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().length() - 1))
- {
- this.sourceName = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().substring(((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().indexOf(";") + 1, ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().length());
- for (int j = 0; j < GraphEditor.allCells.length; j++)
- {
- if ((!((mxCell)GraphEditor.allCells[j]).getStyle().contains("node")) && (!((mxCell)GraphEditor.allCells[j]).getStyle().contains("groundservicing")))
- {
- if (((mxCell)GraphEditor.allCells[j]).getValue().toString().equals(this.sourceName))
- {
- this.cellSource = ((mxCell)GraphEditor.allCells[j]);
- }
- }
- }
- this.sourceName = (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().substring(((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().indexOf(";") + 1, ((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().length()) +
- "#" + ((mxCell)this.cellSource).getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + this.cellSource.getId() + "§");
- this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
- this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
- if ((this.nextCell.getStyle().toString().contains("busbar")) && (!(this.nextCell.getValue().toString() + " ").contains("PP ")) &&
- (componentCondition(this.cellSource)))
- {
- process(0);
- }
- }
- }
- else if (((((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("RAT")) ||
- (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("generateur")) ||
- (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("externalpower")) ||
- (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("battery"))) &&
- (componentCondition(((mxCell)GraphEditor.allEdges[i]).getTarget().getParent())))
- {
- this.cellSource = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
- this.sourceName = (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getValue().toString() + "#" + ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId() + "§");
- this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
- this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
- process(1);
- }
- else if (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("groundservicing"))
- {
- if ((((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().indexOf(";") != -1) && (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().indexOf(";") != ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().length() - 1))
- {
- this.sourceName = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().substring(((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().indexOf(";") + 1, ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().length());
- for (int j = 0; j < GraphEditor.allCells.length; j++)
- {
- if ((!((mxCell)GraphEditor.allCells[j]).getStyle().contains("node")) && (!((mxCell)GraphEditor.allCells[j]).getStyle().contains("groundservicing")))
- {
- if (((mxCell)GraphEditor.allCells[j]).getValue().toString().equals(this.sourceName))
- {
- this.cellSource = ((mxCell)GraphEditor.allCells[j]);
- }
- }
- }
- this.sourceName = (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().substring(((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().indexOf(";") + 1, ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().length()) +
- "#" + ((mxCell)this.cellSource).getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + this.cellSource.getId() + "§");
- this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
- this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
- if ((this.nextCell.getStyle().toString().contains("busbar")) && (!(this.nextCell.getValue().toString() + " ").contains("PP ")) &&
- (componentCondition(this.cellSource)))
- {
- process(0);
- }
- }
- }
- }
- ScenarioPage.etape = "% - Calculation";
- findLoad();
- }
- add(paneLoadTable);
- setBounds(new Rectangle(600, 400));
- // setVisible(true);
- for(int i=0;i<ScenarioPage.selectedPhase.length;i++) {
- JFrame frame = new JFrame();
- JScrollPane pane = new JScrollPane(ataListTable.get(i));
- frame.add(pane);
- // frame.setVisible(true);
- }
- if (ScenarioPage.cheminOutput!=null&&ScenarioPage.cheminTemplate!=null) {
- ScenarioPage.etape = "% - Output file generating";
- ScenarioPage.task.ProgressBar(0,1);
- InProgressDocument.ExportDocumentRequest();
- }
- revalidate();
- }
- /**
- * Effectue la liste des composants suivant la conf et le cablage)
- * @param cpt (0=groundServicing)
- */
- private void process(int cpt)
- {
- boolean present = false;
- //test si deja present dans le tableau
- for (int i = 0; i < loadTable.getRowCount(); i++)
- {
- if (loadTable.getValueAt(i, 0).equals(this.sourceName + "_MAX A"))
- {
- present = true;
- }
- }
- if (present)
- {
- present = false;
- }
- else
- {
- insertLoadLine(this.sourceName);
- insertAtaLine(this.sourceName);
- }
- detectComponentType(this.nextCell, this.edgeSource);
- if (cpt == 0)
- {
- //creation des lignes contenant les informations necessaires pour continuer
- this.cellName = (this.mxcell.getValue().toString() + "#" + this.mxcell.getStyle().toString() + "#¤" + this.sourceName.substring(this.sourceName.lastIndexOf("#¤") + 2, this.sourceName.lastIndexOf("¤§")) + "¤§" + this.mxcell.getId().toString() + "§");
- this.linkModele.addLine(new LinkLine(this.cellName, this.sourceName));
- insertLoadLine(this.cellName);
- insertAtaLine(this.cellName);
- }
- //tant que l'on n'est pas arrive a la fin du "cablage" on continue la liste
- while((cellWait.size()+cpt)>0)
- {
- //action suivant le type de composant
- switch(componentType)
- {
- case "busbar":
- cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
- //definition entre composants (ex:barre/sousbarre)
- linkModele.addLine(new LinkLine(cellName,sourceName));
- for(int i1=0;i1<loadTable.getRowCount();i1++)
- {
- if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(cellName);
- insertAtaLine(cellName);
- }
- //detecte si il y a d'autres elements apres l'actuel
- List<mxICell[]> list=detectAllNextEdge(mxcell, mxedge);
- if(list.size()!=0)
- {
- for(int i1=0;i1<list.size();i1++)
- {
- if(!list.get(i1)[0].getId().toString().contains("Node"))
- {
- linkName.put(list.get(i1)[0].getValue().toString(),cellName);
- }
- else
- {
- linkName.put(list.get(i1)[0].getId().toString(),cellName);
- }
- }
- cellWait.addAll(list);
- actionType();
- }
- break;
- case "equipment":
- cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
- linkModele.addLine(new LinkLine(cellName,sourceName));
- for(int i1=0;i1<loadTable.getRowCount();i1++)
- {
- if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(cellName);
- insertAtaLine(cellName);
- }
- List<mxICell[]> list1=detectAllNextEdge(mxcell, mxedge);
- if(list1.size()!=0)
- {
- for(int i1=0;i1<list1.size();i1++)
- {
- if(!list1.get(i1)[0].getId().toString().contains("Node"))
- {
- linkName.put(list1.get(i1)[0].getValue().toString(),cellName);
- }
- else
- {
- linkName.put(list1.get(i1)[0].getId().toString(),cellName);
- }
- }
- cellWait.addAll(list1);
- actionType();
- }
- break;
- case "contactor":
- if(componentCondition(mxcell))
- {
- List<mxICell[]> list2=detectAllNextEdge(mxcell, mxedge);
- if(list2.size()!=0)
- {
- for(int i1=0;i1<list2.size();i1++)
- {
- if(!list2.get(i1)[0].getId().toString().contains("Node"))
- {
- linkName.put(list2.get(i1)[0].getValue().toString(),sourceName);
- linkContactor.put(list2.get(i1)[0].getValue().toString(),mxcell.getValue().toString());
- }
- else
- {
- linkName.put(list2.get(i1)[0].getId().toString(),sourceName);
- linkContactor.put(list2.get(i1)[0].getId().toString(),mxcell.getValue().toString());
- }
- }
- cellWait.addAll(list2);
- actionType();
- }
- }
- break;
- case "converter":
- cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
- linkModele.addLine(new LinkLine(cellName,sourceName));
- for(int i1=0;i1<loadTable.getRowCount();i1++)
- {
- if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(cellName);
- insertAtaLine(cellName);
- }
- List<mxICell[]> list3=detectAllNextEdge(mxcell, mxedge);
- if(list3.size()!=0)
- {
- for(int i1=0;i1<list3.size();i1++)
- {
- if(!list3.get(i1)[0].getId().toString().contains("Node"))
- {
- linkName.put(list3.get(i1)[0].getValue().toString(),cellName);
- }
- else
- {
- linkName.put(list3.get(i1)[0].getId().toString(),cellName);
- }
- }
- cellWait.addAll(list3);
- actionType();
- }
- case "node":
- List<mxICell[]> list4=detectAllNextEdge(mxcell, mxedge);
- if(list4.size()!=0)
- {
- for(int i1=0;i1<list4.size();i1++)
- {
- if(!list4.get(i1)[0].getId().toString().contains("Node"))
- {
- linkName.put(list4.get(i1)[0].getValue().toString(),sourceName);
- linkContactor.put(list4.get(i1)[0].getValue().toString(),mxcell.getId().toString());
- }
- else
- {
- linkName.put(list4.get(i1)[0].getId().toString(),sourceName);
- linkContactor.put(list4.get(i1)[0].getId().toString(),mxcell.getId().toString());
- }
- }
- cellWait.addAll(list4);
- actionType();
- }
- break;
- case "battery":
- /*????????????????*/
- break;
- case "groundservicing":
- break;
- case "generator":
- /*????????????????*/
- break;
- case "rat":
- /*????????????????*/
- break;
- case "externalpower":
- /*????????????????*/
- break;
- }
- cpt--;
- }
- }
- private void insertLoadLine(String name)
- {
- for(int i=0;i<OpenFileAllCSV.loadList.size();i++) {
- for(int j=0;j<OpenFileAllCSV.phaseList.size();j++) {
- this.listNull = new String[loadTable.getColumnCount()-1];
- for (int k=0;k<this.listNull.length;k++)
- this.listNull[k] = "0.0";
- this.loadModele.addLine(new LoadLine(name +"¥"+OpenFileAllCSV.loadList.get(i)+"Ø"+OpenFileAllCSV.phaseList.get(j), this.listNull));
- }
- }
- }
- private void insertAtaLine(String name)
- {
- for(int i=0;i<OpenFileAllCSV.loadList.size();i++) {
- for(int j=0;j<OpenFileAllCSV.phaseList.size();j++) {
- for(int k=0;k<ataListTable.size();k++) {
- this.listNull = new String[ataListTable.get(0).getColumnCount()-1];
- for (int l=0;l<this.listNull.length;l++)
- this.listNull[l] = "0.0";
- ((AtaTable) ataListTable.get(k).getModel()).addLine(new AtaLine(name +"¥"+OpenFileAllCSV.loadList.get(i)+"Ø"+OpenFileAllCSV.phaseList.get(j), this.listNull));
- }
- }
- }
- }
- private List<mxICell[]> detectAllNextEdge(mxICell parent, mxICell previousEdge)
- {
- List<mxICell[]> list = new ArrayList<mxICell[]>();
- for (int i = 0; i < GraphEditor.allEdges.length; i++)
- {
- if ((((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().toString().equals(((mxCell)parent).getId().toString())) &&
- (GraphEditor.allEdges[i] != previousEdge) && (!((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().contains("groundservicing")))
- {
- mxICell[] cell1 = new mxICell[2];
- cell1[0] = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
- cell1[1] = ((mxICell)GraphEditor.allEdges[i]);
- list.add(cell1);
- }
- else if ((((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().toString().equals(((mxCell)parent).getId().toString())) &&
- (GraphEditor.allEdges[i] != previousEdge) && (!((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().contains("groundservicing")))
- {
- mxICell[] cell2 = new mxICell[2];
- cell2[0] = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
- cell2[1] = ((mxICell)GraphEditor.allEdges[i]);
- list.add(cell2);
- }
- }
- boolean otherComponent = false;
- for (int i = 0; i < list.size(); i++)
- {
- if (!((mxICell[])list.get(i))[0].getStyle().contains("contacteur"))
- {
- for (int j = i + 1; j < list.size(); j++)
- {
- if (((mxICell[])list.get(j))[0].getStyle().contains("contacteur"))
- {
- otherComponent = true;
- }
- }
- if (otherComponent)
- {
- list.add((mxICell[])list.get(i));
- list.remove(i);
- i--;
- otherComponent = false;
- }
- }
- }
- for (int i = 0; i < list.size(); i++)
- {
- if (((mxICell[])list.get(i))[0].getStyle().contains("busbar_p"))
- {
- for (int j = i + 1; j < list.size(); j++)
- {
- if (!((mxICell[])list.get(j))[0].getStyle().contains("busbar_p"))
- {
- otherComponent = true;
- }
- }
- if (otherComponent)
- {
- list.add((mxICell[])list.get(i));
- list.remove(i);
- i--;
- otherComponent = false;
- }
- }
- }
- return list;
- }
- private void detectComponentType(mxICell parent, mxICell connection)
- {
- if (parent.getStyle().toString().contains("busbar"))
- {
- this.componentType = "busbar";
- }
- else if (parent.getStyle().toString().contains("equipment"))
- {
- this.componentType = "equipment";
- }
- else if (parent.getStyle().toString().contains("contacteur"))
- {
- this.componentType = "contactor";
- }
- else if (parent.getStyle().toString().contains("convertisseur"))
- {
- this.componentType = "converter";
- }
- else if (parent.getStyle().toString().contains("node"))
- {
- this.componentType = "node";
- }
- else if (parent.getStyle().toString().contains("battery"))
- {
- this.componentType = "battery";
- }
- else if (parent.getStyle().toString().contains("groundservicing"))
- {
- this.componentType = "groundservicing";
- }
- else if (parent.getStyle().toString().contains("generateur"))
- {
- this.componentType = "generator";
- }
- else if (parent.getStyle().toString().contains("RAT"))
- {
- this.componentType = "rat";
- }
- else if (parent.getStyle().toString().contains("externalpower"))
- {
- this.componentType = "externalpower";
- }
- this.mxcell = parent;
- this.mxedge = connection;
- }
- /**
- * Return true si la logique de object =1.
- * @param object
- * @return
- */
- private boolean componentCondition(mxICell object)
- {
- boolean condition = false;
- for (int i = 0; i < Logic.entetes.length; i++)
- {
- if (Logic.entetes[i].equals(object.getValue().toString()))
- {
- for (int j = 0; j < Logic.lines.size(); j++)
- {
- if ((((LogicLine)Logic.lines.get(j)).getColumnName().equals(ScenarioPage.configurationTable.getValueAt(selection, 0))) &&
- (((LogicLine)Logic.lines.get(j)).getListofLogic(i).equals("1")))
- {
- condition = true;
- break;
- }
- }
- }
- }
- return condition;
- }
- /**
- * continue la liste des composants
- */
- public void actionType()
- {
- boolean present = false;
- String name;
- boolean lineWithsourceTemp = false;
- while(!cellWait.isEmpty())
- {
- detectComponentType(cellWait.get(0)[0],cellWait.get(0)[1]);
- if(!mxcell.getStyle().toString().contains("node")&&!mxcell.getStyle().toString().contains("contacteur"))
- {
- name=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
- }
- else if(!mxcell.getStyle().toString().contains("node"))
- {
- name=linkName.get(mxcell.getValue().toString());
- }
- else
- {
- name=linkName.get(mxcell.getId().toString());
- }
- //necessaire pour garder la meme source d'alimentation lorsque l'on passe ou composant suivant ou jusqu'a une autre source d'alimentation
- String sourceTemp="*tempNull:", linkInit="";
- List<LoadLine> lines = new ArrayList<LoadLine>();
- switch(componentType)
- {
- case "busbar":
- if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
- {
- if((linkName.get(cellWait.get(0)[0].getValue().toString()).contains("battery")||linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur"))&&!cellWait.get(0)[0].getStyle().toString().contains("busbar_p"))
- {
- if(linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur")) {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+name.substring(name.lastIndexOf("¤§"),name.length());
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
- } else {
- linkModele.addLine(new LinkLine(name,linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())));
- lineWithsourceTemp=true;
- }
- }
- else
- {
- if(!linkName.get(cellWait.get(0)[0].getValue().toString()).contains("busbar_"))
- {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+name.substring(name.lastIndexOf("¤§"),name.length());
- }
- else
- {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(linkName.get(cellWait.get(0)[0].getValue().toString()).lastIndexOf("#¤")+2,linkName.get(cellWait.get(0)[0].getValue().toString()).lastIndexOf("¤§"))+name.substring(name.lastIndexOf("¤§"),name.length());
- }
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
- if(lineWithsourceTemp)
- {
- for(int m=0;m<loadTableLink.getRowCount();m++)
- {
- if(linkModele.getValueAt(m,1).toString().contains(linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())))
- {
- linkModele.setValueAt(m,loadTableLink.getValueAt(m,0).toString(),name);
- for(int n=0;n<loadTable.getRowCount();n++)
- {
- if(loadModele.getValueAt(n,0).toString().contains(linkModele.getValueAt(m,0).toString()))
- {
- LoadLine line=new LoadLine(loadModele.getLineAt(n).getRowName(),loadModele.getLineAt(n).getListofLoad());
- for(int p=0;p<loadTableLink.getRowCount();p++)
- {
- if(loadTableLink.getValueAt(p,0).toString().contains(line.getRowName().toString().replace("_MAX A","")))
- {
- linkModele.setValueAt(p,loadTableLink.getValueAt(p,0).toString().substring(0,loadTableLink.getValueAt(p,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadTableLink.getValueAt(p,0).toString().substring(loadTableLink.getValueAt(p,0).toString().lastIndexOf("¤§"),loadTableLink.getValueAt(p,0).toString().length()),loadTableLink.getValueAt(p,1).toString());
- loadModele.setValueAt(loadModele.getValueAt(n+1,0).toString().substring(0,loadModele.getValueAt(n+1,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+1,0).toString().substring(loadModele.getValueAt(n+1,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+1,0).toString().length()),n+1,0);
- loadModele.setValueAt(loadModele.getValueAt(n+2,0).toString().substring(0,loadModele.getValueAt(n+2,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+2,0).toString().substring(loadModele.getValueAt(n+2,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+2,0).toString().length()),n+2,0);
- loadModele.setValueAt(loadModele.getValueAt(n+3,0).toString().substring(0,loadModele.getValueAt(n+3,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+3,0).toString().substring(loadModele.getValueAt(n+3,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+3,0).toString().length()),n+3,0);
- loadModele.setValueAt(loadModele.getValueAt(n+4,0).toString().substring(0,loadModele.getValueAt(n+4,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+4,0).toString().substring(loadModele.getValueAt(n+4,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+4,0).toString().length()),n+4,0);
- loadModele.setValueAt(loadModele.getValueAt(n+5,0).toString().substring(0,loadModele.getValueAt(n+5,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+5,0).toString().substring(loadModele.getValueAt(n+5,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+5,0).toString().length()),n+5,0);
- loadModele.setValueAt(loadModele.getValueAt(n+6,0).toString().substring(0,loadModele.getValueAt(n+6,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+6,0).toString().substring(loadModele.getValueAt(n+6,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+6,0).toString().length()),n+6,0);
- loadModele.setValueAt(loadModele.getValueAt(n+7,0).toString().substring(0,loadModele.getValueAt(n+7,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+7,0).toString().substring(loadModele.getValueAt(n+7,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+7,0).toString().length()),n+7,0);
- }
- }
- line.setRowName(line.getRowName().substring(0,line.getRowName().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+line.getRowName().substring(line.getRowName().lastIndexOf("¤§"),line.getRowName().length()));
- lines.add(line);
- loadModele.removeLine(n);
- n--;
- }
- }
- }
- }
- lineWithsourceTemp=false;
- }
- }
- }
- else
- {
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
- }
- for(int i=0;i<loadTable.getRowCount();i++)
- {
- if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(name);
- insertAtaLine(name);
- for(int i=0;i<lines.size();i++)
- {
- loadModele.addLine(lines.get(i));
- }
- }
- List<mxICell[]> list=detectAllNextEdge(mxcell, mxedge);
- if(list.size()!=0)
- {
- for(int i=0;i<list.size();i++)
- {
- if(!list.get(i)[0].getStyle().toString().contains("node"))
- {
- linkName.put(list.get(i)[0].getValue().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
- }
- else
- {
- linkName.put(list.get(i)[0].getId().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
- }
- }
- cellWait.addAll(list);
- }
- break;
- case "equipment":
- if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
- {
- if((linkName.get(cellWait.get(0)[0].getValue().toString()).contains("battery")||linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur"))&&!cellWait.get(0)[0].getStyle().toString().contains("busbar_p"))
- {
- if(linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur")) {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+name.substring(name.lastIndexOf("¤§"),name.length());
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
- } else {
- linkModele.addLine(new LinkLine(name,linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())));
- lineWithsourceTemp=true;
- }
- }
- else
- {
- if(!linkName.get(cellWait.get(0)[0].getValue().toString()).contains("busbar_"))
- {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+name.substring(name.lastIndexOf("¤§"),name.length());
- }
- else
- {
- name=name.substring(0,name.lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(linkName.get(cellWait.get(0)[0].getValue().toString()).lastIndexOf("#¤")+2,linkName.get(cellWait.get(0)[0].getValue().toString()).lastIndexOf("¤§"))+name.substring(name.lastIndexOf("¤§"),name.length());
- }
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
- if(lineWithsourceTemp)
- {
- for(int m=0;m<loadTableLink.getRowCount();m++)
- {
- if(linkModele.getValueAt(m,1).toString().contains(linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())))
- {
- linkModele.setValueAt(m,loadTableLink.getValueAt(m,0).toString(),name);
- for(int n=0;n<loadTable.getRowCount();n++)
- {
- if(loadModele.getValueAt(n,0).toString().contains(linkModele.getValueAt(m,0).toString()))
- {
- LoadLine line=new LoadLine(loadModele.getLineAt(n).getRowName(),loadModele.getLineAt(n).getListofLoad());
- for(int p=0;p<loadTableLink.getRowCount();p++)
- {
- if(loadTableLink.getValueAt(p,0).toString().contains(line.getRowName().toString().replace("_MAX A","")))
- {
- linkModele.setValueAt(p,loadTableLink.getValueAt(p,0).toString().substring(0,loadTableLink.getValueAt(p,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadTableLink.getValueAt(p,0).toString().substring(loadTableLink.getValueAt(p,0).toString().lastIndexOf("¤§"),loadTableLink.getValueAt(p,0).toString().length()),loadTableLink.getValueAt(p,1).toString());
- loadModele.setValueAt(loadModele.getValueAt(n+1,0).toString().substring(0,loadModele.getValueAt(n+1,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+1,0).toString().substring(loadModele.getValueAt(n+1,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+1,0).toString().length()),n+1,0);
- loadModele.setValueAt(loadModele.getValueAt(n+2,0).toString().substring(0,loadModele.getValueAt(n+2,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+2,0).toString().substring(loadModele.getValueAt(n+2,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+2,0).toString().length()),n+2,0);
- loadModele.setValueAt(loadModele.getValueAt(n+3,0).toString().substring(0,loadModele.getValueAt(n+3,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+3,0).toString().substring(loadModele.getValueAt(n+3,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+3,0).toString().length()),n+3,0);
- loadModele.setValueAt(loadModele.getValueAt(n+4,0).toString().substring(0,loadModele.getValueAt(n+4,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+4,0).toString().substring(loadModele.getValueAt(n+4,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+4,0).toString().length()),n+4,0);
- loadModele.setValueAt(loadModele.getValueAt(n+5,0).toString().substring(0,loadModele.getValueAt(n+5,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+5,0).toString().substring(loadModele.getValueAt(n+5,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+5,0).toString().length()),n+5,0);
- loadModele.setValueAt(loadModele.getValueAt(n+6,0).toString().substring(0,loadModele.getValueAt(n+6,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+6,0).toString().substring(loadModele.getValueAt(n+6,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+6,0).toString().length()),n+6,0);
- loadModele.setValueAt(loadModele.getValueAt(n+7,0).toString().substring(0,loadModele.getValueAt(n+7,0).toString().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+loadModele.getValueAt(n+7,0).toString().substring(loadModele.getValueAt(n+7,0).toString().lastIndexOf("¤§"),loadModele.getValueAt(n+7,0).toString().length()),n+7,0);
- }
- }
- line.setRowName(line.getRowName().substring(0,line.getRowName().lastIndexOf("#¤")+2)+linkName.get(cellWait.get(0)[0].getValue().toString()).substring(0,linkName.get(cellWait.get(0)[0].getValue().toString()).indexOf("#"))+line.getRowName().substring(line.getRowName().lastIndexOf("¤§"),line.getRowName().length()));
- lines.add(line);
- loadModele.removeLine(n);
- n--;
- }
- }
- }
- }
- lineWithsourceTemp=false;
- }
- }
- }
- else
- {
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
- }
- for(int i=0;i<loadTable.getRowCount();i++)
- {
- if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(name);
- insertAtaLine(name);
- for(int i=0;i<lines.size();i++)
- {
- loadModele.addLine(lines.get(i));
- }
- }
- List<mxICell[]> list1=detectAllNextEdge(mxcell, mxedge);
- if(list1.size()!=0)
- {
- for(int i=0;i<list1.size();i++)
- {
- if(!list1.get(i)[0].getStyle().toString().contains("node"))
- {
- linkName.put(list1.get(i)[0].getValue().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list1.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
- }
- else
- {
- linkName.put(list1.get(i)[0].getId().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list1.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
- }
- }
- cellWait.addAll(list1);
- }
- break;
- case "contactor":
- if(componentCondition(mxcell))
- {
- List<mxICell[]> list2=detectAllNextEdge(mxcell, mxedge);
- if(list2.size()!=0)
- {
- for(int i=0;i<list2.size();i++)
- {
- if(!list2.get(i)[0].getStyle().toString().contains("node"))
- {
- linkName.put(list2.get(i)[0].getValue().toString(),name);
- linkInit="@"+mxcell.getValue().toString()+"@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list2.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
- }
- else
- {
- linkName.put(list2.get(i)[0].getId().toString(),name);
- linkInit="@"+mxcell.getValue().toString()+"@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list2.get(i)[0].getId().toString(),mxcell.getValue().toString());
- }
- }
- cellWait.addAll(list2);
- }
- }
- break;
- case "converter":
- if(componentCondition(mxcell))
- {
- if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
- {
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
- }
- else
- {
- linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
- }
- for(int i=0;i<loadTable.getRowCount();i++)
- {
- if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
- {
- present=true;
- }
- }
- if(present)
- {
- present=false;
- }
- else
- {
- insertLoadLine(name);
- insertAtaLine(name);
- }
- List<mxICell[]> list3=detectAllNextEdge(mxcell, mxedge);
- if(list3.size()!=0)
- {
- for(int i=0;i<list3.size();i++)
- {
- if(!list3.get(i)[0].getStyle().toString().contains("node"))
- {
- linkName.put(list3.get(i)[0].getValue().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list3.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
- }
- else
- {
- linkName.put(list3.get(i)[0].getId().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list3.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
- }
- }
- cellWait.addAll(list3);
- }
- }
- break;
- case "node":
- List<mxICell[]> list4=detectAllNextEdge(mxcell, mxedge);
- if(list4.size()!=0)
- {
- for(int i=0;i<list4.size();i++)
- {
- if(!list4.get(i)[0].getStyle().toString().contains("node"))
- {
- linkName.put(list4.get(i)[0].getValue().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getId().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list4.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
- }
- else
- {
- linkName.put(list4.get(i)[0].getId().toString(),name);
- linkInit="@"+linkContactor.get(mxcell.getId().toString())+"@";
- while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
- {
- linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
- }
- linkContactor.put(list4.get(i)[0].getId().toString(),linkContactor.get(mxcell.getId().toString()));
- }
- }
- cellWait.addAll(list4);
- }
- break;
- case "battery":
- /*????????????????*/
- break;
- case "groundservicing":
- /*????????????????*/
- break;
- case "generator":
- /*????????????????*/
- break;
- case "rat":
- /*????????????????*/
- break;
- case "externalpower":
- /*????????????????*/
- break;
- default :
- break;
- }
- cellWait.remove(0);
- }
- }
- /**
- * Recherche et somme les consomations
- */
- private void findLoad()
- {
- boolean equipmentOff = false;
- int progress=loadTable.getRowCount();
- new SLogic();
- ScenarioPage.task.ProgressBar(0, progress);
- //pour toutes les x lignes en remontant la liste des composants (loadTable)
- for (int i = loadTable.getRowCount() - (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()); i >= 0; i -= (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
- //pour toutes les lignes de loadList (ex:MAX/OPE/...)
- for(int z=0;z<OpenFileAllCSV.loadList.size();z++) {
- //pour toutes les phases de phaseList(ex:DC,A,B,C)
- for(int y=0;y<OpenFileAllCSV.phaseList.size();y++) {
- ScenarioPage.task.ProgressBar(progress-i+y+(z*OpenFileAllCSV.phaseList.size()), progress);
- //type de composant
- String ident = loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().indexOf("#") + 1, loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("#"));
- //si c'est une busbar
- if ((ident.contains("busbar_w.png;")) || (ident.contains("busbar_p.png;"))) {
- //designation
- String id = loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0, loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().indexOf("#"));
- //FIN
- String fin = loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().indexOf("§"),loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().length());
- fin = fin.substring(fin.indexOf(";")+1,fin.lastIndexOf(";;;;;"));
- //oneLineTrue=true <=> composant non deleste
- boolean oneLineTrue=true;
- //on ne continue pas avec ce composant des que l'on trouve un condition fausse
- boolean logicFalse=false;
- //savoir si delester ou non
- for(int q=0;q<EShedding.esheddingLines.size();q++) {
- //recherche de la ligne correspondant au FIN
- if(EShedding.esheddingLines.get(q).getESheddingFin().equals(fin)) {
- oneLineTrue=false;
- for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
- logicFalse=false;
- //analyse des equations, test dans l'ordre la logique des composants, des boutons&contexts puis des MODs
- for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
- for(int t=1;t<Logic.entetes.length;t++) {
- if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
- for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
- if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicModeColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
- for(int t=0;t<Mode.modeLines.size();t++) {
- if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- oneLineTrue=true;
- break;
- }
- }
- break;
- }
- }
- //si non deleste
- if(oneLineTrue) {
- //pour chaque phase de vol selectionnee
- for (int k = 0; k < ScenarioPage.selectedPhase.length; k++) {
- //taille =2 pour P et Q
- consumption=new ArrayList<Double[]>(2);
- for(int j = 1; j < OpenFileAllCSV.data.size(); j++) {
- //pour chaque ligne du CSV
- for(int m = 0; m < OpenFileAllCSV.data.get(0).length; m++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.busbarListModele.getValueAt(0,0))) {
- //colonne busbar repere
- if(OpenFileAllCSV.data.get(j)[m].equals(id)) {
- //designation busbar repere
- boolean condition=false;
- if(OpenFileAllCSV.optionListTable.getRowCount()==0)
- condition=true;
- for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
- //colonne phase repere
- if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
- //phase repere
- for(int p=2; p<ScenarioPage.optionListTable.getRowCount();p++) {
- //pour chaque option (sauf cos)
- if(ScenarioPage.optionListModele.getValueAt(p,0).toString().startsWith(">")) {
- //titre option repere (ex:>Load)
- if(p==2&&OpenFileAllCSV.loadListTable.getRowCount()>0) {
- //si option >Load presente
- if(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">","").equals(OpenFileAllCSV.loadListModele.getValueAt(0,0))) {
- for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">",""))) {
- //colonne Load repere
- boolean continu=true;
- //test si option fausse ou fin option =sortie boucle
- while(continu&&p<OpenFileAllCSV.loadListTable.getRowCount()+3) {
- if(!ScenarioPage.optionListModele.getValueAt(p+1,0).toString().startsWith(">")&&p<ScenarioPage.optionListTable.getRowCount()-1) {
- p++;
- if(OpenFileAllCSV.loadList.get(z).equals(ScenarioPage.optionListModele.getValueAt(p,0))&&OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(p,1).toString())) {
- condition=true;
- continu=false;
- } else
- condition=false;
- } else
- continu=false;
- }
- break;
- }
- }
- if(!condition)
- break;
- }
- } else {
- for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">",""))) {
- //colonne "option" repere (ex:C,S,...)
- boolean continu=true;
- //test si option fausse ou fin option =sortie boucle
- while(continu&&p<=ScenarioPage.optionListTable.getRowCount()-2) {
- if(!ScenarioPage.optionListModele.getValueAt(p+1,0).toString().startsWith(">")&&p<ScenarioPage.optionListTable.getRowCount()-1) {
- p++;
- if(OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(p,1).toString())) {
- condition=true;
- continu=false;
- } else
- condition=false;
- } else
- continu=false;
- }
- break;
- }
- }
- }
- if(!condition)
- break;
- }
- }
- }
- break;
- }
- }
- //si condition=true alors on recherchera la consommation
- if(condition) {
- for (int n=0;n<OpenFileAllCSV.data.get(0).length;n++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
- //colone FIN repere
- for (int l = 0; l < ScenarioPage.equipmentTable.getRowCount(); l++) {
- //test si FIN desactive
- if (ScenarioPage.equipmentTable.getValueAt(l, 0).toString().equals(((String[])OpenFileAllCSV.data.get(j))[n])) {
- equipmentOff = true;
- break;
- }
- }
- break;
- }
- }
- if (!equipmentOff)
- //recherche des consommations
- findLoad(i, j, y, z, k, false);
- equipmentOff = false;
- }
- }
- break;
- }
- }
- }
- double Pt=0,Qt=0;
- for(int o=0;o<consumption.size();o++) {
- //calcul de P et Q total
- Pt+=consumption.get(o)[0];
- Qt+=consumption.get(o)[1];
- }
- //necessaire pour attribuer les valeurs sur 3 colonnes (conso, cos, ampere) par phase de vol
- int kT=3*k+1;
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- //pour chaque ligne de la liste des liens entre composant
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥"))))
- {
- //nom du composant superieur (n) au composant (i) repere
- for (int n = 0; n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- //pour chaque ligne de loadTable
- if (loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1)))
- {
- //composant superieur n repere, init cos et S, calcul de P et Q pour le composant i avec les consommations deja presentes sur loadTable
- double costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
- Stempi=getArround(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
- Ptempi=Stempi*costempi,Qtempi=Stempi*Math.sqrt(1-Math.pow(costempi,2));
- Ptempi+=Pt;
- Qtempi+=Qt;
- //calcul des nouveaux S et cos pour le composant i
- Stempi=Math.sqrt(Math.pow(Ptempi,2)+Math.pow(Qtempi,2));
- costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempi!=0.0)?1.0:(Ptempi/Stempi);
- //init cos et S, calcul de P et Q pour le composant n avec les consommations deja presentes sur loadTable
- double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
- Stempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
- Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
- Ptempn+=Ptempi;
- Qtempn+=Qtempi;
- //calcul des nouveaux S et cos pour le composant n
- Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
- costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
- //recuperation de la source d'alimentation et de sa tension pour le composant i
- String source=loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("#¤")+2,loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¤§"));
- double sourceVoltage=1.0;
- for(int j=0;j<loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
- if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(0,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("#")).equals(source)) {
- if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().contains("convertisseur_connect.png"))
- sourceVoltage=Double.parseDouble(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().lastIndexOf(";")+1,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¢")));
- else
- sourceVoltage=Double.parseDouble(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¢")+1,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().lastIndexOf("§")));
- break;
- }
- }
- //attribution des valeurs a loadTable
- //conso pour la phase de vol du composant i
- loadTable.setValueAt(String.valueOf(getArround(Stempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT);
- //cos pour la phase de vol du composant i
- loadTable.setValueAt(String.valueOf(getArroundPF(costempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
- //amperage pour la phase de vol du composant i
- loadTable.setValueAt(String.valueOf(getArround(Stempi/sourceVoltage))+"~"+String.valueOf(sourceVoltage), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
- //conso pour la phase de vol du composant n
- loadTable.setValueAt(String.valueOf(getArround(Stempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT);
- //cos pour la phase de vol du composant n
- loadTable.setValueAt(String.valueOf(getArroundPF(costempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
- //amperage pour la phase de vol du composant n
- loadTable.setValueAt(String.valueOf(getArround(Stempn/sourceVoltage))+"~"+String.valueOf(sourceVoltage), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
- break;
- }
- }
- break;
- }
- }
- }
- }
- }
- else if (y==0&&ident.contains("/convertisseur_connect.png;")) {
- //si c'est un convertisseur
- applyConvertLoad(i+(z*OpenFileAllCSV.phaseList.size()),z);
- }
- else if (ident.contains("/equipment_connect.png;"))
- {
- //si c'est un equipement
- if(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().indexOf("|")!=-1) {
- //si il contient plusieurs FINs
- List<String> fin=new ArrayList<String>();
- String id = loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf(";")+1, loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("§"));
- do {
- fin.add(id.substring(0,id.indexOf("|")));
- id=id.substring(id.indexOf("|")+1,id.length());
- } while(id.indexOf("|")!=-1);
- for(int p=0;p<fin.size();p++) {
- //pour chaque FIN
- boolean oneLineTrue=true;
- boolean logicFalse=false;
- for(int q=0;q<EShedding.esheddingLines.size();q++) {
- //pour chaque ligne equipment shedding
- if(EShedding.esheddingLines.get(q).getESheddingFin().equals(fin.get(p))) {
- //ligne FIN repere
- oneLineTrue=false;
- for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
- //pour chaque ligne d'equations
- logicFalse=false;
- for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- //test chaque source
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
- for(int t=1;t<Logic.entetes.length;t++) {
- if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- //test pour chaque button&context
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
- for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
- if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicModeColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- //test pour chaque MOD
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
- for(int t=0;t<Mode.modeLines.size();t++) {
- if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- oneLineTrue=true;
- break;
- }
- }
- break;
- }
- }
- //meme test pour composant superieur (ici la barre)
- for (int m = 0; m < loadTableLink.getRowCount(); m++) {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥")))) {
- String barFin = loadTableLink.getValueAt(m, 1).toString().substring(loadTableLink.getValueAt(m, 1).toString().indexOf("§"),loadTableLink.getValueAt(m, 1).toString().length());
- barFin = barFin.substring(barFin.indexOf(";")+1,barFin.lastIndexOf(";;;;;"));
- for(int q=0;q<EShedding.esheddingLines.size();q++) {
- if(EShedding.esheddingLines.get(q).getESheddingFin().equals(barFin)) {
- oneLineTrue=false;
- for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
- logicFalse=false;
- for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
- for(int t=1;t<Logic.entetes.length;t++) {
- if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
- for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
- if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- for(int s=EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount();s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicModeColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContextColumnCount()+EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
- for(int t=0;t<Mode.modeLines.size();t++) {
- if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
- if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
- logicFalse=true;
- break;
- }
- }
- }
- }
- if(logicFalse)
- break;
- }
- }
- if(!logicFalse) {
- oneLineTrue=true;
- break;
- }
- }
- break;
- }
- }
- break;
- }
- }
- if(oneLineTrue) {
- for (int k = 0; k < ScenarioPage.selectedPhase.length; k++) {
- consumption=new ArrayList<Double[]>(2);
- for (int j = 1; j < OpenFileAllCSV.data.size(); j++) {
- for (int m = 0; m < OpenFileAllCSV.data.get(0).length; m++) {
- if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
- if (OpenFileAllCSV.data.get(j)[m].equals(fin.get(p))) {
- boolean condition=false;
- if(OpenFileAllCSV.optionListTable.getRowCount()==0)
- condition=true;
- for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
- if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
- if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
- for(int q=2; q<ScenarioPage.optionListTable.getRowCount();q++) {
- if(ScenarioPage.optionListModele.getValueAt(q,0).toString().startsWith(">")) {
- if(q==2&&OpenFileAllCSV.loadListTable.getRowCount()>0) {
- if(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">","").equals(OpenFileAllCSV.loadListModele.getValueAt(0,0))) {
- for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
- if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">",""))) {
- boolean continu=true;
- while(continu&&q<OpenFileAllCSV.loadListTable.getRowCount()+3) {
- if(!ScenarioPage.optionListModele.getValueAt(q+1,0).toString().startsWith(">")&&q<ScenarioPage.optionListTable.getRowCount()-1) {
- q++;
- if(OpenFileAllCSV.loadList.get(z).equals(ScenarioPage.optionListModele.getValueAt(q,0))&&OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(q,1).toString())) {
- condition=true;
- continu=false;
- } else
- condition=false;
- } else
- continu=false;
- }
- break;
- }
- }
- if(!condition)
- break;
- }
- } else {
- for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
- if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">",""))) {
- boolean continu=true;
- while(continu&&q<=ScenarioPage.optionListTable.getRowCount()-2) {
- if(!ScenarioPage.optionListModele.getValueAt(q+1,0).toString().startsWith(">")&&q<ScenarioPage.optionListTable.getRowCount()-1) {
- q++;
- if(OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(q,1).toString())) {
- condition=true;
- continu=false;
- } else
- condition=false;
- } else
- continu=false;
- }
- break;
- }
- }
- }
- if(!condition)
- break;
- }
- }
- }
- break;
- }
- }
- if(condition) {
- for (int n=0;n<OpenFileAllCSV.data.get(0).length;n++) {
- if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
- for (int l = 0; l < ScenarioPage.equipmentTable.getRowCount(); l++) {
- if (ScenarioPage.equipmentTable.getValueAt(l, 0).toString().equals(((String[])OpenFileAllCSV.data.get(j))[n])) {
- equipmentOff = true;
- break;
- }
- }
- break;
- }
- }
- if (!equipmentOff)
- findLoad(i, j, y, z, k, true);
- equipmentOff = false;
- }
- }
- break;
- }
- }
- }
- double Pt=0,Qt=0;
- for(int o=0;o<consumption.size();o++) {
- Pt+=consumption.get(o)[0];
- Qt+=consumption.get(o)[1];
- }
- int kT=3*k+1;
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥"))))
- {
- for (int n = 0; n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if (loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1)))
- {
- double costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
- Stempi=getArround(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
- Ptempi=Stempi*costempi,Qtempi=Stempi*Math.sqrt(1-Math.pow(costempi,2));
- Ptempi+=Pt;
- Qtempi+=Qt;
- Stempi=Math.sqrt(Math.pow(Ptempi,2)+Math.pow(Qtempi,2));
- costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempi!=0.0)?1.0:(Ptempi/Stempi);
- double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
- Stempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
- Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
- Ptempn+=Pt;
- Qtempn+=Qt;
- Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
- costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
- String source=loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("#¤")+2,loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¤§"));
- double sourceVoltage=1.0;
- for(int j=0;j<loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
- if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(0,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("#")).equals(source)) {
- if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().contains("convertisseur_connect.png"))
- sourceVoltage=Double.parseDouble(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().lastIndexOf(";")+1,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¢")));
- else
- sourceVoltage=Double.parseDouble(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().substring(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().indexOf("¢")+1,loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().lastIndexOf("§")));
- break;
- }
- }
- loadTable.setValueAt(String.valueOf(getArround(Stempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT);
- loadTable.setValueAt(String.valueOf(getArroundPF(costempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
- loadTable.setValueAt(String.valueOf(getArround(Stempi/sourceVoltage))+"~"+String.valueOf(sourceVoltage), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
- loadTable.setValueAt(String.valueOf(getArround(Stempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT);
- loadTable.setValueAt(String.valueOf(getArroundPF(costempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
- loadTable.setValueAt(String.valueOf(getArround(Stempn/sourceVoltage))+"~"+String.valueOf(sourceVoltage), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
- break;
- }
- }
- break;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- /**
- * Applique la conversion de sa consommation
- * @param i=ligne loadTable
- * @param z=ligne loadList (MAX/OPE/...)
- */
- private void applyConvertLoad(int i, int z)
- {
- //savoir si c'est un phase converter
- String phaseConverter = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 5, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 4);
- //connaitre la phase selectionnee
- String phase = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 3, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 2);
- //savoir si c'est un static inverter
- String staticInverter = loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf(";")-1,loadTable.getValueAt(i,0).toString().lastIndexOf(";"));
- //connaitre la source d'alimentation
- String source = loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf("#¤")+2,loadTable.getValueAt(i,0).toString().indexOf("¤§"));
- //connaitre la tension generee
- Double voltageConverter = Double.parseDouble(loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf(";")+1,loadTable.getValueAt(i,0).toString().indexOf("¢")))!=0.0?Double.parseDouble(loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf(";")+1,loadTable.getValueAt(i,0).toString().indexOf("¢"))):1.0;
- //connaitre la tension de la source d'alimentation
- Double voltageSource = 1.0;
- for(int j=0;j<this.loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
- if(this.loadModele.getValueAt(j,0).toString().substring(0, this.loadModele.getValueAt(j,0).toString().indexOf("#")).equals(source))
- if(this.loadModele.getValueAt(j,0).toString().contains("generateur_connect.png"))
- voltageSource=Double.parseDouble(this.loadModele.getValueAt(j,0).toString().substring(this.loadModele.getValueAt(j,0).toString().indexOf("¢")+1,this.loadModele.getValueAt(j,0).toString().lastIndexOf("§")));
- else if(this.loadModele.getValueAt(j,0).toString().contains("convertisseur_connect.png"))
- voltageSource=Double.parseDouble(this.loadModele.getValueAt(j,0).toString().substring(this.loadModele.getValueAt(j,0).toString().lastIndexOf(";")+1,this.loadModele.getValueAt(j,0).toString().indexOf("¢")));
- }
- //recuperation du tableau (load,powerfactor,efficiency)
- String cellule = "";
- String[] ligne = new String[3];
- List<String[]> List = new ArrayList<String[]>();
- int col = 0;
- String id = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf("†") + 1, loadTable.getValueAt(i, 0).toString().lastIndexOf("§"));
- for (int q = 0; q < id.length(); q++)
- {
- if (id.charAt(q) != '|')
- {
- cellule = cellule + id.charAt(q);
- }
- else
- {
- ligne[col] = cellule;
- cellule = "";
- if (col == 2)
- {
- col = 0;
- List.add(ligne);
- ligne = new String[3];
- }
- else
- {
- col++;
- }
- }
- }
- //connaitre le courant genere
- double convertCourant = Double.parseDouble(loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().indexOf("§") + 3, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 6));
- if (!staticInverter.equals("1"))
- {
- //si ce n'est pas un static inverter
- for (int k = 0; k < ScenarioPage.selectedPhase.length; k++)
- {
- //pour chaque phase
- int kT=3*k+1;
- double DC = Double.parseDouble((String)loadTable.getValueAt(i, kT));
- double ACA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT));
- double ACCosA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT+1));
- double ACB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT));
- double ACCosB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT+1));
- double ACC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT));
- double ACCosC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT+1));
- double loadMax = ((phaseConverter.equals("1"))?((phase.equals("A"))?ACA:((phase.equals("B"))?ACB:ACC)):DC) / (voltageConverter * convertCourant);
- //approximation du rapport de transformation suivant les valeurs les plus proches
- double loadRefX = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
- double distanceMaxX = Math.abs(loadMax - loadRefX);
- double powerFactorX = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
- double efficiencyX = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
- for (int r = 1; r < List.size(); r++)
- {
- if (Math.abs(loadMax - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceMaxX)
- {
- loadRefX = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceMaxX = Math.abs(loadMax - loadRefX);
- powerFactorX = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiencyX = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- }
- double loadRefY = loadRefX;
- double distanceMaxY = Math.abs(loadMax - Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", ".")));
- double powerFactorY = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
- double efficiencyY = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
- if(distanceMaxX>0) {
- for (int r = 1; r < List.size(); r++)
- {
- if (Math.abs(loadMax - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) <= distanceMaxY && Math.abs(loadMax - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) >= distanceMaxX)
- {
- if(loadMax<loadRefX) {
- if(Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))<loadMax) {
- loadRefY = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceMaxY = Math.abs(loadMax - loadRefY);
- powerFactorY = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiencyY = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- } else if(loadMax>loadRefX) {
- if(Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))>loadMax) {
- loadRefY = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceMaxY = Math.abs(loadMax - loadRefY);
- powerFactorY = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiencyY = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- }
- }
- }
- }
- double powerFactor = powerFactorX;
- double efficiency = efficiencyX;
- if(loadRefX!=loadRefY) {
- powerFactor = (loadMax * (powerFactorX - powerFactorY) + (loadRefX * powerFactorY) - (loadRefY * powerFactorX)) / (loadRefX - loadRefY);
- efficiency = (loadMax * (efficiencyX - efficiencyY) + (loadRefX * efficiencyY) - (loadRefY * efficiencyX)) / (loadRefX - loadRefY);
- }
- double AC = (phaseConverter.equals("1")?(phase.equals("A")?ACA:(phase.equals("B")?ACB:ACC)):DC) / (powerFactor * efficiency);
- if (!phaseConverter.equals("1"))
- {
- //si ce n'est pas un phase converter, division par 3 sur chaque phase
- loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+1, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+1, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+1, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+2, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+2, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+2, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+3, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+3, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+3, kT+2);
- //application des memes valeurs pour le composant superieur
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
- {
- for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if(loadTable.getValueAt(n, 0).toString().substring(0,loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1))&&loadTable.getValueAt(n, 0).toString().substring(loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")+1,loadTable.getValueAt(n, 0).toString().lastIndexOf("Ø")).equals(OpenFileAllCSV.loadList.get(z)))
- {
- double PtempAi,PtempBi,PtempCi,QtempAi,QtempBi,QtempCi;
- PtempAi=(AC/3)*((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?1.0:powerFactor);
- PtempBi=PtempAi;
- PtempCi=PtempAi;
- QtempAi=(AC/3)*Math.sqrt((1-Math.pow(((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?1.0:powerFactor),2)));
- QtempBi=QtempAi;
- QtempCi=QtempAi;
- double costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+1, kT+1))),costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+2, kT+1))),costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+3, kT+1))),
- StempAn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+1, kT))),StempBn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+2, kT))),StempCn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+3, kT))),
- PtempAn=StempAn*costempAn,PtempBn=StempBn*costempBn,PtempCn=StempCn*costempCn,QtempAn=StempAn*Math.sqrt(1-Math.pow(costempAn,2)),QtempBn=StempBn*Math.sqrt(1-Math.pow(costempBn,2)),QtempCn=StempCn*Math.sqrt(1-Math.pow(costempCn,2));
- PtempAn+=PtempAi;
- PtempBn+=PtempBi;
- PtempCn+=PtempCi;
- QtempAn+=QtempAi;
- QtempBn+=QtempBi;
- QtempCn+=QtempCi;
- StempAn=Math.sqrt(Math.pow(PtempAn,2)+Math.pow(QtempAn,2));
- StempBn=Math.sqrt(Math.pow(PtempBn,2)+Math.pow(QtempBn,2));
- StempCn=Math.sqrt(Math.pow(PtempCn,2)+Math.pow(QtempCn,2));
- costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempAn!=0.0)?1.0:(PtempAn/StempAn);
- costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempBn!=0.0)?1.0:(PtempBn/StempBn);
- costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempCn!=0.0)?1.0:(PtempCn/StempCn);
- loadTable.setValueAt(String.valueOf(getArround(StempAn)), n+1, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempAn)), n+1, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempAn/voltageSource))+"~"+String.valueOf(voltageSource), n+1, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(StempBn)), n+2, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempBn)), n+2, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempBn/voltageSource))+"~"+String.valueOf(voltageSource), n+2, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(StempCn)), n+3, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempCn)), n+3, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempCn/voltageSource))+"~"+String.valueOf(voltageSource), n+3, kT+2);
- break;
- }
- }
- break;
- }
- }
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+1, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+1, r+1);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+2, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+2, r+1);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+3, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+3, r+1);
- }
- }
- }
- else if (phaseConverter.equals("1")&&phase.equals("A"))
- {
- //si phase converter
- loadTable.setValueAt(String.valueOf(getArround(AC)), i+1, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosA)), i+1, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+1, kT+2);
- loadTable.setValueAt("0.0", i+2, kT);
- loadTable.setValueAt("0.0", i+2, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+2, kT+2);
- loadTable.setValueAt("0.0", i+3, kT);
- loadTable.setValueAt("0.0", i+3, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+3, kT+2);
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
- {
- for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if (loadTable.getValueAt(n, 0).toString().substring(0,loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1))&&loadTable.getValueAt(n, 0).toString().substring(loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")+1,loadTable.getValueAt(n, 0).toString().lastIndexOf("Ø")).equals(OpenFileAllCSV.loadList.get(z)))
- {
- double PtempAi,QtempAi;
- PtempAi=AC*ACCosA;
- QtempAi=AC*Math.sqrt((1-Math.pow(ACCosA,2)));
- double costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+1, kT+1))),
- StempAn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+1, kT))),
- PtempAn=StempAn*costempAn,QtempAn=StempAn*Math.sqrt(1-Math.pow(costempAn,2));
- PtempAn+=PtempAi;
- QtempAn+=QtempAi;
- StempAn=Math.sqrt(Math.pow(PtempAn,2)+Math.pow(QtempAn,2));
- costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempAn!=0.0)?1.0:(PtempAn/StempAn);
- loadTable.setValueAt(String.valueOf(getArround(StempAn)), n+1, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempAn)), n+1, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempAn/voltageSource))+"~"+String.valueOf(voltageSource), n+1, kT+2);
- break;
- }
- }
- break;
- }
- }
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+1, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+1, r+1);
- }
- }
- }
- else if (phaseConverter.equals("1")&&phase.equals("B"))
- {
- loadTable.setValueAt("0.0", i+1, kT);
- loadTable.setValueAt("0.0", i+1, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+1, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(AC)), i+2, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosB)), i+2, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+2, kT+2);
- loadTable.setValueAt("0.0", i+3, kT);
- loadTable.setValueAt("0.0", i+3, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+3, kT+2);
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
- {
- for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if (loadTable.getValueAt(n, 0).toString().substring(0,loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1))&&loadTable.getValueAt(n, 0).toString().substring(loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")+1,loadTable.getValueAt(n, 0).toString().lastIndexOf("Ø")).equals(OpenFileAllCSV.loadList.get(z)))
- {
- double PtempBi,QtempBi;
- PtempBi=AC*ACCosB;
- QtempBi=AC*Math.sqrt((1-Math.pow(ACCosB,2)));
- double costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+2, kT+1))),
- StempBn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+2, kT))),
- PtempBn=StempBn*costempBn,QtempBn=StempBn*Math.sqrt(1-Math.pow(costempBn,2));
- PtempBn+=PtempBi;
- QtempBn+=QtempBi;
- StempBn=Math.sqrt(Math.pow(PtempBn,2)+Math.pow(QtempBn,2));
- costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempBn!=0.0)?1.0:(PtempBn/StempBn);
- loadTable.setValueAt(String.valueOf(getArround(StempBn)), n+2, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempBn)), n+2, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempBn/voltageSource))+"~"+String.valueOf(voltageSource), n+2, kT+2);
- break;
- }
- }
- break;
- }
- }
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+2, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+2, r+1);
- }
- }
- }
- else if(phaseConverter.equals("1")&&phase.equals("C"))
- {
- loadTable.setValueAt("0.0", i+1, kT);
- loadTable.setValueAt("0.0", i+1, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+1, kT+2);
- loadTable.setValueAt("0.0", i+2, kT);
- loadTable.setValueAt("0.0", i+2, kT+1);
- loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+2, kT+2);
- loadTable.setValueAt(String.valueOf(getArround(AC)), i+3, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosC)), i+3, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+3, kT+2);
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
- {
- for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if (loadTable.getValueAt(n, 0).toString().substring(0,loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1))&&loadTable.getValueAt(n, 0).toString().substring(loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")+1,loadTable.getValueAt(n, 0).toString().lastIndexOf("Ø")).equals(OpenFileAllCSV.loadList.get(z)))
- {
- double PtempCi,QtempCi;
- PtempCi=AC*ACCosC;
- QtempCi=AC*Math.sqrt((1-Math.pow(ACCosC,2)));
- double costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+3, kT+1))),
- StempCn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+3, kT))),
- PtempCn=StempCn*costempCn,QtempCn=StempCn*Math.sqrt(1-Math.pow(costempCn,2));
- PtempCn+=PtempCi;
- QtempCn+=QtempCi;
- StempCn=Math.sqrt(Math.pow(PtempCn,2)+Math.pow(QtempCn,2));
- costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempCn!=0.0)?1.0:(PtempCn/StempCn);
- loadTable.setValueAt(String.valueOf(getArround(StempCn)), n+3, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempCn)), n+3, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(StempCn/voltageSource))+"~"+String.valueOf(voltageSource), n+3, kT+2);
- break;
- }
- }
- break;
- }
- }
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+3, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+3, r+1);
- }
- }
- }
- }
- }
- else
- {
- //si static inverter
- for (int k = 0; k < ScenarioPage.selectedPhase.length; k++)
- {
- int kT=3*k+1;
- double ACA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT));
- double ACCosA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT+1));
- double ACB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT));
- double ACCosB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT+1));
- double ACC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT));
- double ACCosC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT+1));
- double loadA = (ACA * ACCosA) / (3 * voltageConverter * convertCourant);
- double loadB = (ACB * ACCosB) / (3 * voltageConverter * convertCourant);
- double loadC = (ACC * ACCosC) / (3 * voltageConverter * convertCourant);
- double loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
- double distanceA = Math.abs(loadA - loadRef);
- double powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
- double efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
- for (int r = 1; r < List.size(); r++)
- {
- if (Math.abs(loadA - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceA)
- {
- loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceA = Math.abs(loadA - loadRef);
- powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- }
- double DC = (ACA * ACCosA) / (powerFactor * efficiency);
- loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
- double distanceB = Math.abs(loadB - loadRef);
- powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
- efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
- for (int r = 1; r < List.size(); r++)
- {
- if (Math.abs(loadB - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceB)
- {
- loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceB = Math.abs(loadB - loadRef);
- powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- }
- DC += (ACB * ACCosB) / (powerFactor * efficiency);
- loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
- double distanceC = Math.abs(loadC - loadRef);
- powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
- efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
- for (int r = 1; r < List.size(); r++)
- {
- if (Math.abs(loadC - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceC)
- {
- loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
- distanceC = Math.abs(loadC - loadRef);
- powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
- efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
- }
- }
- DC += (ACC * ACCosC) / (powerFactor * efficiency);
- loadTable.setValueAt(String.valueOf(getArround(DC)), i, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(DC/voltageSource))+"~"+String.valueOf(voltageSource), i, kT+2);
- for (int m = 0; m < loadTableLink.getRowCount(); m++)
- {
- if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
- {
- for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
- {
- if (loadTable.getValueAt(n, 0).toString().substring(0,loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(m, 1))&&loadTable.getValueAt(n, 0).toString().substring(loadTable.getValueAt(n, 0).toString().lastIndexOf("¥")+1,loadTable.getValueAt(n, 0).toString().lastIndexOf("Ø")).equals(OpenFileAllCSV.loadList.get(z)))
- {
- double Ptempi;
- Ptempi=DC*powerFactor;
- double Ptempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n, kT)));
- Ptempn+=Ptempi;
- double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Ptempn!=0.0)?1.0:(Ptempn/Ptempn);
- loadTable.setValueAt(String.valueOf(getArround(Ptempn)), n, kT);
- loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempn)), n, kT+1);
- loadTable.setValueAt(String.valueOf(getArround(Ptempn/voltageSource))+"~"+String.valueOf(voltageSource), n, kT+2);
- break;
- }
- }
- break;
- }
- }
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- double StempA=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+1,r))),
- costempA=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+1,r+1))),
- StempB=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+2,r))),
- costempB=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+2,r+1))),
- StempC=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+3,r))),
- costempC=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+3,r+1))),
- DCtemp=(StempA*costempA)/(powerFactor*efficiency)+(StempB*costempB)/(powerFactor*efficiency)+(StempC*costempC)/(powerFactor*efficiency);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(DCtemp/(powerFactor*efficiency))), i, r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(DCtemp/DCtemp)), i, r+1);
- }
- }
- }
- }
- }
- /**
- * Recherche les consommations du composant
- * @param i=ligne tableau LoadTable
- * @param j=ligne C/B List
- * @param y=ligne phase
- * @param z=ligne loadList (MAX/OPE/...)
- * @param k=ligne phase de vol
- * @param isEquipment
- */
- public void findLoad(int i,int j,int y, int z, int k, boolean isEquipment)
- {
- boolean equipmentPresent=false;
- List<String> list = new ArrayList<String>();
- //test si equipement present sur schema
- if(!isEquipment) {
- int p=0;
- while (GraphEditor.CBIdequipment.getItemAt(p)!=null)
- {
- int pos1=GraphEditor.CBIdequipment.getItemAt(p).toString().lastIndexOf(";");
- int pos2=GraphEditor.CBIdequipment.getItemAt(p).toString().indexOf("|");
- while(pos2>0) {
- list.add(GraphEditor.CBIdequipment.getItemAt(p).toString().substring(pos1+1,pos2));
- pos1=pos2;
- pos2=GraphEditor.CBIdequipment.getItemAt(p).toString().substring(pos1+1).indexOf("|");
- if(pos2!=-1)
- pos2+=(pos1+1);
- }
- p++;
- }
- for(int q=0;q<list.size();q++) {
- for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
- if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
- if(list.get(q).equals(OpenFileAllCSV.data.get(j)[m])) {
- equipmentPresent=true;
- break;
- }
- break;
- }
- }
- if(equipmentPresent)
- break;
- }
- }
- //s'il n'y est pas alors on peut ajouter sa conso sur la barre
- if(!equipmentPresent) {
- for (int l=0;l<OpenFileAllCSV.data.get(0).length; l++) {
- //pour chaque colonne du CSV
- if (OpenFileAllCSV.data.get(0)[l].equals(ScenarioPage.selectedPhase[k])) {
- //phase de vol selectionnee reperee, init P et Q
- double P=0,Q=0;
- for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
- //phase reperee
- if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
- //si ={(DC)/A/B/C}
- for(int o=0;o<OpenFileAllCSV.flightPhaseListTable.getRowCount();o++) {
- //pour chaque phase de vol assignee
- if(OpenFileAllCSV.flightPhaseListModele.getValueAt(o,0).equals(ScenarioPage.selectedPhase[k])) {
- //si phase de vol selectionnee = phase de vol assignee
- if(!OpenFileAllCSV.flightPhaseListModele.getValueAt(o,1).equals("")) {
- //si cosinus assigne
- for(int p=0;p<OpenFileAllCSV.data.get(0).length;p++) {
- //pour chaque colonne du CSV
- if(OpenFileAllCSV.data.get(0)[p].equals(OpenFileAllCSV.flightPhaseListModele.getValueAt(o,1))) {
- //colonne cosinus = cosinus assigne
- if(!OpenFileAllCSV.data.get(j)[p].replaceAll(" ","").equals("")) {
- //si cosinus n'est pas vide
- P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*(((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[p].replaceAll(",", ".")));
- Q=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*Math.sqrt(1-Math.pow((((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[p].replaceAll(",", "."))),2));
- break;
- } else {
- //sinon on reprend la categorie COS
- if(OpenFileAllCSV.cosListTable.getRowCount()>0) {
- //si non vide
- for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
- if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.cosListModele.getValueAt(0,0))) {
- P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*(((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[m].replaceAll(",", ".")));
- Q=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*Math.sqrt(1-Math.pow((((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[m].replaceAll(",", "."))),2));
- }
- }
- } else {
- P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."));
- Q=0.0;
- }
- break;
- }
- }
- }
- break;
- } else {
- //sinon on reprend la categorie COS
- if(OpenFileAllCSV.cosListTable.getRowCount()>0) {
- for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
- if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.cosListModele.getValueAt(0,0))) {
- P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*(((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[m].replaceAll(",", ".")));
- Q=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."))*Math.sqrt(1-Math.pow((((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[m].replaceAll(",", "."))),2));
- }
- }
- } else {
- //si non vide
- P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."));
- Q=0.0;
- }
- break;
- }
- }
- }
- //remplissage tableau par ATA
- if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
- for(int q=0;q<OpenFileAllCSV.data.get(0).length;q++) {
- if(OpenFileAllCSV.data.get(0)[q].equals(OpenFileAllCSV.ataListModele.getValueAt(0,0))) {
- if(!OpenFileAllCSV.data.get(j)[q].replaceAll(" ","").equals("")) {
- for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
- if(AtaTable.entetes[r].equals(OpenFileAllCSV.data.get(j)[q].substring(0,2))) {
- double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),r))),
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),r+1))),
- Ptemp=Stemp*costemp, Qtemp=Stemp*Math.sqrt(1-Math.pow(costemp,2));
- Ptemp+=P;
- Qtemp+=Q;
- Stemp=Math.sqrt(Math.pow(Ptemp,2)+Math.pow(Qtemp,2));
- costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stemp!=0.0)?1.0:(Ptemp/Stemp);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp)),i+y+(z*OpenFileAllCSV.phaseList.size()),r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(costemp)),i+y+(z*OpenFileAllCSV.phaseList.size()),r+1);
- String tableStyle = "";
- int lineResearch=0;
- String research=ataListTable.get(k).getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,ataListTable.get(k).getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥"));
- while(!tableStyle.contains("convertisseur")&&lineResearch>=0) {
- for (int m = 0; m < loadTableLink.getRowCount(); m++) {
- if (loadTableLink.getValueAt(m, 0).equals(research)) {
- research=loadTableLink.getValueAt(m,1).toString();
- tableStyle = loadTableLink.getValueAt(m,1).toString().substring(loadTableLink.getValueAt(m,1).toString().indexOf("#") + 1, loadTableLink.getValueAt(m,1).toString().lastIndexOf("#"));
- lineResearch = m;
- break;
- }
- lineResearch=-1;
- tableStyle="";
- }
- }
- if (lineResearch>=0) {
- for (int t = 0; t < ataListTable.get(k).getRowCount(); t += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
- if (ataListTable.get(k).getValueAt(t+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().substring(0,ataListTable.get(k).getValueAt(t+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().lastIndexOf("¥")).equals(loadTableLink.getValueAt(lineResearch, 1))) {
- double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(t+y+(z*OpenFileAllCSV.phaseList.size()), r+1))),
- Stempn=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(t+y+(z*OpenFileAllCSV.phaseList.size()), r))),
- Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
- Ptempn+=P;
- Qtempn+=Q;
- Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
- costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stempn)), t+y+(z*OpenFileAllCSV.phaseList.size()), r);
- ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costempn)), t+y+(z*OpenFileAllCSV.phaseList.size()), r+1);
- break;
- }
- }
- }
- break;
- }
- }
- }
- }
- }
- }
- }
- break;
- }
- }
- Double[] consumptions={P,Q};
- //report des consommations
- consumption.add(consumptions);
- break;
- }
- }
- }
- }
- /**
- * Retourne arroundie de d (precision pour consommation et amperage)
- * @param d
- * @return
- */
- public static double getArround(double d) {
- d = Math.round(d * Math.pow(10.0D, loadPrecisionCalculation)) / Math.pow(10.0D,loadPrecisionCalculation);
- return d;
- }
- /**
- * Retourne arroundie de d (precision pour facteur puissance)
- * @param d
- * @return
- */
- public static double getArroundPF(double d) {
- d = Math.round(d * Math.pow(10.0D, powerFactorPrecisionCalculation)) / Math.pow(10.0D,powerFactorPrecisionCalculation);
- return d;
- }
- /**
- * Retourne liste de string sans doublon
- * @param liste
- * @return
- */
- public List<String> DeleteDouble(List<String> liste)
- {
- for (int i1 = 0; i1 < liste.size(); i1++) {
- for (int i2 = i1 + 1; i2 < liste.size(); i2++) {
- if (((String)liste.get(i1)).equals(liste.get(i2))) {
- liste.remove(i2);
- i2--;
- }
- }
- }
- return liste;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement