1 /*******************************************************************************
2 * Copyright (c) 2011 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.linuxtools
.tmf
.ui
.tests
.views
.uml2sd
.impl
;
14 import org
.eclipse
.linuxtools
.tmf
.component
.TmfComponent
;
15 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimeRange
;
16 import org
.eclipse
.linuxtools
.tmf
.event
.TmfTimestamp
;
17 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfEndSynchSignal
;
18 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfRangeSynchSignal
;
19 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfSignalHandler
;
20 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfStartSynchSignal
;
21 import org
.eclipse
.linuxtools
.tmf
.signal
.TmfTimeSynchSignal
;
24 * Class to implement that certain signals are sent as well as are sent with correct content.
26 public class Uml2SDSignalValidator
extends TmfComponent
implements IUml2SdSignalValidator
{
28 // ------------------------------------------------------------------------
30 // ------------------------------------------------------------------------
31 private int fSignalDepth
= 0;
32 private boolean fIsSignalReceived
= false;
33 private boolean fIsSignalError
= false;
34 private boolean fIsSourceError
= false;
35 private boolean fIsCurrentTimeError
= false;
36 private boolean fIsRangeError
= false;
38 private Object fSource
= null;
39 private TmfTimestamp fCurrentTimestamp
= null;
40 private TmfTimeRange fCurrentTimeRange
= null;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
45 public Uml2SDSignalValidator() {
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
52 public void synchToTime(TmfTimeSynchSignal signal
) {
53 // Set results so that it can be validated in the test case
54 setSignalReceived(true);
55 setSourceError(getSource() != signal
.getSource());
56 setCurrentTimeError(!getCurrentTime().equals(signal
.getCurrentTime()));
60 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
61 // Set results so that it can be validated in the test case
62 setSignalReceived(true);
63 setSourceError(getSource() != signal
.getSource());
64 setCurrentTimeError(!getCurrentTime().equals(signal
.getCurrentTime()));
65 setRangeError(!getCurrentRange().equals(signal
.getCurrentRange()));
69 public void startSynch(TmfStartSynchSignal signal
) {
71 // make sure that the signal which is send by the loader class is not handled by the loader class
72 // after receiving it. i.e. it must not trigger a another signal
74 // Set results so that it can be validated in the test case
75 setSignalError(fSignalDepth
> 1);
79 public void endSynch(TmfEndSynchSignal signal
) {
80 fSignalDepth
= fSignalDepth
> 0 ? fSignalDepth
- 1 : 0;
84 public boolean isSignalReceived() {
85 return fIsSignalReceived
;
89 public void setSignalReceived(boolean received
) {
90 fIsSignalReceived
= received
;
94 public boolean isSourceError() {
95 return fIsSourceError
;
99 public void setSourceError(boolean fIsSourceError
) {
100 this.fIsSourceError
= fIsSourceError
;
104 public boolean isCurrentTimeError() {
105 return fIsCurrentTimeError
;
109 public void setCurrentTimeError(boolean fIsCurrentTimeError
) {
110 this.fIsCurrentTimeError
= fIsCurrentTimeError
;
114 public boolean isRangeError() {
115 return fIsRangeError
;
119 public void setRangeError(boolean fIsRangeError
) {
120 this.fIsRangeError
= fIsRangeError
;
124 public boolean isSignalError() {
125 return fIsSignalError
;
129 public void setSignalError(boolean fIsSignalError
) {
130 this.fIsSignalError
= fIsSignalError
;
134 public Object
getSource() {
139 public void setSource(Object source
) {
144 public TmfTimestamp
getCurrentTime() {
145 return fCurrentTimestamp
;
149 public void setCurrentTime(TmfTimestamp currentTime
) {
150 fCurrentTimestamp
= currentTime
== null ?
null : new TmfTimestamp(currentTime
);
154 public TmfTimeRange
getCurrentRange() {
155 return fCurrentTimeRange
;
159 public void setCurrentRange(TmfTimeRange currentRange
) {
160 fCurrentTimeRange
= currentRange
== null ?
null : new TmfTimeRange(currentRange
);