1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 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
.loader
;
14 import org
.eclipse
.linuxtools
.tmf
.core
.component
.TmfComponent
;
15 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfEndSynchSignal
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfRangeSynchSignal
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfStartSynchSignal
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimeSynchSignal
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimeRange
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimestamp
;
24 * Class to implement that certain signals are sent as well as are sent with correct content.
26 * @author Bernd Hufmann
28 public class Uml2SDSignalValidator
extends TmfComponent
implements IUml2SdSignalValidator
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
33 private int fSignalDepth
= 0;
34 private boolean fIsSignalReceived
= false;
35 private boolean fIsSignalError
= false;
36 private boolean fIsSourceError
= false;
37 private boolean fIsCurrentTimeError
= false;
38 private boolean fIsRangeError
= false;
40 private Object fSource
= null;
41 private TmfTimestamp fCurrentTimestamp
= null;
42 private TmfTimeRange fCurrentTimeRange
= null;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
50 public Uml2SDSignalValidator() {
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 * Signal handler for time synch signal.
58 * @param signal the signal to handle.
61 public void synchToTime(TmfTimeSynchSignal signal
) {
62 // Set results so that it can be validated in the test case
63 setSignalReceived(true);
64 setSourceError(getSource() != signal
.getSource());
65 setCurrentTimeError(!getCurrentTime().equals(signal
.getCurrentTime()));
69 * Signal handler for time range synch signal.
70 * @param signal the signal to handle.
73 public void synchToTimeRange(TmfRangeSynchSignal signal
) {
74 // Set results so that it can be validated in the test case
75 setSignalReceived(true);
76 setSourceError(getSource() != signal
.getSource());
77 setCurrentTimeError(!getCurrentTime().equals(signal
.getCurrentTime()));
78 setRangeError(!getCurrentRange().equals(signal
.getCurrentRange()));
82 * Signal handler for handling start synch signal.
83 * @param signal the signal to handle.
86 public void startSynch(TmfStartSynchSignal signal
) {
88 // make sure that the signal which is send by the loader class is not handled by the loader class
89 // after receiving it. i.e. it must not trigger a another signal
91 // Set results so that it can be validated in the test case
92 setSignalError(fSignalDepth
> 1);
96 * Signal handler for handling end synch signal.
97 * @param signal the signal to handle.
100 public void endSynch(TmfEndSynchSignal signal
) {
101 fSignalDepth
= fSignalDepth
> 0 ? fSignalDepth
- 1 : 0;
105 public boolean isSignalReceived() {
106 return fIsSignalReceived
;
110 public void setSignalReceived(boolean received
) {
111 fIsSignalReceived
= received
;
115 public boolean isSourceError() {
116 return fIsSourceError
;
120 public void setSourceError(boolean fIsSourceError
) {
121 this.fIsSourceError
= fIsSourceError
;
125 public boolean isCurrentTimeError() {
126 return fIsCurrentTimeError
;
130 public void setCurrentTimeError(boolean fIsCurrentTimeError
) {
131 this.fIsCurrentTimeError
= fIsCurrentTimeError
;
135 public boolean isRangeError() {
136 return fIsRangeError
;
140 public void setRangeError(boolean fIsRangeError
) {
141 this.fIsRangeError
= fIsRangeError
;
145 public boolean isSignalError() {
146 return fIsSignalError
;
150 public void setSignalError(boolean fIsSignalError
) {
151 this.fIsSignalError
= fIsSignalError
;
155 public Object
getSource() {
160 public void setSource(Object source
) {
165 public TmfTimestamp
getCurrentTime() {
166 return fCurrentTimestamp
;
170 public void setCurrentTime(TmfTimestamp currentTime
) {
171 fCurrentTimestamp
= currentTime
== null ?
null : new TmfTimestamp(currentTime
);
175 public TmfTimeRange
getCurrentRange() {
176 return fCurrentTimeRange
;
180 public void setCurrentRange(TmfTimeRange currentRange
) {
181 fCurrentTimeRange
= currentRange
== null ?
null : new TmfTimeRange(currentRange
);