diff options
Diffstat (limited to 'clients')
-rw-r--r-- | clients/tde/src/part/scope/part.cpp | 263 | ||||
-rw-r--r-- | clients/tde/src/part/scope/part.h | 2 | ||||
-rw-r--r-- | clients/tde/src/widgets/tracewidget.cpp | 109 | ||||
-rw-r--r-- | clients/tde/src/widgets/tracewidget.h | 11 |
4 files changed, 291 insertions, 94 deletions
diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp index 04fdb55..d6dda20 100644 --- a/clients/tde/src/part/scope/part.cpp +++ b/clients/tde/src/part/scope/part.cpp @@ -37,6 +37,22 @@ struct exit_exception { exit_exception(int c):c(c) { } }; +enum connectionStates { + ScopeState_InitialRequest = 0, + ScopeState_ResetRequest = 2, + ScopeState_HorizontalDivCountRequest = 4, + ScopeState_VerticalDivCountRequest = 6, + ScopeState_ChannelCountRequest = 8, + ScopeState_ChannelActiveStateRequest = 10, + ScopeState_TraceSampleCountRequest = 12, + ScopeState_TraceVoltsDivRequest = 14, + ScopeState_TraceSecondsDivRequest = 16, + ScopeState_TriggerChannelRequest = 18, + ScopeState_TriggerLevelRequest = 20, + ScopeState_TraceRequest = 50, + ScopeState_ExternalCommandRequest = 255 +}; + namespace RemoteLab { typedef KParts::GenericFactory<RemoteLab::ScopePart> Factory; @@ -78,23 +94,38 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject * m_base = new ScopeBase(widget()); m_traceWidget = m_base->traceWidget; m_traceWidget->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding)); - m_traceWidget->setNumberOfCursors(4); + m_traceWidget->setNumberOfCursors(5); + m_traceWidget->setZoomCursorStartIndex(1); + m_traceWidget->setCursorColor(0, TQColor(64, 255, 255)); + m_traceWidget->setCursorHighlightColor(0, TQColor(192, 255, 255)); m_traceWidget->setCursorOrientation(0, TQt::Horizontal); m_traceWidget->setCursorOrientation(1, TQt::Horizontal); - m_traceWidget->setCursorOrientation(2, TQt::Vertical); + m_traceWidget->setCursorOrientation(2, TQt::Horizontal); m_traceWidget->setCursorOrientation(3, TQt::Vertical); + m_traceWidget->setCursorOrientation(4, TQt::Vertical); m_traceWidget->setCursorEnabled(0, true); m_traceWidget->setCursorEnabled(1, true); m_traceWidget->setCursorEnabled(2, true); m_traceWidget->setCursorEnabled(3, true); - m_traceWidget->setCursorName(0, "Cursor H1"); - m_traceWidget->setCursorName(1, "Cursor H2"); - m_traceWidget->setCursorName(2, "Cursor V1"); - m_traceWidget->setCursorName(3, "Cursor V2"); - m_traceWidget->setCursorPosition(0, 25); - m_traceWidget->setCursorPosition(1, 75); - m_traceWidget->setCursorPosition(2, 25); - m_traceWidget->setCursorPosition(3, 75); + m_traceWidget->setCursorEnabled(4, true); + m_traceWidget->setCursorName(0, "Trigger"); + m_traceWidget->setCursorName(1, "Cursor H1"); + m_traceWidget->setCursorName(2, "Cursor H2"); + m_traceWidget->setCursorName(3, "Cursor V1"); + m_traceWidget->setCursorName(4, "Cursor V2"); + m_traceWidget->setCursorPosition(0, 40); + m_traceWidget->setCursorPosition(1, 25); + m_traceWidget->setCursorPosition(2, 75); + m_traceWidget->setCursorPosition(3, 25); + m_traceWidget->setCursorPosition(4, 75); + TraceNumberList activeTraces; + for (uint trace=0; trace<MAXTRACES; trace++) { + activeTraces.append(trace); + } + m_traceWidget->setCursorActiveTraceList(1, activeTraces); + m_traceWidget->setCursorActiveTraceList(2, activeTraces); + m_traceWidget->setCursorActiveTraceList(3, activeTraces); + m_traceWidget->setCursorActiveTraceList(4, activeTraces); m_traceWidget->setZoomBoxEnabled(true); m_base->traceZoomWidget->setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding)); @@ -231,7 +262,7 @@ void ScopePart::setTickerMessage(TQString message) { #define UPDATEDISPLAY_TIMEOUT m_connectionActiveAndValid = false; \ m_tickerState = 0; \ - m_commHandlerState = 2; \ + m_commHandlerState = ScopeState_ResetRequest; \ m_commHandlerMode = 0; \ m_socket->clearIncomingData(); \ setStatusMessage(i18n("Server ping timeout. Please verify the status of your network connection.")); \ @@ -241,7 +272,7 @@ void ScopePart::setTickerMessage(TQString message) { #define COMMUNICATIONS_FAILED m_connectionActiveAndValid = false; \ m_tickerState = 0; \ - m_commHandlerState = 2; \ + m_commHandlerState = ScopeState_ResetRequest; \ m_commHandlerMode = 0; \ m_socket->clearIncomingData(); \ setStatusMessage(i18n("Instrument communication failure. Please verify the status of your network connection.")); \ @@ -250,17 +281,13 @@ void ScopePart::setTickerMessage(TQString message) { return; #define SET_WATCHDOG_TIMER if (!m_updateTimeoutTimer->isActive()) m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); -#define PAT_WATCHDOG_TIMER m_updateTimeoutTimer->stop(); m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); \ - setTickerMessage(i18n("Connected")); +#define PAT_WATCHDOG_TIMER m_updateTimeoutTimer->stop(); m_updateTimeoutTimer->start(NETWORK_COMM_TIMEOUT_MS, TRUE); #define SET_NEXT_STATE(x) if (m_commHandlerMode == 0) { \ m_commHandlerState = x; \ } \ else { \ - m_commHandlerState = 255; \ - } \ - if (m_commHandlerState < 50) { \ - setTickerMessage(i18n("Loading")); \ + m_commHandlerState = ScopeState_ExternalCommandRequest; \ } #define EXEC_NEXT_STATE_IMMEDIATELY m_forcedUpdateTimer->start(0, TRUE); @@ -287,18 +314,19 @@ void ScopePart::mainEventLoop() { if (m_socket) { if ((m_commHandlerMode == 0) || (m_commHandlerMode == 1)) { - if (m_commHandlerState == 0) { + if (m_commHandlerState == ScopeState_InitialRequest) { // Request scope access ds << TQString("OSCILLOSCOPE"); m_socket->writeEndOfFrame(); - m_commHandlerState = 1; + m_commHandlerState = ScopeState_InitialRequest+1; EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 1) { + else if (m_commHandlerState == ScopeState_InitialRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Connected")); // Get command status TQString result; @@ -306,7 +334,7 @@ void ScopePart::mainEventLoop() { m_socket->clearFrameTail(); if (result == "ACK") { - SET_NEXT_STATE(2) + SET_NEXT_STATE(ScopeState_ResetRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -319,18 +347,19 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 2) { + else if (m_commHandlerState == ScopeState_ResetRequest) { // Reset scope ds << TQString("RESET"); m_socket->writeEndOfFrame(); - SET_NEXT_STATE(3) + SET_NEXT_STATE(ScopeState_ResetRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 3) { + else if (m_commHandlerState == ScopeState_ResetRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Reset complete]")); // Get command status TQString result; @@ -338,7 +367,7 @@ void ScopePart::mainEventLoop() { m_socket->clearFrameTail(); if (result == "ACK") { - SET_NEXT_STATE(4) + SET_NEXT_STATE(ScopeState_HorizontalDivCountRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -351,18 +380,19 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 4) { + else if (m_commHandlerState == ScopeState_HorizontalDivCountRequest) { // Get number of horizontal divisions, step 1 ds << TQString("GETHORIZONTALDIVCOUNT"); m_socket->writeEndOfFrame(); - SET_NEXT_STATE(5) + SET_NEXT_STATE(ScopeState_HorizontalDivCountRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 5) { + else if (m_commHandlerState == ScopeState_HorizontalDivCountRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received horizontal division count]")); // Get number of horizontal divisions, step 2 TQString result; @@ -373,7 +403,7 @@ void ScopePart::mainEventLoop() { m_socket->clearFrameTail(); if (result == "ACK") { - SET_NEXT_STATE(6) + SET_NEXT_STATE(ScopeState_VerticalDivCountRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -386,18 +416,19 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 6) { + else if (m_commHandlerState == ScopeState_VerticalDivCountRequest) { // Get number of vertical divisions, step 1 ds << TQString("GETVERTICALDIVCOUNT"); m_socket->writeEndOfFrame(); - SET_NEXT_STATE(7) + SET_NEXT_STATE(ScopeState_VerticalDivCountRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 7) { + else if (m_commHandlerState == ScopeState_VerticalDivCountRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received vertical division count]")); // Get number of vertical divisions, step 2 TQString result; @@ -408,7 +439,7 @@ void ScopePart::mainEventLoop() { m_socket->clearFrameTail(); if (result == "ACK") { - SET_NEXT_STATE(8) + SET_NEXT_STATE(ScopeState_ChannelCountRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -421,18 +452,19 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 8) { + else if (m_commHandlerState == ScopeState_ChannelCountRequest) { // Get number of channels, step 1 ds << TQString("GETNUMBEROFCHANNELS"); m_socket->writeEndOfFrame(); - SET_NEXT_STATE(9) + SET_NEXT_STATE(ScopeState_ChannelCountRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 9) { + else if (m_commHandlerState == ScopeState_ChannelCountRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received number of channels]")); // Get number of channels, step 2 TQString result; @@ -447,7 +479,7 @@ void ScopePart::mainEventLoop() { if (result == "ACK") { m_currentOpChannel = 1; - SET_NEXT_STATE(10) + SET_NEXT_STATE(ScopeState_ChannelActiveStateRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -460,19 +492,20 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 10) { + else if (m_commHandlerState == ScopeState_ChannelActiveStateRequest) { // Get channel status, step 1 ds << TQString("GETCHANNELACTIVE"); ds << m_currentOpChannel; m_socket->writeEndOfFrame(); - SET_NEXT_STATE(11) + SET_NEXT_STATE(ScopeState_ChannelActiveStateRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 11) { + else if (m_commHandlerState == ScopeState_ChannelActiveStateRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received channel %1 activity status]").arg(m_currentOpChannel)); // Get channel status, step 2 TQString result; @@ -487,16 +520,16 @@ void ScopePart::mainEventLoop() { if (result == "ACK") { if (m_currentOpChannel < m_maxNumberOfTraces) { m_currentOpChannel++; - SET_NEXT_STATE(10) + SET_NEXT_STATE(ScopeState_ChannelActiveStateRequest) } else { m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); if (m_currentOpChannel > 0) { - SET_NEXT_STATE(12) + SET_NEXT_STATE(ScopeState_TraceSampleCountRequest) } else { m_currentOpChannel = 1; - SET_NEXT_STATE(8) + SET_NEXT_STATE(ScopeState_ChannelCountRequest) } } EXEC_NEXT_STATE_IMMEDIATELY @@ -511,19 +544,20 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 12) { + else if (m_commHandlerState == ScopeState_TraceSampleCountRequest) { // Get number of samples in trace, step 1 ds << TQString("GETTRACESAMPLECOUNT"); ds << m_currentOpChannel; m_socket->writeEndOfFrame(); - SET_NEXT_STATE(13) + SET_NEXT_STATE(ScopeState_TraceSampleCountRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 13) { + else if (m_commHandlerState == ScopeState_TraceSampleCountRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received trace sample count for channel %1]").arg(m_currentOpChannel)); // Get number of samples in trace, step 2 TQString result; @@ -536,11 +570,11 @@ void ScopePart::mainEventLoop() { if (result == "ACK") { m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces); if (m_currentOpChannel > 0) { - SET_NEXT_STATE(12) + SET_NEXT_STATE(ScopeState_TraceSampleCountRequest) } else { m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); - SET_NEXT_STATE(14) + SET_NEXT_STATE(ScopeState_TraceVoltsDivRequest) } EXEC_NEXT_STATE_IMMEDIATELY } @@ -554,19 +588,20 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 14) { + else if (m_commHandlerState == ScopeState_TraceVoltsDivRequest) { // Get volts per division, step 1 ds << TQString("GETVOLTSDIV"); ds << m_currentOpChannel; m_socket->writeEndOfFrame(); - SET_NEXT_STATE(15) + SET_NEXT_STATE(ScopeState_TraceVoltsDivRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 15) { + else if (m_commHandlerState == ScopeState_TraceVoltsDivRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received volts/div for channel %1]").arg(m_currentOpChannel)); // Get volts per division, step 2 TQString result; @@ -579,11 +614,11 @@ void ScopePart::mainEventLoop() { if (result == "ACK") { m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces); if (m_currentOpChannel > 0) { - SET_NEXT_STATE(14) + SET_NEXT_STATE(ScopeState_TraceVoltsDivRequest) } else { m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); - SET_NEXT_STATE(16) + SET_NEXT_STATE(ScopeState_TraceSecondsDivRequest) } EXEC_NEXT_STATE_IMMEDIATELY } @@ -597,19 +632,20 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 16) { + else if (m_commHandlerState == ScopeState_TraceSecondsDivRequest) { // Get seconds per division, step 1 ds << TQString("GETSECONDSSDIV"); ds << m_currentOpChannel; m_socket->writeEndOfFrame(); - SET_NEXT_STATE(17) + SET_NEXT_STATE(ScopeState_TraceSecondsDivRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 17) { + else if (m_commHandlerState == ScopeState_TraceSecondsDivRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received seconds/div]")); // Get seconds per division, step 2 TQString result; @@ -618,6 +654,86 @@ void ScopePart::mainEventLoop() { ds >> m_secsDiv[m_currentOpChannel]; } m_socket->clearFrameTail(); + + if (result == "ACK") { + m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces); + if (m_currentOpChannel > 0) { + SET_NEXT_STATE(ScopeState_TraceSecondsDivRequest) + } + else { + SET_NEXT_STATE(ScopeState_TriggerChannelRequest) + } + EXEC_NEXT_STATE_IMMEDIATELY + } + else { + COMMUNICATIONS_FAILED + } + } + else { + if (!m_updateTimeoutTimer->isActive()) { + UPDATEDISPLAY_TIMEOUT + } + } + } + else if (m_commHandlerState == ScopeState_TriggerChannelRequest) { + // Get trigger channel, step 1 + ds << TQString("GETTRIGGERCHANNEL"); + ds << m_currentOpChannel; + m_socket->writeEndOfFrame(); + + SET_NEXT_STATE(ScopeState_TriggerChannelRequest+1) + EXEC_NEXT_STATE_IMMEDIATELY + } + else if (m_commHandlerState == ScopeState_TriggerChannelRequest+1) { + // Get response data + if (m_socket->canReadFrame()) { + PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received trigger channel]")); + + // Get trigger channel, step 2 + TQString result; + ds >> result; + if (result == "ACK") { + ds >> m_triggerChannel; + } + m_socket->clearFrameTail(); + + if (result == "ACK") { + SET_NEXT_STATE(ScopeState_TriggerLevelRequest) + EXEC_NEXT_STATE_IMMEDIATELY + } + else { + COMMUNICATIONS_FAILED + } + } + else { + if (!m_updateTimeoutTimer->isActive()) { + UPDATEDISPLAY_TIMEOUT + } + } + } + else if (m_commHandlerState == ScopeState_TriggerLevelRequest) { + // Get trigger level, step 1 + ds << TQString("GETTRIGGERLEVEL"); + ds << m_currentOpChannel; + m_socket->writeEndOfFrame(); + + SET_NEXT_STATE(ScopeState_TriggerLevelRequest+1) + EXEC_NEXT_STATE_IMMEDIATELY + } + else if (m_commHandlerState == ScopeState_TriggerLevelRequest+1) { + // Get response data + if (m_socket->canReadFrame()) { + PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Loading [Received trigger level]")); + + // Get trigger level, step 2 + TQString result; + ds >> result; + if (result == "ACK") { + ds >> m_triggerLevel; + } + m_socket->clearFrameTail(); if (result == "ACK") { // Update display widget(s) @@ -628,14 +744,8 @@ void ScopePart::mainEventLoop() { } if (result == "ACK") { - m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces); - if (m_currentOpChannel > 0) { - SET_NEXT_STATE(16) - } - else { - m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); - SET_NEXT_STATE(50) - } + m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); + SET_NEXT_STATE(ScopeState_TraceRequest) EXEC_NEXT_STATE_IMMEDIATELY } else { @@ -648,19 +758,20 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 50) { + else if (m_commHandlerState == ScopeState_TraceRequest) { // Get trace, step 1 ds << TQString("GETCHANNELTRACE"); ds << m_currentOpChannel; m_socket->writeEndOfFrame(); - SET_NEXT_STATE(51) + SET_NEXT_STATE(ScopeState_TraceRequest+1) EXEC_NEXT_STATE_IMMEDIATELY } - else if (m_commHandlerState == 51) { + else if (m_commHandlerState == ScopeState_TraceRequest+1) { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Running [Received trace for channel %1]").arg(m_currentOpChannel)); // Get trace, step 2 TQDoubleArray trace; @@ -687,11 +798,11 @@ void ScopePart::mainEventLoop() { if (result == "ACK") { m_currentOpChannel = getNextActiveChannel(m_currentOpChannel, m_channelActive, m_maxNumberOfTraces); if (m_currentOpChannel > 0) { - SET_NEXT_STATE(50) + SET_NEXT_STATE(ScopeState_TraceRequest) } else { m_currentOpChannel = getNextActiveChannel(0, m_channelActive, m_maxNumberOfTraces); - SET_NEXT_STATE(50) + SET_NEXT_STATE(ScopeState_TraceRequest) } EXEC_NEXT_STATE_IMMEDIATELY } @@ -705,7 +816,7 @@ void ScopePart::mainEventLoop() { } } } - else if (m_commHandlerState == 255) { + else if (m_commHandlerState == ScopeState_ExternalCommandRequest) { // Execute pending command m_commHandlerMode = 2; m_socket->clearIncomingData(); @@ -716,7 +827,7 @@ void ScopePart::mainEventLoop() { else if (m_commHandlerMode == 2) { if (m_commHandlerCommandState == 0) { m_commHandlerMode = 0; - m_commHandlerState = 10; + m_commHandlerState = ScopeState_ChannelActiveStateRequest; EXEC_NEXT_STATE_IMMEDIATELY } else if (m_commHandlerCommandState == 1) { @@ -733,6 +844,7 @@ void ScopePart::mainEventLoop() { // Get response data if (m_socket->canReadFrame()) { PAT_WATCHDOG_TIMER + setTickerMessage(i18n("Connected")); // Set channel active, step 2 TQString result; @@ -765,7 +877,7 @@ void ScopePart::mainEventLoop() { } } else { - m_commHandlerState = 0; + m_commHandlerState = ScopeState_ResetRequest; m_commHandlerCommandState = 0; } @@ -896,6 +1008,11 @@ void ScopePart::updateGraticule() { m_base->traceZoomWidget->setNumberOfHorizontalDivisions(m_hdivs); m_base->traceZoomWidget->setNumberOfVerticalDivisions(m_vdivs); + TraceNumberList activeTraces; + activeTraces.append(m_triggerChannel-1); + m_traceWidget->setCursorActiveTraceList(0, activeTraces); + m_traceWidget->setCursorPosition(0, (50.0-((m_triggerLevel*100.0)/(m_voltsDiv[m_triggerChannel]*m_vdivs)))); + m_traceWidget->setTraceColor(0, TQColor(255, 255, 255)); m_traceWidget->setTraceColor(1, TQColor(128, 255, 128)); m_traceWidget->setTraceColor(2, TQColor(255, 255, 128)); diff --git a/clients/tde/src/part/scope/part.h b/clients/tde/src/part/scope/part.h index 0032a3e..1e342da 100644 --- a/clients/tde/src/part/scope/part.h +++ b/clients/tde/src/part/scope/part.h @@ -71,6 +71,8 @@ namespace RemoteLab TQ_INT16 m_nextOpParameter16; TQ_INT16 m_hdivs; TQ_INT16 m_vdivs; + TQ_INT16 m_triggerChannel; + double m_triggerLevel; TQ_INT32 m_samplesInTrace[MAXTRACES+1]; bool m_channelActive[MAXTRACES+1]; double m_voltsDiv[MAXTRACES+1]; diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp index e3803ed..e62bdb0 100644 --- a/clients/tde/src/widgets/tracewidget.cpp +++ b/clients/tde/src/widgets/tracewidget.cpp @@ -114,12 +114,15 @@ TraceData::TraceData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), p paramLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor()); paramLabel->setPaletteForegroundColor(color); paramLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine); + TQFont font; + font = paramLabel->font(); + font.setPointSize(font.pointSize()-1); + paramLabel->setFont(font); paramLabel->hide(); graphStatusLabel = new TQLabel(labelParent); graphStatusLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor()); graphStatusLabel->setPaletteForegroundColor(color); graphStatusLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine); - TQFont font; font = graphStatusLabel->font(); font.setPointSize(font.pointSize()-1); graphStatusLabel->setFont(font); @@ -232,6 +235,7 @@ void TraceData::movePosOneTick() { emit(offsetChanged(offset)); parentWidget->updateTraceText(); + parentWidget->updateCursorText(); parentWidget->m_graticuleWidget->repaint(false); } @@ -242,6 +246,7 @@ void TraceData::moveNegOneTick() { emit(offsetChanged(offset)); parentWidget->updateTraceText(); + parentWidget->updateCursorText(); parentWidget->m_graticuleWidget->repaint(false); } @@ -250,6 +255,7 @@ void TraceData::resetVPosition() { emit(offsetChanged(offset)); parentWidget->updateTraceText(); + parentWidget->updateCursorText(); parentWidget->m_graticuleWidget->repaint(false); } @@ -267,11 +273,21 @@ CursorData::CursorData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), paramLabel->setPaletteBackgroundColor(labelParent->paletteBackgroundColor()); paramLabel->setPaletteForegroundColor(color); paramLabel->setAlignment(TQt::AlignHCenter|TQt::AlignVCenter|TQt::SingleLine); + TQFont font; + font = paramLabel->font(); + font.setPointSize(font.pointSize()-1); + paramLabel->setFont(font); paramLabel->hide(); singleIncrBtn = new TQPushButton(labelParent); singleDecrBtn = new TQPushButton(labelParent); multiIncrBtn = new TQPushButton(labelParent); multiDecrBtn = new TQPushButton(labelParent); + font = singleIncrBtn->font(); + font.setPointSize(font.pointSize()-1); + singleIncrBtn->setFont(font); + singleDecrBtn->setFont(font); + multiIncrBtn->setFont(font); + multiDecrBtn->setFont(font); singleIncrBtn->setText("+"); singleDecrBtn->setText("-"); multiIncrBtn->setText("++"); @@ -788,6 +804,7 @@ TraceWidget::TraceWidget(TQWidget* parent, const char* name) : TQWidget(parent, m_vertDivs(0), m_cursorDarkness(CURSOR_DARKNESS_FACTOR), m_zoomBoxDarkness(ZOOM_SHADING_DARKNESS_FACTOR), + m_zoomCursorStartIndex(0), m_zoomBoxEnabled(false) { setBackgroundMode(NoBackground); setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding)); @@ -943,20 +960,23 @@ void TraceWidget::updateCursorText() { cursorText = TQString("<qt><nobr>%1").arg(m_cursorArray[cursor]->cursorName); // If this is a horizontal cursor, list all vertical positions for all channels // If this is a vertical cursor, list the horizontal positions for all channels + for (uint trace=0;trace<m_traceArray.count();trace++) { - if (m_traceArray[trace]->enabled) { + if ((m_traceArray[trace]->enabled) && (m_cursorArray[cursor]->activeTraceLabelList.contains(trace) > 0)) { double horizontal_range = (m_traceArray[trace]->rightEdge-m_traceArray[trace]->leftEdge); double vertical_range = (m_traceArray[trace]->bottomEdge-m_traceArray[trace]->topEdge); if (m_cursorArray[cursor]->orientation == TQt::Horizontal) { - double realCursorPosition = (m_traceArray[trace]->topEdge+((m_cursorArray[cursor]->position/100.0)*vertical_range)); + double realCursorPosition = (m_traceArray[trace]->topEdge+((m_cursorArray[cursor]->position/100.0)*vertical_range)-m_traceArray[trace]->offset); TQString deltaText; - for (uint cursor2=0;cursor2<m_cursorArray.count();cursor2++) { - if (cursor2 != cursor) { - if (m_cursorArray[cursor2]->orientation == m_cursorArray[cursor]->orientation) { - double realSecondaryCursorPosition = (m_traceArray[trace]->topEdge+((m_cursorArray[cursor2]->position/100.0)*vertical_range)); - deltaText = trUtf8("Δ") + prettyFormat(fabs(realCursorPosition-realSecondaryCursorPosition), vertical_range, m_traceArray[trace]->verticalUnits); - break; + if (cursor >= m_zoomCursorStartIndex) { + for (uint cursor2=m_zoomCursorStartIndex;cursor2<m_cursorArray.count();cursor2++) { + if (cursor2 != cursor) { + if (m_cursorArray[cursor2]->orientation == m_cursorArray[cursor]->orientation) { + double realSecondaryCursorPosition = (m_traceArray[trace]->topEdge+((m_cursorArray[cursor2]->position/100.0)*vertical_range)); + deltaText = trUtf8("Δ") + prettyFormat(fabs(realCursorPosition-realSecondaryCursorPosition), vertical_range, m_traceArray[trace]->verticalUnits); + break; + } } } } @@ -965,12 +985,14 @@ void TraceWidget::updateCursorText() { else { double realCursorPosition = (m_traceArray[trace]->leftEdge+((m_cursorArray[cursor]->position/100.0)*horizontal_range)); TQString deltaText; - for (uint cursor2=0;cursor2<m_cursorArray.count();cursor2++) { - if (cursor2 != cursor) { - if (m_cursorArray[cursor2]->orientation == m_cursorArray[cursor]->orientation) { - double realSecondaryCursorPosition = (m_traceArray[trace]->leftEdge+((m_cursorArray[cursor2]->position/100.0)*horizontal_range)); - deltaText = trUtf8("Δ") + prettyFormat(fabs(realCursorPosition-realSecondaryCursorPosition), horizontal_range, m_traceArray[trace]->horizontalUnits); - break; + if (cursor >= m_zoomCursorStartIndex) { + for (uint cursor2=m_zoomCursorStartIndex;cursor2<m_cursorArray.count();cursor2++) { + if (cursor2 != cursor) { + if (m_cursorArray[cursor2]->orientation == m_cursorArray[cursor]->orientation) { + double realSecondaryCursorPosition = (m_traceArray[trace]->leftEdge+((m_cursorArray[cursor2]->position/100.0)*horizontal_range)); + deltaText = trUtf8("Δ") + prettyFormat(fabs(realCursorPosition-realSecondaryCursorPosition), horizontal_range, m_traceArray[trace]->horizontalUnits); + break; + } } } } @@ -1122,6 +1144,43 @@ void TraceWidget::setCursorPosition(uint cursorNumber, double position) { m_graticuleWidget->repaint(false); } +TQColor TraceWidget::cursorColor(uint cursorNumber) { + VERIFY_CURSOR_ARRAY_SIZE + + return m_cursorArray[cursorNumber]->color; +} + +void TraceWidget::setCursorColor(uint cursorNumber, TQColor color) { + VERIFY_CURSOR_ARRAY_SIZE + + m_cursorArray[cursorNumber]->color = color; + updateCursorText(); + m_graticuleWidget->updateGraticule(); + m_graticuleWidget->repaint(false); +} + +TQColor TraceWidget::cursorHighlightColor(uint cursorNumber) { + VERIFY_CURSOR_ARRAY_SIZE + + return m_cursorArray[cursorNumber]->highlightColor; +} + +void TraceWidget::setCursorHighlightColor(uint cursorNumber, TQColor color) { + VERIFY_CURSOR_ARRAY_SIZE + + m_cursorArray[cursorNumber]->highlightColor = color; + updateCursorText(); + m_graticuleWidget->updateGraticule(); + m_graticuleWidget->repaint(false); +} + +void TraceWidget::setCursorActiveTraceList(uint cursorNumber, TraceNumberList list) { + VERIFY_CURSOR_ARRAY_SIZE + + m_cursorArray[cursorNumber]->activeTraceLabelList = list; + updateCursorText(); +} + bool TraceWidget::cursorEnabled(uint cursorNumber) { VERIFY_CURSOR_ARRAY_SIZE @@ -1188,7 +1247,7 @@ void TraceWidget::setNumberOfCursors(uint cursorNumber) { TQRectF TraceWidget::zoomBox() { uint i; - if ((m_cursorArray.count() < 4) || (!m_zoomBoxEnabled)) { + if ((m_cursorArray.count() < (4+m_zoomCursorStartIndex)) || (!m_zoomBoxEnabled)) { if (!m_zoomBoxPrev.isNull()) { m_zoomBoxPrev = TQRectF(); emit(zoomBoxChanged(m_zoomBoxPrev)); @@ -1202,7 +1261,7 @@ TQRectF TraceWidget::zoomBox() { double vert[2]; int j = 0; int k = 0; - for (i=0;i<m_cursorArray.count(); i++) { + for (i=m_zoomCursorStartIndex;i<m_cursorArray.count(); i++) { if (m_cursorArray[i]->orientation == TQt::Horizontal) { if (j<2) { vert[j] = m_cursorArray[i]->position; @@ -1243,7 +1302,7 @@ TQRectF TraceWidget::zoomBox() { TQRectF TraceWidget::zoomCursorBox() { uint i; - if ((m_cursorArray.count() < 4) || (!m_zoomBoxEnabled)) { + if ((m_cursorArray.count() < (4+m_zoomCursorStartIndex)) || (!m_zoomBoxEnabled)) { return TQRectF(); } else { @@ -1253,7 +1312,7 @@ TQRectF TraceWidget::zoomCursorBox() { double vert[2]; int j = 0; int k = 0; - for (i=0;i<m_cursorArray.count(); i++) { + for (i=m_zoomCursorStartIndex;i<m_cursorArray.count(); i++) { if (m_cursorArray[i]->orientation == TQt::Horizontal) { if (j<2) { vert[j] = m_cursorArray[i]->position; @@ -1309,7 +1368,7 @@ void TraceWidget::setZoomCursorBox(const TQRectF rect) { boundedRect.setHeight(100.0); } - if ((m_cursorArray.count() < 4) || (!m_zoomBoxEnabled)) { + if ((m_cursorArray.count() < (4+m_zoomCursorStartIndex)) || (!m_zoomBoxEnabled)) { return; } else { @@ -1319,7 +1378,7 @@ void TraceWidget::setZoomCursorBox(const TQRectF rect) { CursorData* vert[2]; int j = 0; int k = 0; - for (i=0;i<m_cursorArray.count(); i++) { + for (i=m_zoomCursorStartIndex;i<m_cursorArray.count(); i++) { if (m_cursorArray[i]->orientation == TQt::Horizontal) { if (j<2) { vert[j] = m_cursorArray[i]; @@ -1352,6 +1411,14 @@ void TraceWidget::setZoomCursorBox(const TQRectF rect) { } } +unsigned int TraceWidget::zoomCursorStartIndex() { + return m_zoomCursorStartIndex; +} + +void TraceWidget::setZoomCursorStartIndex(unsigned int index) { + m_zoomCursorStartIndex = index; +} + void TraceWidget::setZoomBoxEnabled(bool enabled) { m_zoomBoxEnabled = enabled; m_graticuleWidget->updateGraticule(); diff --git a/clients/tde/src/widgets/tracewidget.h b/clients/tde/src/widgets/tracewidget.h index 9a478ac..130904f 100644 --- a/clients/tde/src/widgets/tracewidget.h +++ b/clients/tde/src/widgets/tracewidget.h @@ -42,6 +42,8 @@ class TQRectF double m_h; }; +typedef TQValueList<int> TraceNumberList; + class TraceData : public TQObject { Q_OBJECT @@ -114,6 +116,7 @@ class CursorData : public TQObject bool enabled; TQt::Orientation orientation; double position; + TraceNumberList activeTraceLabelList; TQString cursorName; TQLabel* paramLabel; TQPushButton* singleIncrBtn; @@ -199,6 +202,11 @@ class TraceWidget : public TQWidget double cursorPosition(uint cursorNumber); void setCursorPosition(uint cursorNumber, double position); + TQColor cursorColor(uint cursorNumber); + void setCursorColor(uint cursorNumber, TQColor); + TQColor cursorHighlightColor(uint cursorNumber); + void setCursorHighlightColor(uint cursorNumber, TQColor); + void setCursorActiveTraceList(uint cursorNumber, TraceNumberList list); bool cursorEnabled(uint cursorNumber); void setCursorEnabled(uint cursorNumber, bool enabled); TQString cursorName(uint cursorNumber); @@ -213,6 +221,8 @@ class TraceWidget : public TQWidget void setZoomBoxEnabled(bool enabled); TQRectF zoomCursorBox(); void setZoomCursorBox(const TQRectF rect); + unsigned int zoomCursorStartIndex(); + void setZoomCursorStartIndex(unsigned int index); static TQString prettyFormat(double value, double rangeDetectValue, TQString baseUnits, unsigned int precision=3); @@ -237,6 +247,7 @@ class TraceWidget : public TQWidget unsigned int m_vertDivs; unsigned int m_cursorDarkness; unsigned int m_zoomBoxDarkness; + unsigned int m_zoomCursorStartIndex; bool m_zoomBoxEnabled; TQRectF m_zoomBoxPrev; TraceList m_traceArray; |