
#include "StationDataECU.hpp"
#include "cJSON.h"
#include <vector>

namespace otx {
	namespace jidu {

		StationDataECU::StationDataECU() {
			this->mNumber = 0;
		}

		std::string StationDataECU::getEcuName() { return this->mEcuName; }
		void StationDataECU::setEcuName(const std::string& v) { this->mEcuName = v; }

		std::string StationDataECU::getEcuAddress() { return this->mEcuAddress; }
		void StationDataECU::setEcuAddress(const std::string& v) { this->mEcuAddress = v; }

		std::string StationDataECU::getServerId() { return this->mServerId; }
		void StationDataECU::StationDataECU::setServerId(const std::string& v) { this->mServerId = v; }

		std::string StationDataECU::getDid() { return this->mDid; }
		void StationDataECU::setDid(const std::string& v) { this->mDid = v; }

		std::string StationDataECU::getResultData() { return this->mResultData; }
		void StationDataECU::setResultData(const std::string& v) { this->mResultData = v; }

		std::string StationDataECU::getValue() { return this->mValue; }
		void StationDataECU::setValue(const std::string& v) { this->mValue = v; }

		std::string StationDataECU::getExpectData() { return this->mExpectData; }
		void StationDataECU::setExpectData(const std::string& v) { this->mExpectData = v; }

		std::size_t StationDataECU::getNumber() { return this->mNumber; }
		void StationDataECU::setNumber(std::size_t v) { this->mNumber = v; }

		std::string StationDataECU::toJsonString() {
			std::string result;
			cJSON* obj = cJSON_CreateObject();

			if (this->mEcuName.size() > 0) {
				cJSON_AddStringToObject(obj, "ecuName", this->mEcuName.c_str());
			}

			if (this->mEcuAddress.size() > 0) {
				cJSON_AddStringToObject(obj, "ecuAddress", this->mEcuAddress.c_str());
			}

			if (this->mServerId.size() > 0) {
				cJSON_AddStringToObject(obj, "serverId", this->mServerId.c_str());
			}

			if (this->mDid.size() > 0) {
				cJSON_AddStringToObject(obj, "did", this->mDid.c_str());
			}

			if (this->mResultData.size() > 0) {
				cJSON_AddStringToObject(obj, "resultData", this->mResultData.c_str());
			}

			if (this->mValue.size() > 0) {
				cJSON_AddStringToObject(obj, "value", this->mValue.c_str());
			}

			if (this->mExpectData.size() > 0) {
				cJSON_AddStringToObject(obj, "expectData", this->mExpectData.c_str());
			}

			if (this->mNumber != 0) {
				cJSON_AddStringToObject(obj, "number", std::to_string(this->mNumber).c_str());
			}

			char* tepm = cJSON_PrintUnformatted(obj);
			cJSON_Delete(obj);
			result = tepm;
			cJSON_free(tepm);
			return result;
		}

	} // namespace jidu
} // namespace otx
