code style
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "contrib.h"
|
||||
#include "tem.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBEBUS_CONTRIB_H_
|
||||
#define LIBEBUS_CONTRIB_H_
|
||||
#ifndef LIB_EBUS_CONTRIB_H_
|
||||
#define LIB_EBUS_CONTRIB_H_
|
||||
|
||||
/** @file contrib.h
|
||||
* Contributed sources that may be excluded from regular builds.
|
||||
@@ -32,4 +32,4 @@ using namespace std;
|
||||
*/
|
||||
bool libebus_contrib_register();
|
||||
|
||||
#endif // LIBEBUS_CONTRIB_H_
|
||||
#endif // LIB_EBUS_CONTRIB_H_
|
||||
|
||||
@@ -20,14 +20,14 @@
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "datatype.h"
|
||||
#include "tem.h"
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <vector>
|
||||
#include <cstring>
|
||||
#include <math.h>
|
||||
#include "datatype.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -35,8 +35,7 @@ void contrib_tem_register() {
|
||||
DataTypeList::getInstance()->add(new TemParamDataType("TEM_P"));
|
||||
}
|
||||
|
||||
result_t TemParamDataType::derive(int divisor, unsigned char bitCount, NumberDataType* &derived)
|
||||
{
|
||||
result_t TemParamDataType::derive(int divisor, unsigned char bitCount, NumberDataType* &derived) {
|
||||
if (divisor == 0) {
|
||||
divisor = 1;
|
||||
}
|
||||
@@ -52,8 +51,7 @@ result_t TemParamDataType::derive(int divisor, unsigned char bitCount, NumberDat
|
||||
|
||||
result_t TemParamDataType::readSymbols(SymbolString& input, const bool isMaster,
|
||||
const unsigned char offset, const unsigned char length,
|
||||
ostringstream& output, OutputFormat outputFormat)
|
||||
{
|
||||
ostringstream& output, OutputFormat outputFormat) {
|
||||
unsigned int value = 0;
|
||||
|
||||
result_t result = readRawValue(input, offset, length, value);
|
||||
@@ -90,8 +88,7 @@ result_t TemParamDataType::readSymbols(SymbolString& input, const bool isMaster,
|
||||
|
||||
result_t TemParamDataType::writeSymbols(istringstream& input,
|
||||
const unsigned char offset, const unsigned char length,
|
||||
SymbolString& output, const bool isMaster, unsigned char* usedLength)
|
||||
{
|
||||
SymbolString& output, const bool isMaster, unsigned char* usedLength) {
|
||||
unsigned int value;
|
||||
int grp, num;
|
||||
string token;
|
||||
|
||||
@@ -16,12 +16,9 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LIBEBUS_CONTRIB_TEM_H_
|
||||
#define LIBEBUS_CONTRIB_TEM_H_
|
||||
#ifndef LIB_EBUS_CONTRIB_TEM_H_
|
||||
#define LIB_EBUS_CONTRIB_TEM_H_
|
||||
|
||||
#include "symbol.h"
|
||||
#include "result.h"
|
||||
#include "datatype.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@@ -29,6 +26,9 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include "symbol.h"
|
||||
#include "result.h"
|
||||
#include "datatype.h"
|
||||
|
||||
/** @file tem.h
|
||||
* Contributed data types for TEM devices not part of regular releases.
|
||||
@@ -71,4 +71,4 @@ public:
|
||||
*/
|
||||
void contrib_tem_register();
|
||||
|
||||
#endif // LIBEBUS_CONTRIB_TEM_H_
|
||||
#endif // LIB_EBUS_CONTRIB_TEM_H_
|
||||
|
||||
@@ -16,18 +16,19 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tem.h"
|
||||
#include "data.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "tem.h"
|
||||
#include "data.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static bool error = false;
|
||||
|
||||
void verify(bool expectFailMatch, string type, string input,
|
||||
bool match, string expectStr, string gotStr)
|
||||
{
|
||||
bool match, string expectStr, string gotStr) {
|
||||
match = match && expectStr == gotStr;
|
||||
if (expectFailMatch) {
|
||||
if (match) {
|
||||
@@ -46,8 +47,7 @@ void verify(bool expectFailMatch, string type, string input,
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int main() {
|
||||
DataType* type = DataTypeList::getInstance()->get("TEM_P");
|
||||
if (type == NULL) {
|
||||
cout << "datatype not registered" << endl;
|
||||
@@ -108,7 +108,7 @@ int main()
|
||||
fields = NULL;
|
||||
}
|
||||
vector<string>::iterator it = entries.begin();
|
||||
result = DataField::create(it, entries.end(), templates, fields, isSet, false, (mstr[1]==BROADCAST || isMaster(mstr[1])));
|
||||
result = DataField::create(it, entries.end(), templates, fields, isSet, false, (mstr[1] == BROADCAST || isMaster(mstr[1])));
|
||||
if (result != RESULT_OK) {
|
||||
cout << "\"" << check[0] << "\": create error: " << getResultCode(result) << endl;
|
||||
error = true;
|
||||
@@ -145,7 +145,7 @@ int main()
|
||||
if (result >= RESULT_OK) {
|
||||
result = fields->read(pt_slaveData, sstr, 0, output, 0, -1, !output.str().empty());
|
||||
}
|
||||
if (failedRead)
|
||||
if (failedRead) {
|
||||
if (result >= RESULT_OK) {
|
||||
cout << " failed read " << fields->getName() << " >" << check[2] << " " << check[3]
|
||||
<< "< error: unexpectedly succeeded" << endl;
|
||||
@@ -154,20 +154,20 @@ int main()
|
||||
cout << " failed read " << fields->getName() << " >" << check[2] << " " << check[3]
|
||||
<< "< OK" << endl;
|
||||
}
|
||||
else if (result < RESULT_OK) {
|
||||
} else if (result < RESULT_OK) {
|
||||
cout << " read " << fields->getName() << " >" << check[2] << " " << check[3]
|
||||
<< "< error: " << getResultCode(result) << endl;
|
||||
error = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
bool match = strcasecmp(output.str().c_str(), expectStr.c_str()) == 0;
|
||||
verify(failedReadMatch, "read", check[2], match, expectStr, output.str());
|
||||
}
|
||||
|
||||
istringstream input(expectStr);
|
||||
result = fields->write(input, pt_masterData, writeMstr, 0);
|
||||
if (result >= RESULT_OK)
|
||||
if (result >= RESULT_OK) {
|
||||
result = fields->write(input, pt_slaveData, writeSstr, 0);
|
||||
}
|
||||
if (failedWrite) {
|
||||
if (result >= RESULT_OK) {
|
||||
cout << " failed write " << fields->getName() << " >"
|
||||
@@ -177,8 +177,7 @@ int main()
|
||||
cout << " failed write " << fields->getName() << " >"
|
||||
<< expectStr << "< OK" << endl;
|
||||
}
|
||||
}
|
||||
else if (result < RESULT_OK) {
|
||||
} else if (result < RESULT_OK) {
|
||||
cout << " write " << fields->getName() << " >" << expectStr
|
||||
<< "< error: " << getResultCode(result) << endl;
|
||||
error = true;
|
||||
@@ -191,6 +190,5 @@ int main()
|
||||
}
|
||||
|
||||
delete templates;
|
||||
|
||||
return error ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user