void TestLocalSocket_Peer::fetchControlSocket() { QWriteLocker locker(&m_peerSocketLock); if(m_peerSocket) { m_peerSocketReady.wakeAll(); return; } QLocalSocket * ret = m_localCtrlServer->nextPendingConnection(); QElapsedTimer timer; timer.start(); while(!ret && timer.elapsed() < 30000) { m_localCtrlServer->waitForNewConnection(2000); ret = m_localCtrlServer->nextPendingConnection(); } m_peerSocket = ret; connect(m_peerSocket, SIGNAL(readyRead()), SLOT(readControlData())); // qDebug("Got control socket!"); m_peerSocketReady.wakeAll(); }
int processCtrlRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiCtrlRecT * ctrlRec) { SaErrorT status; int retval = SAF_TEST_NOTSUPPORT; SaHpiCtrlNumT ctrlNum = ctrlRec->Num; int maxBytes; ControlData controlData; maxBytes = getMaxBytes(ctrlRec); if (!ctrlRec->WriteOnly && isTextControl(ctrlRec) && canSetControlState(ctrlRec) && maxBytes >= 4) { // Save the original mode and state data so that it can be restored. status = readControlData(sessionId, resourceId, ctrlRec, &controlData); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiControlGet, SA_OK, status); } else { retval = run_test(sessionId, resourceId, ctrlRec); // Restore the original mode and state data. restoreControlData(sessionId, resourceId, ctrlNum, &controlData); } } return retval; }
int processCtrlRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiCtrlRecT * ctrlRec) { SaErrorT status; int retval = SAF_TEST_NOTSUPPORT; SaHpiCtrlNumT ctrlNum = ctrlRec->Num; ControlData controlData; int numBytes; SaHpiBoolT success; if (!ctrlRec->WriteOnly && isTextControl(ctrlRec) && canSetControlState(ctrlRec)) { // Read the mode and all of the text buffers for later restoration. status = readControlData(sessionId, resourceId, ctrlRec, &controlData); if (status != SA_OK) { e_trace(); retval = SAF_TEST_UNRESOLVED; } else { // Fill up the text buffers so that we know we really have something to clear. status = setControlAllTextBuffers(sessionId, resourceId, ctrlRec, BYTE_VALUE_1); if (status != SA_OK) { e_trace(); retval = SAF_TEST_UNRESOLVED; } else { // Clear all of the text buffers and overwrite half of the first line. numBytes = getMaxBytes(ctrlRec) / 2; status = setControlTextBuffer(sessionId, resourceId, ctrlRec, SAHPI_TLN_ALL_LINES, numBytes, BYTE_VALUE_2); if (status != SA_OK) { e_trace(); retval = SAF_TEST_FAIL; } else { // Verify that the text buffers contain what we expect. status = verifyTextBuffers(sessionId, resourceId, ctrlRec, numBytes, &success); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; } else if (success) { retval = SAF_TEST_PASS; } else { retval = SAF_TEST_FAIL; } } } // Restore the mode and text data. restoreControlData(sessionId, resourceId, ctrlNum, &controlData); } } return retval; }
int processCtrlRdr(SaHpiSessionIdT sessionId, SaHpiResourceIdT resourceId, SaHpiRdrT * rdr, SaHpiCtrlRecT * ctrlRec) { SaErrorT status; int retval = SAF_TEST_NOTSUPPORT; int lineNum; int maxLines; int maxBytes; SaHpiCtrlNumT ctrlNum = ctrlRec->Num; SaHpiCtrlModeT ctrlMode; SaHpiCtrlStateT ctrlState; ControlData controlData; if (!ctrlRec->WriteOnly && isTextControl(ctrlRec) && canSetControlState(ctrlRec)) { status = readControlData(sessionId, resourceId, ctrlRec, &controlData); if (status != SA_OK) { e_trace(); retval = SAF_TEST_UNRESOLVED; } else { // Change the return value if anything goes wrong. retval = SAF_TEST_PASS; maxLines = ctrlRec->TypeUnion.Text.MaxLines; maxBytes = getMaxBytes(ctrlRec); // Initialize the ctrl state information that is the same // for each invocation of saHpiControlSet(). status = setControlAllTextBuffers(sessionId, resourceId, ctrlRec, BYTE_VALUE_1); if (status != SA_OK) { e_trace(); retval = SAF_TEST_FAIL; } else { // If we succesfully change each line of text, then read the // text data to verify that the change really did occur. for (lineNum = 1; lineNum <= maxLines; lineNum++) { ctrlState.StateUnion.Text.Line = lineNum; status = saHpiControlGet(sessionId, resourceId, ctrlNum, &ctrlMode, &ctrlState); if (status != SA_OK) { retval = SAF_TEST_UNRESOLVED; e_print(saHpiControlGet, SA_OK, status); break; } else if (!matchesTextBuffer (&ctrlState.StateUnion.Text. Text, maxBytes, BYTE_VALUE_1, maxBytes)) { retval = SAF_TEST_FAIL; m_print ("Text Buffers do not match!"); break; } } } restoreControlData(sessionId, resourceId, ctrlNum, &controlData); } } return retval; }