@ -30,6 +30,7 @@
# include <tdefiledialog.h>
# include <tdeparts/genericfactory.h>
# include <kstatusbar.h>
# include <ktextedit.h>
# include <kstdaction.h>
# include <tqfile.h> //encodeName()
# include <tqtimer.h>
@ -64,23 +65,28 @@ enum connectionStates {
ScopeState_ResetRequest = 2 ,
ScopeState_HorizontalDivCountRequest = 4 ,
ScopeState_VerticalDivCountRequest = 6 ,
ScopeState_ChannelCountRequest = 8 ,
ScopeState_ChannelActiveStateRequest = 10 ,
ScopeState_TraceSampleCountRequest = 12 ,
ScopeState_TracePermittedVoltsDivRequest = 14 ,
ScopeState_TraceVoltsDivRequest = 16 ,
ScopeState_TraceSecondsDivRequest = 18 ,
ScopeState_TriggerChannelRequest = 20 ,
ScopeState_TriggerLevelRequest = 22 ,
ScopeState_RunningRequest = 24 ,
ScopeState_PermittedSecondsDivRequest = 8 ,
ScopeState_ChannelCountRequest = 10 ,
ScopeState_ChannelActiveStateRequest = 12 ,
ScopeState_TraceSampleCountRequest = 14 ,
ScopeState_TracePermittedVoltsDivRequest = 16 ,
ScopeState_TraceVoltsDivRequest = 18 ,
ScopeState_TraceSecondsDivRequest = 20 ,
ScopeState_HorizontalTimebaseRequest = 22 ,
ScopeState_TriggerChannelRequest = 24 ,
ScopeState_TriggerLevelRequest = 26 ,
ScopeState_RunningRequest = 28 ,
ScopeState_TraceRequest = 50 ,
ScopeState_ChannelActiveStateUpdate = 100 ,
ScopeState_TraceVoltsDivUpdate = 102 ,
ScopeState_TriggerLevelUpdate = 104 ,
ScopeState_RunningUpdate = 106 ,
ScopeState_HorizontalTimebaseUpdate = 106 ,
ScopeState_RunningUpdate = 108 ,
ScopeState_ExternalCommandRequest = 255
} ;
# define ScopeState_ReloadSettings ScopeState_ChannelActiveStateRequest
namespace RemoteLab {
typedef KParts : : GenericFactory < RemoteLab : : ScopePart > Factory ;
@ -162,9 +168,64 @@ void TraceControlWidget::vdivChanged(int index) {
emit ( voltsPerDivChanged ( value ) ) ;
}
TimebaseControlWidget : : TimebaseControlWidget ( TQWidget * parent , const char * name )
: TQWidget ( parent , name )
{
TQGridLayout * topGrid = new TQGridLayout ( this ) ;
m_groupBox = new TQGroupBox ( this ) ;
m_groupBox - > setColumnLayout ( 0 , TQt : : Vertical ) ;
topGrid - > addMultiCellWidget ( m_groupBox , 0 , 0 , 0 , 0 ) ;
m_groupBox - > setTitle ( i18n ( " Timebase " ) ) ;
m_primaryLayout = new TQGridLayout ( m_groupBox - > layout ( ) , 1 , 1 , KDialog : : spacingHint ( ) ) ;
m_secondsDivComboBox = new TQComboBox ( m_groupBox ) ;
connect ( m_secondsDivComboBox , SIGNAL ( activated ( int ) ) , this , SLOT ( sdivChanged ( int ) ) ) ;
m_primaryLayout - > addMultiCellWidget ( m_secondsDivComboBox , 0 , 0 , 0 , 0 ) ;
TQLabel * label = new TQLabel ( m_groupBox ) ;
label - > setText ( i18n ( " /div " ) ) ;
m_primaryLayout - > addMultiCellWidget ( label , 0 , 0 , 1 , 1 ) ;
}
TimebaseControlWidget : : ~ TimebaseControlWidget ( ) {
//
}
void TimebaseControlWidget : : setSecondsPerDivList ( TQDoubleList list ) {
m_secondsDivList = list ;
// Update drop down list
double prevValue = m_secondsDivComboBox - > currentText ( ) . toDouble ( ) ;
m_secondsDivComboBox - > clear ( ) ;
TQDoubleList : : iterator it ;
int i = 0 ;
for ( it = m_secondsDivList . begin ( ) ; it ! = m_secondsDivList . end ( ) ; + + it ) {
m_secondsDivComboBox - > insertItem ( TQString ( " %1 " ) . arg ( TraceWidget : : prettyFormat ( * it , * it , " s " , 3 ) ) , i ) ;
if ( prevValue = = ( * it ) ) {
m_secondsDivComboBox - > setCurrentItem ( i ) ;
}
i + + ;
}
}
void TimebaseControlWidget : : setSelectedSecondsPerDiv ( double sdiv ) {
int i = 0 ;
for ( i = 0 ; i < m_secondsDivComboBox - > count ( ) ; i + + ) {
if ( m_secondsDivComboBox - > text ( i ) = = TraceWidget : : prettyFormat ( sdiv , sdiv , " s " , 3 ) ) {
m_secondsDivComboBox - > setCurrentItem ( i ) ;
}
}
}
void TimebaseControlWidget : : sdivChanged ( int index ) {
Q_UNUSED ( index )
double value = m_secondsDivList [ m_secondsDivComboBox - > currentItem ( ) ] ;
emit ( secondsPerDivChanged ( value ) ) ;
}
ScopePart : : ScopePart ( TQWidget * parentWidget , const char * widgetName , TQObject * parent , const char * name , const TQStringList & )
: RemoteInstrumentPart ( parent , name ) , m_traceWidget ( 0 ) , m_commHandlerState ( - 1 ) , m_commHandlerMode ( 0 ) , m_commHandlerCommandState ( 0 ) , m_connectionActiveAndValid ( false ) ,
m_triggerChannel ( - 1 ) , m_base ( 0 ) , stopTraceUpdate ( false )
m_triggerChannel ( - 1 ) , m_ settingsChanged( false ) , m_ base( 0 ) , stopTraceUpdate ( false )
{
// Initialize important base class variables
m_clientLibraryName = CLIENT_LIBRARY ;
@ -196,11 +257,16 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_channelActiveSet [ traceno ] = false ;
}
m_triggerLevelSet = false ;
m_horizontalTimebaseSet = false ;
m_runningSet = false ;
// Create widgets
m_base = new ScopeBase ( widget ( ) ) ;
m_traceControlWidgetGrid = new TQGridLayout ( m_base - > traceControlLayoutWidget ) ;
m_timebaseControlWidgetGrid = new TQGridLayout ( m_base - > timebaseControlLayoutWidget ) ;
m_timebaseControlWidget = new TimebaseControlWidget ( m_base - > timebaseControlLayoutWidget ) ;
connect ( m_timebaseControlWidget , SIGNAL ( secondsPerDivChanged ( double ) ) , this , SLOT ( traceControlSDivChanged ( double ) ) ) ;
m_timebaseControlWidgetGrid - > addMultiCellWidget ( m_timebaseControlWidget , 0 , 0 , 0 , 0 ) ;
m_traceWidget = m_base - > traceScrollWidget - > traceWidget ( ) ;
connect ( m_traceWidget , SIGNAL ( cursorDragged ( uint , double ) ) , this , SLOT ( cursorLevelChanged ( uint , double ) ) ) ;
m_base - > traceScrollWidget - > setSizePolicy ( TQSizePolicy ( TQSizePolicy : : MinimumExpanding , TQSizePolicy : : MinimumExpanding ) ) ;
@ -359,6 +425,7 @@ void ScopePart::setTickerMessage(TQString message) {
if ( m_channelActiveSet [ i ] ) updatesPending = true ;
if ( m_voltsDivSet [ i ] ) updatesPending = true ;
if ( m_triggerLevelSet ) updatesPending = true ;
if ( m_horizontalTimebaseSet ) updatesPending = true ;
if ( m_runningSet ) updatesPending = true ;
}
@ -459,12 +526,12 @@ void ScopePart::mainEventLoop() {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Connected " ) ) ;
// Get command status
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_ResetRequest )
EXEC_NEXT_STATE_IMMEDIATELY
@ -502,12 +569,12 @@ void ScopePart::mainEventLoop() {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Loading [Reset complete] " ) ) ;
// Get command status
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_HorizontalDivCountRequest )
EXEC_NEXT_STATE_IMMEDIATELY
@ -599,7 +666,56 @@ void ScopePart::mainEventLoop() {
ds > > m_vdivs ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_PermittedSecondsDivRequest )
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
if ( stopTraceUpdate = = false ) {
COMMUNICATIONS_FAILED
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
else {
if ( ! m_updateTimeoutTimer - > isActive ( ) ) {
if ( stopTraceUpdate = = false ) {
UPDATEDISPLAY_TIMEOUT
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
}
else if ( m_commHandlerState = = ScopeState_PermittedSecondsDivRequest ) {
// Get permitted seconds/div settings, step 1
ds < < TQString ( " GETPERMITTEDSDIVS " ) ;
ds < < m_currentOpChannel ;
m_socket - > writeEndOfFrame ( ) ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_PermittedSecondsDivRequest + 1 )
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_PermittedSecondsDivRequest + 1 ) {
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Loading [Received allowed seconds/div list] " ) ) ;
// Get permitted seconds/div settings, step 2
TQString result ;
ds > > result ;
if ( result = = " ACK " ) {
TQDoubleList list ;
ds > > list ;
m_timebaseControlWidget - > setSecondsPerDivList ( list ) ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_ChannelCountRequest )
EXEC_NEXT_STATE_IMMEDIATELY
@ -637,7 +753,7 @@ void ScopePart::mainEventLoop() {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Loading [Received number of channels] " ) ) ;
// Get number of channels, step 2
TQString result ;
ds > > result ;
@ -649,7 +765,7 @@ void ScopePart::mainEventLoop() {
updateTraceControlWidgets ( ) ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = 1 ;
SET_NEXT_STATE ( ScopeState_ChannelActiveStateRequest )
@ -751,7 +867,7 @@ void ScopePart::mainEventLoop() {
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 ;
ds > > result ;
@ -759,7 +875,7 @@ void ScopePart::mainEventLoop() {
ds > > m_samplesInTrace [ m_currentOpChannel ] ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( m_currentOpChannel , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_currentOpChannel > 0 ) {
@ -863,7 +979,7 @@ void ScopePart::mainEventLoop() {
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 ;
ds > > result ;
@ -871,7 +987,7 @@ void ScopePart::mainEventLoop() {
ds > > m_voltsDiv [ m_currentOpChannel ] ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( m_currentOpChannel , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_currentOpChannel > 0 ) {
@ -932,7 +1048,7 @@ void ScopePart::mainEventLoop() {
SET_NEXT_STATE ( ScopeState_TraceSecondsDivRequest )
}
else {
SET_NEXT_STATE ( ScopeState_ TriggerChannel Request)
SET_NEXT_STATE ( ScopeState_ HorizontalTimebase Request)
}
EXEC_NEXT_STATE_IMMEDIATELY
}
@ -956,6 +1072,54 @@ void ScopePart::mainEventLoop() {
}
}
}
else if ( m_commHandlerState = = ScopeState_HorizontalTimebaseRequest ) {
// Get horizontal timebase, step 1
ds < < TQString ( " GETHORIZTIMEBASE " ) ;
m_socket - > writeEndOfFrame ( ) ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_HorizontalTimebaseRequest + 1 )
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_HorizontalTimebaseRequest + 1 ) {
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Loading [Received horizontal timebase] " ) ) ;
// Get horizontal timebase, step 2
TQString result ;
ds > > result ;
if ( result = = " ACK " ) {
ds > > m_horizontalTimebase ;
m_timebaseControlWidget - > setSelectedSecondsPerDiv ( m_horizontalTimebase ) ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = 1 ;
SET_NEXT_STATE ( ScopeState_TriggerChannelRequest )
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
if ( stopTraceUpdate = = false ) {
COMMUNICATIONS_FAILED
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
else {
if ( ! m_updateTimeoutTimer - > isActive ( ) ) {
if ( stopTraceUpdate = = false ) {
UPDATEDISPLAY_TIMEOUT
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
}
else if ( m_commHandlerState = = ScopeState_TriggerChannelRequest ) {
// Get trigger channel, step 1
ds < < TQString ( " GETTRIGGERCHANNEL " ) ;
@ -978,7 +1142,7 @@ void ScopePart::mainEventLoop() {
ds > > m_triggerChannel ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_TriggerLevelRequest )
EXEC_NEXT_STATE_IMMEDIATELY
@ -1025,7 +1189,7 @@ void ScopePart::mainEventLoop() {
ds > > m_triggerLevel ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
// Update display widget(s)
updateGraticule ( ) ;
@ -1079,7 +1243,7 @@ void ScopePart::mainEventLoop() {
m_running = ( status ! = 0 ) ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
// Update display widget(s)
updateGraticule ( ) ;
@ -1116,7 +1280,6 @@ void ScopePart::mainEventLoop() {
ds < < m_currentOpChannel ;
m_socket - > writeEndOfFrame ( ) ;
m_lastChangesRequireFullUpdate = false ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TraceRequest + 1 )
EXEC_NEXT_STATE_IMMEDIATELY
}
@ -1154,12 +1317,13 @@ void ScopePart::mainEventLoop() {
& & ( m_channelActiveSet [ m_currentOpChannel ] = = false )
& & ( m_voltsDivSet [ m_currentOpChannel ] = = false )
& & ( m_triggerLevelSet = = false )
& & ( m_horizontalTimebaseSet = = false )
& & ( m_runningSet = = false )
) {
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = 1 ;
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
EXEC_NEXT_STATE_IMMEDIATELY
@ -1193,28 +1357,23 @@ void ScopePart::mainEventLoop() {
ds < < active ;
m_socket - > writeEndOfFrame ( ) ;
m_lastChangesRequireFullUpdate = true ;
m_channelActiveSet [ m_currentOpChannel ] = false ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_ChannelActiveStateUpdate + 1 )
}
else {
m_currentOpChannel = m_currentOpChannel + 1 ;
if ( m_currentOpChannel < m_maxNumberOfTraces ) {
m_currentOpChannel + + ;
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_lastChangesRequireFullUpdate ) {
SET_NEXT_STATE ( ScopeState_TraceVoltsDivRequest )
}
else {
SET_NEXT_STATE ( ScopeState_TraceVoltsDivUpdate )
}
SET_NEXT_STATE ( ScopeState_TraceVoltsDivUpdate )
}
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_ChannelActiveStateUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
@ -1224,18 +1383,19 @@ void ScopePart::mainEventLoop() {
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( m_currentOpChannel , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_currentOpChannel > 0 ) {
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
else {
m_currentOpChannel = getNextActiveChannel( 0 , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_ lastChangesRequireFullUpdate ) {
SET_NEXT_STATE ( ScopeState_ TraceVoltsDivRequest )
m_currentOpChannel = m_currentOpChannel + 1 ;
if ( m_ currentOpChannel < m_maxNumberOfTraces ) {
SET_NEXT_STATE ( ScopeState_ ChannelActiveStateUpdate )
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceVoltsDivUpdate )
}
}
@ -1284,16 +1444,17 @@ void ScopePart::mainEventLoop() {
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_TraceVoltsDivUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Updating [Set volts/div for channel %1] " ) . arg ( m_currentOpChannel ) ) ;
// Set volts per division, step 2
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( m_currentOpChannel , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_currentOpChannel > 0 ) {
@ -1325,7 +1486,7 @@ void ScopePart::mainEventLoop() {
}
}
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate ) {
if ( m_ voltsDivSet[ m_currentOpChannel ] ) {
if ( m_ triggerLevelSet ) {
// Set trigger level, step 1
ds < < TQString ( " SETTRIGGERLEVEL " ) ;
ds < < m_triggerLevel ;
@ -1335,22 +1496,73 @@ void ScopePart::mainEventLoop() {
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TriggerLevelUpdate + 1 )
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_HorizontalTimebaseUpdate )
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Updating [Set trigger level] " ) ) ;
// Set trigger level, step 2
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_HorizontalTimebaseUpdate )
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
if ( stopTraceUpdate = = false ) {
COMMUNICATIONS_FAILED
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
else {
if ( ! m_updateTimeoutTimer - > isActive ( ) ) {
if ( stopTraceUpdate = = false ) {
UPDATEDISPLAY_TIMEOUT
}
else {
setTickerMessage ( i18n ( " Data acquisition stopped " ) ) ;
}
}
}
}
else if ( m_commHandlerState = = ScopeState_HorizontalTimebaseUpdate ) {
if ( m_horizontalTimebaseSet ) {
// Set horizontal timebase, step 1
ds < < TQString ( " SETHORIZTIMEBASE " ) ;
ds < < m_horizontalTimebase ;
m_socket - > writeEndOfFrame ( ) ;
m_horizontalTimebaseSet = false ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_HorizontalTimebaseUpdate + 1 )
}
else {
SET_NEXT_STATE ( ScopeState_RunningUpdate )
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_HorizontalTimebaseUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Updating [Set horizontal timebase] " ) ) ;
// Set horizontal timebase, step 2
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_RunningUpdate )
EXEC_NEXT_STATE_IMMEDIATELY
@ -1388,24 +1600,38 @@ void ScopePart::mainEventLoop() {
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
if ( m_settingsChanged ) {
m_settingsChanged = false ;
SET_NEXT_STATE ( ScopeState_ReloadSettings )
}
else {
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_RunningUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Updating [Set run status] " ) ) ;
// Set running, step 2
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
if ( m_settingsChanged ) {
m_settingsChanged = false ;
SET_NEXT_STATE ( ScopeState_ReloadSettings )
}
else {
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
@ -1462,7 +1688,7 @@ void ScopePart::mainEventLoop() {
TQString result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
m_commHandlerCommandState = 0 ;
EXEC_NEXT_STATE_IMMEDIATELY
@ -1526,6 +1752,7 @@ void ScopePart::stopDAQ() {
m_voltsDivSet [ i ] = false ;
}
m_triggerLevelSet = false ;
m_horizontalTimebaseSet = false ;
m_runningSet = false ;
m_commHandlerMode = 1 ;
m_commHandlerCommandState = 3 ;
@ -1534,7 +1761,7 @@ void ScopePart::stopDAQ() {
}
# define WAVEFORM_MAGIC_NUMBER 1
# define WAVEFORM_FILE_VERSION 1
# define WAVEFORM_FILE_VERSION 2
void ScopePart : : saveWaveforms ( ) {
TQString saveFileName = KFileDialog : : getSaveFileName ( TQString : : null , " *.wfm|Waveform Files (*.wfm) " , 0 , i18n ( " Save waveforms... " ) ) ;
@ -1563,6 +1790,7 @@ void ScopePart::saveWaveforms() {
for ( int cursorno = 0 ; cursorno < 5 ; cursorno + + ) {
ds < < m_traceWidget - > cursorPosition ( cursorno ) ;
}
ds < < m_base - > userNotes - > text ( ) ;
}
}
@ -1577,7 +1805,7 @@ void ScopePart::recallWaveforms() {
ds > > magicNumber ;
if ( magicNumber = = WAVEFORM_MAGIC_NUMBER ) {
ds > > version ;
if ( version == WAVEFORM_FILE_VERSION ) {
if ( ( version > = 1 ) & & ( version < = WAVEFORM_FILE_VERSION ) ) {
ds > > m_hdivs ;
ds > > m_vdivs ;
ds > > m_maxNumberOfTraces ;
@ -1607,6 +1835,14 @@ void ScopePart::recallWaveforms() {
ds > > cursorPos ;
m_traceWidget - > setCursorPosition ( cursorno , cursorPos ) ;
}
if ( version < 2 ) {
m_base - > userNotes - > setText ( TQString : : null ) ;
}
else {
TQString notes ;
ds > > notes ;
m_base - > userNotes - > setText ( notes ) ;
}
m_triggerChannel = - 1 ;
m_triggerLevel = 0 ;
updateGraticule ( ) ;
@ -1616,7 +1852,7 @@ void ScopePart::recallWaveforms() {
updateTraceControlWidgets ( ) ;
}
else {
KMessageBox : : error ( 0 , i18n ( " <qt>The selected waveform file version does not match this client</qt>" ) , i18n ( " Invalid File " ) ) ;
KMessageBox : : error ( 0 , i18n ( " <qt>The selected waveform file version (%1) is not compatible with this client, which only understands versions %2-%3</qt>" ) . arg ( version ) . arg ( 1 ) . arg ( WAVEFORM_FILE_VERSION ) , i18n ( " Invalid File " ) ) ;
}
}
else {
@ -1756,6 +1992,11 @@ void ScopePart::traceControlVDivChanged(double vdiv) {
updateTraceControlWidgets ( ) ;
}
void ScopePart : : traceControlSDivChanged ( double sdiv ) {
m_horizontalTimebase = sdiv ;
m_horizontalTimebaseSet = true ;
}
void ScopePart : : cursorLevelChanged ( uint cursor , double level ) {
if ( cursor = = 0 ) {
// Trigger level changed