Add interface mode selection

Make servers use less CPU
master
Timothy Pearson 12 years ago
parent b5fa21be6e
commit d5316f5795

@ -257,8 +257,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -279,8 +279,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -316,8 +316,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -338,8 +338,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -529,8 +529,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -767,8 +767,8 @@
</property> </property>
<property name="sizeHint"> <property name="sizeHint">
<size> <size>
<width>20</width> <width>0</width>
<height>20</height> <height>0</height>
</size> </size>
</property> </property>
</spacer> </spacer>

@ -854,20 +854,42 @@ void FPGAViewPart::processLockouts() {
} }
} }
// Interface mode switching handlers
if (m_interfaceMode == BasicInterfaceMode) { if (m_interfaceMode == BasicInterfaceMode) {
m_modeBasicEnabled->setChecked(true); m_modeBasicEnabled->setChecked(true);
m_modeIntermediateEnabled->setChecked(false); m_modeIntermediateEnabled->setChecked(false);
m_modeAdvancedEnabled->setChecked(false); m_modeAdvancedEnabled->setChecked(false);
m_base->groupLCDDisplay->show();
m_base->groupLEDDisplay->hide();
m_base->groupBatchTest->hide();
m_base->groupDataProcessing->hide();
m_base->groupInputImage->hide();
m_base->groupOutputImage->hide();
} }
if (m_interfaceMode == IntermediateInterfaceMode) { if (m_interfaceMode == IntermediateInterfaceMode) {
m_modeBasicEnabled->setChecked(false); m_modeBasicEnabled->setChecked(false);
m_modeIntermediateEnabled->setChecked(true); m_modeIntermediateEnabled->setChecked(true);
m_modeAdvancedEnabled->setChecked(false); m_modeAdvancedEnabled->setChecked(false);
m_base->groupLCDDisplay->show();
m_base->groupLEDDisplay->show();
m_base->groupBatchTest->show();
m_base->groupDataProcessing->hide();
m_base->groupInputImage->hide();
m_base->groupOutputImage->hide();
} }
if (m_interfaceMode == AdvancedInterfaceMode) { if (m_interfaceMode == AdvancedInterfaceMode) {
m_modeBasicEnabled->setChecked(false); m_modeBasicEnabled->setChecked(false);
m_modeIntermediateEnabled->setChecked(false); m_modeIntermediateEnabled->setChecked(false);
m_modeAdvancedEnabled->setChecked(true); m_modeAdvancedEnabled->setChecked(true);
m_base->groupLCDDisplay->show();
m_base->groupLEDDisplay->show();
m_base->groupBatchTest->show();
m_base->groupDataProcessing->show();
m_base->groupInputImage->show();
m_base->groupOutputImage->show();
} }
if ((m_base->batchTestInputFile->url() != "") && (m_base->batchTestOutputFile->url() != "") && (m_commHandlerMode == 0) && (m_connectionActiveAndValid == true)) { if ((m_base->batchTestInputFile->url() != "") && (m_base->batchTestOutputFile->url() != "") && (m_commHandlerMode == 0) && (m_connectionActiveAndValid == true)) {
@ -918,19 +940,26 @@ void FPGAViewPart::processLockouts() {
} }
} }
void FPGAViewPart::resizeToHint() {
resize(widget()->sizeHint());
}
void FPGAViewPart::switchToBasicMode() { void FPGAViewPart::switchToBasicMode() {
m_interfaceMode = BasicInterfaceMode; m_interfaceMode = BasicInterfaceMode;
processLockouts(); processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
} }
void FPGAViewPart::switchToIntermediateMode() { void FPGAViewPart::switchToIntermediateMode() {
m_interfaceMode = IntermediateInterfaceMode; m_interfaceMode = IntermediateInterfaceMode;
processLockouts(); processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
} }
void FPGAViewPart::switchToAdvancedMode() { void FPGAViewPart::switchToAdvancedMode() {
m_interfaceMode = AdvancedInterfaceMode; m_interfaceMode = AdvancedInterfaceMode;
processLockouts(); processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
} }
void FPGAViewPart::connectionClosed() { void FPGAViewPart::connectionClosed() {
@ -1039,8 +1068,12 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false; connToServerConnecting = false;
connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData())); connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData()));
connect(m_socket, SIGNAL(newDataReceived()), this, SLOT(updateDisplay())); connect(m_socket, SIGNAL(newDataReceived()), this, SLOT(updateDisplay()));
m_tickerState = 0;
m_commHandlerState = 0;
m_commHandlerMode = 0;
m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE); m_updateTimer->start(FPGA_COMM_TIMEOUT_MS, FALSE);
processLockouts(); processLockouts();
updateDisplay();
return; return;
} }
else if (response == "ERRNOCONN") { else if (response == "ERRNOCONN") {

@ -156,6 +156,7 @@ namespace RemoteLab
private slots: private slots:
void postInit(); void postInit();
void resizeToHint();
void updateDisplay(); void updateDisplay();
void processLockouts(); void processLockouts();
void connectionClosed(); void connectionClosed();

@ -63,7 +63,7 @@ namespace KParts
void RemoteInstrumentPart::resize(TQSize size) { void RemoteInstrumentPart::resize(TQSize size) {
TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent()); TQWidget* parentWidget = dynamic_cast<TQWidget*>(parent());
if (parentWidget) { if (parentWidget) {
parentWidget->resize(size); parentWidget->setFixedSize(size);
} }
} }

@ -131,7 +131,10 @@ int AuthSocket::initiateKerberosHandshake() {
} }
} }
void AuthSocket::servLoop() { int AuthSocket::servLoop() {
bool transferred_data;
transferred_data = false;
if (m_servActive) { if (m_servActive) {
TQString command; TQString command;
TQDataStream ds(this); TQDataStream ds(this);
@ -159,6 +162,7 @@ void AuthSocket::servLoop() {
delete m_servClientTimeout; delete m_servClientTimeout;
m_servClientTimeout = NULL; m_servClientTimeout = NULL;
} }
transferred_data = true;
m_servState = 1; m_servState = 1;
} }
break; break;
@ -180,6 +184,7 @@ void AuthSocket::servLoop() {
krbstat = m_servClientSocket->kerberosStatus(); krbstat = m_servClientSocket->kerberosStatus();
if ((krbstat == TDEKerberosClientSocket::KerberosInitializing) || (krbstat == TDEKerberosClientSocket::KerberosInUse)) { if ((krbstat == TDEKerberosClientSocket::KerberosInitializing) || (krbstat == TDEKerberosClientSocket::KerberosInUse)) {
if (krbstat == TDEKerberosClientSocket::KerberosInUse) { if (krbstat == TDEKerberosClientSocket::KerberosInUse) {
transferred_data = true;
m_servState = 3; m_servState = 3;
} }
} }
@ -205,6 +210,7 @@ void AuthSocket::servLoop() {
clientDS >> server_reply; clientDS >> server_reply;
if (server_reply == "OK") { if (server_reply == "OK") {
ds << TQString("OK"); ds << TQString("OK");
transferred_data = true;
m_servState = 4; m_servState = 4;
} }
else { else {
@ -245,10 +251,12 @@ void AuthSocket::servLoop() {
if (canReadData()) { if (canReadData()) {
reclen = readBlock(ba.data(), 8192); reclen = readBlock(ba.data(), 8192);
m_servClientSocket->writeBlock(ba.data(), reclen); m_servClientSocket->writeBlock(ba.data(), reclen);
transferred_data = true;
} }
if (m_servClientSocket->canReadData()) { if (m_servClientSocket->canReadData()) {
reclen = m_servClientSocket->readBlock(ba.data(), 8192); reclen = m_servClientSocket->readBlock(ba.data(), 8192);
writeBlock(ba.data(), reclen); writeBlock(ba.data(), reclen);
transferred_data = true;
} }
} }
else { else {
@ -260,21 +268,40 @@ void AuthSocket::servLoop() {
break; break;
} }
} }
if (transferred_data) {
return 1;
}
else {
return 0;
}
} }
void AuthSocket::commandLoop() { void AuthSocket::commandLoop() {
bool transferred_data;
if (m_servActive) { if (m_servActive) {
servLoop(); transferred_data = false;
if (m_loopTimer) m_loopTimer->start(0, TRUE); if (servLoop() == 1) {
transferred_data = true;
}
if (transferred_data) {
if (m_loopTimer) m_loopTimer->start(0, TRUE);
}
else {
if (m_loopTimer) m_loopTimer->start(100, TRUE);
}
return; return;
} }
m_criticalSection++; m_criticalSection++;
try { try {
transferred_data = false;
if (state() == TQSocket::Connected) { if (state() == TQSocket::Connected) {
if (canReadData()) { if (canReadData()) {
TQString command; TQString command;
TQDataStream ds(this); TQDataStream ds(this);
transferred_data = true;
ds >> command; ds >> command;
if (command != "") { if (command != "") {
@ -432,7 +459,12 @@ void AuthSocket::commandLoop() {
} }
m_criticalSection--; m_criticalSection--;
if (m_loopTimer) m_loopTimer->start(0, TRUE); if (transferred_data) {
if (m_loopTimer) m_loopTimer->start(0, TRUE);
}
else {
if (m_loopTimer) m_loopTimer->start(100, TRUE);
}
return; return;
} }
} }

@ -58,7 +58,7 @@ class AuthSocket : public TDEKerberosServerSocket
int connectToDatabase(); int connectToDatabase();
void connectionClosedHandler(); void connectionClosedHandler();
void commandLoop(); void commandLoop();
void servLoop(); int servLoop();
private: private:
int line; int line;

@ -161,13 +161,16 @@ int FPGASocket::setupSerial() {
void FPGASocket::commandLoop() { void FPGASocket::commandLoop() {
int cc; int cc;
char buffer[10000]; char buffer[10000];
bool transferred_data;
m_criticalSection++; m_criticalSection++;
try { try {
transferred_data = false;
if (state() == TQSocket::Connected) { if (state() == TQSocket::Connected) {
cc = read(m_fd_tty, buffer, 10000); cc = read(m_fd_tty, buffer, 10000);
if (cc > 0) { if (cc > 0) {
writeBlock(buffer, cc); writeBlock(buffer, cc);
transferred_data = true;
printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout); printf("[DEBUG] Got %d bytes from the serial port\n\r", cc); fflush(stdout);
} }
if (canReadData()) { if (canReadData()) {
@ -176,12 +179,18 @@ void FPGASocket::commandLoop() {
if (write(m_fd_tty, buffer, cc) < 0) { if (write(m_fd_tty, buffer, cc) < 0) {
// ERROR // ERROR
} }
transferred_data = true;
printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout); printf("[DEBUG] Got %d bytes from the network interface\n\r", cc); fflush(stdout);
} }
} }
} }
m_criticalSection--; m_criticalSection--;
if (m_loopTimer) m_loopTimer->start(0, TRUE); if (transferred_data) {
if (m_loopTimer) m_loopTimer->start(0, TRUE);
}
else {
if (m_loopTimer) m_loopTimer->start(100, TRUE);
}
return; return;
} }
catch (...) { catch (...) {

Loading…
Cancel
Save