973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
973c2be1 |
5 | // This library is free software; you can redistribute it and / or modify it |
6 | // under the terms of the GNU Lesser General Public version 2.1 as published |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | #include <XSControl_SignTransferStatus.ixx> |
15 | #include <Transfer_Binder.hxx> |
16 | #include <TCollection_AsciiString.hxx> |
17 | #include <Interface_Check.hxx> |
18 | //#include <stdio.h> |
19 | |
20 | static TCollection_AsciiString& themes() |
21 | { |
22 | static TCollection_AsciiString tm; |
23 | return tm; |
24 | } |
25 | // si resultat avec type: a exploiter tout de suite ! |
26 | |
27 | XSControl_SignTransferStatus::XSControl_SignTransferStatus () |
28 | : IFSelect_Signature("Transfer Status") { } |
29 | |
30 | XSControl_SignTransferStatus::XSControl_SignTransferStatus |
31 | (const Handle(XSControl_TransferReader)& TR) |
32 | : IFSelect_Signature("Transfer Status") , |
33 | theTR (TR) { } |
34 | |
35 | void XSControl_SignTransferStatus::SetReader |
36 | (const Handle(XSControl_TransferReader)& TR) |
37 | { theTR = TR; } |
38 | |
39 | void XSControl_SignTransferStatus::SetMap |
40 | (const Handle(Transfer_TransientProcess)& TP) |
41 | { theTP = TP; } |
42 | |
43 | Handle(Transfer_TransientProcess) XSControl_SignTransferStatus::Map () const |
44 | { return theTP; } |
45 | |
46 | Handle(XSControl_TransferReader) XSControl_SignTransferStatus::Reader () const |
47 | { return theTR; } |
48 | |
49 | |
50 | |
51 | // BinderStatus retourne une valeur : |
52 | // 0 Binder Null. 1 void 2 Warning seul 3 Fail seul |
53 | // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail |
54 | // 20 Abnormal (Interrupted) |
55 | |
56 | static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder) |
57 | { |
58 | Standard_Integer stat = 0; |
59 | if (binder.IsNull()) return 0; |
60 | Interface_CheckStatus cst = binder->Check()->Status(); |
61 | Transfer_StatusExec est = binder->StatusExec (); |
62 | Standard_Boolean res = binder->HasResult(); |
63 | if (est == Transfer_StatusRun || est == Transfer_StatusLoop) return 20; |
64 | if (cst == Interface_CheckOK) stat = (res ? 11 : 1); |
65 | else if (cst == Interface_CheckWarning) stat = (res ? 12 : 2); |
66 | else if (cst == Interface_CheckFail) stat = (res ? 13 : 3); |
67 | |
68 | return stat; |
69 | } |
70 | |
71 | |
72 | Standard_CString XSControl_SignTransferStatus::Value |
73 | (const Handle(Standard_Transient)& ent, |
74 | const Handle(Interface_InterfaceModel)& /*model*/) const |
75 | { |
76 | if (ent.IsNull()) return ""; |
77 | Handle(Transfer_TransientProcess) TP = theTP; |
78 | if (TP.IsNull() && !theTR.IsNull()) TP = theTR->TransientProcess(); |
79 | if (TP.IsNull()) return ""; |
80 | |
81 | Handle(Transfer_Binder) binder = TP->Find(ent); |
82 | |
83 | Standard_Integer stat = BinderStatus (binder); |
84 | |
85 | if (stat <= 1) return ""; |
86 | if (stat == 2) return "Warning"; |
87 | if (stat == 3) return "Fail"; |
88 | if (stat == 20) return "Fail on run"; |
89 | |
90 | themes().Clear(); |
91 | if (stat > 10) { |
92 | // Y a un resultat : donner son type |
93 | Handle(Transfer_Binder) bnd = binder; |
94 | Standard_Integer hasres = Standard_False; |
95 | while (!bnd.IsNull()) { |
96 | if (bnd->Status() != Transfer_StatusVoid) { |
97 | if (!hasres) themes().AssignCat("Result:"); |
98 | else themes().AssignCat(","); |
99 | themes().AssignCat(bnd->ResultTypeName()); |
100 | hasres = Standard_True; |
101 | } |
102 | bnd = bnd->NextResult(); |
103 | } |
104 | // if (stat == 11) sprintf(themes,"Result:%s",binder->ResultTypeName()); |
105 | if (stat == 12) themes().AssignCat("/Warning"); |
106 | if (stat == 13) themes().AssignCat("/Fail"); |
107 | } |
108 | return themes().ToCString(); |
109 | } |