개정판 1ff0105e
dev issue #1169 : flow direction check
Change-Id: Ifacfacf71a5063818679a42377d82e7ffc44ab3a
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
40 | 40 |
List<Line> NewBranchLines = new List<Line>(); |
41 | 41 |
List<Tuple<string, Line, Line>> BranchLines = new List<Tuple<string, Line, Line>>(); |
42 | 42 |
List<string> ZeroLengthModelItemID = new List<string>(); |
43 |
List<string> ZeroLengthModelItemIDReverse = new List<string>(); |
|
43 | 44 |
List<Symbol> prioritySymbols; |
44 | 45 |
|
45 | 46 |
public AutoModeling(SPPID_Document document, dynamic application, Ingr.RAD2D.Application radApp) |
... | ... | |
100 | 101 |
RunBranchLineModeling(); |
101 | 102 |
|
102 | 103 |
// Clear Attribute |
103 |
RunClearInconsistancy(); |
|
104 |
RunClearValueInconsistancy();
|
|
104 | 105 |
|
105 | 106 |
// EndBreak Modeling |
106 | 107 |
RunEndBreakModeling(); |
... | ... | |
112 | 113 |
RunJoinRunForSameConnector(); |
113 | 114 |
|
114 | 115 |
// Check FlowDirection |
115 |
|
|
116 |
RunFlowDirection(); |
|
116 | 117 |
|
117 | 118 |
//// LineNumber Modeling |
118 | 119 |
//RunLineNumberModeling(); |
... | ... | |
387 | 388 |
} |
388 | 389 |
} |
389 | 390 |
} |
390 |
private void RunClearInconsistancy() |
|
391 |
private void RunClearValueInconsistancy()
|
|
391 | 392 |
{ |
392 | 393 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, 1); |
393 | 394 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Clear Attribute"); |
394 |
SetSystemEditingCommand(false); |
|
395 | 395 |
|
396 | 396 |
bool loop = true; |
397 | 397 |
while (loop) |
... | ... | |
576 | 576 |
// SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
577 | 577 |
//} |
578 | 578 |
#endregion |
579 |
SetSystemEditingCommand(true); |
|
580 | 579 |
} |
581 | 580 |
private void RunEndBreakModeling() |
582 | 581 |
{ |
... | ... | |
643 | 642 |
} |
644 | 643 |
private void RunFlowDirection() |
645 | 644 |
{ |
646 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
|
645 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count + ZeroLengthModelItemID.Count + ZeroLengthModelItemIDReverse.Count);
|
|
647 | 646 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Check Flow Direction"); |
648 | 647 |
foreach (var line in document.LINES) |
649 | 648 |
{ |
649 |
if (!string.IsNullOrEmpty(line.SPPID.ModelItemId)) |
|
650 |
{ |
|
651 |
LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
|
652 |
if (modelItem != null) |
|
653 |
{ |
|
654 |
LMAAttribute attribute = modelItem.Attributes["FlowDirection"]; |
|
655 |
if (attribute != null) |
|
656 |
{ |
|
657 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
658 |
modelItem.Commit(); |
|
659 |
} |
|
650 | 660 |
|
661 |
SetFlowDirectionByLine(line.SPPID.ModelItemId); |
|
662 |
|
|
663 |
ReleaseCOMObjects(modelItem); |
|
664 |
} |
|
665 |
} |
|
651 | 666 |
|
652 | 667 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
653 | 668 |
} |
669 |
foreach (var modelId in ZeroLengthModelItemID) |
|
670 |
{ |
|
671 |
LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId); |
|
672 |
LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"]; |
|
673 |
if (attribute != null) |
|
674 |
{ |
|
675 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
676 |
zeroLengthModelItem.Commit(); |
|
677 |
} |
|
678 |
|
|
679 |
SetFlowDirectionByLine(modelId); |
|
680 |
|
|
681 |
ReleaseCOMObjects(zeroLengthModelItem); |
|
682 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
683 |
} |
|
684 |
foreach (var modelId in ZeroLengthModelItemIDReverse) |
|
685 |
{ |
|
686 |
LMModelItem zeroLengthModelItem = dataSource.GetModelItem(modelId); |
|
687 |
LMAAttribute attribute = zeroLengthModelItem.Attributes["FlowDirection"]; |
|
688 |
if (attribute != null) |
|
689 |
{ |
|
690 |
attribute.set_Value("End 1 is downstream (Outlet)"); |
|
691 |
zeroLengthModelItem.Commit(); |
|
692 |
} |
|
693 |
|
|
694 |
SetFlowDirectionByLine(modelId); |
|
695 |
|
|
696 |
ReleaseCOMObjects(zeroLengthModelItem); |
|
697 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
698 |
} |
|
699 |
} |
|
700 |
|
|
701 |
private void SetFlowDirectionByLine(string lineModelItemID) |
|
702 |
{ |
|
703 |
LMModelItem modelItem = dataSource.GetModelItem(lineModelItemID); |
|
704 |
if (modelItem != null) |
|
705 |
{ |
|
706 |
LMAAttribute attribute = modelItem.Attributes["FlowDirection"]; |
|
707 |
if (attribute != null && !DBNull.Value.Equals(attribute.get_Value())) |
|
708 |
{ |
|
709 |
string sFlowDirection = attribute.get_Value().ToString(); |
|
710 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
711 |
{ |
|
712 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
713 |
{ |
|
714 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
715 |
|
|
716 |
foreach (LMRelationship relationship in connector.Relation1Relationships) |
|
717 |
SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection); |
|
718 |
foreach (LMRelationship relationship in connector.Relation2Relationships) |
|
719 |
SetSymbolFlowDirectionByRelationShip(relationship, connector, sFlowDirection); |
|
720 |
|
|
721 |
ReleaseCOMObjects(connector); |
|
722 |
} |
|
723 |
} |
|
724 |
} |
|
725 |
ReleaseCOMObjects(modelItem); |
|
726 |
} |
|
727 |
|
|
728 |
void SetSymbolFlowDirectionByRelationShip(LMRelationship relationship, LMConnector connector, string sFlowDirection) |
|
729 |
{ |
|
730 |
// Item2가 Symbol |
|
731 |
if (!DBNull.Value.Equals(relationship.Item1RepresentationID) && relationship.Item1RepresentationID == connector.Id && |
|
732 |
relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.get_RepresentationType() == "Symbol") |
|
733 |
{ |
|
734 |
int symbolIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
735 |
int lineIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
736 |
LMModelItem symbolModelItem = relationship.Item2RepresentationObject.ModelItemObject; |
|
737 |
|
|
738 |
SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem); |
|
739 |
|
|
740 |
symbolModelItem.Commit(); |
|
741 |
ReleaseCOMObjects(symbolModelItem); |
|
742 |
} |
|
743 |
// Item1이 Symbol |
|
744 |
else if (!DBNull.Value.Equals(relationship.Item2RepresentationID) && relationship.Item2RepresentationID == connector.Id && |
|
745 |
relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.get_RepresentationType() == "Symbol") |
|
746 |
{ |
|
747 |
int symbolIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
748 |
int lineIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
749 |
LMModelItem symbolModelItem = relationship.Item1RepresentationObject.ModelItemObject; |
|
750 |
|
|
751 |
SetSymbolFlowDirection(lineIndex, symbolIndex, sFlowDirection, symbolModelItem); |
|
752 |
|
|
753 |
symbolModelItem.Commit(); |
|
754 |
ReleaseCOMObjects(symbolModelItem); |
|
755 |
} |
|
756 |
} |
|
757 |
|
|
758 |
void SetSymbolFlowDirection(int lineIndex, int symbolIndex, string sFlowDirection, LMModelItem symbolModelItem) |
|
759 |
{ |
|
760 |
string attrName = "PipingPoint" + symbolIndex + ".FlowDirection"; |
|
761 |
LMAAttribute attribute = symbolModelItem.Attributes[attrName]; |
|
762 |
if (attribute != null) |
|
763 |
{ |
|
764 |
if (lineIndex == 0 && sFlowDirection == "End 1 is upstream (Inlet)") |
|
765 |
attribute.set_Value("End 1 is downstream (Outlet)"); |
|
766 |
else if (lineIndex == 0 && sFlowDirection == "End 1 is downstream (Outlet)") |
|
767 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
768 |
else if (lineIndex == 1 && sFlowDirection == "End 1 is upstream (Inlet)") |
|
769 |
attribute.set_Value("End 1 is upstream (Inlet)"); |
|
770 |
else if (lineIndex == 1 && sFlowDirection == "End 1 is downstream (Outlet)") |
|
771 |
attribute.set_Value("End 1 is downstream (Outlet)"); |
|
772 |
} |
|
773 |
} |
|
654 | 774 |
} |
655 | 775 |
|
656 | 776 |
private void RunLineNumberModeling() |
... | ... | |
1980 | 2100 |
if (_LMConnector != null) |
1981 | 2101 |
{ |
1982 | 2102 |
RemoveConnectorForReModelingLine(newConnector); |
1983 |
ZeroLengthModelItemID.Add(_LMConnector.ModelItemID); |
|
2103 |
ZeroLengthModelItemIDReverse.Add(_LMConnector.ModelItemID);
|
|
1984 | 2104 |
ReleaseCOMObjects(_LMConnector); |
1985 | 2105 |
} |
1986 | 2106 |
ReleaseCOMObjects(placeRunInputs); |
... | ... | |
2852 | 2972 |
return targetConnector; |
2853 | 2973 |
} |
2854 | 2974 |
|
2975 |
private LMConnector GetLMConnectorOnlyOne(string modelItemID) |
|
2976 |
{ |
|
2977 |
LMConnector result = null; |
|
2978 |
List<LMConnector> connectors = new List<LMConnector>(); |
|
2979 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
|
2980 |
|
|
2981 |
if (modelItem != null) |
|
2982 |
{ |
|
2983 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
2984 |
{ |
|
2985 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
2986 |
connectors.Add(dataSource.GetConnector(rep.Id)); |
|
2987 |
} |
|
2988 |
|
|
2989 |
ReleaseCOMObjects(modelItem); |
|
2990 |
} |
|
2991 |
|
|
2992 |
if (connectors.Count == 1) |
|
2993 |
result = connectors[0]; |
|
2994 |
else |
|
2995 |
foreach (var item in connectors) |
|
2996 |
ReleaseCOMObjects(item); |
|
2997 |
|
|
2998 |
return result; |
|
2999 |
} |
|
3000 |
|
|
2855 | 3001 |
/// <summary> |
2856 | 3002 |
/// Line Number Symbol을 실제로 Modeling하는 메서드 |
2857 | 3003 |
/// </summary> |
DTI_PID/SPPIDConverter/ConverterDocking.cs | ||
---|---|---|
307 | 307 |
} |
308 | 308 |
else if (inconsistency.get_InconsistencyTypeIndex() == 3) |
309 | 309 |
{ |
310 |
|
|
310 |
|
|
311 | 311 |
} |
312 | 312 |
} |
313 | 313 |
relationship.Commit(); |
... | ... | |
315 | 315 |
} |
316 | 316 |
first = false; |
317 | 317 |
|
318 |
|
|
318 |
LMModelItem modelItem = dataSource.GetModelItem("FDC835123FF941489A5327FE364E3F03"); |
|
319 |
if (modelItem != null) |
|
320 |
{ |
|
321 |
string attrValue = modelItem.Attributes["FlowDirection"].get_Value().ToString(); |
|
322 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
323 |
{ |
|
324 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
325 |
{ |
|
326 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
327 |
foreach (LMRelationship relationship in connector.Relation1Relationships) |
|
328 |
{ |
|
329 |
// Item2가 Symbol |
|
330 |
if (relationship.Item1RepresentationID != null && relationship.Item1RepresentationID == connector.Id && |
|
331 |
relationship.Item2RepresentationObject.get_RepresentationType() == "Symbol") |
|
332 |
{ |
|
333 |
int symbolIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
334 |
int lineIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
335 |
LMModelItem symbolModelItem = relationship.Item2RepresentationObject.ModelItemObject; |
|
336 |
|
|
337 |
string symbolAttr = "PipingPoint" + symbolIndex + ".FlowDirection"; |
|
338 |
if (lineIndex == 0 && attrValue == "End 1 is upstream (Inlet)") |
|
339 |
{ |
|
340 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
341 |
} |
|
342 |
else if (lineIndex == 0 && attrValue == "End 1 is downstream (Outlet)") |
|
343 |
{ |
|
344 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
345 |
} |
|
346 |
else if (lineIndex == 1 && attrValue == "End 1 is upstream (Inlet)") |
|
347 |
{ |
|
348 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
349 |
} |
|
350 |
else if (lineIndex == 1 && attrValue == "End 1 is downstream (Outlet)") |
|
351 |
{ |
|
352 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
353 |
} |
|
354 |
|
|
355 |
symbolModelItem.Commit(); |
|
356 |
ReleaseCOMObjects(symbolModelItem); |
|
357 |
} |
|
358 |
// Item1이 Symbol |
|
359 |
else if (relationship.Item2RepresentationID != null && relationship.Item2RepresentationID == connector.Id && |
|
360 |
relationship.Item1RepresentationObject.get_RepresentationType() == "Symbol") |
|
361 |
{ |
|
362 |
int symbolIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
363 |
int lineIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
364 |
LMModelItem symbolModelItem = relationship.Item1RepresentationObject.ModelItemObject; |
|
365 |
|
|
366 |
string symbolAttr = "PipingPoint" + symbolIndex + ".FlowDirection"; |
|
367 |
if (lineIndex == 0 && attrValue == "End 1 is upstream (Inlet)") |
|
368 |
{ |
|
369 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
370 |
} |
|
371 |
else if (lineIndex == 0 && attrValue == "End 1 is downstream (Outlet)") |
|
372 |
{ |
|
373 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
374 |
} |
|
375 |
else if (lineIndex == 1 && attrValue == "End 1 is upstream (Inlet)") |
|
376 |
{ |
|
377 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
378 |
} |
|
379 |
else if (lineIndex == 1 && attrValue == "End 1 is downstream (Outlet)") |
|
380 |
{ |
|
381 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
382 |
} |
|
383 |
|
|
384 |
symbolModelItem.Commit(); |
|
385 |
ReleaseCOMObjects(symbolModelItem); |
|
386 |
} |
|
387 |
} |
|
388 |
|
|
389 |
foreach (LMRelationship relationship in connector.Relation2Relationships) |
|
390 |
{ |
|
391 |
// Item2가 Symbol |
|
392 |
if (relationship.Item1RepresentationID != null && relationship.Item1RepresentationID == connector.Id && |
|
393 |
relationship.Item2RepresentationObject.get_RepresentationType() == "Symbol") |
|
394 |
{ |
|
395 |
int symbolIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
396 |
int lineIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
397 |
LMModelItem symbolModelItem = relationship.Item2RepresentationObject.ModelItemObject; |
|
398 |
|
|
399 |
string symbolAttr = "PipingPoint" + symbolIndex + ".FlowDirection"; |
|
400 |
if (lineIndex == 0 && attrValue == "End 1 is upstream (Inlet)") |
|
401 |
{ |
|
402 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
403 |
} |
|
404 |
else if (lineIndex == 0 && attrValue == "End 1 is downstream (Outlet)") |
|
405 |
{ |
|
406 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
407 |
} |
|
408 |
else if (lineIndex == 1 && attrValue == "End 1 is upstream (Inlet)") |
|
409 |
{ |
|
410 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
411 |
} |
|
412 |
else if (lineIndex == 1 && attrValue == "End 1 is downstream (Outlet)") |
|
413 |
{ |
|
414 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
415 |
} |
|
416 |
|
|
417 |
symbolModelItem.Commit(); |
|
418 |
ReleaseCOMObjects(symbolModelItem); |
|
419 |
} |
|
420 |
// Item1이 Symbol |
|
421 |
else if (relationship.Item2RepresentationID != null && relationship.Item2RepresentationID == connector.Id && |
|
422 |
relationship.Item1RepresentationObject.get_RepresentationType() == "Symbol") |
|
423 |
{ |
|
424 |
int symbolIndex = Convert.ToInt32(relationship.get_Item1Location()); |
|
425 |
int lineIndex = Convert.ToInt32(relationship.get_Item2Location()); |
|
426 |
LMModelItem symbolModelItem = relationship.Item1RepresentationObject.ModelItemObject; |
|
427 |
|
|
428 |
string symbolAttr = "PipingPoint" + symbolIndex + ".FlowDirection"; |
|
429 |
if (lineIndex == 0 && attrValue == "End 1 is upstream (Inlet)") |
|
430 |
{ |
|
431 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
432 |
} |
|
433 |
else if (lineIndex == 0 && attrValue == "End 1 is downstream (Outlet)") |
|
434 |
{ |
|
435 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
436 |
} |
|
437 |
else if (lineIndex == 1 && attrValue == "End 1 is upstream (Inlet)") |
|
438 |
{ |
|
439 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is upstream (Inlet)"); |
|
440 |
} |
|
441 |
else if (lineIndex == 1 && attrValue == "End 1 is downstream (Outlet)") |
|
442 |
{ |
|
443 |
symbolModelItem.Attributes[symbolAttr].set_Value("End 1 is downstream (Outlet)"); |
|
444 |
} |
|
445 |
|
|
446 |
symbolModelItem.Commit(); |
|
447 |
ReleaseCOMObjects(symbolModelItem); |
|
448 |
} |
|
449 |
} |
|
450 |
|
|
451 |
ReleaseCOMObjects(connector); |
|
452 |
} |
|
453 |
|
|
454 |
} |
|
455 |
} |
|
319 | 456 |
|
320 | 457 |
//foreach (LMRelationship relationship in currentDrawing.Relationships) |
321 | 458 |
//{ |
내보내기 Unified diff