Enhancements

- Server now updates the "packet list" after every "apply" rather than before a "start transmit" (if dirty) - this better reflects user's expectation from these operations
- Client disables the entire application and changes to a "Busy" cursor when "applying" stream configuration

Fixes
- UDP checksum no longer is zero but a valid value
- Order of streams no longer gets messed up across a "apply"
This commit is contained in:
Srivats P. 2010-01-10 14:40:33 +00:00
parent 78a2de040b
commit 70ca42fbb3
10 changed files with 47 additions and 22 deletions

View File

@ -2,11 +2,16 @@
#include <QApplication>
QMainWindow *mainWindow;
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
MainWindow mainWin;
QApplication app(argc, argv);
int exitCode;
mainWin.show();
return app.exec();
mainWindow = new MainWindow;
mainWindow->show();
exitCode = app.exec();
delete mainWindow;
return exitCode;
}

View File

@ -39,7 +39,7 @@ void Port::updateStreamOrdinalsFromIndex()
void Port::reorderStreamsByOrdinals()
{
qSort(mStreams);
qSort(mStreams.begin(), mStreams.end(), StreamBase::StreamLessThan);
}
bool Port::newStreamAt(int index)
@ -176,7 +176,7 @@ void Port::getModifiedStreamsSinceLastSync(
void Port::when_syncComplete()
{
qSort(mStreams);
//reorderStreamsByOrdinals();
mLastSyncStreamList.clear();
for (int i=0; i<mStreams.size(); i++)

View File

@ -1,9 +1,13 @@
#include <QtGlobal>
#include <QProcess>
#include <QTemporaryFile>
#include "portgroup.h"
#include <QApplication>
#include <QCursor>
#include <QMainWindow>
#include <QProcess>
#include <QTemporaryFile>
#include <QtGlobal>
extern QMainWindow *mainWindow;
quint32 PortGroup::mPortGroupAllocId = 0;
@ -129,6 +133,9 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
{
OstProto::StreamIdList streamIdList;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
mainWindow->setDisabled(true);
qDebug("applying 'deleted streams' ...");
streamIdList.mutable_port_id()->set_id(mPorts[portIndex]->id());
@ -177,6 +184,10 @@ void PortGroup::when_configApply(int portIndex, uint *cookie)
qDebug("apply completed");
mPorts[portIndex]->when_syncComplete();
delete cookie;
mainWindow->setEnabled(true);
QApplication::restoreOverrideCursor();
break;
default:
@ -431,7 +442,7 @@ _exit:
return;
}
void PortGroup::processModifyStreamAck(OstProto::Ack */*ack*/)
void PortGroup::processModifyStreamAck(OstProto::Ack * /*ack*/)
{
qDebug("In %s", __FUNCTION__);

View File

@ -113,11 +113,6 @@ ProtocolListIterator* StreamBase::createProtocolListIterator() const
return new ProtocolListIterator(*currentFrameProtocols);
}
bool StreamBase::operator < (const StreamBase &s) const
{
return(mCore->ordinal() < s.mCore->ordinal());
}
quint32 StreamBase::id()
{
return mStreamId->id();
@ -380,3 +375,7 @@ int StreamBase::frameValue(uchar *buf, int bufMaxSize, int n) const
return pktLen;
}
bool StreamBase::StreamLessThan(StreamBase* stream1, StreamBase* stream2)
{
return stream1->ordinal() < stream2->ordinal() ? true : false;
}

View File

@ -54,8 +54,6 @@ public:
e_nw_goto_id
};
bool operator < (const StreamBase &s) const;
quint32 id();
bool setId(quint32 id);
@ -114,6 +112,8 @@ public:
bool isFrameVariable() const;
int frameValue(uchar *buf, int bufMaxSize, int n) const;
static bool StreamLessThan(StreamBase* stream1, StreamBase* stream2);
};
#endif

View File

@ -203,6 +203,7 @@ QVariant UdpProtocol::fieldData(int index, FieldAttrib attrib,
else
cksum = protocolFrameCksum(streamIndex, CksumTcpUdp);
qDebug("UDP cksum = %hu", cksum);
break;
}
default:
cksum = 0;

View File

@ -31,6 +31,12 @@ AbstractPort::~AbstractPort()
{
}
StreamBase* AbstractPort::streamAtIndex(int index)
{
Q_ASSERT(index < streamList_.size());
return streamList_.at(index);
}
StreamBase* AbstractPort::stream(int streamId)
{
for (int i = 0; i < streamList_.size(); i++)
@ -79,7 +85,7 @@ void AbstractPort::updatePacketList()
qDebug("In %s", __FUNCTION__);
// First sort the streams by ordinalValue
qSort(streamList_);
qSort(streamList_.begin(), streamList_.end(), StreamBase::StreamLessThan);
clearPacketList();

View File

@ -34,6 +34,7 @@ public:
void protoDataCopyInto(OstProto::Port *port) { port->CopyFrom(data_); }
int streamCount() { return streamList_.size(); }
StreamBase* streamAtIndex(int index);
StreamBase* stream(int streamId);
bool addStream(StreamBase *stream);
bool deleteStream(int streamId);

View File

@ -88,7 +88,7 @@ void MyService::getStreamIdList(::google::protobuf::RpcController* controller,
OstProto::StreamId *s;
s = response->add_stream_id();
s->set_id(portInfo[portId]->stream(i)->id());
s->set_id(portInfo[portId]->streamAtIndex(i)->id());
}
done->Run();
return;
@ -224,6 +224,9 @@ void MyService::modifyStream(::google::protobuf::RpcController* controller,
}
}
if (portInfo[portId]->isDirty())
portInfo[portId]->updatePacketList();
//! \todo(LOW): fill-in response "Ack"????
done->Run();

View File

@ -29,8 +29,7 @@ public:
}
virtual void startTransmit() {
if (isDirty())
updatePacketList();
Q_ASSERT(!isDirty());
transmitter_->start();
}
virtual void stopTransmit() { transmitter_->stop(); }