Fix scope part crashes

Add server-provided caption support
Properly brand client application
master
Timothy Pearson 10 years ago
parent 9c98267db3
commit bd0400a096

@ -69,7 +69,7 @@ RemoteMDI::RemoteMDI()
// When we change view, change the status bar text
connect(this, SIGNAL(viewActivated(KMdiChildView*)), this, SLOT(currentChanged(KMdiChildView*)));
ac->setHighlightingEnabled(true);
ac->setHighlightingEnabled(true);
connect(ac, TQT_SIGNAL(actionStatusText(const TQString&)), this, TQT_SLOT(updateStatusBarMainMessage(const TQString&) ));
connect(ac, TQT_SIGNAL(clearStatusText()), statusBar(), TQT_SLOT(clear()));
@ -304,12 +304,31 @@ void RemoteMDI::finishConnectingToServer() {
*ds >> protover;
m_rsvSvrSocket->clearFrameTail();
printf("[DEBUG] Got magic number %d and protocol version %d\n\r", magicnum, protover); fflush(stdout);
delete ds;
if ((magicnum == MAGIC_NUMBER) && (protover == PROTOCOL_VERSION)) {
// Request server name
TQString serverName;
*ds << TQString("NAME");
m_rsvSvrSocket->writeEndOfFrame();
while (!m_rsvSvrSocket->canReadFrame()) {
tqApp->processEvents();
if (!m_rsvSvrSocket) {
return;
}
}
*ds >> serverName;
m_rsvSvrSocket->clearFrameTail();
// Set caption if a valid server name was received
if ((serverName != "") && (serverName != "ERRINVCMD")) {
setCaption(TQString("%1 - %2").arg(serverName).arg(kapp->caption()));
}
delete ds;
disconnect_action->setEnabled(true);
promptForStationType();
}
else {
delete ds;
disconnectFromServer();
KMessageBox::error(this, i18n("<qt>The remote server is not compatible with this client</qt>"), i18n("Connection Failed"));
}

@ -1,5 +1,24 @@
//Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>, (C) 2012
//Copyright: See COPYING file that comes with this distribution
/*
* Remote Laboratory Workspaces Client
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (c) 2012-2014 Timothy Pearson
* Raptor Engineering
* http://www.raptorengineeringinc.com
*/
#ifndef DEFINE_H
#define DEFINE_H
@ -12,6 +31,6 @@
#define APP_NAME "remote_laboratory_client"
#define APP_VERSION "1.0"
#define APP_PRETTYNAME "Remote Laboratory Client"
#define APP_PRETTYNAME "uLab Workspaces Client"
#endif

@ -163,6 +163,14 @@
<property name="title">
<string>Notes</string>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>3</vsizetype>
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<grid>
<widget class="KTextEdit" row="0" column="0" colspan="1">
<property name="name">
@ -171,6 +179,14 @@
<property name="text">
<string></string>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>3</vsizetype>
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
</widget>
</grid>
</widget>

@ -1972,7 +1972,9 @@ void ScopePart::processTriggerButtons() {
}
for (int i=0; i<m_maxNumberOfTraces;i++) {
m_traceControlWidgetList[i]->setTriggerChannel(i == (m_triggerChannel-1));
if (m_traceControlWidgetList[i]) {
m_traceControlWidgetList[i]->setTriggerChannel(i == (m_triggerChannel-1));
}
}
}

@ -1661,7 +1661,8 @@ void TraceWidget::updateTraceText() {
offsetText = TQString(" +%1").arg(prettyFormat(fabs(offset), vertical_range, m_traceArray[trace]->verticalUnits));
}
}
m_traceArray[trace]->paramLabel->setText(TQString("<qt><nobr>%1%2<br>%3/div,%4/div<br>%5,%6<br>%7,%8</qt>").arg(m_traceArray[trace]->traceName).arg(offsetText).arg(prettyFormat(horizontal_units_per_division, horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(vertical_units_per_division, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->leftEdge, (m_useAbsoluteHorizontalRange)?m_traceArray[trace]->rightEdge:horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->topEdge, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->rightEdge, (m_useAbsoluteHorizontalRange)?m_traceArray[trace]->rightEdge:horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->bottomEdge, vertical_range, m_traceArray[trace]->verticalUnits)));
TQString traceDataString = TQString("<br>%1,%2,%3").arg(prettyFormat(m_traceArray[trace]->sampleMin, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->sampleMax, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->sampleAverage, vertical_range, m_traceArray[trace]->verticalUnits));
m_traceArray[trace]->paramLabel->setText(TQString("<qt><nobr>%1%2<br>%3/div,%4/div<br>%5,%6<br>%7,%8%9</qt>").arg(m_traceArray[trace]->traceName).arg(offsetText).arg(prettyFormat(horizontal_units_per_division, horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(vertical_units_per_division, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->leftEdge, (m_useAbsoluteHorizontalRange)?m_traceArray[trace]->rightEdge:horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->topEdge, vertical_range, m_traceArray[trace]->verticalUnits)).arg(prettyFormat(m_traceArray[trace]->rightEdge, (m_useAbsoluteHorizontalRange)?m_traceArray[trace]->rightEdge:horizontal_range, m_traceArray[trace]->horizontalUnits)).arg(prettyFormat(m_traceArray[trace]->bottomEdge, vertical_range, m_traceArray[trace]->verticalUnits)).arg(traceDataString));
m_traceArray[trace]->leftLabel->setText(TQString("<qt><nobr>%1</qt>").arg(m_traceArray[trace]->traceName));
}
}
@ -1795,9 +1796,32 @@ TQDoubleArray& TraceWidget::samples(uint traceNumber) {
void TraceWidget::setSamples(uint traceNumber, TQDoubleArray& tqda, bool deferUpdate) {
VERIFY_TRACE_ARRAY_SIZE
unsigned int i;
double curValue;
m_traceArray[traceNumber]->sampleArray = tqda;
m_traceArray[traceNumber]->numberOfSamples = tqda.size();
// Calculate trace minimum, maximum, and average
m_traceArray[traceNumber]->sampleMin = DBL_MAX;
m_traceArray[traceNumber]->sampleMax = DBL_MIN;
m_traceArray[traceNumber]->sampleAverage = 0;
m_traceArray[traceNumber]->minIndex = 0;
m_traceArray[traceNumber]->maxIndex = 0;
for (i=0; i<m_traceArray[traceNumber]->sampleArray.size(); i++) {
curValue = m_traceArray[traceNumber]->sampleArray[i];
if (curValue < m_traceArray[traceNumber]->sampleMin) {
m_traceArray[traceNumber]->sampleMin = curValue;
m_traceArray[traceNumber]->minIndex = i;
}
if (curValue > m_traceArray[traceNumber]->sampleMax) {
m_traceArray[traceNumber]->sampleMax = curValue;
m_traceArray[traceNumber]->maxIndex = i;
}
m_traceArray[traceNumber]->sampleAverage = m_traceArray[traceNumber]->sampleAverage + curValue;
}
m_traceArray[traceNumber]->sampleAverage = m_traceArray[traceNumber]->sampleAverage / m_traceArray[traceNumber]->numberOfSamples;
if (!deferUpdate) {
updateCursorText();
m_graticuleWidget->repaint(false);

@ -104,6 +104,11 @@ class TraceData : public TQObject
TQDoubleArray sampleArray;
TQDoubleArray positionArray;
unsigned int numberOfSamples;
double sampleMax;
double sampleMin;
double sampleAverage;
double minIndex;
double maxIndex;
long leftEdgeIndex;
long rightEdgeIndex;
double offset;

Loading…
Cancel
Save