Advertisement
Guest User

op

a guest
Dec 1st, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 127.02 KB | None | 0 0
  1. package scenario;
  2.  
  3. import cbList.open.OpenFileAllCSV;
  4.  
  5. import com.mxgraph.model.mxCell;
  6. import com.mxgraph.model.mxICell;
  7.  
  8. import elecNetwork.view.GraphEditor;
  9. import elecNetwork.view.logic.EShedding;
  10. import elecNetwork.view.logic.Logic;
  11. import elecNetwork.view.logic.LogicLine;
  12. import elecNetwork.view.logic.Mode;
  13. import elecNetwork.view.logic.SLogic;
  14. import elecNetwork.view.logic.open.OpenFileQLE;
  15.  
  16. import java.awt.Rectangle;
  17. import java.util.ArrayList;
  18. import java.util.Hashtable;
  19. import java.util.List;
  20.  
  21. import javax.swing.JFrame;
  22. import javax.swing.JScrollPane;
  23. import javax.swing.JTable;
  24.  
  25. import main.MainWindow;
  26. import scenario.export.ExportDocument;
  27.  
  28. public class Calculation extends JFrame
  29. {
  30. private static final long serialVersionUID = 1L;
  31. public String componentType;
  32. public String sourceName;
  33. public String cellName;
  34. public mxICell mxcell;
  35. public mxICell mxedge;
  36. public mxICell cellSource;
  37. public mxICell edgeSource;
  38. public mxICell nextCell;
  39. public Hashtable<String, String> linkName;
  40. public Hashtable<String, String> linkContactor;
  41. public Hashtable<String, String> linkSource;
  42. public List<mxICell[]> cellWait;
  43. //liste du tableau des charges
  44. public LoadTable loadModele;
  45. //liste des liens entre composants
  46. public LinkTable linkModele;
  47. public String[] listNull;
  48. public static JTable loadTable;
  49. public static JTable loadTableLink;
  50. public List<String> busbarList;
  51. public int ligneCpt = 0;
  52. public static ExportDocument InProgressDocument;
  53. public static int selection;
  54. public static List<Double[]> consumption;
  55. //valeurs par defaut pour precision des consommations et amperage, et facteur de puissance
  56. public static int loadPrecisionCalculation=10;
  57. public static int powerFactorPrecisionCalculation=10;
  58. public static List<JTable> ataListTable;
  59.  
  60. public Calculation(int selectionEntry)
  61. {
  62. //nombre de configuration
  63. selection=selectionEntry;
  64. this.linkName = new Hashtable<String,String>();
  65. this.linkContactor = new Hashtable<String,String>();
  66. this.linkSource = new Hashtable<String,String>();
  67. this.cellWait = new ArrayList<mxICell[]>();
  68. this.loadModele = new LoadTable();
  69. this.linkModele = new LinkTable();
  70. loadTable = new JTable(this.loadModele);
  71. loadTable.getColumnModel().getColumn(0).setPreferredWidth(187);
  72. JScrollPane paneLoadTable = new JScrollPane(loadTable);
  73. loadTable.setAutoResizeMode(0);
  74. ataListTable = new ArrayList<JTable>();
  75. for(int i=0;i<ScenarioPage.selectedPhase.length;i++)
  76. ataListTable.add(new JTable(new AtaTable()));
  77. loadTableLink = new JTable(this.linkModele);
  78. if (GraphEditor.allEdges.length != 0)
  79. {
  80. for (int i = 0; i < GraphEditor.allEdges.length; i++)
  81. {
  82. MainWindow.scenario.revalidate();
  83. ScenarioPage.progressbar.setIndeterminate(false);
  84. ScenarioPage.task.ProgressBar(i+1, GraphEditor.allEdges.length);
  85. //recherche des sources d'alimentation puis s'il s'agit d'une source ou d'une cible lors du cablage
  86. if (((((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("RAT")) ||
  87. (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("generateur")) ||
  88. (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("externalpower")) ||
  89. (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("battery"))) &&
  90. (componentCondition(((mxCell)GraphEditor.allEdges[i]).getSource().getParent())))
  91. {
  92. this.cellSource = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
  93. 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() + "§");
  94. this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
  95. this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
  96. process(1);
  97. }
  98. else if (((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().toString().contains("groundservicing"))
  99. {
  100. 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))
  101. {
  102. 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());
  103. for (int j = 0; j < GraphEditor.allCells.length; j++)
  104. {
  105. if ((!((mxCell)GraphEditor.allCells[j]).getStyle().contains("node")) && (!((mxCell)GraphEditor.allCells[j]).getStyle().contains("groundservicing")))
  106. {
  107. if (((mxCell)GraphEditor.allCells[j]).getValue().toString().equals(this.sourceName))
  108. {
  109. this.cellSource = ((mxCell)GraphEditor.allCells[j]);
  110. }
  111. }
  112. }
  113. 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()) +
  114. "#" + ((mxCell)this.cellSource).getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + this.cellSource.getId() + "§");
  115. this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
  116. this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
  117. if ((this.nextCell.getStyle().toString().contains("busbar")) && (!(this.nextCell.getValue().toString() + " ").contains("PP ")) &&
  118. (componentCondition(this.cellSource)))
  119. {
  120. process(0);
  121. }
  122. }
  123. }
  124. else if (((((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("RAT")) ||
  125. (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("generateur")) ||
  126. (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("externalpower")) ||
  127. (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("battery"))) &&
  128. (componentCondition(((mxCell)GraphEditor.allEdges[i]).getTarget().getParent())))
  129. {
  130. this.cellSource = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
  131. 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() + "§");
  132. this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
  133. this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
  134. process(1);
  135. }
  136. else if (((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().toString().contains("groundservicing"))
  137. {
  138. 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))
  139. {
  140. 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());
  141. for (int j = 0; j < GraphEditor.allCells.length; j++)
  142. {
  143. if ((!((mxCell)GraphEditor.allCells[j]).getStyle().contains("node")) && (!((mxCell)GraphEditor.allCells[j]).getStyle().contains("groundservicing")))
  144. {
  145. if (((mxCell)GraphEditor.allCells[j]).getValue().toString().equals(this.sourceName))
  146. {
  147. this.cellSource = ((mxCell)GraphEditor.allCells[j]);
  148. }
  149. }
  150. }
  151. 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()) +
  152. "#" + ((mxCell)this.cellSource).getStyle() + "#¤" + this.cellSource.getValue().toString() + "¤§" + this.cellSource.getId() + "§");
  153. this.edgeSource = ((mxICell)GraphEditor.allEdges[i]);
  154. this.nextCell = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
  155. if ((this.nextCell.getStyle().toString().contains("busbar")) && (!(this.nextCell.getValue().toString() + " ").contains("PP ")) &&
  156. (componentCondition(this.cellSource)))
  157. {
  158. process(0);
  159. }
  160. }
  161. }
  162. }
  163. ScenarioPage.etape = "% - Calculation";
  164. findLoad();
  165. }
  166. add(paneLoadTable);
  167. setBounds(new Rectangle(600, 400));
  168. // setVisible(true);
  169. for(int i=0;i<ScenarioPage.selectedPhase.length;i++) {
  170. JFrame frame = new JFrame();
  171. JScrollPane pane = new JScrollPane(ataListTable.get(i));
  172. frame.add(pane);
  173. // frame.setVisible(true);
  174. }
  175.  
  176. if (ScenarioPage.cheminOutput!=null&&ScenarioPage.cheminTemplate!=null) {
  177. ScenarioPage.etape = "% - Output file generating";
  178. ScenarioPage.task.ProgressBar(0,1);
  179. InProgressDocument.ExportDocumentRequest();
  180. }
  181. revalidate();
  182. }
  183.  
  184. /**
  185. * Effectue la liste des composants suivant la conf et le cablage)
  186. * @param cpt (0=groundServicing)
  187. */
  188. private void process(int cpt)
  189. {
  190. boolean present = false;
  191. //test si deja present dans le tableau
  192. for (int i = 0; i < loadTable.getRowCount(); i++)
  193. {
  194. if (loadTable.getValueAt(i, 0).equals(this.sourceName + "_MAX A"))
  195. {
  196. present = true;
  197. }
  198. }
  199. if (present)
  200. {
  201. present = false;
  202. }
  203. else
  204. {
  205. insertLoadLine(this.sourceName);
  206. insertAtaLine(this.sourceName);
  207. }
  208. detectComponentType(this.nextCell, this.edgeSource);
  209. if (cpt == 0)
  210. {
  211. //creation des lignes contenant les informations necessaires pour continuer
  212. this.cellName = (this.mxcell.getValue().toString() + "#" + this.mxcell.getStyle().toString() + "#¤" + this.sourceName.substring(this.sourceName.lastIndexOf("#¤") + 2, this.sourceName.lastIndexOf("¤§")) + "¤§" + this.mxcell.getId().toString() + "§");
  213. this.linkModele.addLine(new LinkLine(this.cellName, this.sourceName));
  214. insertLoadLine(this.cellName);
  215. insertAtaLine(this.cellName);
  216. }
  217. //tant que l'on n'est pas arrive a la fin du "cablage" on continue la liste
  218. while((cellWait.size()+cpt)>0)
  219. {
  220. //action suivant le type de composant
  221. switch(componentType)
  222. {
  223. case "busbar":
  224. cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
  225. //definition entre composants (ex:barre/sousbarre)
  226. linkModele.addLine(new LinkLine(cellName,sourceName));
  227. for(int i1=0;i1<loadTable.getRowCount();i1++)
  228. {
  229. if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
  230. {
  231. present=true;
  232. }
  233. }
  234. if(present)
  235. {
  236. present=false;
  237. }
  238. else
  239. {
  240. insertLoadLine(cellName);
  241. insertAtaLine(cellName);
  242. }
  243. //detecte si il y a d'autres elements apres l'actuel
  244. List<mxICell[]> list=detectAllNextEdge(mxcell, mxedge);
  245. if(list.size()!=0)
  246. {
  247. for(int i1=0;i1<list.size();i1++)
  248. {
  249. if(!list.get(i1)[0].getId().toString().contains("Node"))
  250. {
  251. linkName.put(list.get(i1)[0].getValue().toString(),cellName);
  252. }
  253. else
  254. {
  255. linkName.put(list.get(i1)[0].getId().toString(),cellName);
  256. }
  257. }
  258. cellWait.addAll(list);
  259. actionType();
  260. }
  261. break;
  262.  
  263. case "equipment":
  264. cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
  265. linkModele.addLine(new LinkLine(cellName,sourceName));
  266. for(int i1=0;i1<loadTable.getRowCount();i1++)
  267. {
  268. if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
  269. {
  270. present=true;
  271. }
  272. }
  273. if(present)
  274. {
  275. present=false;
  276. }
  277. else
  278. {
  279. insertLoadLine(cellName);
  280. insertAtaLine(cellName);
  281. }
  282. List<mxICell[]> list1=detectAllNextEdge(mxcell, mxedge);
  283. if(list1.size()!=0)
  284. {
  285. for(int i1=0;i1<list1.size();i1++)
  286. {
  287. if(!list1.get(i1)[0].getId().toString().contains("Node"))
  288. {
  289. linkName.put(list1.get(i1)[0].getValue().toString(),cellName);
  290. }
  291. else
  292. {
  293. linkName.put(list1.get(i1)[0].getId().toString(),cellName);
  294. }
  295. }
  296. cellWait.addAll(list1);
  297. actionType();
  298. }
  299. break;
  300.  
  301. case "contactor":
  302. if(componentCondition(mxcell))
  303. {
  304. List<mxICell[]> list2=detectAllNextEdge(mxcell, mxedge);
  305. if(list2.size()!=0)
  306. {
  307. for(int i1=0;i1<list2.size();i1++)
  308. {
  309. if(!list2.get(i1)[0].getId().toString().contains("Node"))
  310. {
  311. linkName.put(list2.get(i1)[0].getValue().toString(),sourceName);
  312. linkContactor.put(list2.get(i1)[0].getValue().toString(),mxcell.getValue().toString());
  313. }
  314. else
  315. {
  316. linkName.put(list2.get(i1)[0].getId().toString(),sourceName);
  317. linkContactor.put(list2.get(i1)[0].getId().toString(),mxcell.getValue().toString());
  318. }
  319. }
  320. cellWait.addAll(list2);
  321. actionType();
  322. }
  323. }
  324. break;
  325.  
  326. case "converter":
  327. cellName=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
  328. linkModele.addLine(new LinkLine(cellName,sourceName));
  329. for(int i1=0;i1<loadTable.getRowCount();i1++)
  330. {
  331. if(loadTable.getValueAt(i1, 0).equals(cellName+"_MAX A"))
  332. {
  333. present=true;
  334. }
  335. }
  336. if(present)
  337. {
  338. present=false;
  339. }
  340. else
  341. {
  342. insertLoadLine(cellName);
  343. insertAtaLine(cellName);
  344. }
  345. List<mxICell[]> list3=detectAllNextEdge(mxcell, mxedge);
  346. if(list3.size()!=0)
  347. {
  348. for(int i1=0;i1<list3.size();i1++)
  349. {
  350. if(!list3.get(i1)[0].getId().toString().contains("Node"))
  351. {
  352. linkName.put(list3.get(i1)[0].getValue().toString(),cellName);
  353. }
  354. else
  355. {
  356. linkName.put(list3.get(i1)[0].getId().toString(),cellName);
  357. }
  358. }
  359. cellWait.addAll(list3);
  360. actionType();
  361. }
  362.  
  363. case "node":
  364. List<mxICell[]> list4=detectAllNextEdge(mxcell, mxedge);
  365. if(list4.size()!=0)
  366. {
  367. for(int i1=0;i1<list4.size();i1++)
  368. {
  369. if(!list4.get(i1)[0].getId().toString().contains("Node"))
  370. {
  371. linkName.put(list4.get(i1)[0].getValue().toString(),sourceName);
  372. linkContactor.put(list4.get(i1)[0].getValue().toString(),mxcell.getId().toString());
  373. }
  374. else
  375. {
  376. linkName.put(list4.get(i1)[0].getId().toString(),sourceName);
  377. linkContactor.put(list4.get(i1)[0].getId().toString(),mxcell.getId().toString());
  378. }
  379. }
  380. cellWait.addAll(list4);
  381. actionType();
  382. }
  383. break;
  384.  
  385. case "battery":
  386.  
  387. /*????????????????*/
  388.  
  389. break;
  390.  
  391. case "groundservicing":
  392.  
  393.  
  394.  
  395. break;
  396.  
  397. case "generator":
  398.  
  399. /*????????????????*/
  400.  
  401. break;
  402.  
  403. case "rat":
  404.  
  405. /*????????????????*/
  406.  
  407. break;
  408.  
  409. case "externalpower":
  410.  
  411. /*????????????????*/
  412.  
  413. break;
  414. }
  415. cpt--;
  416. }
  417. }
  418.  
  419. private void insertLoadLine(String name)
  420. {
  421. for(int i=0;i<OpenFileAllCSV.loadList.size();i++) {
  422. for(int j=0;j<OpenFileAllCSV.phaseList.size();j++) {
  423. this.listNull = new String[loadTable.getColumnCount()-1];
  424. for (int k=0;k<this.listNull.length;k++)
  425. this.listNull[k] = "0.0";
  426. this.loadModele.addLine(new LoadLine(name +"¥"+OpenFileAllCSV.loadList.get(i)+"Ø"+OpenFileAllCSV.phaseList.get(j), this.listNull));
  427. }
  428. }
  429. }
  430. private void insertAtaLine(String name)
  431. {
  432. for(int i=0;i<OpenFileAllCSV.loadList.size();i++) {
  433. for(int j=0;j<OpenFileAllCSV.phaseList.size();j++) {
  434. for(int k=0;k<ataListTable.size();k++) {
  435. this.listNull = new String[ataListTable.get(0).getColumnCount()-1];
  436. for (int l=0;l<this.listNull.length;l++)
  437. this.listNull[l] = "0.0";
  438. ((AtaTable) ataListTable.get(k).getModel()).addLine(new AtaLine(name +"¥"+OpenFileAllCSV.loadList.get(i)+"Ø"+OpenFileAllCSV.phaseList.get(j), this.listNull));
  439. }
  440. }
  441. }
  442. }
  443.  
  444. private List<mxICell[]> detectAllNextEdge(mxICell parent, mxICell previousEdge)
  445. {
  446. List<mxICell[]> list = new ArrayList<mxICell[]>();
  447. for (int i = 0; i < GraphEditor.allEdges.length; i++)
  448. {
  449. if ((((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getId().toString().equals(((mxCell)parent).getId().toString())) &&
  450. (GraphEditor.allEdges[i] != previousEdge) && (!((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getStyle().contains("groundservicing")))
  451. {
  452. mxICell[] cell1 = new mxICell[2];
  453. cell1[0] = ((mxCell)GraphEditor.allEdges[i]).getTarget().getParent();
  454. cell1[1] = ((mxICell)GraphEditor.allEdges[i]);
  455. list.add(cell1);
  456. }
  457. else if ((((mxCell)GraphEditor.allEdges[i]).getTarget().getParent().getId().toString().equals(((mxCell)parent).getId().toString())) &&
  458. (GraphEditor.allEdges[i] != previousEdge) && (!((mxCell)GraphEditor.allEdges[i]).getSource().getParent().getStyle().contains("groundservicing")))
  459. {
  460. mxICell[] cell2 = new mxICell[2];
  461. cell2[0] = ((mxCell)GraphEditor.allEdges[i]).getSource().getParent();
  462. cell2[1] = ((mxICell)GraphEditor.allEdges[i]);
  463. list.add(cell2);
  464. }
  465. }
  466. boolean otherComponent = false;
  467.  
  468. for (int i = 0; i < list.size(); i++)
  469. {
  470. if (!((mxICell[])list.get(i))[0].getStyle().contains("contacteur"))
  471. {
  472. for (int j = i + 1; j < list.size(); j++)
  473. {
  474. if (((mxICell[])list.get(j))[0].getStyle().contains("contacteur"))
  475. {
  476. otherComponent = true;
  477. }
  478. }
  479. if (otherComponent)
  480. {
  481. list.add((mxICell[])list.get(i));
  482. list.remove(i);
  483. i--;
  484. otherComponent = false;
  485. }
  486. }
  487. }
  488.  
  489. for (int i = 0; i < list.size(); i++)
  490. {
  491. if (((mxICell[])list.get(i))[0].getStyle().contains("busbar_p"))
  492. {
  493. for (int j = i + 1; j < list.size(); j++)
  494. {
  495. if (!((mxICell[])list.get(j))[0].getStyle().contains("busbar_p"))
  496. {
  497. otherComponent = true;
  498. }
  499. }
  500. if (otherComponent)
  501. {
  502. list.add((mxICell[])list.get(i));
  503. list.remove(i);
  504. i--;
  505. otherComponent = false;
  506. }
  507. }
  508. }
  509. return list;
  510. }
  511.  
  512. private void detectComponentType(mxICell parent, mxICell connection)
  513. {
  514. if (parent.getStyle().toString().contains("busbar"))
  515. {
  516. this.componentType = "busbar";
  517. }
  518. else if (parent.getStyle().toString().contains("equipment"))
  519. {
  520. this.componentType = "equipment";
  521. }
  522. else if (parent.getStyle().toString().contains("contacteur"))
  523. {
  524. this.componentType = "contactor";
  525. }
  526. else if (parent.getStyle().toString().contains("convertisseur"))
  527. {
  528. this.componentType = "converter";
  529. }
  530. else if (parent.getStyle().toString().contains("node"))
  531. {
  532. this.componentType = "node";
  533. }
  534. else if (parent.getStyle().toString().contains("battery"))
  535. {
  536. this.componentType = "battery";
  537. }
  538. else if (parent.getStyle().toString().contains("groundservicing"))
  539. {
  540. this.componentType = "groundservicing";
  541. }
  542. else if (parent.getStyle().toString().contains("generateur"))
  543. {
  544. this.componentType = "generator";
  545. }
  546. else if (parent.getStyle().toString().contains("RAT"))
  547. {
  548. this.componentType = "rat";
  549. }
  550. else if (parent.getStyle().toString().contains("externalpower"))
  551. {
  552. this.componentType = "externalpower";
  553. }
  554. this.mxcell = parent;
  555. this.mxedge = connection;
  556. }
  557.  
  558. /**
  559. * Return true si la logique de object =1.
  560. * @param object
  561. * @return
  562. */
  563. private boolean componentCondition(mxICell object)
  564. {
  565. boolean condition = false;
  566. for (int i = 0; i < Logic.entetes.length; i++)
  567. {
  568. if (Logic.entetes[i].equals(object.getValue().toString()))
  569. {
  570. for (int j = 0; j < Logic.lines.size(); j++)
  571. {
  572. if ((((LogicLine)Logic.lines.get(j)).getColumnName().equals(ScenarioPage.configurationTable.getValueAt(selection, 0))) &&
  573. (((LogicLine)Logic.lines.get(j)).getListofLogic(i).equals("1")))
  574. {
  575. condition = true;
  576. break;
  577. }
  578. }
  579. }
  580. }
  581. return condition;
  582. }
  583.  
  584. /**
  585. * continue la liste des composants
  586. */
  587. public void actionType()
  588. {
  589. boolean present = false;
  590. String name;
  591. boolean lineWithsourceTemp = false;
  592. while(!cellWait.isEmpty())
  593. {
  594. detectComponentType(cellWait.get(0)[0],cellWait.get(0)[1]);
  595. if(!mxcell.getStyle().toString().contains("node")&&!mxcell.getStyle().toString().contains("contacteur"))
  596. {
  597. name=mxcell.getValue().toString()+"#"+mxcell.getStyle().toString()+"#¤"+sourceName.substring(sourceName.lastIndexOf("#¤")+2, sourceName.lastIndexOf("¤§"))+"¤§"+mxcell.getId().toString()+"§";
  598. }
  599. else if(!mxcell.getStyle().toString().contains("node"))
  600. {
  601. name=linkName.get(mxcell.getValue().toString());
  602. }
  603. else
  604. {
  605. name=linkName.get(mxcell.getId().toString());
  606. }
  607. //necessaire pour garder la meme source d'alimentation lorsque l'on passe ou composant suivant ou jusqu'a une autre source d'alimentation
  608. String sourceTemp="*tempNull:", linkInit="";
  609. List<LoadLine> lines = new ArrayList<LoadLine>();
  610. switch(componentType)
  611. {
  612. case "busbar":
  613. if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
  614. {
  615. 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"))
  616. {
  617. if(linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur")) {
  618. 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());
  619. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
  620. } else {
  621. linkModele.addLine(new LinkLine(name,linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())));
  622. lineWithsourceTemp=true;
  623. }
  624. }
  625. else
  626. {
  627. if(!linkName.get(cellWait.get(0)[0].getValue().toString()).contains("busbar_"))
  628. {
  629. 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());
  630. }
  631. else
  632. {
  633. 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());
  634. }
  635. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
  636. if(lineWithsourceTemp)
  637. {
  638. for(int m=0;m<loadTableLink.getRowCount();m++)
  639. {
  640. if(linkModele.getValueAt(m,1).toString().contains(linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())))
  641. {
  642. linkModele.setValueAt(m,loadTableLink.getValueAt(m,0).toString(),name);
  643. for(int n=0;n<loadTable.getRowCount();n++)
  644. {
  645. if(loadModele.getValueAt(n,0).toString().contains(linkModele.getValueAt(m,0).toString()))
  646. {
  647. LoadLine line=new LoadLine(loadModele.getLineAt(n).getRowName(),loadModele.getLineAt(n).getListofLoad());
  648. for(int p=0;p<loadTableLink.getRowCount();p++)
  649. {
  650. if(loadTableLink.getValueAt(p,0).toString().contains(line.getRowName().toString().replace("_MAX A","")))
  651. {
  652. 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());
  653. 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);
  654. 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);
  655. 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);
  656. 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);
  657. 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);
  658. 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);
  659. 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);
  660. }
  661. }
  662. 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()));
  663. lines.add(line);
  664. loadModele.removeLine(n);
  665. n--;
  666. }
  667. }
  668. }
  669. }
  670. lineWithsourceTemp=false;
  671. }
  672. }
  673. }
  674. else
  675. {
  676. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
  677. }
  678. for(int i=0;i<loadTable.getRowCount();i++)
  679. {
  680. if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
  681. {
  682. present=true;
  683. }
  684. }
  685. if(present)
  686. {
  687. present=false;
  688. }
  689. else
  690. {
  691. insertLoadLine(name);
  692. insertAtaLine(name);
  693. for(int i=0;i<lines.size();i++)
  694. {
  695. loadModele.addLine(lines.get(i));
  696. }
  697. }
  698. List<mxICell[]> list=detectAllNextEdge(mxcell, mxedge);
  699. if(list.size()!=0)
  700. {
  701. for(int i=0;i<list.size();i++)
  702. {
  703. if(!list.get(i)[0].getStyle().toString().contains("node"))
  704. {
  705. linkName.put(list.get(i)[0].getValue().toString(),name);
  706. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  707. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  708. {
  709. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  710. }
  711. linkContactor.put(list.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
  712. }
  713. else
  714. {
  715. linkName.put(list.get(i)[0].getId().toString(),name);
  716. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  717. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  718. {
  719. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  720. }
  721. linkContactor.put(list.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
  722. }
  723. }
  724. cellWait.addAll(list);
  725. }
  726. break;
  727.  
  728. case "equipment":
  729. if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
  730. {
  731. 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"))
  732. {
  733. if(linkName.get(cellWait.get(0)[0].getValue().toString()).contains("convertisseur")) {
  734. 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());
  735. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
  736. } else {
  737. linkModele.addLine(new LinkLine(name,linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())));
  738. lineWithsourceTemp=true;
  739. }
  740. }
  741. else
  742. {
  743. if(!linkName.get(cellWait.get(0)[0].getValue().toString()).contains("busbar_"))
  744. {
  745. 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());
  746. }
  747. else
  748. {
  749. 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());
  750. }
  751. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
  752. if(lineWithsourceTemp)
  753. {
  754. for(int m=0;m<loadTableLink.getRowCount();m++)
  755. {
  756. if(linkModele.getValueAt(m,1).toString().contains(linkContactor.get(cellWait.get(0)[0].getValue().toString())+sourceTemp+linkName.get(cellWait.get(0)[0].getValue().toString())))
  757. {
  758. linkModele.setValueAt(m,loadTableLink.getValueAt(m,0).toString(),name);
  759. for(int n=0;n<loadTable.getRowCount();n++)
  760. {
  761. if(loadModele.getValueAt(n,0).toString().contains(linkModele.getValueAt(m,0).toString()))
  762. {
  763. LoadLine line=new LoadLine(loadModele.getLineAt(n).getRowName(),loadModele.getLineAt(n).getListofLoad());
  764. for(int p=0;p<loadTableLink.getRowCount();p++)
  765. {
  766. if(loadTableLink.getValueAt(p,0).toString().contains(line.getRowName().toString().replace("_MAX A","")))
  767. {
  768. 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());
  769. 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);
  770. 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);
  771. 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);
  772. 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);
  773. 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);
  774. 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);
  775. 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);
  776. }
  777. }
  778. 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()));
  779. lines.add(line);
  780. loadModele.removeLine(n);
  781. n--;
  782. }
  783. }
  784. }
  785. }
  786. lineWithsourceTemp=false;
  787. }
  788. }
  789. }
  790. else
  791. {
  792. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
  793. }
  794. for(int i=0;i<loadTable.getRowCount();i++)
  795. {
  796. if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
  797. {
  798. present=true;
  799. }
  800. }
  801. if(present)
  802. {
  803. present=false;
  804. }
  805. else
  806. {
  807. insertLoadLine(name);
  808. insertAtaLine(name);
  809. for(int i=0;i<lines.size();i++)
  810. {
  811. loadModele.addLine(lines.get(i));
  812. }
  813. }
  814. List<mxICell[]> list1=detectAllNextEdge(mxcell, mxedge);
  815. if(list1.size()!=0)
  816. {
  817. for(int i=0;i<list1.size();i++)
  818. {
  819. if(!list1.get(i)[0].getStyle().toString().contains("node"))
  820. {
  821. linkName.put(list1.get(i)[0].getValue().toString(),name);
  822. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  823. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  824. {
  825. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  826. }
  827. linkContactor.put(list1.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
  828. }
  829. else
  830. {
  831. linkName.put(list1.get(i)[0].getId().toString(),name);
  832. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  833. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  834. {
  835. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  836. }
  837. linkContactor.put(list1.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
  838. }
  839. }
  840. cellWait.addAll(list1);
  841. }
  842. break;
  843.  
  844. case "contactor":
  845. if(componentCondition(mxcell))
  846. {
  847. List<mxICell[]> list2=detectAllNextEdge(mxcell, mxedge);
  848. if(list2.size()!=0)
  849. {
  850. for(int i=0;i<list2.size();i++)
  851. {
  852. if(!list2.get(i)[0].getStyle().toString().contains("node"))
  853. {
  854. linkName.put(list2.get(i)[0].getValue().toString(),name);
  855. linkInit="@"+mxcell.getValue().toString()+"@"+linkContactor.get(mxcell.getValue().toString())+"@";
  856. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  857. {
  858. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  859. }
  860. linkContactor.put(list2.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
  861. }
  862. else
  863. {
  864. linkName.put(list2.get(i)[0].getId().toString(),name);
  865. linkInit="@"+mxcell.getValue().toString()+"@"+linkContactor.get(mxcell.getValue().toString())+"@";
  866. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  867. {
  868. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  869. }
  870. linkContactor.put(list2.get(i)[0].getId().toString(),mxcell.getValue().toString());
  871. }
  872. }
  873. cellWait.addAll(list2);
  874. }
  875. }
  876. break;
  877.  
  878. case "converter":
  879. if(componentCondition(mxcell))
  880. {
  881. if(!cellWait.get(0)[0].getStyle().toString().contains("node"))
  882. {
  883. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getValue().toString())));
  884. }
  885. else
  886. {
  887. linkModele.addLine(new LinkLine(name,linkName.get(cellWait.get(0)[0].getId().toString())));
  888. }
  889. for(int i=0;i<loadTable.getRowCount();i++)
  890. {
  891. if(loadTable.getValueAt(i, 0).equals(name+"_MAX A"))
  892. {
  893. present=true;
  894. }
  895. }
  896. if(present)
  897. {
  898. present=false;
  899. }
  900. else
  901. {
  902. insertLoadLine(name);
  903. insertAtaLine(name);
  904. }
  905. List<mxICell[]> list3=detectAllNextEdge(mxcell, mxedge);
  906. if(list3.size()!=0)
  907. {
  908. for(int i=0;i<list3.size();i++)
  909. {
  910. if(!list3.get(i)[0].getStyle().toString().contains("node"))
  911. {
  912. linkName.put(list3.get(i)[0].getValue().toString(),name);
  913. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  914. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  915. {
  916. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  917. }
  918. linkContactor.put(list3.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
  919. }
  920. else
  921. {
  922. linkName.put(list3.get(i)[0].getId().toString(),name);
  923. linkInit="@"+linkContactor.get(mxcell.getValue().toString())+"@";
  924. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  925. {
  926. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  927. }
  928. linkContactor.put(list3.get(i)[0].getId().toString(),linkContactor.get(mxcell.getValue().toString()));
  929. }
  930. }
  931. cellWait.addAll(list3);
  932. }
  933. }
  934. break;
  935.  
  936. case "node":
  937. List<mxICell[]> list4=detectAllNextEdge(mxcell, mxedge);
  938. if(list4.size()!=0)
  939. {
  940. for(int i=0;i<list4.size();i++)
  941. {
  942. if(!list4.get(i)[0].getStyle().toString().contains("node"))
  943. {
  944. linkName.put(list4.get(i)[0].getValue().toString(),name);
  945. linkInit="@"+linkContactor.get(mxcell.getId().toString())+"@";
  946. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  947. {
  948. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  949. }
  950. linkContactor.put(list4.get(i)[0].getValue().toString(),linkInit.substring(1,linkInit.length()-1));
  951. }
  952. else
  953. {
  954. linkName.put(list4.get(i)[0].getId().toString(),name);
  955. linkInit="@"+linkContactor.get(mxcell.getId().toString())+"@";
  956. while(linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))!=null)
  957. {
  958. linkInit=linkInit+linkContactor.get(linkInit.substring(linkInit.substring(0,linkInit.length()-1).lastIndexOf("@")+1,linkInit.lastIndexOf("@")))+"@";
  959. }
  960. linkContactor.put(list4.get(i)[0].getId().toString(),linkContactor.get(mxcell.getId().toString()));
  961. }
  962. }
  963. cellWait.addAll(list4);
  964. }
  965. break;
  966.  
  967. case "battery":
  968.  
  969. /*????????????????*/
  970.  
  971. break;
  972.  
  973. case "groundservicing":
  974.  
  975. /*????????????????*/
  976.  
  977. break;
  978.  
  979. case "generator":
  980.  
  981. /*????????????????*/
  982.  
  983. break;
  984.  
  985. case "rat":
  986.  
  987. /*????????????????*/
  988.  
  989. break;
  990.  
  991. case "externalpower":
  992.  
  993. /*????????????????*/
  994.  
  995. break;
  996.  
  997. default :
  998. break;
  999. }
  1000. cellWait.remove(0);
  1001. }
  1002. }
  1003.  
  1004. /**
  1005. * Recherche et somme les consomations
  1006. */
  1007. private void findLoad()
  1008. {
  1009. boolean equipmentOff = false;
  1010. int progress=loadTable.getRowCount();
  1011. new SLogic();
  1012. ScenarioPage.task.ProgressBar(0, progress);
  1013. //pour toutes les x lignes en remontant la liste des composants (loadTable)
  1014. for (int i = loadTable.getRowCount() - (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()); i >= 0; i -= (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
  1015. //pour toutes les lignes de loadList (ex:MAX/OPE/...)
  1016. for(int z=0;z<OpenFileAllCSV.loadList.size();z++) {
  1017. //pour toutes les phases de phaseList(ex:DC,A,B,C)
  1018. for(int y=0;y<OpenFileAllCSV.phaseList.size();y++) {
  1019. ScenarioPage.task.ProgressBar(progress-i+y+(z*OpenFileAllCSV.phaseList.size()), progress);
  1020. //type de composant
  1021. 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("#"));
  1022. //si c'est une busbar
  1023. if ((ident.contains("busbar_w.png;")) || (ident.contains("busbar_p.png;"))) {
  1024. //designation
  1025. 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("#"));
  1026. //FIN
  1027. 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());
  1028. fin = fin.substring(fin.indexOf(";")+1,fin.lastIndexOf(";;;;;"));
  1029. //oneLineTrue=true <=> composant non deleste
  1030. boolean oneLineTrue=true;
  1031. //on ne continue pas avec ce composant des que l'on trouve un condition fausse
  1032. boolean logicFalse=false;
  1033. //savoir si delester ou non
  1034. for(int q=0;q<EShedding.esheddingLines.size();q++) {
  1035. //recherche de la ligne correspondant au FIN
  1036. if(EShedding.esheddingLines.get(q).getESheddingFin().equals(fin)) {
  1037. oneLineTrue=false;
  1038. for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
  1039. logicFalse=false;
  1040. //analyse des equations, test dans l'ordre la logique des composants, des boutons&contexts puis des MODs
  1041. for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
  1042. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
  1043. for(int t=1;t<Logic.entetes.length;t++) {
  1044. if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
  1045. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
  1046. logicFalse=true;
  1047. break;
  1048. }
  1049. }
  1050. }
  1051. }
  1052. if(logicFalse)
  1053. break;
  1054. }
  1055. if(!logicFalse) {
  1056. 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++) {
  1057. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
  1058. for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
  1059. if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
  1060. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
  1061. logicFalse=true;
  1062. break;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. if(logicFalse)
  1068. break;
  1069. }
  1070. }
  1071. if(!logicFalse) {
  1072. 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++) {
  1073. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
  1074. for(int t=0;t<Mode.modeLines.size();t++) {
  1075. if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
  1076. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
  1077. logicFalse=true;
  1078. break;
  1079. }
  1080. }
  1081. }
  1082. }
  1083. if(logicFalse)
  1084. break;
  1085. }
  1086. }
  1087. if(!logicFalse) {
  1088. oneLineTrue=true;
  1089. break;
  1090. }
  1091. }
  1092. break;
  1093. }
  1094. }
  1095. //si non deleste
  1096. if(oneLineTrue) {
  1097. //pour chaque phase de vol selectionnee
  1098. for (int k = 0; k < ScenarioPage.selectedPhase.length; k++) {
  1099. //taille =2 pour P et Q
  1100. consumption=new ArrayList<Double[]>(2);
  1101. for(int j = 1; j < OpenFileAllCSV.data.size(); j++) {
  1102. //pour chaque ligne du CSV
  1103. for(int m = 0; m < OpenFileAllCSV.data.get(0).length; m++) {
  1104. //pour chaque colonne du CSV
  1105. if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.busbarListModele.getValueAt(0,0))) {
  1106. //colonne busbar repere
  1107. if(OpenFileAllCSV.data.get(j)[m].equals(id)) {
  1108. //designation busbar repere
  1109. boolean condition=false;
  1110. if(OpenFileAllCSV.optionListTable.getRowCount()==0)
  1111. condition=true;
  1112. for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
  1113. //pour chaque colonne du CSV
  1114. if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
  1115. //colonne phase repere
  1116. if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
  1117. //phase repere
  1118. for(int p=2; p<ScenarioPage.optionListTable.getRowCount();p++) {
  1119. //pour chaque option (sauf cos)
  1120. if(ScenarioPage.optionListModele.getValueAt(p,0).toString().startsWith(">")) {
  1121. //titre option repere (ex:>Load)
  1122. if(p==2&&OpenFileAllCSV.loadListTable.getRowCount()>0) {
  1123. //si option >Load presente
  1124. if(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">","").equals(OpenFileAllCSV.loadListModele.getValueAt(0,0))) {
  1125. for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
  1126. //pour chaque colonne du CSV
  1127. if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">",""))) {
  1128. //colonne Load repere
  1129. boolean continu=true;
  1130. //test si option fausse ou fin option =sortie boucle
  1131. while(continu&&p<OpenFileAllCSV.loadListTable.getRowCount()+3) {
  1132. if(!ScenarioPage.optionListModele.getValueAt(p+1,0).toString().startsWith(">")&&p<ScenarioPage.optionListTable.getRowCount()-1) {
  1133. p++;
  1134. 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())) {
  1135. condition=true;
  1136. continu=false;
  1137. } else
  1138. condition=false;
  1139. } else
  1140. continu=false;
  1141. }
  1142. break;
  1143. }
  1144. }
  1145. if(!condition)
  1146. break;
  1147. }
  1148. } else {
  1149. for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
  1150. //pour chaque colonne du CSV
  1151. if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0).toString().replaceFirst(">",""))) {
  1152. //colonne "option" repere (ex:C,S,...)
  1153. boolean continu=true;
  1154. //test si option fausse ou fin option =sortie boucle
  1155. while(continu&&p<=ScenarioPage.optionListTable.getRowCount()-2) {
  1156. if(!ScenarioPage.optionListModele.getValueAt(p+1,0).toString().startsWith(">")&&p<ScenarioPage.optionListTable.getRowCount()-1) {
  1157. p++;
  1158. if(OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(p,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(p,1).toString())) {
  1159. condition=true;
  1160. continu=false;
  1161. } else
  1162. condition=false;
  1163. } else
  1164. continu=false;
  1165. }
  1166. break;
  1167. }
  1168. }
  1169. }
  1170. if(!condition)
  1171. break;
  1172. }
  1173. }
  1174. }
  1175. break;
  1176. }
  1177. }
  1178. //si condition=true alors on recherchera la consommation
  1179. if(condition) {
  1180. for (int n=0;n<OpenFileAllCSV.data.get(0).length;n++) {
  1181. //pour chaque colonne du CSV
  1182. if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
  1183. //colone FIN repere
  1184. for (int l = 0; l < ScenarioPage.equipmentTable.getRowCount(); l++) {
  1185. //test si FIN desactive
  1186. if (ScenarioPage.equipmentTable.getValueAt(l, 0).toString().equals(((String[])OpenFileAllCSV.data.get(j))[n])) {
  1187. equipmentOff = true;
  1188. break;
  1189. }
  1190. }
  1191. break;
  1192. }
  1193. }
  1194. if (!equipmentOff)
  1195. //recherche des consommations
  1196. findLoad(i, j, y, z, k, false);
  1197. equipmentOff = false;
  1198. }
  1199. }
  1200. break;
  1201. }
  1202. }
  1203. }
  1204. double Pt=0,Qt=0;
  1205. for(int o=0;o<consumption.size();o++) {
  1206. //calcul de P et Q total
  1207. Pt+=consumption.get(o)[0];
  1208. Qt+=consumption.get(o)[1];
  1209. }
  1210. //necessaire pour attribuer les valeurs sur 3 colonnes (conso, cos, ampere) par phase de vol
  1211. int kT=3*k+1;
  1212. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1213. {
  1214. //pour chaque ligne de la liste des liens entre composant
  1215. 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("¥"))))
  1216. {
  1217. //nom du composant superieur (n) au composant (i) repere
  1218. for (int n = 0; n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1219. {
  1220. //pour chaque ligne de loadTable
  1221. 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)))
  1222. {
  1223. //composant superieur n repere, init cos et S, calcul de P et Q pour le composant i avec les consommations deja presentes sur loadTable
  1224. double costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
  1225. Stempi=getArround(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
  1226. Ptempi=Stempi*costempi,Qtempi=Stempi*Math.sqrt(1-Math.pow(costempi,2));
  1227. Ptempi+=Pt;
  1228. Qtempi+=Qt;
  1229. //calcul des nouveaux S et cos pour le composant i
  1230. Stempi=Math.sqrt(Math.pow(Ptempi,2)+Math.pow(Qtempi,2));
  1231. costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempi!=0.0)?1.0:(Ptempi/Stempi);
  1232.  
  1233. //init cos et S, calcul de P et Q pour le composant n avec les consommations deja presentes sur loadTable
  1234. double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
  1235. Stempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
  1236. Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
  1237. Ptempn+=Ptempi;
  1238. Qtempn+=Qtempi;
  1239. //calcul des nouveaux S et cos pour le composant n
  1240. Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
  1241. costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
  1242.  
  1243. //recuperation de la source d'alimentation et de sa tension pour le composant i
  1244. 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("¤§"));
  1245. double sourceVoltage=1.0;
  1246. for(int j=0;j<loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
  1247. 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)) {
  1248. if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().contains("convertisseur_connect.png"))
  1249. 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("¢")));
  1250. else
  1251. 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("§")));
  1252. break;
  1253. }
  1254. }
  1255. //attribution des valeurs a loadTable
  1256. //conso pour la phase de vol du composant i
  1257. loadTable.setValueAt(String.valueOf(getArround(Stempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT);
  1258. //cos pour la phase de vol du composant i
  1259. loadTable.setValueAt(String.valueOf(getArroundPF(costempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
  1260. //amperage pour la phase de vol du composant i
  1261. loadTable.setValueAt(String.valueOf(getArround(Stempi/sourceVoltage))+"~"+String.valueOf(sourceVoltage), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
  1262. //conso pour la phase de vol du composant n
  1263. loadTable.setValueAt(String.valueOf(getArround(Stempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT);
  1264. //cos pour la phase de vol du composant n
  1265. loadTable.setValueAt(String.valueOf(getArroundPF(costempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
  1266. //amperage pour la phase de vol du composant n
  1267. loadTable.setValueAt(String.valueOf(getArround(Stempn/sourceVoltage))+"~"+String.valueOf(sourceVoltage), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
  1268. break;
  1269. }
  1270. }
  1271. break;
  1272. }
  1273. }
  1274. }
  1275. }
  1276. }
  1277. else if (y==0&&ident.contains("/convertisseur_connect.png;")) {
  1278. //si c'est un convertisseur
  1279. applyConvertLoad(i+(z*OpenFileAllCSV.phaseList.size()),z);
  1280. }
  1281. else if (ident.contains("/equipment_connect.png;"))
  1282. {
  1283. //si c'est un equipement
  1284. if(loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), 0).toString().indexOf("|")!=-1) {
  1285. //si il contient plusieurs FINs
  1286. List<String> fin=new ArrayList<String>();
  1287. 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("§"));
  1288. do {
  1289. fin.add(id.substring(0,id.indexOf("|")));
  1290. id=id.substring(id.indexOf("|")+1,id.length());
  1291. } while(id.indexOf("|")!=-1);
  1292. for(int p=0;p<fin.size();p++) {
  1293. //pour chaque FIN
  1294. boolean oneLineTrue=true;
  1295. boolean logicFalse=false;
  1296. for(int q=0;q<EShedding.esheddingLines.size();q++) {
  1297. //pour chaque ligne equipment shedding
  1298. if(EShedding.esheddingLines.get(q).getESheddingFin().equals(fin.get(p))) {
  1299. //ligne FIN repere
  1300. oneLineTrue=false;
  1301. for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
  1302. //pour chaque ligne d'equations
  1303. logicFalse=false;
  1304. for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
  1305. //test chaque source
  1306. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
  1307. for(int t=1;t<Logic.entetes.length;t++) {
  1308. if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
  1309. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
  1310. logicFalse=true;
  1311. break;
  1312. }
  1313. }
  1314. }
  1315. }
  1316. if(logicFalse)
  1317. break;
  1318. }
  1319. if(!logicFalse) {
  1320. 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++) {
  1321. //test pour chaque button&context
  1322. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
  1323. for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
  1324. if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
  1325. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
  1326. logicFalse=true;
  1327. break;
  1328. }
  1329. }
  1330. }
  1331. }
  1332. if(logicFalse)
  1333. break;
  1334. }
  1335. }
  1336. if(!logicFalse) {
  1337. 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++) {
  1338. //test pour chaque MOD
  1339. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
  1340. for(int t=0;t<Mode.modeLines.size();t++) {
  1341. if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
  1342. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
  1343. logicFalse=true;
  1344. break;
  1345. }
  1346. }
  1347. }
  1348. }
  1349. if(logicFalse)
  1350. break;
  1351. }
  1352. }
  1353. if(!logicFalse) {
  1354. oneLineTrue=true;
  1355. break;
  1356. }
  1357. }
  1358. break;
  1359. }
  1360. }
  1361. //meme test pour composant superieur (ici la barre)
  1362. for (int m = 0; m < loadTableLink.getRowCount(); m++) {
  1363. 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("¥")))) {
  1364. String barFin = loadTableLink.getValueAt(m, 1).toString().substring(loadTableLink.getValueAt(m, 1).toString().indexOf("§"),loadTableLink.getValueAt(m, 1).toString().length());
  1365. barFin = barFin.substring(barFin.indexOf(";")+1,barFin.lastIndexOf(";;;;;"));
  1366. for(int q=0;q<EShedding.esheddingLines.size();q++) {
  1367. if(EShedding.esheddingLines.get(q).getESheddingFin().equals(barFin)) {
  1368. oneLineTrue=false;
  1369. for(int r=0;r<EShedding.esheddingLines.get(q).getESheddingTableRowCount();r++) {
  1370. logicFalse=false;
  1371. for(int s=0;s<EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSourceColumnCount();s++) {
  1372. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).toString().equals("X")) {
  1373. for(int t=1;t<Logic.entetes.length;t++) {
  1374. if(Logic.entetes[t].equals(SLogic.entetesSLogic[s])) {
  1375. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicSource(s).equals(Logic.lines.get(selection).getListofLogic(t))) {
  1376. logicFalse=true;
  1377. break;
  1378. }
  1379. }
  1380. }
  1381. }
  1382. if(logicFalse)
  1383. break;
  1384. }
  1385. if(!logicFalse) {
  1386. 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++) {
  1387. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).toString().equals("X")) {
  1388. for(int t=0;t<OpenFileQLE.bContextList.get(selection).getRowCount();t++) {
  1389. if(OpenFileQLE.bContextList.get(selection).getValueAt(t,1).equals(SLogic.entetesSLogic[s])) {
  1390. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicBContext(s).equals(((boolean) OpenFileQLE.bContextList.get(selection).getValueAt(t,0)?"1":"0"))) {
  1391. logicFalse=true;
  1392. break;
  1393. }
  1394. }
  1395. }
  1396. }
  1397. if(logicFalse)
  1398. break;
  1399. }
  1400. }
  1401. if(!logicFalse) {
  1402. 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++) {
  1403. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).toString().equals("X")) {
  1404. for(int t=0;t<Mode.modeLines.size();t++) {
  1405. if(Mode.modeLines.get(t).getModeName().equals(SLogic.entetesSLogic[s])) {
  1406. if(!EShedding.esheddingLines.get(q).getESheddingTable().get(r).getSLogicMode(s).equals((Mode.modeLines.get(t).getModeBool()?"1":"0"))) {
  1407. logicFalse=true;
  1408. break;
  1409. }
  1410. }
  1411. }
  1412. }
  1413. if(logicFalse)
  1414. break;
  1415. }
  1416. }
  1417. if(!logicFalse) {
  1418. oneLineTrue=true;
  1419. break;
  1420. }
  1421. }
  1422. break;
  1423. }
  1424. }
  1425. break;
  1426. }
  1427. }
  1428. if(oneLineTrue) {
  1429. for (int k = 0; k < ScenarioPage.selectedPhase.length; k++) {
  1430. consumption=new ArrayList<Double[]>(2);
  1431. for (int j = 1; j < OpenFileAllCSV.data.size(); j++) {
  1432. for (int m = 0; m < OpenFileAllCSV.data.get(0).length; m++) {
  1433. if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
  1434. if (OpenFileAllCSV.data.get(j)[m].equals(fin.get(p))) {
  1435. boolean condition=false;
  1436. if(OpenFileAllCSV.optionListTable.getRowCount()==0)
  1437. condition=true;
  1438. for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
  1439. if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
  1440. if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
  1441. for(int q=2; q<ScenarioPage.optionListTable.getRowCount();q++) {
  1442. if(ScenarioPage.optionListModele.getValueAt(q,0).toString().startsWith(">")) {
  1443. if(q==2&&OpenFileAllCSV.loadListTable.getRowCount()>0) {
  1444. if(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">","").equals(OpenFileAllCSV.loadListModele.getValueAt(0,0))) {
  1445. for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
  1446. if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">",""))) {
  1447. boolean continu=true;
  1448. while(continu&&q<OpenFileAllCSV.loadListTable.getRowCount()+3) {
  1449. if(!ScenarioPage.optionListModele.getValueAt(q+1,0).toString().startsWith(">")&&q<ScenarioPage.optionListTable.getRowCount()-1) {
  1450. q++;
  1451. 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())) {
  1452. condition=true;
  1453. continu=false;
  1454. } else
  1455. condition=false;
  1456. } else
  1457. continu=false;
  1458. }
  1459. break;
  1460. }
  1461. }
  1462. if(!condition)
  1463. break;
  1464. }
  1465. } else {
  1466. for (int o = 0; o < OpenFileAllCSV.data.get(0).length; o++) {
  1467. if(OpenFileAllCSV.data.get(0)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0).toString().replaceFirst(">",""))) {
  1468. boolean continu=true;
  1469. while(continu&&q<=ScenarioPage.optionListTable.getRowCount()-2) {
  1470. if(!ScenarioPage.optionListModele.getValueAt(q+1,0).toString().startsWith(">")&&q<ScenarioPage.optionListTable.getRowCount()-1) {
  1471. q++;
  1472. if(OpenFileAllCSV.data.get(j)[o].equals(ScenarioPage.optionListModele.getValueAt(q,0))&&Boolean.valueOf(ScenarioPage.optionListModele.getValueAt(q,1).toString())) {
  1473. condition=true;
  1474. continu=false;
  1475. } else
  1476. condition=false;
  1477. } else
  1478. continu=false;
  1479. }
  1480. break;
  1481. }
  1482. }
  1483. }
  1484. if(!condition)
  1485. break;
  1486. }
  1487. }
  1488. }
  1489. break;
  1490. }
  1491. }
  1492. if(condition) {
  1493. for (int n=0;n<OpenFileAllCSV.data.get(0).length;n++) {
  1494. if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
  1495. for (int l = 0; l < ScenarioPage.equipmentTable.getRowCount(); l++) {
  1496. if (ScenarioPage.equipmentTable.getValueAt(l, 0).toString().equals(((String[])OpenFileAllCSV.data.get(j))[n])) {
  1497. equipmentOff = true;
  1498. break;
  1499. }
  1500. }
  1501. break;
  1502. }
  1503. }
  1504. if (!equipmentOff)
  1505. findLoad(i, j, y, z, k, true);
  1506. equipmentOff = false;
  1507. }
  1508. }
  1509. break;
  1510. }
  1511. }
  1512. }
  1513. double Pt=0,Qt=0;
  1514. for(int o=0;o<consumption.size();o++) {
  1515. Pt+=consumption.get(o)[0];
  1516. Qt+=consumption.get(o)[1];
  1517.  
  1518. }
  1519. int kT=3*k+1;
  1520. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1521. {
  1522. 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("¥"))))
  1523. {
  1524. for (int n = 0; n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1525. {
  1526. 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)))
  1527. {
  1528. double costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
  1529. Stempi=getArround(Double.parseDouble((String)loadTable.getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
  1530. Ptempi=Stempi*costempi,Qtempi=Stempi*Math.sqrt(1-Math.pow(costempi,2));
  1531. Ptempi+=Pt;
  1532. Qtempi+=Qt;
  1533. Stempi=Math.sqrt(Math.pow(Ptempi,2)+Math.pow(Qtempi,2));
  1534. costempi=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempi!=0.0)?1.0:(Ptempi/Stempi);
  1535.  
  1536. double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1))),
  1537. Stempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+y+(z*OpenFileAllCSV.phaseList.size()), kT))),
  1538. Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
  1539. Ptempn+=Pt;
  1540. Qtempn+=Qt;
  1541. Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
  1542. costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
  1543.  
  1544. 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("¤§"));
  1545. double sourceVoltage=1.0;
  1546. for(int j=0;j<loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
  1547. 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)) {
  1548. if(loadTable.getValueAt(j+y+(z*OpenFileAllCSV.phaseList.size()),0).toString().contains("convertisseur_connect.png"))
  1549. 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("¢")));
  1550. else
  1551. 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("§")));
  1552. break;
  1553. }
  1554. }
  1555.  
  1556. loadTable.setValueAt(String.valueOf(getArround(Stempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT);
  1557. loadTable.setValueAt(String.valueOf(getArroundPF(costempi)), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
  1558. loadTable.setValueAt(String.valueOf(getArround(Stempi/sourceVoltage))+"~"+String.valueOf(sourceVoltage), i+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
  1559. loadTable.setValueAt(String.valueOf(getArround(Stempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT);
  1560. loadTable.setValueAt(String.valueOf(getArroundPF(costempn)), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+1);
  1561. loadTable.setValueAt(String.valueOf(getArround(Stempn/sourceVoltage))+"~"+String.valueOf(sourceVoltage), n+y+(z*OpenFileAllCSV.phaseList.size()), kT+2);
  1562. break;
  1563. }
  1564. }
  1565. break;
  1566. }
  1567. }
  1568. }
  1569. }
  1570. }
  1571. }
  1572. }
  1573. }
  1574. }
  1575. }
  1576. }
  1577.  
  1578. /**
  1579. * Applique la conversion de sa consommation
  1580. * @param i=ligne loadTable
  1581. * @param z=ligne loadList (MAX/OPE/...)
  1582. */
  1583. private void applyConvertLoad(int i, int z)
  1584. {
  1585. //savoir si c'est un phase converter
  1586. String phaseConverter = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 5, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 4);
  1587. //connaitre la phase selectionnee
  1588. String phase = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 3, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 2);
  1589. //savoir si c'est un static inverter
  1590. String staticInverter = loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf(";")-1,loadTable.getValueAt(i,0).toString().lastIndexOf(";"));
  1591. //connaitre la source d'alimentation
  1592. String source = loadTable.getValueAt(i,0).toString().substring(loadTable.getValueAt(i,0).toString().lastIndexOf("#¤")+2,loadTable.getValueAt(i,0).toString().indexOf("¤§"));
  1593. //connaitre la tension generee
  1594. 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;
  1595. //connaitre la tension de la source d'alimentation
  1596. Double voltageSource = 1.0;
  1597. for(int j=0;j<this.loadModele.getRowCount();j+=(OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
  1598. if(this.loadModele.getValueAt(j,0).toString().substring(0, this.loadModele.getValueAt(j,0).toString().indexOf("#")).equals(source))
  1599. if(this.loadModele.getValueAt(j,0).toString().contains("generateur_connect.png"))
  1600. 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("§")));
  1601. else if(this.loadModele.getValueAt(j,0).toString().contains("convertisseur_connect.png"))
  1602. 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("¢")));
  1603. }
  1604. //recuperation du tableau (load,powerfactor,efficiency)
  1605. String cellule = "";
  1606. String[] ligne = new String[3];
  1607. List<String[]> List = new ArrayList<String[]>();
  1608. int col = 0;
  1609. String id = loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().lastIndexOf("†") + 1, loadTable.getValueAt(i, 0).toString().lastIndexOf("§"));
  1610. for (int q = 0; q < id.length(); q++)
  1611. {
  1612. if (id.charAt(q) != '|')
  1613. {
  1614. cellule = cellule + id.charAt(q);
  1615. }
  1616. else
  1617. {
  1618. ligne[col] = cellule;
  1619. cellule = "";
  1620. if (col == 2)
  1621. {
  1622. col = 0;
  1623. List.add(ligne);
  1624. ligne = new String[3];
  1625. }
  1626. else
  1627. {
  1628. col++;
  1629. }
  1630. }
  1631. }
  1632. //connaitre le courant genere
  1633. double convertCourant = Double.parseDouble(loadTable.getValueAt(i, 0).toString().substring(loadTable.getValueAt(i, 0).toString().indexOf("§") + 3, loadTable.getValueAt(i, 0).toString().lastIndexOf(";") - 6));
  1634. if (!staticInverter.equals("1"))
  1635. {
  1636. //si ce n'est pas un static inverter
  1637. for (int k = 0; k < ScenarioPage.selectedPhase.length; k++)
  1638. {
  1639. //pour chaque phase
  1640. int kT=3*k+1;
  1641. double DC = Double.parseDouble((String)loadTable.getValueAt(i, kT));
  1642. double ACA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT));
  1643. double ACCosA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT+1));
  1644. double ACB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT));
  1645. double ACCosB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT+1));
  1646. double ACC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT));
  1647. double ACCosC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT+1));
  1648. double loadMax = ((phaseConverter.equals("1"))?((phase.equals("A"))?ACA:((phase.equals("B"))?ACB:ACC)):DC) / (voltageConverter * convertCourant);
  1649.  
  1650. //approximation du rapport de transformation suivant les valeurs les plus proches
  1651. double loadRefX = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
  1652. double distanceMaxX = Math.abs(loadMax - loadRefX);
  1653. double powerFactorX = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
  1654. double efficiencyX = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
  1655. for (int r = 1; r < List.size(); r++)
  1656. {
  1657. if (Math.abs(loadMax - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceMaxX)
  1658. {
  1659. loadRefX = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1660. distanceMaxX = Math.abs(loadMax - loadRefX);
  1661. powerFactorX = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1662. efficiencyX = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1663. }
  1664. }
  1665. double loadRefY = loadRefX;
  1666. double distanceMaxY = Math.abs(loadMax - Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", ".")));
  1667. double powerFactorY = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
  1668. double efficiencyY = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
  1669. if(distanceMaxX>0) {
  1670. for (int r = 1; r < List.size(); r++)
  1671. {
  1672. 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)
  1673. {
  1674. if(loadMax<loadRefX) {
  1675. if(Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))<loadMax) {
  1676. loadRefY = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1677. distanceMaxY = Math.abs(loadMax - loadRefY);
  1678. powerFactorY = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1679. efficiencyY = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1680. }
  1681. } else if(loadMax>loadRefX) {
  1682. if(Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))>loadMax) {
  1683. loadRefY = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1684. distanceMaxY = Math.abs(loadMax - loadRefY);
  1685. powerFactorY = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1686. efficiencyY = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1687. }
  1688. }
  1689. }
  1690. }
  1691. }
  1692. double powerFactor = powerFactorX;
  1693. double efficiency = efficiencyX;
  1694. if(loadRefX!=loadRefY) {
  1695. powerFactor = (loadMax * (powerFactorX - powerFactorY) + (loadRefX * powerFactorY) - (loadRefY * powerFactorX)) / (loadRefX - loadRefY);
  1696. efficiency = (loadMax * (efficiencyX - efficiencyY) + (loadRefX * efficiencyY) - (loadRefY * efficiencyX)) / (loadRefX - loadRefY);
  1697. }
  1698. double AC = (phaseConverter.equals("1")?(phase.equals("A")?ACA:(phase.equals("B")?ACB:ACC)):DC) / (powerFactor * efficiency);
  1699.  
  1700. if (!phaseConverter.equals("1"))
  1701. {
  1702. //si ce n'est pas un phase converter, division par 3 sur chaque phase
  1703. loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+1, kT);
  1704. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+1, kT+1);
  1705. loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+1, kT+2);
  1706. loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+2, kT);
  1707. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+2, kT+1);
  1708. loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+2, kT+2);
  1709. loadTable.setValueAt(String.valueOf(getArround(AC/3)), i+3, kT);
  1710. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i+3, kT+1);
  1711. loadTable.setValueAt(String.valueOf(getArround(AC/(3*voltageSource))), i+3, kT+2);
  1712. //application des memes valeurs pour le composant superieur
  1713. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1714. {
  1715. if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
  1716. {
  1717. for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1718. {
  1719. 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)))
  1720. {
  1721. double PtempAi,PtempBi,PtempCi,QtempAi,QtempBi,QtempCi;
  1722. PtempAi=(AC/3)*((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?1.0:powerFactor);
  1723. PtempBi=PtempAi;
  1724. PtempCi=PtempAi;
  1725. QtempAi=(AC/3)*Math.sqrt((1-Math.pow(((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?1.0:powerFactor),2)));
  1726. QtempBi=QtempAi;
  1727. QtempCi=QtempAi;
  1728.  
  1729. 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))),
  1730. 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))),
  1731. 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));
  1732. PtempAn+=PtempAi;
  1733. PtempBn+=PtempBi;
  1734. PtempCn+=PtempCi;
  1735. QtempAn+=QtempAi;
  1736. QtempBn+=QtempBi;
  1737. QtempCn+=QtempCi;
  1738. StempAn=Math.sqrt(Math.pow(PtempAn,2)+Math.pow(QtempAn,2));
  1739. StempBn=Math.sqrt(Math.pow(PtempBn,2)+Math.pow(QtempBn,2));
  1740. StempCn=Math.sqrt(Math.pow(PtempCn,2)+Math.pow(QtempCn,2));
  1741. costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempAn!=0.0)?1.0:(PtempAn/StempAn);
  1742. costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempBn!=0.0)?1.0:(PtempBn/StempBn);
  1743. costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempCn!=0.0)?1.0:(PtempCn/StempCn);
  1744.  
  1745. loadTable.setValueAt(String.valueOf(getArround(StempAn)), n+1, kT);
  1746. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempAn)), n+1, kT+1);
  1747. loadTable.setValueAt(String.valueOf(getArround(StempAn/voltageSource))+"~"+String.valueOf(voltageSource), n+1, kT+2);
  1748. loadTable.setValueAt(String.valueOf(getArround(StempBn)), n+2, kT);
  1749. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempBn)), n+2, kT+1);
  1750. loadTable.setValueAt(String.valueOf(getArround(StempBn/voltageSource))+"~"+String.valueOf(voltageSource), n+2, kT+2);
  1751. loadTable.setValueAt(String.valueOf(getArround(StempCn)), n+3, kT);
  1752. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempCn)), n+3, kT+1);
  1753. loadTable.setValueAt(String.valueOf(getArround(StempCn/voltageSource))+"~"+String.valueOf(voltageSource), n+3, kT+2);
  1754. break;
  1755. }
  1756. }
  1757. break;
  1758. }
  1759. }
  1760. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  1761. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  1762. double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
  1763. costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
  1764. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+1, r);
  1765. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+1, r+1);
  1766. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+2, r);
  1767. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+2, r+1);
  1768. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency*3))), i+3, r);
  1769. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+3, r+1);
  1770. }
  1771. }
  1772. }
  1773. else if (phaseConverter.equals("1")&&phase.equals("A"))
  1774. {
  1775. //si phase converter
  1776. loadTable.setValueAt(String.valueOf(getArround(AC)), i+1, kT);
  1777. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosA)), i+1, kT+1);
  1778. loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+1, kT+2);
  1779. loadTable.setValueAt("0.0", i+2, kT);
  1780. loadTable.setValueAt("0.0", i+2, kT+1);
  1781. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+2, kT+2);
  1782. loadTable.setValueAt("0.0", i+3, kT);
  1783. loadTable.setValueAt("0.0", i+3, kT+1);
  1784. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+3, kT+2);
  1785. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1786. {
  1787. if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
  1788. {
  1789. for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1790. {
  1791. 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)))
  1792. {
  1793. double PtempAi,QtempAi;
  1794. PtempAi=AC*ACCosA;
  1795. QtempAi=AC*Math.sqrt((1-Math.pow(ACCosA,2)));
  1796.  
  1797. double costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+1, kT+1))),
  1798. StempAn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+1, kT))),
  1799. PtempAn=StempAn*costempAn,QtempAn=StempAn*Math.sqrt(1-Math.pow(costempAn,2));
  1800. PtempAn+=PtempAi;
  1801. QtempAn+=QtempAi;
  1802. StempAn=Math.sqrt(Math.pow(PtempAn,2)+Math.pow(QtempAn,2));
  1803. costempAn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempAn!=0.0)?1.0:(PtempAn/StempAn);
  1804.  
  1805. loadTable.setValueAt(String.valueOf(getArround(StempAn)), n+1, kT);
  1806. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempAn)), n+1, kT+1);
  1807. loadTable.setValueAt(String.valueOf(getArround(StempAn/voltageSource))+"~"+String.valueOf(voltageSource), n+1, kT+2);
  1808. break;
  1809. }
  1810. }
  1811. break;
  1812. }
  1813. }
  1814. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  1815. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  1816. double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
  1817. costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
  1818. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+1, r);
  1819. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+1, r+1);
  1820. }
  1821. }
  1822. }
  1823. else if (phaseConverter.equals("1")&&phase.equals("B"))
  1824. {
  1825. loadTable.setValueAt("0.0", i+1, kT);
  1826. loadTable.setValueAt("0.0", i+1, kT+1);
  1827. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+1, kT+2);
  1828. loadTable.setValueAt(String.valueOf(getArround(AC)), i+2, kT);
  1829. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosB)), i+2, kT+1);
  1830. loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+2, kT+2);
  1831. loadTable.setValueAt("0.0", i+3, kT);
  1832. loadTable.setValueAt("0.0", i+3, kT+1);
  1833. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+3, kT+2);
  1834. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1835. {
  1836. if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
  1837. {
  1838. for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1839. {
  1840. 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)))
  1841. {
  1842. double PtempBi,QtempBi;
  1843. PtempBi=AC*ACCosB;
  1844. QtempBi=AC*Math.sqrt((1-Math.pow(ACCosB,2)));
  1845.  
  1846. double costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+2, kT+1))),
  1847. StempBn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+2, kT))),
  1848. PtempBn=StempBn*costempBn,QtempBn=StempBn*Math.sqrt(1-Math.pow(costempBn,2));
  1849. PtempBn+=PtempBi;
  1850. QtempBn+=QtempBi;
  1851. StempBn=Math.sqrt(Math.pow(PtempBn,2)+Math.pow(QtempBn,2));
  1852. costempBn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempBn!=0.0)?1.0:(PtempBn/StempBn);
  1853.  
  1854. loadTable.setValueAt(String.valueOf(getArround(StempBn)), n+2, kT);
  1855. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempBn)), n+2, kT+1);
  1856. loadTable.setValueAt(String.valueOf(getArround(StempBn/voltageSource))+"~"+String.valueOf(voltageSource), n+2, kT+2);
  1857. break;
  1858. }
  1859. }
  1860. break;
  1861. }
  1862. }
  1863. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  1864. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  1865. double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
  1866. costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
  1867. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+2, r);
  1868. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+2, r+1);
  1869. }
  1870. }
  1871. }
  1872. else if(phaseConverter.equals("1")&&phase.equals("C"))
  1873. {
  1874. loadTable.setValueAt("0.0", i+1, kT);
  1875. loadTable.setValueAt("0.0", i+1, kT+1);
  1876. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+1, kT+2);
  1877. loadTable.setValueAt("0.0", i+2, kT);
  1878. loadTable.setValueAt("0.0", i+2, kT+1);
  1879. loadTable.setValueAt("0.0"+"~"+String.valueOf(voltageSource), i+2, kT+2);
  1880. loadTable.setValueAt(String.valueOf(getArround(AC)), i+3, kT);
  1881. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(ACCosC)), i+3, kT+1);
  1882. loadTable.setValueAt(String.valueOf(getArround(AC/voltageSource))+"~"+String.valueOf(voltageSource), i+3, kT+2);
  1883. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1884. {
  1885. if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
  1886. {
  1887. for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1888. {
  1889. 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)))
  1890. {
  1891. double PtempCi,QtempCi;
  1892. PtempCi=AC*ACCosC;
  1893. QtempCi=AC*Math.sqrt((1-Math.pow(ACCosC,2)));
  1894.  
  1895. double costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)loadTable.getValueAt(n+3, kT+1))),
  1896. StempCn=getArround(Double.parseDouble((String)loadTable.getValueAt(n+3, kT))),
  1897. PtempCn=StempCn*costempCn,QtempCn=StempCn*Math.sqrt(1-Math.pow(costempCn,2));
  1898. PtempCn+=PtempCi;
  1899. QtempCn+=QtempCi;
  1900. StempCn=Math.sqrt(Math.pow(PtempCn,2)+Math.pow(QtempCn,2));
  1901. costempCn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&StempCn!=0.0)?1.0:(PtempCn/StempCn);
  1902.  
  1903. loadTable.setValueAt(String.valueOf(getArround(StempCn)), n+3, kT);
  1904. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempCn)), n+3, kT+1);
  1905. loadTable.setValueAt(String.valueOf(getArround(StempCn/voltageSource))+"~"+String.valueOf(voltageSource), n+3, kT+2);
  1906. break;
  1907. }
  1908. }
  1909. break;
  1910. }
  1911. }
  1912. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  1913. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  1914. double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r))),
  1915. costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i,r+1)));
  1916. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp/(powerFactor*efficiency))), i+3, r);
  1917. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costemp)), i+3, r+1);
  1918. }
  1919. }
  1920. }
  1921. }
  1922. }
  1923. else
  1924. {
  1925. //si static inverter
  1926. for (int k = 0; k < ScenarioPage.selectedPhase.length; k++)
  1927. {
  1928. int kT=3*k+1;
  1929. double ACA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT));
  1930. double ACCosA = Double.parseDouble((String)loadTable.getValueAt(i+1, kT+1));
  1931. double ACB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT));
  1932. double ACCosB = Double.parseDouble((String)loadTable.getValueAt(i+2, kT+1));
  1933. double ACC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT));
  1934. double ACCosC = Double.parseDouble((String)loadTable.getValueAt(i+3, kT+1));
  1935. double loadA = (ACA * ACCosA) / (3 * voltageConverter * convertCourant);
  1936. double loadB = (ACB * ACCosB) / (3 * voltageConverter * convertCourant);
  1937. double loadC = (ACC * ACCosC) / (3 * voltageConverter * convertCourant);
  1938. double loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
  1939. double distanceA = Math.abs(loadA - loadRef);
  1940. double powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
  1941. double efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
  1942. for (int r = 1; r < List.size(); r++)
  1943. {
  1944. if (Math.abs(loadA - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceA)
  1945. {
  1946. loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1947. distanceA = Math.abs(loadA - loadRef);
  1948. powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1949. efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1950. }
  1951. }
  1952. double DC = (ACA * ACCosA) / (powerFactor * efficiency);
  1953. loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
  1954. double distanceB = Math.abs(loadB - loadRef);
  1955. powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
  1956. efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
  1957. for (int r = 1; r < List.size(); r++)
  1958. {
  1959. if (Math.abs(loadB - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceB)
  1960. {
  1961. loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1962. distanceB = Math.abs(loadB - loadRef);
  1963. powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1964. efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1965. }
  1966. }
  1967. DC += (ACB * ACCosB) / (powerFactor * efficiency);
  1968. loadRef = Double.parseDouble(((String[])List.get(0))[0].toString().replaceAll(",", "."));
  1969. double distanceC = Math.abs(loadC - loadRef);
  1970. powerFactor = Double.parseDouble(((String[])List.get(0))[1].toString().replaceAll(",", "."));
  1971. efficiency = Double.parseDouble(((String[])List.get(0))[2].toString().replaceAll(",", "."));
  1972. for (int r = 1; r < List.size(); r++)
  1973. {
  1974. if (Math.abs(loadC - Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."))) < distanceC)
  1975. {
  1976. loadRef = Double.parseDouble(((String[])List.get(r))[0].toString().replaceAll(",", "."));
  1977. distanceC = Math.abs(loadC - loadRef);
  1978. powerFactor = Double.parseDouble(((String[])List.get(r))[1].toString().replaceAll(",", "."));
  1979. efficiency = Double.parseDouble(((String[])List.get(r))[2].toString().replaceAll(",", "."));
  1980. }
  1981. }
  1982. DC += (ACC * ACCosC) / (powerFactor * efficiency);
  1983.  
  1984. loadTable.setValueAt(String.valueOf(getArround(DC)), i, kT);
  1985. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(powerFactor)), i, kT+1);
  1986. loadTable.setValueAt(String.valueOf(getArround(DC/voltageSource))+"~"+String.valueOf(voltageSource), i, kT+2);
  1987. for (int m = 0; m < loadTableLink.getRowCount(); m++)
  1988. {
  1989. if (loadTableLink.getValueAt(m, 0).equals(loadTable.getValueAt(i, 0).toString().substring(0,loadTable.getValueAt(i, 0).toString().lastIndexOf("¥"))))
  1990. {
  1991. for (int n = z*OpenFileAllCSV.phaseList.size(); n < loadTable.getRowCount(); n += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size()))
  1992. {
  1993. 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)))
  1994. {
  1995. double Ptempi;
  1996. Ptempi=DC*powerFactor;
  1997.  
  1998. double Ptempn=getArround(Double.parseDouble((String)loadTable.getValueAt(n, kT)));
  1999. Ptempn+=Ptempi;
  2000.  
  2001. double costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Ptempn!=0.0)?1.0:(Ptempn/Ptempn);
  2002.  
  2003. loadTable.setValueAt(String.valueOf(getArround(Ptempn)), n, kT);
  2004. loadTable.setValueAt(String.valueOf((boolean) ScenarioPage.optionListModele.getValueAt(1,1)?"1.0":getArroundPF(costempn)), n, kT+1);
  2005. loadTable.setValueAt(String.valueOf(getArround(Ptempn/voltageSource))+"~"+String.valueOf(voltageSource), n, kT+2);
  2006. break;
  2007. }
  2008. }
  2009. break;
  2010. }
  2011. }
  2012. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  2013. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  2014. double StempA=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+1,r))),
  2015. costempA=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+1,r+1))),
  2016. StempB=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+2,r))),
  2017. costempB=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+2,r+1))),
  2018. StempC=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+3,r))),
  2019. costempC=((boolean) ScenarioPage.optionListModele.getValueAt(1,1))?1.0:getArroundPF(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+3,r+1))),
  2020. DCtemp=(StempA*costempA)/(powerFactor*efficiency)+(StempB*costempB)/(powerFactor*efficiency)+(StempC*costempC)/(powerFactor*efficiency);
  2021. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(DCtemp/(powerFactor*efficiency))), i, r);
  2022. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(DCtemp/DCtemp)), i, r+1);
  2023. }
  2024. }
  2025. }
  2026. }
  2027. }
  2028.  
  2029. /**
  2030. * Recherche les consommations du composant
  2031. * @param i=ligne tableau LoadTable
  2032. * @param j=ligne C/B List
  2033. * @param y=ligne phase
  2034. * @param z=ligne loadList (MAX/OPE/...)
  2035. * @param k=ligne phase de vol
  2036. * @param isEquipment
  2037. */
  2038. public void findLoad(int i,int j,int y, int z, int k, boolean isEquipment)
  2039. {
  2040. boolean equipmentPresent=false;
  2041. List<String> list = new ArrayList<String>();
  2042. //test si equipement present sur schema
  2043. if(!isEquipment) {
  2044. int p=0;
  2045. while (GraphEditor.CBIdequipment.getItemAt(p)!=null)
  2046. {
  2047. int pos1=GraphEditor.CBIdequipment.getItemAt(p).toString().lastIndexOf(";");
  2048. int pos2=GraphEditor.CBIdequipment.getItemAt(p).toString().indexOf("|");
  2049. while(pos2>0) {
  2050. list.add(GraphEditor.CBIdequipment.getItemAt(p).toString().substring(pos1+1,pos2));
  2051. pos1=pos2;
  2052. pos2=GraphEditor.CBIdequipment.getItemAt(p).toString().substring(pos1+1).indexOf("|");
  2053. if(pos2!=-1)
  2054. pos2+=(pos1+1);
  2055. }
  2056. p++;
  2057. }
  2058. for(int q=0;q<list.size();q++) {
  2059. for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
  2060. if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.finListModele.getValueAt(0,0))) {
  2061. if(list.get(q).equals(OpenFileAllCSV.data.get(j)[m])) {
  2062. equipmentPresent=true;
  2063. break;
  2064. }
  2065. break;
  2066. }
  2067. }
  2068. if(equipmentPresent)
  2069. break;
  2070. }
  2071. }
  2072. //s'il n'y est pas alors on peut ajouter sa conso sur la barre
  2073. if(!equipmentPresent) {
  2074. for (int l=0;l<OpenFileAllCSV.data.get(0).length; l++) {
  2075. //pour chaque colonne du CSV
  2076. if (OpenFileAllCSV.data.get(0)[l].equals(ScenarioPage.selectedPhase[k])) {
  2077. //phase de vol selectionnee reperee, init P et Q
  2078. double P=0,Q=0;
  2079. for(int n = 0; n < OpenFileAllCSV.data.get(0).length; n++) {
  2080. //pour chaque colonne du CSV
  2081. if(OpenFileAllCSV.data.get(0)[n].equals(OpenFileAllCSV.phaseListModele.getValueAt(0,0))) {
  2082. //phase reperee
  2083. if(OpenFileAllCSV.data.get(j)[n].replaceAll(" ","").equals(OpenFileAllCSV.phaseList.get(y))) {
  2084. //si ={(DC)/A/B/C}
  2085. for(int o=0;o<OpenFileAllCSV.flightPhaseListTable.getRowCount();o++) {
  2086. //pour chaque phase de vol assignee
  2087. if(OpenFileAllCSV.flightPhaseListModele.getValueAt(o,0).equals(ScenarioPage.selectedPhase[k])) {
  2088. //si phase de vol selectionnee = phase de vol assignee
  2089. if(!OpenFileAllCSV.flightPhaseListModele.getValueAt(o,1).equals("")) {
  2090. //si cosinus assigne
  2091. for(int p=0;p<OpenFileAllCSV.data.get(0).length;p++) {
  2092. //pour chaque colonne du CSV
  2093. if(OpenFileAllCSV.data.get(0)[p].equals(OpenFileAllCSV.flightPhaseListModele.getValueAt(o,1))) {
  2094. //colonne cosinus = cosinus assigne
  2095. if(!OpenFileAllCSV.data.get(j)[p].replaceAll(" ","").equals("")) {
  2096. //si cosinus n'est pas vide
  2097. 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(",", ".")));
  2098. 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));
  2099. break;
  2100. } else {
  2101. //sinon on reprend la categorie COS
  2102. if(OpenFileAllCSV.cosListTable.getRowCount()>0) {
  2103. //si non vide
  2104. for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
  2105. if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.cosListModele.getValueAt(0,0))) {
  2106. 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(",", ".")));
  2107. 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));
  2108. }
  2109. }
  2110. } else {
  2111. P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."));
  2112. Q=0.0;
  2113. }
  2114. break;
  2115. }
  2116. }
  2117. }
  2118. break;
  2119. } else {
  2120. //sinon on reprend la categorie COS
  2121. if(OpenFileAllCSV.cosListTable.getRowCount()>0) {
  2122. for(int m=0;m<OpenFileAllCSV.data.get(0).length;m++) {
  2123. if(OpenFileAllCSV.data.get(0)[m].equals(OpenFileAllCSV.cosListModele.getValueAt(0,0))) {
  2124. 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(",", ".")));
  2125. 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));
  2126. }
  2127. }
  2128. } else {
  2129. //si non vide
  2130. P=Double.parseDouble(((String[])OpenFileAllCSV.data.get(j))[l].replaceAll(",", "."));
  2131. Q=0.0;
  2132. }
  2133. break;
  2134. }
  2135. }
  2136. }
  2137. //remplissage tableau par ATA
  2138. if(OpenFileAllCSV.ataListTable.getRowCount()>0) {
  2139. for(int q=0;q<OpenFileAllCSV.data.get(0).length;q++) {
  2140. if(OpenFileAllCSV.data.get(0)[q].equals(OpenFileAllCSV.ataListModele.getValueAt(0,0))) {
  2141. if(!OpenFileAllCSV.data.get(j)[q].replaceAll(" ","").equals("")) {
  2142. for(int r=1;r<ataListTable.get(k).getColumnCount();r+=2) {
  2143. if(AtaTable.entetes[r].equals(OpenFileAllCSV.data.get(j)[q].substring(0,2))) {
  2144. double Stemp=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(i+y+(z*OpenFileAllCSV.phaseList.size()),r))),
  2145. 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))),
  2146. Ptemp=Stemp*costemp, Qtemp=Stemp*Math.sqrt(1-Math.pow(costemp,2));
  2147. Ptemp+=P;
  2148. Qtemp+=Q;
  2149. Stemp=Math.sqrt(Math.pow(Ptemp,2)+Math.pow(Qtemp,2));
  2150. costemp=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stemp!=0.0)?1.0:(Ptemp/Stemp);
  2151. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stemp)),i+y+(z*OpenFileAllCSV.phaseList.size()),r);
  2152. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(costemp)),i+y+(z*OpenFileAllCSV.phaseList.size()),r+1);
  2153. String tableStyle = "";
  2154. int lineResearch=0;
  2155. 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("¥"));
  2156. while(!tableStyle.contains("convertisseur")&&lineResearch>=0) {
  2157. for (int m = 0; m < loadTableLink.getRowCount(); m++) {
  2158. if (loadTableLink.getValueAt(m, 0).equals(research)) {
  2159. research=loadTableLink.getValueAt(m,1).toString();
  2160. tableStyle = loadTableLink.getValueAt(m,1).toString().substring(loadTableLink.getValueAt(m,1).toString().indexOf("#") + 1, loadTableLink.getValueAt(m,1).toString().lastIndexOf("#"));
  2161. lineResearch = m;
  2162. break;
  2163. }
  2164. lineResearch=-1;
  2165. tableStyle="";
  2166. }
  2167. }
  2168. if (lineResearch>=0) {
  2169. for (int t = 0; t < ataListTable.get(k).getRowCount(); t += (OpenFileAllCSV.loadList.size()*OpenFileAllCSV.phaseList.size())) {
  2170. 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))) {
  2171. 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))),
  2172. Stempn=getArround(Double.parseDouble((String)ataListTable.get(k).getValueAt(t+y+(z*OpenFileAllCSV.phaseList.size()), r))),
  2173. Ptempn=Stempn*costempn,Qtempn=Stempn*Math.sqrt(1-Math.pow(costempn,2));
  2174. Ptempn+=P;
  2175. Qtempn+=Q;
  2176. Stempn=Math.sqrt(Math.pow(Ptempn,2)+Math.pow(Qtempn,2));
  2177. costempn=((boolean) ScenarioPage.optionListModele.getValueAt(1,1)&&Stempn!=0.0)?1.0:(Ptempn/Stempn);
  2178. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArround(Stempn)), t+y+(z*OpenFileAllCSV.phaseList.size()), r);
  2179. ((AtaTable) ataListTable.get(k).getModel()).setValueAt(String.valueOf(getArroundPF(costempn)), t+y+(z*OpenFileAllCSV.phaseList.size()), r+1);
  2180. break;
  2181. }
  2182. }
  2183. }
  2184. break;
  2185. }
  2186. }
  2187. }
  2188. }
  2189. }
  2190. }
  2191. }
  2192. break;
  2193. }
  2194. }
  2195. Double[] consumptions={P,Q};
  2196. //report des consommations
  2197. consumption.add(consumptions);
  2198. break;
  2199. }
  2200. }
  2201. }
  2202. }
  2203.  
  2204. /**
  2205. * Retourne arroundie de d (precision pour consommation et amperage)
  2206. * @param d
  2207. * @return
  2208. */
  2209. public static double getArround(double d) {
  2210. d = Math.round(d * Math.pow(10.0D, loadPrecisionCalculation)) / Math.pow(10.0D,loadPrecisionCalculation);
  2211. return d;
  2212. }
  2213.  
  2214. /**
  2215. * Retourne arroundie de d (precision pour facteur puissance)
  2216. * @param d
  2217. * @return
  2218. */
  2219. public static double getArroundPF(double d) {
  2220. d = Math.round(d * Math.pow(10.0D, powerFactorPrecisionCalculation)) / Math.pow(10.0D,powerFactorPrecisionCalculation);
  2221. return d;
  2222. }
  2223.  
  2224. /**
  2225. * Retourne liste de string sans doublon
  2226. * @param liste
  2227. * @return
  2228. */
  2229. public List<String> DeleteDouble(List<String> liste)
  2230. {
  2231. for (int i1 = 0; i1 < liste.size(); i1++) {
  2232. for (int i2 = i1 + 1; i2 < liste.size(); i2++) {
  2233. if (((String)liste.get(i1)).equals(liste.get(i2))) {
  2234. liste.remove(i2);
  2235. i2--;
  2236. }
  2237. }
  2238. }
  2239. return liste;
  2240. }
  2241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement