b84c95ba6429ee8f50daeab4031dca0313adb5a7
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / networkanalyzer / PceResult.java
1 /*
2  * Copyright © 2017 AT&T, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.transportpce.pce.networkanalyzer;
10
11 import java.math.BigDecimal;
12 import java.util.List;
13 import java.util.Map;
14 import org.opendaylight.transportpce.common.ResponseCodes;
15 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev190531.ServiceFormat;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.AToZDirection;
18 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev201210.path.description.ZToADirection;
19 import org.opendaylight.yangtools.yang.common.Uint16;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 public class PceResult {
24     private static final Logger LOG = LoggerFactory.getLogger(PceResult.class);
25     private String calcMessage = "503 Calculator Unavailable";
26     private boolean calcStatus = false;
27     private String responseCode = ResponseCodes.RESPONSE_FAILED;
28     private long resultWavelength = GridConstant.IRRELEVANT_WAVELENGTH_NUMBER;
29     private Map<String, Uint16> resultTribPort;
30     private Map<String, List<Uint16>> resultTribSlot;
31     private Integer resultTribSlotNb = -1;
32     private String serviceType = "";
33     private BigDecimal minFreq;
34     private BigDecimal maxFreq;
35
36     // for now it is constant returned as received from A-end
37     private long rate = -1;
38     private  ServiceFormat serviceFormat = ServiceFormat.OC;
39
40     public enum LocalCause {
41         NONE, TOO_HIGH_LATENCY, OUT_OF_SPEC_OSNR, NO_PATH_EXISTS, INT_PROBLEM, HD_NODE_INCLUDE;
42     }
43
44     private LocalCause localCause = LocalCause.NONE;
45
46     private AToZDirection atozdirection = null;
47     private ZToADirection ztoadirection = null;
48
49     public void setRC(String rc) {
50         switch (rc) {
51             case ResponseCodes.RESPONSE_OK :
52                 calcMessage = "Path is calculated by PCE";
53                 calcStatus = true;
54                 responseCode = ResponseCodes.RESPONSE_OK;
55                 break;
56             case ResponseCodes.RESPONSE_FAILED :
57                 responseCode = ResponseCodes.RESPONSE_FAILED;
58                 calcStatus = false;
59                 calcMessage = "No path available by PCE";
60                 break;
61             default:
62                 LOG.error("setRC: RespondeCodes unknown");
63         }
64     }
65
66     public String toString() {
67         return ("[" + calcMessage + "] code:[" + responseCode + "] wavelength=" + resultWavelength + " localCause="
68                 + localCause + " rate=" + rate + " serviceType = " + serviceType);
69     }
70
71     public boolean getStatus() {
72         return calcStatus;
73     }
74
75     public String getMessage() {
76         return calcMessage;
77     }
78
79     public String getResponseCode() {
80         return responseCode;
81     }
82
83     public long getResultWavelength() {
84         return resultWavelength;
85     }
86
87     public void setResultWavelength(long resultWavelength) {
88         this.resultWavelength = resultWavelength;
89     }
90
91     public AToZDirection getAtoZDirection() {
92         return atozdirection;
93     }
94
95     public ZToADirection getZtoADirection() {
96         return ztoadirection;
97     }
98
99     public void setAtoZDirection(AToZDirection atozDirection) {
100         this.atozdirection = atozDirection;
101     }
102
103     public void setZtoADirection(ZToADirection ztoaDirection) {
104         this.ztoadirection = ztoaDirection;
105     }
106
107     public long getRate() {
108         return rate;
109     }
110
111     public void setRate(long rate) {
112         this.rate = rate;
113     }
114
115     public ServiceFormat getServiceFormat() {
116         return serviceFormat;
117     }
118
119     public void setServiceFormat(ServiceFormat serviceFormat) {
120         this.serviceFormat = serviceFormat;
121     }
122
123     public LocalCause getLocalCause() {
124         return localCause;
125     }
126
127     public void setLocalCause(LocalCause lc) {
128         this.localCause = lc;
129     }
130
131     public void setCalcMessage(String calcMessage) {
132         this.calcMessage = calcMessage;
133     }
134
135     public Map<String, Uint16> getResultTribPort() {
136         return resultTribPort;
137     }
138
139     public void setResultTribPort(Map<String, Uint16> resultTribPort) {
140         this.resultTribPort = resultTribPort;
141     }
142
143     public Map<String, List<Uint16>> getResultTribSlot() {
144         return resultTribSlot;
145     }
146
147     public void setResultTribSlot(Map<String, List<Uint16>> resultTribSlot) {
148         this.resultTribSlot = resultTribSlot;
149     }
150
151     public int getResultTribSlotNb() {
152         return resultTribSlotNb;
153     }
154
155     public void setResultTribSlotNb(int resultTribSlotNb) {
156         this.resultTribSlotNb = resultTribSlotNb;
157     }
158
159     public String getServiceType() {
160         return serviceType;
161     }
162
163     public void setServiceType(String serviceType) {
164         this.serviceType = serviceType;
165     }
166
167     /**
168      * Get the minimal frequency.
169      * @return the minFreq.
170      */
171     public BigDecimal getMinFreq() {
172         return minFreq;
173     }
174
175     /**
176      * Set the minimal frequency.
177      * @param minFreq the minFreq to set.
178      */
179     public void setMinFreq(BigDecimal minFreq) {
180         this.minFreq = minFreq;
181     }
182
183     /**
184      * Get the maximal frequency.
185      * @return the maxFreq.
186      */
187     public BigDecimal getMaxFreq() {
188         return maxFreq;
189     }
190
191     /**
192      * Set the maximal frequency.
193      * @param maxFreq the maxFreq to set.
194      */
195     public void setMaxFreq(BigDecimal maxFreq) {
196         this.maxFreq = maxFreq;
197     }
198
199 }