Use version 13.1.0 of openroadm-network models
[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 org.opendaylight.transportpce.common.ResponseCodes;
14 import org.opendaylight.transportpce.common.fixedflex.GridConstant;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.otn.common.types.rev210924.OpucnTribSlotDef;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat;
17 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.AToZDirection;
18 import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.path.description.ZToADirection;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class PceResult {
23     private static final Logger LOG = LoggerFactory.getLogger(PceResult.class);
24     private String calcMessage = "503 Calculator Unavailable";
25     private boolean calcStatus = false;
26     private String responseCode = ResponseCodes.RESPONSE_FAILED;
27     private long resultWavelength = GridConstant.IRRELEVANT_WAVELENGTH_NUMBER;
28     private List<OpucnTribSlotDef> resultTribSlotDefList;
29     private String serviceType = "";
30     private BigDecimal minFreq;
31     private BigDecimal maxFreq;
32
33     // for now it is constant returned as received from A-end
34     private long rate = -1;
35     private  ServiceFormat serviceFormat = ServiceFormat.OC;
36
37     public enum LocalCause {
38         NONE, TOO_HIGH_LATENCY, OUT_OF_SPEC_OSNR, NO_PATH_EXISTS, INT_PROBLEM, HD_NODE_INCLUDE;
39     }
40
41     private LocalCause localCause = LocalCause.NONE;
42
43     private AToZDirection atozdirection = null;
44     private ZToADirection ztoadirection = null;
45
46     public void setRC(String rc) {
47         switch (rc) {
48             case ResponseCodes.RESPONSE_OK :
49                 calcMessage = "Path is calculated by PCE";
50                 calcStatus = true;
51                 responseCode = ResponseCodes.RESPONSE_OK;
52                 break;
53             case ResponseCodes.RESPONSE_FAILED :
54                 responseCode = ResponseCodes.RESPONSE_FAILED;
55                 calcStatus = false;
56                 calcMessage = "No path available by PCE";
57                 break;
58             default:
59                 LOG.error("setRC: RespondeCodes unknown");
60         }
61     }
62
63     public String toString() {
64         return ("[" + calcMessage + "] code:[" + responseCode + "] wavelength=" + resultWavelength + " localCause="
65                 + localCause + " rate=" + rate + " serviceType = " + serviceType);
66     }
67
68     public boolean getStatus() {
69         return calcStatus;
70     }
71
72     public String getMessage() {
73         return calcMessage;
74     }
75
76     public String getResponseCode() {
77         return responseCode;
78     }
79
80     public long getResultWavelength() {
81         return resultWavelength;
82     }
83
84     public void setResultWavelength(long resultWavelength) {
85         this.resultWavelength = resultWavelength;
86     }
87
88     public AToZDirection getAtoZDirection() {
89         return atozdirection;
90     }
91
92     public ZToADirection getZtoADirection() {
93         return ztoadirection;
94     }
95
96     public void setAtoZDirection(AToZDirection atozDirection) {
97         this.atozdirection = atozDirection;
98     }
99
100     public void setZtoADirection(ZToADirection ztoaDirection) {
101         this.ztoadirection = ztoaDirection;
102     }
103
104     public long getRate() {
105         return rate;
106     }
107
108     public void setRate(long rate) {
109         this.rate = rate;
110     }
111
112     public ServiceFormat getServiceFormat() {
113         return serviceFormat;
114     }
115
116     public void setServiceFormat(ServiceFormat serviceFormat) {
117         this.serviceFormat = serviceFormat;
118     }
119
120     public LocalCause getLocalCause() {
121         return localCause;
122     }
123
124     public void setLocalCause(LocalCause lc) {
125         this.localCause = lc;
126     }
127
128     public void setCalcMessage(String calcMessage) {
129         this.calcMessage = calcMessage;
130     }
131
132     public List<OpucnTribSlotDef> getResultTribPortTribSlot() {
133         return resultTribSlotDefList;
134     }
135
136     public void setResultTribPortTribSlot(List<OpucnTribSlotDef> resultTribPortTribSlot) {
137         this.resultTribSlotDefList = resultTribPortTribSlot;
138     }
139
140     public String getServiceType() {
141         return serviceType;
142     }
143
144     public void setServiceType(String serviceType) {
145         this.serviceType = serviceType;
146     }
147
148     /**
149      * Get the minimal frequency.
150      * @return the minFreq.
151      */
152     public BigDecimal getMinFreq() {
153         return minFreq;
154     }
155
156     /**
157      * Set the minimal frequency.
158      * @param minFreq the minFreq to set.
159      */
160     public void setMinFreq(BigDecimal minFreq) {
161         this.minFreq = minFreq;
162     }
163
164     /**
165      * Get the maximal frequency.
166      * @return the maxFreq.
167      */
168     public BigDecimal getMaxFreq() {
169         return maxFreq;
170     }
171
172     /**
173      * Set the maximal frequency.
174      * @param maxFreq the maxFreq to set.
175      */
176     public void setMaxFreq(BigDecimal maxFreq) {
177         this.maxFreq = maxFreq;
178     }
179
180 }