b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <XSControl_SignTransferStatus.ixx> |
19 | #include <Transfer_Binder.hxx> |
20 | #include <TCollection_AsciiString.hxx> |
21 | #include <Interface_Check.hxx> |
22 | //#include <stdio.h> |
23 | |
24 | static TCollection_AsciiString& themes() |
25 | { |
26 | static TCollection_AsciiString tm; |
27 | return tm; |
28 | } |
29 | // si resultat avec type: a exploiter tout de suite ! |
30 | |
31 | XSControl_SignTransferStatus::XSControl_SignTransferStatus () |
32 | : IFSelect_Signature("Transfer Status") { } |
33 | |
34 | XSControl_SignTransferStatus::XSControl_SignTransferStatus |
35 | (const Handle(XSControl_TransferReader)& TR) |
36 | : IFSelect_Signature("Transfer Status") , |
37 | theTR (TR) { } |
38 | |
39 | void XSControl_SignTransferStatus::SetReader |
40 | (const Handle(XSControl_TransferReader)& TR) |
41 | { theTR = TR; } |
42 | |
43 | void XSControl_SignTransferStatus::SetMap |
44 | (const Handle(Transfer_TransientProcess)& TP) |
45 | { theTP = TP; } |
46 | |
47 | Handle(Transfer_TransientProcess) XSControl_SignTransferStatus::Map () const |
48 | { return theTP; } |
49 | |
50 | Handle(XSControl_TransferReader) XSControl_SignTransferStatus::Reader () const |
51 | { return theTR; } |
52 | |
53 | |
54 | |
55 | // BinderStatus retourne une valeur : |
56 | // 0 Binder Null. 1 void 2 Warning seul 3 Fail seul |
57 | // 11 Resultat OK. 12 Resultat+Warning. 13 Resultat+Fail |
58 | // 20 Abnormal (Interrupted) |
59 | |
60 | static Standard_Integer BinderStatus (const Handle(Transfer_Binder)& binder) |
61 | { |
62 | Standard_Integer stat = 0; |
63 | if (binder.IsNull()) return 0; |
64 | Interface_CheckStatus cst = binder->Check()->Status(); |
65 | Transfer_StatusExec est = binder->StatusExec (); |
66 | Standard_Boolean res = binder->HasResult(); |
67 | if (est == Transfer_StatusRun || est == Transfer_StatusLoop) return 20; |
68 | if (cst == Interface_CheckOK) stat = (res ? 11 : 1); |
69 | else if (cst == Interface_CheckWarning) stat = (res ? 12 : 2); |
70 | else if (cst == Interface_CheckFail) stat = (res ? 13 : 3); |
71 | |
72 | return stat; |
73 | } |
74 | |
75 | |
76 | Standard_CString XSControl_SignTransferStatus::Value |
77 | (const Handle(Standard_Transient)& ent, |
78 | const Handle(Interface_InterfaceModel)& /*model*/) const |
79 | { |
80 | if (ent.IsNull()) return ""; |
81 | Handle(Transfer_TransientProcess) TP = theTP; |
82 | if (TP.IsNull() && !theTR.IsNull()) TP = theTR->TransientProcess(); |
83 | if (TP.IsNull()) return ""; |
84 | |
85 | Handle(Transfer_Binder) binder = TP->Find(ent); |
86 | |
87 | Standard_Integer stat = BinderStatus (binder); |
88 | |
89 | if (stat <= 1) return ""; |
90 | if (stat == 2) return "Warning"; |
91 | if (stat == 3) return "Fail"; |
92 | if (stat == 20) return "Fail on run"; |
93 | |
94 | themes().Clear(); |
95 | if (stat > 10) { |
96 | // Y a un resultat : donner son type |
97 | Handle(Transfer_Binder) bnd = binder; |
98 | Standard_Integer hasres = Standard_False; |
99 | while (!bnd.IsNull()) { |
100 | if (bnd->Status() != Transfer_StatusVoid) { |
101 | if (!hasres) themes().AssignCat("Result:"); |
102 | else themes().AssignCat(","); |
103 | themes().AssignCat(bnd->ResultTypeName()); |
104 | hasres = Standard_True; |
105 | } |
106 | bnd = bnd->NextResult(); |
107 | } |
108 | // if (stat == 11) sprintf(themes,"Result:%s",binder->ResultTypeName()); |
109 | if (stat == 12) themes().AssignCat("/Warning"); |
110 | if (stat == 13) themes().AssignCat("/Fail"); |
111 | } |
112 | return themes().ToCString(); |
113 | } |