1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
/*
 * Copyright 2011-17 Fraunhofer ISE, energy & meteo Systems GmbH and other contributors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package org.openmuc.openiec61850;
 
import java.util.List;
 
public class Report {
 
    private final String rptId;
    private final Integer sqNum;
    private final Integer subSqNum;
    private final boolean moreSegmentsFollow;
    private final String dataSetRef;
    private final Boolean bufOvfl;
    private final Long confRev;
    private final BdaEntryTime timeOfEntry;
    private final BdaOctetString entryId;
    private final boolean[] inclusionBitString;
    private final List<FcModelNode> values;
    private final List<BdaReasonForInclusion> reasonCodes;
 
    public Report(String rptId, Integer sqNum, Integer subSqNum, boolean moreSegmentsFollow, String dataSetRef,
            Boolean bufOvfl, Long confRev, BdaEntryTime timeOfEntry, BdaOctetString entryId,
            boolean[] inclusionBitString, List<FcModelNode> values, List<BdaReasonForInclusion> reasonCodes) {
        this.rptId = rptId;
        this.sqNum = sqNum;
        this.subSqNum = subSqNum;
        this.moreSegmentsFollow = moreSegmentsFollow;
        this.dataSetRef = dataSetRef;
        this.bufOvfl = bufOvfl;
        this.confRev = confRev;
        this.timeOfEntry = timeOfEntry;
        this.entryId = entryId;
        this.inclusionBitString = inclusionBitString;
        this.values = values;
        this.reasonCodes = reasonCodes;
    }
 
    public String getRptId() {
        return rptId;
    }
 
    /**
     * Sequence numberThe parameter MoreSegmentsFollow indicates that more report segments with the same sequence number
     * follow, counted up for every {@code Report} instance generated
     * 
     * @return the sequence number
     */
    public Integer getSqNum() {
        return sqNum;
    }
 
    /**
     * For the case of long reports that do not fit into one message, a single report shall be divided into subreports.
     * Each segment – of one report – shall be numbered with the same sequence number and a unique SubSqNum.
     * 
     * @return the subsequence number
     */
    public Integer getSubSqNum() {
        return subSqNum;
    }
 
    /**
     * The parameter MoreSegmentsFollow indicates that more report segments with the same sequence number follow
     * 
     * @return true if more segments follow
     */
    public boolean isMoreSegmentsFollow() {
        return moreSegmentsFollow;
    }
 
    public String getDataSetRef() {
        return dataSetRef;
    }
 
    /**
     * The parameter BufOvfl shall indicate to the client that entries within the buffer may have been lost. The
     * detection of possible loss of information occurs when a client requests a resynchronization to a non-existent
     * entry or to the first entry in the queue.
     * 
     * @return true if buffer overflow is true
     */
    public Boolean getBufOvfl() {
        return bufOvfl;
    }
 
    public Long getConfRev() {
        return confRev;
    }
 
    /**
     * The parameter TimeOfEntry shall specify the time when the EntryID was created
     * 
     * @return the time of entry
     */
    public BdaEntryTime getTimeOfEntry() {
        return timeOfEntry;
    }
 
    public BdaOctetString getEntryId() {
        return entryId;
    }
 
    /**
     * Indicator of data set members included in the report
     * 
     * @return the inclusion bit string as a byte array
     */
    public boolean[] getInclusionBitString() {
        return inclusionBitString;
    }
 
    /**
     * Gets the reasons for inclusion
     * 
     * @return the reasons for inclusion
     */
    public List<BdaReasonForInclusion> getReasonCodes() {
        return reasonCodes;
    }
 
    public List<FcModelNode> getValues() {
        return values;
    }
 
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("Report ID: ").append(rptId);
        sb.append("\nData set reference: ").append(dataSetRef);
 
        if (sqNum != null) {
            sb.append("\nSequence number: ").append(sqNum);
        }
        if (subSqNum != null) {
            sb.append("\nSubsequence number: ").append(subSqNum);
            if (moreSegmentsFollow) {
                sb.append(" (more segments follow)");
            }
        }
        if (timeOfEntry != null) {
            sb.append("\nTime of entry (unix timestamp): ").append(timeOfEntry.getTimestampValue());
        }
        if (bufOvfl != null) {
            sb.append("\nBuffer overflow: ").append(bufOvfl);
        }
        if (entryId != null) {
            sb.append("\nEntry ID: ").append(HexConverter.toHexString(entryId.getValue()));
        }
        if (confRev != null) {
            sb.append("\nConfiguration revision: ").append(confRev.toString());
        }
        sb.append("\nReported data set members:");
        int index = 0;
        for (FcModelNode reportedDataSetMember : values) {
            sb.append("\n").append(reportedDataSetMember.toString());
            if (reasonCodes != null) {
                sb.append(", reason: ").append(reasonCodes.get(index));
            }
            index++;
        }
 
        return sb.toString();
    }
 
}