blob: 8a04df4324ea4681d3ab00f53fa898f5267109ae (
plain)
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
|
/***************************************************************************
* Copyright (C) 2005 by David Saxton *
* david@bluehaze.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "oscilloscopedata.h"
#include "oscilloscope.h"
//BEGIN class ProbeData
ProbeData::ProbeData( int id )
: m_id(id)
{
m_resetTime = Simulator::self()->time();
// b_isPaused = false;
m_color = TQt::black;
m_drawPosition = 0.5;
m_insertPos = 0;
}
ProbeData::~ProbeData()
{
unregisterProbe(m_id);
}
void ProbeData::setColor( TQColor color )
{
m_color = color;
emit displayAttributeChanged();
}
//END class ProbeData
//BEGIN class LogicProbeData
LogicProbeData::LogicProbeData( int id )
: ProbeData(id)
{
}
void LogicProbeData::eraseData()
{
bool lastValue = false;
bool hasLastValue = m_insertPos > 0;
if (hasLastValue)
lastValue = m_data[m_insertPos-1].value;
m_data.reset();
m_insertPos = 0;
m_resetTime = Simulator::self()->time();
if (hasLastValue)
addDataPoint( LogicDataPoint( lastValue, m_resetTime ) );
}
ullong LogicProbeData::findPos( llong time ) const
{
if ( time <= 0 )
return 0;
for ( int a = m_data.allocatedUpTo()-1; a >= 0; a-- )
{
DCArray<LogicDataPoint> * dcArray = m_data.dcArray(a);
// We're only interested in this if the earliest recorded data point in this dcArray is <= time
if ( m_data.toPos( a, 0, 0 ) >= m_insertPos || (dcArray->chunk(0)->data[0].time > ullong(time)) )
continue;
// Cool, somewhere in this dcArray....
for ( int b = dcArray->allocatedUpTo()-1; b >= 0; b-- )
{
// Done check if the data we'd be accessing is beyond that set
if ( m_data.toPos( a, b, 0 ) >= m_insertPos || dcArray->chunk(b)->data[0].time > ullong(time) )
continue;
// Soon...
for ( int c = DATA_CHUNK_SIZE-1; c >= 0; c-- )
{
ullong pos = m_data.toPos( a, b, c );
if ( pos >= m_insertPos || dcArray->chunk(b)->data[c].time > ullong(time) )
continue;
// Wee!
return pos;
}
}
}
// Either we have no data points, or the one closest to the given time will be the one at the start
return 0;
}
//END class LogicProbeData
//BEGIN class FloatingProbeData
FloatingProbeData::FloatingProbeData( int id )
: ProbeData(id)
{
m_scaling = Linear;
m_upperAbsValue = 10.0;
m_lowerAbsValue = 0.1;
}
void FloatingProbeData::eraseData()
{
m_data.reset();
m_insertPos = 0;
m_resetTime = Simulator::self()->time();
}
ullong FloatingProbeData::findPos( llong time ) const
{
if ( time <= 0 || ullong(time) <= m_resetTime || m_insertPos == 0 )
return 0;
ullong at = ullong((time-m_resetTime)*double(LINEAR_UPDATE_RATE)/double(LOGIC_UPDATE_RATE));
if ( at >= m_insertPos )
at = m_insertPos-1;
return at;
}
ullong FloatingProbeData::toTime( ullong at ) const
{
return ullong(m_resetTime + (at*LOGIC_UPDATE_RATE/LINEAR_UPDATE_RATE));
}
void FloatingProbeData::setScaling( Scaling scaling )
{
if ( m_scaling == scaling )
return;
m_scaling = scaling;
emit displayAttributeChanged();
}
void FloatingProbeData::setUpperAbsValue( double upperAbsValue )
{
if ( m_upperAbsValue == upperAbsValue )
return;
m_upperAbsValue = upperAbsValue;
emit displayAttributeChanged();
}
void FloatingProbeData::setLowerAbsValue( double lowerAbsValue )
{
if ( m_lowerAbsValue == lowerAbsValue )
return;
m_lowerAbsValue = lowerAbsValue;
emit displayAttributeChanged();
}
#include "oscilloscopedata.moc"
//END class FloatingProbeData
|