@ -53,10 +53,12 @@ enum connectionStates {
ScopeState_TraceSecondsDivRequest = 18 ,
ScopeState_TraceSecondsDivRequest = 18 ,
ScopeState_TriggerChannelRequest = 20 ,
ScopeState_TriggerChannelRequest = 20 ,
ScopeState_TriggerLevelRequest = 22 ,
ScopeState_TriggerLevelRequest = 22 ,
ScopeState_RunningRequest = 24 ,
ScopeState_TraceRequest = 50 ,
ScopeState_TraceRequest = 50 ,
ScopeState_ChannelActiveStateUpdate = 100 ,
ScopeState_ChannelActiveStateUpdate = 100 ,
ScopeState_TraceVoltsDivUpdate = 102 ,
ScopeState_TraceVoltsDivUpdate = 102 ,
ScopeState_TriggerLevelUpdate = 104 ,
ScopeState_TriggerLevelUpdate = 104 ,
ScopeState_RunningUpdate = 106 ,
ScopeState_ExternalCommandRequest = 255
ScopeState_ExternalCommandRequest = 255
} ;
} ;
@ -175,6 +177,7 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_channelActiveSet [ traceno ] = false ;
m_channelActiveSet [ traceno ] = false ;
}
}
m_triggerLevelSet = false ;
m_triggerLevelSet = false ;
m_runningSet = false ;
// Create widgets
// Create widgets
m_base = new ScopeBase ( widget ( ) ) ;
m_base = new ScopeBase ( widget ( ) ) ;
@ -222,6 +225,8 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
connect ( m_base - > acqStart , SIGNAL ( clicked ( ) ) , this , SLOT ( startDAQ ( ) ) ) ;
connect ( m_base - > acqStart , SIGNAL ( clicked ( ) ) , this , SLOT ( startDAQ ( ) ) ) ;
connect ( m_base - > acqStop , SIGNAL ( clicked ( ) ) , this , SLOT ( stopDAQ ( ) ) ) ;
connect ( m_base - > acqStop , SIGNAL ( clicked ( ) ) , this , SLOT ( stopDAQ ( ) ) ) ;
connect ( m_base - > runControlStartButton , SIGNAL ( clicked ( ) ) , this , SLOT ( startScope ( ) ) ) ;
connect ( m_base - > runControlStopButton , SIGNAL ( clicked ( ) ) , this , SLOT ( stopScope ( ) ) ) ;
connect ( m_base - > waveformSave , SIGNAL ( clicked ( ) ) , this , SLOT ( saveWaveforms ( ) ) ) ;
connect ( m_base - > waveformSave , SIGNAL ( clicked ( ) ) , this , SLOT ( saveWaveforms ( ) ) ) ;
connect ( m_base - > waveformRecall , SIGNAL ( clicked ( ) ) , this , SLOT ( recallWaveforms ( ) ) ) ;
connect ( m_base - > waveformRecall , SIGNAL ( clicked ( ) ) , this , SLOT ( recallWaveforms ( ) ) ) ;
@ -291,6 +296,14 @@ void ScopePart::processLockouts() {
m_base - > waveformSave - > setEnabled ( false ) ;
m_base - > waveformSave - > setEnabled ( false ) ;
m_base - > waveformRecall - > setEnabled ( false ) ;
m_base - > waveformRecall - > setEnabled ( false ) ;
}
}
if ( m_running ) {
m_base - > runControlStartButton - > setEnabled ( false ) ;
m_base - > runControlStopButton - > setEnabled ( true ) ;
}
else {
m_base - > runControlStartButton - > setEnabled ( true ) ;
m_base - > runControlStopButton - > setEnabled ( false ) ;
}
}
}
void ScopePart : : disconnectFromServerCallback ( ) {
void ScopePart : : disconnectFromServerCallback ( ) {
@ -324,6 +337,7 @@ void ScopePart::setTickerMessage(TQString message) {
if ( m_channelActiveSet [ i ] ) updatesPending = true ;
if ( m_channelActiveSet [ i ] ) updatesPending = true ;
if ( m_voltsDivSet [ i ] ) updatesPending = true ;
if ( m_voltsDivSet [ i ] ) updatesPending = true ;
if ( m_triggerLevelSet ) updatesPending = true ;
if ( m_triggerLevelSet ) updatesPending = true ;
if ( m_runningSet ) updatesPending = true ;
}
}
m_connectionActiveAndValid = true ;
m_connectionActiveAndValid = true ;
@ -883,6 +897,50 @@ void ScopePart::mainEventLoop() {
updateGraticule ( ) ;
updateGraticule ( ) ;
}
}
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_RunningRequest )
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
COMMUNICATIONS_FAILED
}
}
else {
if ( ! m_updateTimeoutTimer - > isActive ( ) ) {
UPDATEDISPLAY_TIMEOUT
}
}
}
else if ( m_commHandlerState = = ScopeState_RunningRequest ) {
// Get running, step 1
ds < < TQString ( " GETRUNNING " ) ;
ds < < m_currentOpChannel ;
m_socket - > writeEndOfFrame ( ) ;
SET_NEXT_STATE ( ScopeState_RunningRequest + 1 )
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_RunningRequest + 1 ) {
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
setTickerMessage ( i18n ( " Loading [Received run status] " ) ) ;
// Get running, step 2
TQString result ;
ds > > result ;
if ( result = = " ACK " ) {
TQ_INT16 status ;
ds > > status ;
m_running = ( status ! = 0 ) ;
}
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
// Update display widget(s)
updateGraticule ( ) ;
}
if ( result = = " ACK " ) {
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
@ -942,6 +1000,7 @@ void ScopePart::mainEventLoop() {
& & ( m_channelActiveSet [ m_currentOpChannel ] = = false )
& & ( m_channelActiveSet [ m_currentOpChannel ] = = false )
& & ( m_voltsDivSet [ m_currentOpChannel ] = = false )
& & ( m_voltsDivSet [ m_currentOpChannel ] = = false )
& & ( m_triggerLevelSet = = false )
& & ( m_triggerLevelSet = = false )
& & ( m_runningSet = = false )
) {
) {
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
}
@ -1108,6 +1167,48 @@ void ScopePart::mainEventLoop() {
ds > > result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
m_socket - > clearFrameTail ( ) ;
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_RunningUpdate )
EXEC_NEXT_STATE_IMMEDIATELY
}
else {
COMMUNICATIONS_FAILED
}
}
else {
if ( ! m_updateTimeoutTimer - > isActive ( ) ) {
UPDATEDISPLAY_TIMEOUT
}
}
}
else if ( m_commHandlerState = = ScopeState_RunningUpdate ) {
if ( m_runningSet ) {
// Set running, step 1
ds < < TQString ( " SETRUNNING " ) ;
TQ_INT16 running = ( m_running ) ? 1 : 0 ;
ds < < running ;
m_socket - > writeEndOfFrame ( ) ;
m_runningSet = false ;
SET_NEXT_STATE ( ScopeState_RunningUpdate + 1 )
}
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
EXEC_NEXT_STATE_IMMEDIATELY
}
else if ( m_commHandlerState = = ScopeState_RunningUpdate + 1 ) {
// 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 " ) {
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
@ -1211,6 +1312,7 @@ void ScopePart::stopDAQ() {
m_voltsDivSet [ i ] = false ;
m_voltsDivSet [ i ] = false ;
}
}
m_triggerLevelSet = false ;
m_triggerLevelSet = false ;
m_runningSet = false ;
m_commHandlerMode = 1 ;
m_commHandlerMode = 1 ;
m_commHandlerCommandState = 3 ;
m_commHandlerCommandState = 3 ;
mainEventLoop ( ) ;
mainEventLoop ( ) ;
@ -1447,6 +1549,16 @@ void ScopePart::cursorLevelChanged(uint cursor, double level) {
}
}
}
}
void ScopePart : : startScope ( ) {
m_running = true ;
m_runningSet = true ;
}
void ScopePart : : stopScope ( ) {
m_running = false ;
m_runningSet = true ;
}
KAboutData * ScopePart : : createAboutData ( ) {
KAboutData * ScopePart : : createAboutData ( ) {
return new KAboutData ( APP_NAME , I18N_NOOP ( APP_PRETTYNAME ) , APP_VERSION ) ;
return new KAboutData ( APP_NAME , I18N_NOOP ( APP_PRETTYNAME ) , APP_VERSION ) ;
}
}