@ -30,6 +30,7 @@
# include <tdefiledialog.h>
# include <tdefiledialog.h>
# include <tdeparts/genericfactory.h>
# include <tdeparts/genericfactory.h>
# include <kstatusbar.h>
# include <kstatusbar.h>
# include <ktextedit.h>
# include <kstdaction.h>
# include <kstdaction.h>
# include <tqfile.h> //encodeName()
# include <tqfile.h> //encodeName()
# include <tqtimer.h>
# include <tqtimer.h>
@ -64,23 +65,28 @@ enum connectionStates {
ScopeState_ResetRequest = 2 ,
ScopeState_ResetRequest = 2 ,
ScopeState_HorizontalDivCountRequest = 4 ,
ScopeState_HorizontalDivCountRequest = 4 ,
ScopeState_VerticalDivCountRequest = 6 ,
ScopeState_VerticalDivCountRequest = 6 ,
ScopeState_ChannelCountRequest = 8 ,
ScopeState_PermittedSecondsDivRequest = 8 ,
ScopeState_ChannelActiveStateRequest = 10 ,
ScopeState_ChannelCountRequest = 10 ,
ScopeState_TraceSampleCountRequest = 12 ,
ScopeState_ChannelActiveStateRequest = 12 ,
ScopeState_TracePermittedVoltsDivRequest = 14 ,
ScopeState_TraceSampleCountRequest = 14 ,
ScopeState_TraceVoltsDivRequest = 16 ,
ScopeState_TracePermittedVoltsDivRequest = 16 ,
ScopeState_TraceSecondsDivRequest = 18 ,
ScopeState_TraceVoltsDivRequest = 18 ,
ScopeState_TriggerChannelRequest = 20 ,
ScopeState_TraceSecondsDivRequest = 20 ,
ScopeState_TriggerLevelRequest = 22 ,
ScopeState_HorizontalTimebaseRequest = 22 ,
ScopeState_RunningRequest = 24 ,
ScopeState_TriggerChannelRequest = 24 ,
ScopeState_TriggerLevelRequest = 26 ,
ScopeState_RunningRequest = 28 ,
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_HorizontalTimebaseUpdate = 106 ,
ScopeState_RunningUpdate = 108 ,
ScopeState_ExternalCommandRequest = 255
ScopeState_ExternalCommandRequest = 255
} ;
} ;
# define ScopeState_ReloadSettings ScopeState_ChannelActiveStateRequest
namespace RemoteLab {
namespace RemoteLab {
typedef KParts : : GenericFactory < RemoteLab : : ScopePart > Factory ;
typedef KParts : : GenericFactory < RemoteLab : : ScopePart > Factory ;
@ -162,9 +168,64 @@ void TraceControlWidget::vdivChanged(int index) {
emit ( voltsPerDivChanged ( value ) ) ;
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 & )
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 ) ,
: 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
// Initialize important base class variables
m_clientLibraryName = CLIENT_LIBRARY ;
m_clientLibraryName = CLIENT_LIBRARY ;
@ -196,11 +257,16 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_channelActiveSet [ traceno ] = false ;
m_channelActiveSet [ traceno ] = false ;
}
}
m_triggerLevelSet = false ;
m_triggerLevelSet = false ;
m_horizontalTimebaseSet = false ;
m_runningSet = false ;
m_runningSet = false ;
// Create widgets
// Create widgets
m_base = new ScopeBase ( widget ( ) ) ;
m_base = new ScopeBase ( widget ( ) ) ;
m_traceControlWidgetGrid = new TQGridLayout ( m_base - > traceControlLayoutWidget ) ;
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 ( ) ;
m_traceWidget = m_base - > traceScrollWidget - > traceWidget ( ) ;
connect ( m_traceWidget , SIGNAL ( cursorDragged ( uint , double ) ) , this , SLOT ( cursorLevelChanged ( uint , double ) ) ) ;
connect ( m_traceWidget , SIGNAL ( cursorDragged ( uint , double ) ) , this , SLOT ( cursorLevelChanged ( uint , double ) ) ) ;
m_base - > traceScrollWidget - > setSizePolicy ( TQSizePolicy ( TQSizePolicy : : MinimumExpanding , TQSizePolicy : : MinimumExpanding ) ) ;
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_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_horizontalTimebaseSet ) updatesPending = true ;
if ( m_runningSet ) updatesPending = true ;
if ( m_runningSet ) updatesPending = true ;
}
}
@ -600,6 +667,55 @@ void ScopePart::mainEventLoop() {
}
}
m_socket - > clearFrameTail ( ) ;
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 " ) {
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_ChannelCountRequest )
SET_NEXT_STATE ( ScopeState_ChannelCountRequest )
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
@ -932,8 +1048,56 @@ void ScopePart::mainEventLoop() {
SET_NEXT_STATE ( ScopeState_TraceSecondsDivRequest )
SET_NEXT_STATE ( ScopeState_TraceSecondsDivRequest )
}
}
else {
else {
SET_NEXT_STATE ( ScopeState_TriggerChannelRequest )
SET_NEXT_STATE ( ScopeState_HorizontalTimebaseRequest )
}
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_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
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else {
else {
@ -1116,7 +1280,6 @@ void ScopePart::mainEventLoop() {
ds < < m_currentOpChannel ;
ds < < m_currentOpChannel ;
m_socket - > writeEndOfFrame ( ) ;
m_socket - > writeEndOfFrame ( ) ;
m_lastChangesRequireFullUpdate = false ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TraceRequest + 1 )
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TraceRequest + 1 )
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
}
}
@ -1154,12 +1317,13 @@ 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_horizontalTimebaseSet = = false )
& & ( m_runningSet = = false )
& & ( m_runningSet = = false )
) {
) {
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = 1 ;
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
}
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
@ -1193,28 +1357,23 @@ void ScopePart::mainEventLoop() {
ds < < active ;
ds < < active ;
m_socket - > writeEndOfFrame ( ) ;
m_socket - > writeEndOfFrame ( ) ;
m_lastChangesRequireFullUpdate = true ;
m_channelActiveSet [ m_currentOpChannel ] = false ;
m_channelActiveSet [ m_currentOpChannel ] = false ;
SET_NEXT_STATE_DATA_WAITING ( ScopeState_ChannelActiveStateUpdate + 1 )
SET_NEXT_STATE_DATA_WAITING ( ScopeState_ChannelActiveStateUpdate + 1 )
}
}
else {
else {
m_currentOpChannel = m_currentOpChannel + 1 ;
if ( m_currentOpChannel < m_maxNumberOfTraces ) {
if ( m_currentOpChannel < m_maxNumberOfTraces ) {
m_currentOpChannel + + ;
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
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
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else if ( m_commHandlerState = = ScopeState_ChannelActiveStateUpdate + 1 ) {
else if ( m_commHandlerState = = ScopeState_ChannelActiveStateUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
PAT_WATCHDOG_TIMER
@ -1231,11 +1390,12 @@ void ScopePart::mainEventLoop() {
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
SET_NEXT_STATE ( ScopeState_ChannelActiveStateUpdate )
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = m_currentOpChannel + 1 ;
if ( m_ lastChangesRequireFullUpdate ) {
if ( m_ currentOpChannel < m_maxNumberOfTraces ) {
SET_NEXT_STATE ( ScopeState_ TraceVoltsDivRequest )
SET_NEXT_STATE ( ScopeState_ ChannelActiveStateUpdate )
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_TraceVoltsDivUpdate )
SET_NEXT_STATE ( ScopeState_TraceVoltsDivUpdate )
}
}
}
}
@ -1284,6 +1444,7 @@ void ScopePart::mainEventLoop() {
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else if ( m_commHandlerState = = ScopeState_TraceVoltsDivUpdate + 1 ) {
else if ( m_commHandlerState = = ScopeState_TraceVoltsDivUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
PAT_WATCHDOG_TIMER
@ -1325,7 +1486,7 @@ void ScopePart::mainEventLoop() {
}
}
}
}
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate ) {
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate ) {
if ( m_ voltsDivSet[ m_currentOpChannel ] ) {
if ( m_ triggerLevelSet ) {
// Set trigger level, step 1
// Set trigger level, step 1
ds < < TQString ( " SETTRIGGERLEVEL " ) ;
ds < < TQString ( " SETTRIGGERLEVEL " ) ;
ds < < m_triggerLevel ;
ds < < m_triggerLevel ;
@ -1335,12 +1496,12 @@ void ScopePart::mainEventLoop() {
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TriggerLevelUpdate + 1 )
SET_NEXT_STATE_DATA_WAITING ( ScopeState_TriggerLevelUpdate + 1 )
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
SET_NEXT_STATE ( ScopeState_HorizontalTimebaseUpdate )
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
}
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate + 1 ) {
else if ( m_commHandlerState = = ScopeState_TriggerLevelUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
PAT_WATCHDOG_TIMER
@ -1351,6 +1512,57 @@ void ScopePart::mainEventLoop() {
ds > > result ;
ds > > result ;
m_socket - > clearFrameTail ( ) ;
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 " ) {
if ( result = = " ACK " ) {
SET_NEXT_STATE ( ScopeState_RunningUpdate )
SET_NEXT_STATE ( ScopeState_RunningUpdate )
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
@ -1388,11 +1600,19 @@ void ScopePart::mainEventLoop() {
}
}
else {
else {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_settingsChanged ) {
m_settingsChanged = false ;
SET_NEXT_STATE ( ScopeState_ReloadSettings )
}
else {
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
}
}
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else if ( m_commHandlerState = = ScopeState_RunningUpdate + 1 ) {
else if ( m_commHandlerState = = ScopeState_RunningUpdate + 1 ) {
m_settingsChanged = true ;
// Get response data
// Get response data
if ( m_socket - > canReadFrame ( ) ) {
if ( m_socket - > canReadFrame ( ) ) {
PAT_WATCHDOG_TIMER
PAT_WATCHDOG_TIMER
@ -1405,7 +1625,13 @@ void ScopePart::mainEventLoop() {
if ( result = = " ACK " ) {
if ( result = = " ACK " ) {
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
m_currentOpChannel = getNextActiveChannel ( 0 , m_channelActive , m_maxNumberOfTraces ) ;
if ( m_settingsChanged ) {
m_settingsChanged = false ;
SET_NEXT_STATE ( ScopeState_ReloadSettings )
}
else {
SET_NEXT_STATE ( ScopeState_TraceRequest )
SET_NEXT_STATE ( ScopeState_TraceRequest )
}
EXEC_NEXT_STATE_IMMEDIATELY
EXEC_NEXT_STATE_IMMEDIATELY
}
}
else {
else {
@ -1526,6 +1752,7 @@ void ScopePart::stopDAQ() {
m_voltsDivSet [ i ] = false ;
m_voltsDivSet [ i ] = false ;
}
}
m_triggerLevelSet = false ;
m_triggerLevelSet = false ;
m_horizontalTimebaseSet = false ;
m_runningSet = false ;
m_runningSet = false ;
m_commHandlerMode = 1 ;
m_commHandlerMode = 1 ;
m_commHandlerCommandState = 3 ;
m_commHandlerCommandState = 3 ;
@ -1534,7 +1761,7 @@ void ScopePart::stopDAQ() {
}
}
# define WAVEFORM_MAGIC_NUMBER 1
# define WAVEFORM_MAGIC_NUMBER 1
# define WAVEFORM_FILE_VERSION 1
# define WAVEFORM_FILE_VERSION 2
void ScopePart : : saveWaveforms ( ) {
void ScopePart : : saveWaveforms ( ) {
TQString saveFileName = KFileDialog : : getSaveFileName ( TQString : : null , " *.wfm|Waveform Files (*.wfm) " , 0 , i18n ( " Save waveforms... " ) ) ;
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 + + ) {
for ( int cursorno = 0 ; cursorno < 5 ; cursorno + + ) {
ds < < m_traceWidget - > cursorPosition ( cursorno ) ;
ds < < m_traceWidget - > cursorPosition ( cursorno ) ;
}
}
ds < < m_base - > userNotes - > text ( ) ;
}
}
}
}
@ -1577,7 +1805,7 @@ void ScopePart::recallWaveforms() {
ds > > magicNumber ;
ds > > magicNumber ;
if ( magicNumber = = WAVEFORM_MAGIC_NUMBER ) {
if ( magicNumber = = WAVEFORM_MAGIC_NUMBER ) {
ds > > version ;
ds > > version ;
if ( version == WAVEFORM_FILE_VERSION ) {
if ( ( version > = 1 ) & & ( version < = WAVEFORM_FILE_VERSION ) ) {
ds > > m_hdivs ;
ds > > m_hdivs ;
ds > > m_vdivs ;
ds > > m_vdivs ;
ds > > m_maxNumberOfTraces ;
ds > > m_maxNumberOfTraces ;
@ -1607,6 +1835,14 @@ void ScopePart::recallWaveforms() {
ds > > cursorPos ;
ds > > cursorPos ;
m_traceWidget - > setCursorPosition ( cursorno , 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_triggerChannel = - 1 ;
m_triggerLevel = 0 ;
m_triggerLevel = 0 ;
updateGraticule ( ) ;
updateGraticule ( ) ;
@ -1616,7 +1852,7 @@ void ScopePart::recallWaveforms() {
updateTraceControlWidgets ( ) ;
updateTraceControlWidgets ( ) ;
}
}
else {
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 {
else {
@ -1756,6 +1992,11 @@ void ScopePart::traceControlVDivChanged(double vdiv) {
updateTraceControlWidgets ( ) ;
updateTraceControlWidgets ( ) ;
}
}
void ScopePart : : traceControlSDivChanged ( double sdiv ) {
m_horizontalTimebase = sdiv ;
m_horizontalTimebaseSet = true ;
}
void ScopePart : : cursorLevelChanged ( uint cursor , double level ) {
void ScopePart : : cursorLevelChanged ( uint cursor , double level ) {
if ( cursor = = 0 ) {
if ( cursor = = 0 ) {
// Trigger level changed
// Trigger level changed