|
|
@ -151,7 +151,7 @@ KNutClient::~KNutClient(void) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::slotTryFirstConnection (int maxCount) {
|
|
|
|
void KNutClient::slotTryFirstConnection (int maxCount) {
|
|
|
|
//qDebug ("KNutClient::slotTryFirstConnection");
|
|
|
|
//tqDebug ("KNutClient::slotTryFirstConnection");
|
|
|
|
|
|
|
|
|
|
|
|
//knutNet begin the first test of connection (connectToHost will be made after emiting signal tryFirstConnection )
|
|
|
|
//knutNet begin the first test of connection (connectToHost will be made after emiting signal tryFirstConnection )
|
|
|
|
// repaints icon
|
|
|
|
// repaints icon
|
|
|
@ -161,7 +161,7 @@ void KNutClient::slotTryFirstConnection (int maxCount) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::slotTryReepatFirstConnection (int number ) {
|
|
|
|
void KNutClient::slotTryReepatFirstConnection (int number ) {
|
|
|
|
//qDebug ("KNutClient::slotTryFirstConnection");
|
|
|
|
//tqDebug ("KNutClient::slotTryFirstConnection");
|
|
|
|
//knutNet begin nexts test of connection
|
|
|
|
//knutNet begin nexts test of connection
|
|
|
|
|
|
|
|
|
|
|
|
if (mainWindow) mainWindow->setProgressConnectPB (number);
|
|
|
|
if (mainWindow) mainWindow->setProgressConnectPB (number);
|
|
|
@ -170,7 +170,7 @@ void KNutClient::slotTryReepatFirstConnection (int number ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::slotFirstConnection (void) {
|
|
|
|
void KNutClient::slotFirstConnection (void) {
|
|
|
|
//qDebug ("sKNutClient::slotFirstConnection");
|
|
|
|
//tqDebug ("sKNutClient::slotFirstConnection");
|
|
|
|
//TCP - UDP connection to server was made
|
|
|
|
//TCP - UDP connection to server was made
|
|
|
|
|
|
|
|
|
|
|
|
bool reconnecting = m_mainUpsInfo.reconnecting;
|
|
|
|
bool reconnecting = m_mainUpsInfo.reconnecting;
|
|
|
@ -224,7 +224,7 @@ void KNutClient::slotFirstConnection (void) {
|
|
|
|
|
|
|
|
|
|
|
|
switch (m_mainUpsInfo.nutVariables) { // type of variables, old or new (with dot)
|
|
|
|
switch (m_mainUpsInfo.nutVariables) { // type of variables, old or new (with dot)
|
|
|
|
case 1:
|
|
|
|
case 1:
|
|
|
|
//qDebug ("sKNutClient::slotFirstConnection - var 1");
|
|
|
|
//tqDebug ("sKNutClient::slotFirstConnection - var 1");
|
|
|
|
if (!(m_mainUpsInfo.upsNet->existName("BATT_RUNTIME"))) m_mainUpsInfo.runtimeVar="BATT_RUNTIME";
|
|
|
|
if (!(m_mainUpsInfo.upsNet->existName("BATT_RUNTIME"))) m_mainUpsInfo.runtimeVar="BATT_RUNTIME";
|
|
|
|
else m_mainUpsInfo.runtimeVar="RUNTIME";
|
|
|
|
else m_mainUpsInfo.runtimeVar="RUNTIME";
|
|
|
|
m_mainUpsInfo.upsLoadVar="LOADPCT";
|
|
|
|
m_mainUpsInfo.upsLoadVar="LOADPCT";
|
|
|
@ -233,7 +233,7 @@ void KNutClient::slotFirstConnection (void) {
|
|
|
|
m_mainUpsInfo.statusVar="STATUS";
|
|
|
|
m_mainUpsInfo.statusVar="STATUS";
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
//qDebug ("sKNutClient::slotFirstConnection - var 2");
|
|
|
|
//tqDebug ("sKNutClient::slotFirstConnection - var 2");
|
|
|
|
m_mainUpsInfo.runtimeVar="battery.runtime";
|
|
|
|
m_mainUpsInfo.runtimeVar="battery.runtime";
|
|
|
|
m_mainUpsInfo.upsLoadVar="ups.load";
|
|
|
|
m_mainUpsInfo.upsLoadVar="ups.load";
|
|
|
|
m_mainUpsInfo.lowxferVar="input.transfer.low";
|
|
|
|
m_mainUpsInfo.lowxferVar="input.transfer.low";
|
|
|
@ -264,7 +264,7 @@ void KNutClient::slotFirstConnection (void) {
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::slotErrorConnection (int error) {
|
|
|
|
void KNutClient::slotErrorConnection (int error) {
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug ("KNutClient::slotErrorConnection (1)");
|
|
|
|
//tqDebug ("KNutClient::slotErrorConnection (1)");
|
|
|
|
|
|
|
|
|
|
|
|
if (mainWindow) mainWindow->hideConnectPB();
|
|
|
|
if (mainWindow) mainWindow->hideConnectPB();
|
|
|
|
|
|
|
|
|
|
|
@ -277,7 +277,7 @@ void KNutClient::slotErrorConnection (int error) {
|
|
|
|
if (m_myDock) m_myDock->repaintDock(true);
|
|
|
|
if (m_myDock) m_myDock->repaintDock(true);
|
|
|
|
|
|
|
|
|
|
|
|
if (m_mainUpsInfo.reconnecting) {
|
|
|
|
if (m_mainUpsInfo.reconnecting) {
|
|
|
|
//qDebug ("KNutClient::slotErrorConnection (2)");
|
|
|
|
//tqDebug ("KNutClient::slotErrorConnection (2)");
|
|
|
|
m_mainUpsInfo.reconnectCount++;
|
|
|
|
m_mainUpsInfo.reconnectCount++;
|
|
|
|
if (m_mainUpsInfo.reconnectCount > countNextConnDelay) m_mainUpsInfo.reconnectCount = countNextConnDelay;
|
|
|
|
if (m_mainUpsInfo.reconnectCount > countNextConnDelay) m_mainUpsInfo.reconnectCount = countNextConnDelay;
|
|
|
|
|
|
|
|
|
|
|
@ -285,7 +285,7 @@ void KNutClient::slotErrorConnection (int error) {
|
|
|
|
m_reconnectTimer->start( nextConnDelay[m_mainUpsInfo.reconnectCount-1]*1000, TRUE ); // starts reconnect timer again
|
|
|
|
m_reconnectTimer->start( nextConnDelay[m_mainUpsInfo.reconnectCount-1]*1000, TRUE ); // starts reconnect timer again
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
//qDebug ("KNutClient::slotErrorConnection (3)");
|
|
|
|
//tqDebug ("KNutClient::slotErrorConnection (3)");
|
|
|
|
addEventString (KNutVarData::errorToText(m_mainUpsInfo.netError),m_mainUpsInfo.record.name);
|
|
|
|
addEventString (KNutVarData::errorToText(m_mainUpsInfo.netError),m_mainUpsInfo.record.name);
|
|
|
|
// KNutVarData::showError (mainUpsInfo.netError);
|
|
|
|
// KNutVarData::showError (mainUpsInfo.netError);
|
|
|
|
if ((m_myMessMan)) m_myMessMan->addMessage(KNutVarData::errorToText(m_mainUpsInfo.netError),knc::errorLevel,true);
|
|
|
|
if ((m_myMessMan)) m_myMessMan->addMessage(KNutVarData::errorToText(m_mainUpsInfo.netError),knc::errorLevel,true);
|
|
|
@ -529,7 +529,7 @@ bool KNutClient::commitData (TQSessionManager&) {
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::upsActivate (void) {
|
|
|
|
void KNutClient::upsActivate (void) {
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug ("KNutClient::upsActivate");
|
|
|
|
//tqDebug ("KNutClient::upsActivate");
|
|
|
|
|
|
|
|
|
|
|
|
m_mainUpsInfo.upsNet = new KNutNet( m_mainUpsInfo.record.upsAddress,m_mainUpsInfo.record.upsName,m_mainUpsInfo.record.port,0,1);
|
|
|
|
m_mainUpsInfo.upsNet = new KNutNet( m_mainUpsInfo.record.upsAddress,m_mainUpsInfo.record.upsName,m_mainUpsInfo.record.port,0,1);
|
|
|
|
if (m_mainUpsInfo.upsNet->getState() != KNutNet::Connected) {
|
|
|
|
if (m_mainUpsInfo.upsNet->getState() != KNutNet::Connected) {
|
|
|
@ -677,7 +677,7 @@ void KNutClient::setActiveUpsInfo (TQString name) {
|
|
|
|
void KNutClient::getUpsData (void) {
|
|
|
|
void KNutClient::getUpsData (void) {
|
|
|
|
int runNetError;
|
|
|
|
int runNetError;
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug("KNutClient::getUpsData");
|
|
|
|
//tqDebug("KNutClient::getUpsData");
|
|
|
|
|
|
|
|
|
|
|
|
//loads values for selected variables <getUpsValues(false)> / activate values
|
|
|
|
//loads values for selected variables <getUpsValues(false)> / activate values
|
|
|
|
if (!(runNetError=m_mainUpsInfo.upsNet->getUpsValues(false))) { // data from upsNet is ok
|
|
|
|
if (!(runNetError=m_mainUpsInfo.upsNet->getUpsValues(false))) { // data from upsNet is ok
|
|
|
@ -761,7 +761,7 @@ void KNutClient::slotTimeout (void) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KNutClient::slotConnectionClosed(void) {
|
|
|
|
void KNutClient::slotConnectionClosed(void) {
|
|
|
|
//qDebug("KNutClient::slotConnectionClosed");
|
|
|
|
//tqDebug("KNutClient::slotConnectionClosed");
|
|
|
|
|
|
|
|
|
|
|
|
m_mainUpsInfo.netError = KNutNet::ConnetionClosedByServer;
|
|
|
|
m_mainUpsInfo.netError = KNutNet::ConnetionClosedByServer;
|
|
|
|
|
|
|
|
|
|
|
@ -790,7 +790,7 @@ void KNutClient::slotConnectionClosed(void) {
|
|
|
|
void KNutClient::showStatusEvent(void) {
|
|
|
|
void KNutClient::showStatusEvent(void) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//qDebug ("KNutClient::showStatusEvent");
|
|
|
|
//tqDebug ("KNutClient::showStatusEvent");
|
|
|
|
int myState = m_mainUpsInfo.upsNet->readStatus();
|
|
|
|
int myState = m_mainUpsInfo.upsNet->readStatus();
|
|
|
|
if (myState != m_mainUpsInfo.oldState) {
|
|
|
|
if (myState != m_mainUpsInfo.oldState) {
|
|
|
|
|
|
|
|
|
|
|
|