|
|
@ -528,12 +528,12 @@ int KNutNet::version (int countRepeat, const int delay) {
|
|
|
|
outBuffer=outBuffer.stripWhiteSpace ();
|
|
|
|
outBuffer=outBuffer.stripWhiteSpace ();
|
|
|
|
|
|
|
|
|
|
|
|
if (outBuffer.length() > 0) {
|
|
|
|
if (outBuffer.length() > 0) {
|
|
|
|
outBuffer = outBuffer.mid(outBuffer.tqfind("upsd")+4);
|
|
|
|
outBuffer = outBuffer.mid(outBuffer.find("upsd")+4);
|
|
|
|
int n = outBuffer.tqfind(".");
|
|
|
|
int n = outBuffer.find(".");
|
|
|
|
if (n > 0) {
|
|
|
|
if (n > 0) {
|
|
|
|
TQString firstNumber= outBuffer.left(n);
|
|
|
|
TQString firstNumber= outBuffer.left(n);
|
|
|
|
TQString secondNumber= outBuffer.mid(n+1);
|
|
|
|
TQString secondNumber= outBuffer.mid(n+1);
|
|
|
|
int n = secondNumber.tqfind(".");
|
|
|
|
int n = secondNumber.find(".");
|
|
|
|
if (n > 0) {
|
|
|
|
if (n > 0) {
|
|
|
|
bool ok;
|
|
|
|
bool ok;
|
|
|
|
secondNumber = secondNumber.left(n);
|
|
|
|
secondNumber = secondNumber.left(n);
|
|
|
@ -637,7 +637,7 @@ TQString KNutNet::parseValue (const TQString line) {
|
|
|
|
|
|
|
|
|
|
|
|
if (line.isEmpty()) return "";
|
|
|
|
if (line.isEmpty()) return "";
|
|
|
|
if (line[0] != "\"") {
|
|
|
|
if (line[0] != "\"") {
|
|
|
|
if ((m_posChar=line.tqfind(' ')) == -1) return line;
|
|
|
|
if ((m_posChar=line.find(' ')) == -1) return line;
|
|
|
|
else return line.left(m_posChar+1);
|
|
|
|
else return line.left(m_posChar+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
@ -676,7 +676,7 @@ int KNutNet::parseTypeValue (TQString line, int& lenString ) {
|
|
|
|
inputStream >> word;
|
|
|
|
inputStream >> word;
|
|
|
|
if (word == "RW") ret += RW_FLAG;
|
|
|
|
if (word == "RW") ret += RW_FLAG;
|
|
|
|
if (word == "ENUM") ret += ENUM_FLAG;
|
|
|
|
if (word == "ENUM") ret += ENUM_FLAG;
|
|
|
|
if (word.tqfind("STRING:") != -1) {
|
|
|
|
if (word.find("STRING:") != -1) {
|
|
|
|
word = word.mid(7);
|
|
|
|
word = word.mid(7);
|
|
|
|
ret += STRING_FLAG;
|
|
|
|
ret += STRING_FLAG;
|
|
|
|
lenString = word.toInt();
|
|
|
|
lenString = word.toInt();
|
|
|
@ -700,7 +700,7 @@ int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQS
|
|
|
|
|
|
|
|
|
|
|
|
if (line.isEmpty()) return NONE;
|
|
|
|
if (line.isEmpty()) return NONE;
|
|
|
|
|
|
|
|
|
|
|
|
if ((posChar=line.tqfind(' ')) == -1) {
|
|
|
|
if ((posChar=line.find(' ')) == -1) {
|
|
|
|
if (setKey(line) == OK) return OK;
|
|
|
|
if (setKey(line) == OK) return OK;
|
|
|
|
else return NONE;
|
|
|
|
else return NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -718,7 +718,7 @@ int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQS
|
|
|
|
value = parseValue(line);
|
|
|
|
value = parseValue(line);
|
|
|
|
return key1;
|
|
|
|
return key1;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
if ((posChar=line.tqfind(' ')) == -1) return NONE;
|
|
|
|
if ((posChar=line.find(' ')) == -1) return NONE;
|
|
|
|
word2 = line.left(posChar);
|
|
|
|
word2 = line.left(posChar);
|
|
|
|
key2 = setKey( word2);
|
|
|
|
key2 = setKey( word2);
|
|
|
|
line = line.mid(posChar+1);
|
|
|
|
line = line.mid(posChar+1);
|
|
|
@ -740,7 +740,7 @@ int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQS
|
|
|
|
return key1;
|
|
|
|
return key1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((posChar=line.tqfind(' ')) == -1) return NONE;
|
|
|
|
if ((posChar=line.find(' ')) == -1) return NONE;
|
|
|
|
|
|
|
|
|
|
|
|
word3 = line.left(posChar);
|
|
|
|
word3 = line.left(posChar);
|
|
|
|
key3 = setKey( word3);
|
|
|
|
key3 = setKey( word3);
|
|
|
@ -787,7 +787,7 @@ int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQS
|
|
|
|
return BEGIN_LIST_CMD;
|
|
|
|
return BEGIN_LIST_CMD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key3 == ENUM) {
|
|
|
|
if (key3 == ENUM) {
|
|
|
|
if ((posChar=line.tqfind(' ')) == -1) return NONE;
|
|
|
|
if ((posChar=line.find(' ')) == -1) return NONE;
|
|
|
|
upsName = line.left(posChar);
|
|
|
|
upsName = line.left(posChar);
|
|
|
|
line=line.mid(posChar+1);
|
|
|
|
line=line.mid(posChar+1);
|
|
|
|
varName = line.stripWhiteSpace();
|
|
|
|
varName = line.stripWhiteSpace();
|
|
|
@ -809,7 +809,7 @@ int KNutNet::parseLine(TQString& line, TQString& upsName ,TQString& varName, TQS
|
|
|
|
return END_LIST_CMD;
|
|
|
|
return END_LIST_CMD;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (key3 == ENUM) {
|
|
|
|
if (key3 == ENUM) {
|
|
|
|
if ((posChar=line.tqfind(' ')) == -1) return NONE;
|
|
|
|
if ((posChar=line.find(' ')) == -1) return NONE;
|
|
|
|
upsName = line.left(posChar);
|
|
|
|
upsName = line.left(posChar);
|
|
|
|
line=line.mid(posChar+1);
|
|
|
|
line=line.mid(posChar+1);
|
|
|
|
varName = line.stripWhiteSpace();
|
|
|
|
varName = line.stripWhiteSpace();
|
|
|
@ -831,18 +831,18 @@ int KNutNet::newDescription (const TQCString inBuffer, TQString& upsDescription
|
|
|
|
outBuffer=outBuffer.stripWhiteSpace ();
|
|
|
|
outBuffer=outBuffer.stripWhiteSpace ();
|
|
|
|
TQString word1, word2, word3;
|
|
|
|
TQString word1, word2, word3;
|
|
|
|
|
|
|
|
|
|
|
|
if ((m_posChar = outBuffer.tqfind(' ')) == -1)
|
|
|
|
if ((m_posChar = outBuffer.find(' ')) == -1)
|
|
|
|
word1 = outBuffer;
|
|
|
|
word1 = outBuffer;
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
word1 = outBuffer.left(m_posChar);
|
|
|
|
word1 = outBuffer.left(m_posChar);
|
|
|
|
word2 = outBuffer.mid(m_posChar+1);
|
|
|
|
word2 = outBuffer.mid(m_posChar+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (word1 == "DESC") {
|
|
|
|
if (word1 == "DESC") {
|
|
|
|
if ((m_posChar = word2.tqfind('\"')) == -1) word3="";
|
|
|
|
if ((m_posChar = word2.find('\"')) == -1) word3="";
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
word3 = word2.mid(m_posChar+1);
|
|
|
|
word3 = word2.mid(m_posChar+1);
|
|
|
|
if ((m_posChar = word3.tqfind('\"')) != -1) word3=word3.left(m_posChar);
|
|
|
|
if ((m_posChar = word3.find('\"')) != -1) word3=word3.left(m_posChar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!word3.isEmpty()) upsDescription=word3;
|
|
|
|
if (!word3.isEmpty()) upsDescription=word3;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -920,14 +920,14 @@ int KNutNet::getUpsData (const TQCString sBuffer, TQString& rBuffer, const TQCSt
|
|
|
|
rBuffer.append(recvBuffer.data()); // adds reading data to main input buffer
|
|
|
|
rBuffer.append(recvBuffer.data()); // adds reading data to main input buffer
|
|
|
|
if (endString.isEmpty()) endRecv = false;
|
|
|
|
if (endString.isEmpty()) endRecv = false;
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (recvBuffer.tqfindRev(endString.data()) == -1) {
|
|
|
|
if (recvBuffer.findRev(endString.data()) == -1) {
|
|
|
|
//doesn't find right end of input data
|
|
|
|
//doesn't find right end of input data
|
|
|
|
if (m_commandSocket->bytesAvailable() == 0) m_commandSocket->waitForMore(1000);
|
|
|
|
if (m_commandSocket->bytesAvailable() == 0) m_commandSocket->waitForMore(1000);
|
|
|
|
if (m_commandSocket->bytesAvailable() > 0) endRecv=true; // makes other cyckle og while
|
|
|
|
if (m_commandSocket->bytesAvailable() > 0) endRecv=true; // makes other cyckle og while
|
|
|
|
else endRecv=false;
|
|
|
|
else endRecv=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//finds right end of input data
|
|
|
|
//finds right end of input data
|
|
|
|
else endRecv = false; // we have found what we want to tqfind
|
|
|
|
else endRecv = false; // we have found what we want to find
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (endRecv);
|
|
|
|
} while (endRecv);
|
|
|
|
return 0; // all is OK
|
|
|
|
return 0; // all is OK
|
|
|
@ -1287,14 +1287,14 @@ int KNutNet::getUpsVars1 ( void) {
|
|
|
|
while (!(inLine = varInputStream.readLine()).isNull()) {
|
|
|
|
while (!(inLine = varInputStream.readLine()).isNull()) {
|
|
|
|
inLine=inLine.stripWhiteSpace();
|
|
|
|
inLine=inLine.stripWhiteSpace();
|
|
|
|
|
|
|
|
|
|
|
|
if ((m_posChar=inLine.tqfind(' ')) == -1) word1=inLine;
|
|
|
|
if ((m_posChar=inLine.find(' ')) == -1) word1=inLine;
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
word1=inLine.left(m_posChar);
|
|
|
|
word1=inLine.left(m_posChar);
|
|
|
|
inLine = inLine.mid(m_posChar+1);
|
|
|
|
inLine = inLine.mid(m_posChar+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (word1.isEmpty()) { m_error = UnknownFormat; return m_error; }
|
|
|
|
if (word1.isEmpty()) { m_error = UnknownFormat; return m_error; }
|
|
|
|
if (inCountLine == 1) {
|
|
|
|
if (inCountLine == 1) {
|
|
|
|
if ((m_posChar=inLine.tqfind(' ')) == -1) word2=inLine;
|
|
|
|
if ((m_posChar=inLine.find(' ')) == -1) word2=inLine;
|
|
|
|
else word2=inLine.left(m_posChar);
|
|
|
|
else word2=inLine.left(m_posChar);
|
|
|
|
if (word1 =="ENUM") {
|
|
|
|
if (word1 =="ENUM") {
|
|
|
|
if (word2 != word) { m_error = UnknownFormat; return m_error; }
|
|
|
|
if (word2 != word) { m_error = UnknownFormat; return m_error; }
|
|
|
@ -1313,10 +1313,10 @@ int KNutNet::getUpsVars1 ( void) {
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (word1 == "END") break;
|
|
|
|
if (word1 == "END") break;
|
|
|
|
if (word1 != "OPTION") { m_error = UnknownFormat; return m_error; }
|
|
|
|
if (word1 != "OPTION") { m_error = UnknownFormat; return m_error; }
|
|
|
|
if ((m_posChar = inLine.tqfind('\"')) == -1) word2 = "";
|
|
|
|
if ((m_posChar = inLine.find('\"')) == -1) word2 = "";
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
word2 = inLine.mid(m_posChar+1);
|
|
|
|
word2 = inLine.mid(m_posChar+1);
|
|
|
|
if ((m_posChar=word2.tqfind('\"')) != -1) word2 = word2.left(m_posChar);
|
|
|
|
if ((m_posChar=word2.find('\"')) != -1) word2 = word2.left(m_posChar);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
enumString->push_back(word2);
|
|
|
|
enumString->push_back(word2);
|
|
|
|
varMax++;
|
|
|
|
varMax++;
|
|
|
@ -1604,7 +1604,7 @@ int KNutNet::getUpsValues1 (const bool allVars ) {// allVars = true vse; allVars
|
|
|
|
if (word1 == "ANS") {
|
|
|
|
if (word1 == "ANS") {
|
|
|
|
// answer - odpoved
|
|
|
|
// answer - odpoved
|
|
|
|
// odstranime pripadne jmeno upsky
|
|
|
|
// odstranime pripadne jmeno upsky
|
|
|
|
if ((m_posChar = word2.tqfind('@')) != -1) word2 = word2.left(m_posChar);
|
|
|
|
if ((m_posChar = word2.find('@')) != -1) word2 = word2.left(m_posChar);
|
|
|
|
if ( word2 != (*it).upsVarName ) {
|
|
|
|
if ( word2 != (*it).upsVarName ) {
|
|
|
|
m_error=UnknownAnswer;
|
|
|
|
m_error=UnknownAnswer;
|
|
|
|
return m_error;// neni to odpoved na spravnou promennou
|
|
|
|
return m_error;// neni to odpoved na spravnou promennou
|
|
|
|