Add interface mode selection

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

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

@ -854,20 +854,42 @@ void FPGAViewPart::processLockouts() {
}
}
// Interface mode switching handlers
if (m_interfaceMode == BasicInterfaceMode) {
m_modeBasicEnabled->setChecked(true);
m_modeIntermediateEnabled->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) {
m_modeBasicEnabled->setChecked(false);
m_modeIntermediateEnabled->setChecked(true);
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) {
m_modeBasicEnabled->setChecked(false);
m_modeIntermediateEnabled->setChecked(false);
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)) {
@ -918,19 +940,26 @@ void FPGAViewPart::processLockouts() {
}
}
void FPGAViewPart::resizeToHint() {
resize(widget()->sizeHint());
}
void FPGAViewPart::switchToBasicMode() {
m_interfaceMode = BasicInterfaceMode;
processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
}
void FPGAViewPart::switchToIntermediateMode() {
m_interfaceMode = IntermediateInterfaceMode;
processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
}
void FPGAViewPart::switchToAdvancedMode() {
m_interfaceMode = AdvancedInterfaceMode;
processLockouts();
TQTimer::singleShot(0, this, SLOT(resizeToHint()));
}
void FPGAViewPart::connectionClosed() {
@ -1039,8 +1068,12 @@ printf("[RAJA DEBUG 400.0] Got '%s' from the server\n\r", response.ascii()); ffl
connToServerConnecting = false;
connect(m_socket, SIGNAL(readyRead()), m_socket, SLOT(processPendingData()));
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);
processLockouts();
updateDisplay();
return;
}
else if (response == "ERRNOCONN") {

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

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

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

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

Loading…
Cancel
Save