diff options
Diffstat (limited to 'SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo')
27 files changed, 3953 insertions, 0 deletions
diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCs.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCs.cpp new file mode 100644 index 000000000..a3c87aca2 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCs.cpp @@ -0,0 +1,119 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCs.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetDTCs& GetDTCs::operator =(const GetDTCs& c) +{ + ecuName=c.ecuName; + if(encrypted) delete encrypted; + encrypted= c.encrypted ? new bool(c.encrypted[0]) : 0; + appId=c.appId; + return *this; +} + + +GetDTCs::~GetDTCs(void) +{ + if(encrypted) delete encrypted; +} + + +GetDTCs::GetDTCs(void) : + RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETDTCS), + encrypted(0) +{ +} + + +GetDTCs::GetDTCs(const GetDTCs& c) : RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETDTCS,c.getId()) +{ + *this=c; +} + + +unsigned int GetDTCs::get_ecuName(void) +{ + return ecuName; +} + +bool GetDTCs::set_ecuName(unsigned int ecuName_) +{ + ecuName=ecuName_; + return true; +} + +const bool* GetDTCs::get_encrypted(void) +{ + return encrypted; +} + +bool GetDTCs::set_encrypted(const bool& encrypted_) +{ + if(encrypted) delete encrypted; + encrypted=new bool(encrypted_); + return true; +} + +void GetDTCs::reset_encrypted(void) +{ + if(encrypted) delete encrypted; + encrypted=0; +} + +int GetDTCs::get_appId(void) +{ + return appId; +} + +bool GetDTCs::set_appId(int appId_) +{ + appId=appId_; + return true; +} + +bool GetDTCs::checkIntegrity(void) +{ + return GetDTCsMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.cpp new file mode 100644 index 000000000..f02c40215 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.cpp @@ -0,0 +1,141 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCs.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetDTCsMarshaller::checkIntegrity(GetDTCs& s) +{ + return checkIntegrityConst(s); +} + + +bool GetDTCsMarshaller::fromString(const std::string& s,GetDTCs& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetDTCsMarshaller::toString(const GetDTCs& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetDTCsMarshaller::checkIntegrityConst(const GetDTCs& s) +{ + if(s.ecuName>65535) return false; + + return true; +} + + +Json::Value GetDTCsMarshaller::toJSON(const GetDTCs& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["method"]=Json::Value("VehicleInfo.GetDTCs"); + + json["id"]=Json::Value(e.getId()); + json["params"]=Json::Value(Json::objectValue); + json["params"]["ecuName"]=Json::Value(e.ecuName);; + if(e.encrypted) + json["params"]["encrypted"]=Json::Value(e.encrypted[0]);; + json["params"]["appId"]=Json::Value(e.appId);; + return json; +} + + +bool GetDTCsMarshaller::fromJSON(const Json::Value& json,GetDTCs& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("method") || !json["method"].isString() || json["method"].asString().compare("VehicleInfo.GetDTCs")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("params")) return false; + + Json::Value js=json["params"]; + if(!js.isObject()) return false; + if(!js.isMember("ecuName") || !js["ecuName"].isInt()) return false; + c.ecuName=js["ecuName"].asInt(); + if(c.ecuName>65535) return false; + + if(c.encrypted) delete c.encrypted; + c.encrypted=0; + if(js.isMember("encrypted")) + { + if(!js["encrypted"].isBool()) return false; + c.encrypted=new bool(); + c.encrypted[0]=js["encrypted"].asBool(); + + } + + if(!js.isMember("appId") || !js["appId"].isInt()) return false; + c.appId=js["appId"].asInt(); + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.h new file mode 100644 index 000000000..aae1bde8d --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETDTCSMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETDTCSMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCs.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetDTCsMarshaller + { + static bool checkIntegrity(GetDTCs& e); + static bool checkIntegrityConst(const GetDTCs& e); + + static bool fromString(const std::string& s,GetDTCs& e); + static const std::string toString(const GetDTCs& e); + + static bool fromJSON(const Json::Value& s,GetDTCs& e); + static Json::Value toJSON(const GetDTCs& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponse.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponse.cpp new file mode 100644 index 000000000..04d170d97 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponse.cpp @@ -0,0 +1,95 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCsResponse.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetDTCsResponse& GetDTCsResponse::operator =(const GetDTCsResponse& c) +{ + if(dtcList) delete dtcList; + dtcList= c.dtcList ? new std::vector<NsSmartDeviceLinkRPCV2::DTC>(c.dtcList[0]) : 0; + return *this; +} + + +GetDTCsResponse::~GetDTCsResponse(void) +{ + if(dtcList) delete dtcList; +} + + +GetDTCsResponse::GetDTCsResponse(void) : + RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETDTCSRESPONSE), + dtcList(0) +{ +} + + +GetDTCsResponse::GetDTCsResponse(const GetDTCsResponse& c) : RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETDTCSRESPONSE,c.getId(),c.getResult()) +{ + *this=c; +} + + +const std::vector< NsSmartDeviceLinkRPCV2::DTC>* GetDTCsResponse::get_dtcList(void) +{ + return dtcList; +} + +bool GetDTCsResponse::set_dtcList(const std::vector< NsSmartDeviceLinkRPCV2::DTC>& dtcList_) +{ + if(dtcList) delete dtcList; + dtcList=new std::vector< NsSmartDeviceLinkRPCV2::DTC>(dtcList_); + return true; +} + +void GetDTCsResponse::reset_dtcList(void) +{ + if(dtcList) delete dtcList; + dtcList=0; +} + +bool GetDTCsResponse::checkIntegrity(void) +{ + return GetDTCsResponseMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.cpp new file mode 100644 index 000000000..c2cd4ec6c --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.cpp @@ -0,0 +1,162 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCsResponse.h" +#include "../src/SDLRPCObjectsImpl/V2/DTCMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetDTCsResponseMarshaller::checkIntegrity(GetDTCsResponse& s) +{ + return checkIntegrityConst(s); +} + + +bool GetDTCsResponseMarshaller::fromString(const std::string& s,GetDTCsResponse& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetDTCsResponseMarshaller::toString(const GetDTCsResponse& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetDTCsResponseMarshaller::checkIntegrityConst(const GetDTCsResponse& s) +{ + if(s.dtcList) + { + unsigned int i=s.dtcList[0].size(); + if(i<1) return false; + if(i>100) return false; + } + + return true; +} + + +Json::Value GetDTCsResponseMarshaller::toJSON(const GetDTCsResponse& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["id"]=Json::Value(e.getId()); + json["result"]=Json::Value(Json::objectValue); + NsSmartDeviceLinkRPCV2::Result r(static_cast<NsSmartDeviceLinkRPCV2::Result::ResultInternal>(e.getResult())); + json["result"]["resultCode"]=NsSmartDeviceLinkRPCV2::ResultMarshaller::toJSON(r); + json["result"]["method"]=Json::Value("VehicleInfo.GetDTCsResponse"); + + if(e.dtcList) + { + unsigned int i=e.dtcList[0].size(); + Json::Value j=Json::Value(Json::arrayValue); + j.resize(i); + while(i--) + j[i]=NsSmartDeviceLinkRPCV2::DTCMarshaller::toJSON(e.dtcList[0][i]); + + json["result"]["dtcList"]=j; + } + return json; +} + + +bool GetDTCsResponseMarshaller::fromJSON(const Json::Value& json,GetDTCsResponse& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("result")) return false; + + Json::Value js=json["result"]; + if(!js.isObject()) return false; + + NsSmartDeviceLinkRPCV2::Result r; + if(!js.isMember("resultCode") || !js["resultCode"].isString()) return false; + if(!js.isMember("method") || !js["method"].isString()) return false; + if(js["method"].asString().compare("VehicleInfo.GetDTCsResponse")) return false; + + if(!NsSmartDeviceLinkRPCV2::ResultMarshaller::fromJSON(js["resultCode"],r)) return false; + c.setResult(r.get()); + if(c.dtcList) delete c.dtcList; + c.dtcList=0; + if(js.isMember("dtcList")) + { + if(!js["dtcList"].isArray()) return false; + unsigned int i=js["dtcList"].size(); + if(i<1) return false; + if(i>100) return false; + + c.dtcList=new std::vector<NsSmartDeviceLinkRPCV2::DTC>(); + c.dtcList->resize(js["dtcList"].size()); + + while(i--) + if(!NsSmartDeviceLinkRPCV2::DTCMarshaller::fromJSON(js["dtcList"][i],c.dtcList[0][i])) return false; + } + + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.h new file mode 100644 index 000000000..9737b7f96 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetDTCsResponseMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETDTCSRESPONSEMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETDTCSRESPONSEMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetDTCsResponse.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetDTCsResponseMarshaller + { + static bool checkIntegrity(GetDTCsResponse& e); + static bool checkIntegrityConst(const GetDTCsResponse& e); + + static bool fromString(const std::string& s,GetDTCsResponse& e); + static const std::string toString(const GetDTCsResponse& e); + + static bool fromJSON(const Json::Value& s,GetDTCsResponse& e); + static Json::Value toJSON(const GetDTCsResponse& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleData.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleData.cpp new file mode 100644 index 000000000..89ea015b3 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleData.cpp @@ -0,0 +1,97 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleData.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetVehicleData& GetVehicleData::operator =(const GetVehicleData& c) +{ + dataType=c.dataType; + appId=c.appId; + return *this; +} + + +GetVehicleData::~GetVehicleData(void) +{ +} + + +GetVehicleData::GetVehicleData(void) : + RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLEDATA) +{ +} + + +GetVehicleData::GetVehicleData(const GetVehicleData& c) : RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLEDATA,c.getId()) +{ + *this=c; +} + + +const NsSmartDeviceLinkRPCV2::VehicleDataType& GetVehicleData::get_dataType(void) +{ + return dataType; +} + +bool GetVehicleData::set_dataType(const NsSmartDeviceLinkRPCV2::VehicleDataType& dataType_) +{ + dataType=dataType_; + return true; +} + +int GetVehicleData::get_appId(void) +{ + return appId; +} + +bool GetVehicleData::set_appId(int appId_) +{ + appId=appId_; + return true; +} + +bool GetVehicleData::checkIntegrity(void) +{ + return GetVehicleDataMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.cpp new file mode 100644 index 000000000..338a3852c --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.cpp @@ -0,0 +1,128 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleData.h" +#include "../src/SDLRPCObjectsImpl/V2/VehicleDataTypeMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetVehicleDataMarshaller::checkIntegrity(GetVehicleData& s) +{ + return checkIntegrityConst(s); +} + + +bool GetVehicleDataMarshaller::fromString(const std::string& s,GetVehicleData& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetVehicleDataMarshaller::toString(const GetVehicleData& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetVehicleDataMarshaller::checkIntegrityConst(const GetVehicleData& s) +{ + if(!NsSmartDeviceLinkRPCV2::VehicleDataTypeMarshaller::checkIntegrityConst(s.dataType)) return false; + + return true; +} + + +Json::Value GetVehicleDataMarshaller::toJSON(const GetVehicleData& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["method"]=Json::Value("VehicleInfo.GetVehicleData"); + + json["id"]=Json::Value(e.getId()); + json["params"]=Json::Value(Json::objectValue); + json["params"]["dataType"]=NsSmartDeviceLinkRPCV2::VehicleDataTypeMarshaller::toJSON(e.dataType);; + json["params"]["appId"]=Json::Value(e.appId);; + return json; +} + + +bool GetVehicleDataMarshaller::fromJSON(const Json::Value& json,GetVehicleData& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("method") || !json["method"].isString() || json["method"].asString().compare("VehicleInfo.GetVehicleData")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("params")) return false; + + Json::Value js=json["params"]; + if(!js.isObject()) return false; + if(!js.isMember("dataType") || !NsSmartDeviceLinkRPCV2::VehicleDataTypeMarshaller::fromJSON(js["dataType"],c.dataType)) return false; + + if(!js.isMember("appId") || !js["appId"].isInt()) return false; + c.appId=js["appId"].asInt(); + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.h new file mode 100644 index 000000000..d5137291a --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLEDATAMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLEDATAMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleData.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetVehicleDataMarshaller + { + static bool checkIntegrity(GetVehicleData& e); + static bool checkIntegrityConst(const GetVehicleData& e); + + static bool fromString(const std::string& s,GetVehicleData& e); + static const std::string toString(const GetVehicleData& e); + + static bool fromJSON(const Json::Value& s,GetVehicleData& e); + static Json::Value toJSON(const GetVehicleData& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.cpp new file mode 100644 index 000000000..0f26b8428 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.cpp @@ -0,0 +1,447 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetVehicleDataResponse& GetVehicleDataResponse::operator =(const GetVehicleDataResponse& c) +{ + if(gps) delete gps; + gps= c.gps ? new NsSmartDeviceLinkRPCV2::GPSData(c.gps[0]) : 0; + if(speed) delete speed; + speed= c.speed ? new float(c.speed[0]) : 0; + if(rpm) delete rpm; + rpm= c.rpm ? new unsigned int(c.rpm[0]) : 0; + if(fuelLevel) delete fuelLevel; + fuelLevel= c.fuelLevel ? new float(c.fuelLevel[0]) : 0; + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy= c.avgFuelEconomy ? new float(c.avgFuelEconomy[0]) : 0; + if(batteryVoltage) delete batteryVoltage; + batteryVoltage= c.batteryVoltage ? new float(c.batteryVoltage[0]) : 0; + if(externalTemperature) delete externalTemperature; + externalTemperature= c.externalTemperature ? new float(c.externalTemperature[0]) : 0; + if(vin) delete vin; + vin= c.vin ? new std::string(c.vin[0]) : 0; + if(prndl) delete prndl; + prndl= c.prndl ? new NsSmartDeviceLinkRPCV2::PRNDL(c.prndl[0]) : 0; + if(tirePressure) delete tirePressure; + tirePressure= c.tirePressure ? new NsSmartDeviceLinkRPCV2::TireStatus(c.tirePressure[0]) : 0; + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage= c.batteryPackVoltage ? new float(c.batteryPackVoltage[0]) : 0; + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent= c.batteryPackCurrent ? new float(c.batteryPackCurrent[0]) : 0; + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature= c.batteryPackTemperature ? new int(c.batteryPackTemperature[0]) : 0; + if(engineTorque) delete engineTorque; + engineTorque= c.engineTorque ? new int(c.engineTorque[0]) : 0; + if(odometer) delete odometer; + odometer= c.odometer ? new unsigned int(c.odometer[0]) : 0; + if(tripOdometer) delete tripOdometer; + tripOdometer= c.tripOdometer ? new unsigned int(c.tripOdometer[0]) : 0; + if(satRadioESN) delete satRadioESN; + satRadioESN= c.satRadioESN ? new std::string(c.satRadioESN[0]) : 0; + return *this; +} + + +GetVehicleDataResponse::~GetVehicleDataResponse(void) +{ + if(gps) delete gps; + if(speed) delete speed; + if(rpm) delete rpm; + if(fuelLevel) delete fuelLevel; + if(avgFuelEconomy) delete avgFuelEconomy; + if(batteryVoltage) delete batteryVoltage; + if(externalTemperature) delete externalTemperature; + if(vin) delete vin; + if(prndl) delete prndl; + if(tirePressure) delete tirePressure; + if(batteryPackVoltage) delete batteryPackVoltage; + if(batteryPackCurrent) delete batteryPackCurrent; + if(batteryPackTemperature) delete batteryPackTemperature; + if(engineTorque) delete engineTorque; + if(odometer) delete odometer; + if(tripOdometer) delete tripOdometer; + if(satRadioESN) delete satRadioESN; +} + + +GetVehicleDataResponse::GetVehicleDataResponse(void) : + RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLEDATARESPONSE), + gps(0), + speed(0), + rpm(0), + fuelLevel(0), + avgFuelEconomy(0), + batteryVoltage(0), + externalTemperature(0), + vin(0), + prndl(0), + tirePressure(0), + batteryPackVoltage(0), + batteryPackCurrent(0), + batteryPackTemperature(0), + engineTorque(0), + odometer(0), + tripOdometer(0), + satRadioESN(0) +{ +} + + +GetVehicleDataResponse::GetVehicleDataResponse(const GetVehicleDataResponse& c) : RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLEDATARESPONSE,c.getId(),c.getResult()) +{ + *this=c; +} + + +const NsSmartDeviceLinkRPCV2::GPSData* GetVehicleDataResponse::get_gps(void) +{ + return gps; +} + +bool GetVehicleDataResponse::set_gps(const NsSmartDeviceLinkRPCV2::GPSData& gps_) +{ + if(gps) delete gps; + gps=new NsSmartDeviceLinkRPCV2::GPSData(gps_); + return true; +} + +void GetVehicleDataResponse::reset_gps(void) +{ + if(gps) delete gps; + gps=0; +} + +const float* GetVehicleDataResponse::get_speed(void) +{ + return speed; +} + +bool GetVehicleDataResponse::set_speed(const float& speed_) +{ + if(speed) delete speed; + speed=new float(speed_); + return true; +} + +void GetVehicleDataResponse::reset_speed(void) +{ + if(speed) delete speed; + speed=0; +} + +const unsigned int* GetVehicleDataResponse::get_rpm(void) +{ + return rpm; +} + +bool GetVehicleDataResponse::set_rpm(const unsigned int& rpm_) +{ + if(rpm) delete rpm; + rpm=new unsigned int(rpm_); + return true; +} + +void GetVehicleDataResponse::reset_rpm(void) +{ + if(rpm) delete rpm; + rpm=0; +} + +const float* GetVehicleDataResponse::get_fuelLevel(void) +{ + return fuelLevel; +} + +bool GetVehicleDataResponse::set_fuelLevel(const float& fuelLevel_) +{ + if(fuelLevel) delete fuelLevel; + fuelLevel=new float(fuelLevel_); + return true; +} + +void GetVehicleDataResponse::reset_fuelLevel(void) +{ + if(fuelLevel) delete fuelLevel; + fuelLevel=0; +} + +const float* GetVehicleDataResponse::get_avgFuelEconomy(void) +{ + return avgFuelEconomy; +} + +bool GetVehicleDataResponse::set_avgFuelEconomy(const float& avgFuelEconomy_) +{ + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy=new float(avgFuelEconomy_); + return true; +} + +void GetVehicleDataResponse::reset_avgFuelEconomy(void) +{ + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy=0; +} + +const float* GetVehicleDataResponse::get_batteryVoltage(void) +{ + return batteryVoltage; +} + +bool GetVehicleDataResponse::set_batteryVoltage(const float& batteryVoltage_) +{ + if(batteryVoltage) delete batteryVoltage; + batteryVoltage=new float(batteryVoltage_); + return true; +} + +void GetVehicleDataResponse::reset_batteryVoltage(void) +{ + if(batteryVoltage) delete batteryVoltage; + batteryVoltage=0; +} + +const float* GetVehicleDataResponse::get_externalTemperature(void) +{ + return externalTemperature; +} + +bool GetVehicleDataResponse::set_externalTemperature(const float& externalTemperature_) +{ + if(externalTemperature) delete externalTemperature; + externalTemperature=new float(externalTemperature_); + return true; +} + +void GetVehicleDataResponse::reset_externalTemperature(void) +{ + if(externalTemperature) delete externalTemperature; + externalTemperature=0; +} + +const std::string* GetVehicleDataResponse::get_vin(void) +{ + return vin; +} + +bool GetVehicleDataResponse::set_vin(const std::string& vin_) +{ + if(vin) delete vin; + vin=new std::string(vin_); + return true; +} + +void GetVehicleDataResponse::reset_vin(void) +{ + if(vin) delete vin; + vin=0; +} + +const NsSmartDeviceLinkRPCV2::PRNDL* GetVehicleDataResponse::get_prndl(void) +{ + return prndl; +} + +bool GetVehicleDataResponse::set_prndl(const NsSmartDeviceLinkRPCV2::PRNDL& prndl_) +{ + if(prndl) delete prndl; + prndl=new NsSmartDeviceLinkRPCV2::PRNDL(prndl_); + return true; +} + +void GetVehicleDataResponse::reset_prndl(void) +{ + if(prndl) delete prndl; + prndl=0; +} + +const NsSmartDeviceLinkRPCV2::TireStatus* GetVehicleDataResponse::get_tirePressure(void) +{ + return tirePressure; +} + +bool GetVehicleDataResponse::set_tirePressure(const NsSmartDeviceLinkRPCV2::TireStatus& tirePressure_) +{ + if(tirePressure) delete tirePressure; + tirePressure=new NsSmartDeviceLinkRPCV2::TireStatus(tirePressure_); + return true; +} + +void GetVehicleDataResponse::reset_tirePressure(void) +{ + if(tirePressure) delete tirePressure; + tirePressure=0; +} + +const float* GetVehicleDataResponse::get_batteryPackVoltage(void) +{ + return batteryPackVoltage; +} + +bool GetVehicleDataResponse::set_batteryPackVoltage(const float& batteryPackVoltage_) +{ + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage=new float(batteryPackVoltage_); + return true; +} + +void GetVehicleDataResponse::reset_batteryPackVoltage(void) +{ + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage=0; +} + +const float* GetVehicleDataResponse::get_batteryPackCurrent(void) +{ + return batteryPackCurrent; +} + +bool GetVehicleDataResponse::set_batteryPackCurrent(const float& batteryPackCurrent_) +{ + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent=new float(batteryPackCurrent_); + return true; +} + +void GetVehicleDataResponse::reset_batteryPackCurrent(void) +{ + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent=0; +} + +const int* GetVehicleDataResponse::get_batteryPackTemperature(void) +{ + return batteryPackTemperature; +} + +bool GetVehicleDataResponse::set_batteryPackTemperature(const int& batteryPackTemperature_) +{ + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature=new int(batteryPackTemperature_); + return true; +} + +void GetVehicleDataResponse::reset_batteryPackTemperature(void) +{ + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature=0; +} + +const int* GetVehicleDataResponse::get_engineTorque(void) +{ + return engineTorque; +} + +bool GetVehicleDataResponse::set_engineTorque(const int& engineTorque_) +{ + if(engineTorque) delete engineTorque; + engineTorque=new int(engineTorque_); + return true; +} + +void GetVehicleDataResponse::reset_engineTorque(void) +{ + if(engineTorque) delete engineTorque; + engineTorque=0; +} + +const unsigned int* GetVehicleDataResponse::get_odometer(void) +{ + return odometer; +} + +bool GetVehicleDataResponse::set_odometer(const unsigned int& odometer_) +{ + if(odometer) delete odometer; + odometer=new unsigned int(odometer_); + return true; +} + +void GetVehicleDataResponse::reset_odometer(void) +{ + if(odometer) delete odometer; + odometer=0; +} + +const unsigned int* GetVehicleDataResponse::get_tripOdometer(void) +{ + return tripOdometer; +} + +bool GetVehicleDataResponse::set_tripOdometer(const unsigned int& tripOdometer_) +{ + if(tripOdometer) delete tripOdometer; + tripOdometer=new unsigned int(tripOdometer_); + return true; +} + +void GetVehicleDataResponse::reset_tripOdometer(void) +{ + if(tripOdometer) delete tripOdometer; + tripOdometer=0; +} + +const std::string* GetVehicleDataResponse::get_satRadioESN(void) +{ + return satRadioESN; +} + +bool GetVehicleDataResponse::set_satRadioESN(const std::string& satRadioESN_) +{ + if(satRadioESN) delete satRadioESN; + satRadioESN=new std::string(satRadioESN_); + return true; +} + +void GetVehicleDataResponse::reset_satRadioESN(void) +{ + if(satRadioESN) delete satRadioESN; + satRadioESN=0; +} + +bool GetVehicleDataResponse::checkIntegrity(void) +{ + return GetVehicleDataResponseMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.cpp new file mode 100644 index 000000000..b6179c15f --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.cpp @@ -0,0 +1,376 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.h" +#include "../src/SDLRPCObjectsImpl/V2/GPSDataMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/PRNDLMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/TireStatusMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetVehicleDataResponseMarshaller::checkIntegrity(GetVehicleDataResponse& s) +{ + return checkIntegrityConst(s); +} + + +bool GetVehicleDataResponseMarshaller::fromString(const std::string& s,GetVehicleDataResponse& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetVehicleDataResponseMarshaller::toString(const GetVehicleDataResponse& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetVehicleDataResponseMarshaller::checkIntegrityConst(const GetVehicleDataResponse& s) +{ + if(s.gps && (!NsSmartDeviceLinkRPCV2::GPSDataMarshaller::checkIntegrityConst(s.gps[0]))) return false; + + if(s.speed && (s.speed[0]<-100 || s.speed[0]>500)) return false; + + if(s.rpm && (s.rpm[0]>20000)) return false; + + if(s.fuelLevel && (s.fuelLevel[0]<0 || s.fuelLevel[0]>100)) return false; + + if(s.avgFuelEconomy && (s.avgFuelEconomy[0]<0 || s.avgFuelEconomy[0]>7000)) return false; + + if(s.batteryVoltage && (s.batteryVoltage[0]<0 || s.batteryVoltage[0]>26)) return false; + + if(s.externalTemperature && (s.externalTemperature[0]<-40 || s.externalTemperature[0]>100)) return false; + + if(s.vin && (s.vin[0].length()>17)) return false; + + if(s.prndl && (!NsSmartDeviceLinkRPCV2::PRNDLMarshaller::checkIntegrityConst(s.prndl[0]))) return false; + + if(s.tirePressure && (!NsSmartDeviceLinkRPCV2::TireStatusMarshaller::checkIntegrityConst(s.tirePressure[0]))) return false; + + if(s.batteryPackVoltage && (s.batteryPackVoltage[0]<-1000 || s.batteryPackVoltage[0]>1000)) return false; + + if(s.batteryPackCurrent && (s.batteryPackCurrent[0]<-1000 || s.batteryPackCurrent[0]>1000)) return false; + + if(s.batteryPackTemperature && (s.batteryPackTemperature[0]<-50 || s.batteryPackTemperature[0]>250)) return false; + + if(s.engineTorque && (s.engineTorque[0]<-10000 || s.engineTorque[0]>55000)) return false; + + if(s.odometer && (s.odometer[0]>2000000)) return false; + + if(s.tripOdometer && (s.tripOdometer[0]>2000000)) return false; + + if(s.satRadioESN && (s.satRadioESN[0].length()>500)) return false; + + return true; +} + + +Json::Value GetVehicleDataResponseMarshaller::toJSON(const GetVehicleDataResponse& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["id"]=Json::Value(e.getId()); + json["result"]=Json::Value(Json::objectValue); + NsSmartDeviceLinkRPCV2::Result r(static_cast<NsSmartDeviceLinkRPCV2::Result::ResultInternal>(e.getResult())); + json["result"]["resultCode"]=NsSmartDeviceLinkRPCV2::ResultMarshaller::toJSON(r); + json["result"]["method"]=Json::Value("VehicleInfo.GetVehicleDataResponse"); + + if(e.gps) + json["result"]["gps"]=NsSmartDeviceLinkRPCV2::GPSDataMarshaller::toJSON(e.gps[0]);; + if(e.speed) + json["result"]["speed"]=Json::Value(e.speed[0]);; + if(e.rpm) + json["result"]["rpm"]=Json::Value(e.rpm[0]);; + if(e.fuelLevel) + json["result"]["fuelLevel"]=Json::Value(e.fuelLevel[0]);; + if(e.avgFuelEconomy) + json["result"]["avgFuelEconomy"]=Json::Value(e.avgFuelEconomy[0]);; + if(e.batteryVoltage) + json["result"]["batteryVoltage"]=Json::Value(e.batteryVoltage[0]);; + if(e.externalTemperature) + json["result"]["externalTemperature"]=Json::Value(e.externalTemperature[0]);; + if(e.vin) + json["result"]["vin"]=Json::Value(e.vin[0]);; + if(e.prndl) + json["result"]["prndl"]=NsSmartDeviceLinkRPCV2::PRNDLMarshaller::toJSON(e.prndl[0]);; + if(e.tirePressure) + json["result"]["tirePressure"]=NsSmartDeviceLinkRPCV2::TireStatusMarshaller::toJSON(e.tirePressure[0]);; + if(e.batteryPackVoltage) + json["result"]["batteryPackVoltage"]=Json::Value(e.batteryPackVoltage[0]);; + if(e.batteryPackCurrent) + json["result"]["batteryPackCurrent"]=Json::Value(e.batteryPackCurrent[0]);; + if(e.batteryPackTemperature) + json["result"]["batteryPackTemperature"]=Json::Value(e.batteryPackTemperature[0]);; + if(e.engineTorque) + json["result"]["engineTorque"]=Json::Value(e.engineTorque[0]);; + if(e.odometer) + json["result"]["odometer"]=Json::Value(e.odometer[0]);; + if(e.tripOdometer) + json["result"]["tripOdometer"]=Json::Value(e.tripOdometer[0]);; + if(e.satRadioESN) + json["result"]["satRadioESN"]=Json::Value(e.satRadioESN[0]);; + return json; +} + + +bool GetVehicleDataResponseMarshaller::fromJSON(const Json::Value& json,GetVehicleDataResponse& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("result")) return false; + + Json::Value js=json["result"]; + if(!js.isObject()) return false; + + NsSmartDeviceLinkRPCV2::Result r; + if(!js.isMember("resultCode") || !js["resultCode"].isString()) return false; + if(!js.isMember("method") || !js["method"].isString()) return false; + if(js["method"].asString().compare("VehicleInfo.GetVehicleDataResponse")) return false; + + if(!NsSmartDeviceLinkRPCV2::ResultMarshaller::fromJSON(js["resultCode"],r)) return false; + c.setResult(r.get()); + if(c.gps) delete c.gps; + c.gps=0; + if(js.isMember("gps")) + { + c.gps=new NsSmartDeviceLinkRPCV2::GPSData(); + if(!NsSmartDeviceLinkRPCV2::GPSDataMarshaller::fromJSON(js["gps"],c.gps[0])) return false; + } + + if(c.speed) delete c.speed; + c.speed=0; + if(js.isMember("speed")) + { + if(!js["speed"].isNumeric()) return false; + c.speed=new float(); + c.speed[0]=js["speed"].asDouble(); + if(c.speed[0]<-100 || c.speed[0]>500) return false; + + } + + if(c.rpm) delete c.rpm; + c.rpm=0; + if(js.isMember("rpm")) + { + if(!js["rpm"].isInt()) return false; + c.rpm=new unsigned int(); + c.rpm[0]=js["rpm"].asInt(); + if(c.rpm[0]>20000) return false; + + } + + if(c.fuelLevel) delete c.fuelLevel; + c.fuelLevel=0; + if(js.isMember("fuelLevel")) + { + if(!js["fuelLevel"].isNumeric()) return false; + c.fuelLevel=new float(); + c.fuelLevel[0]=js["fuelLevel"].asDouble(); + if(c.fuelLevel[0]<0 || c.fuelLevel[0]>100) return false; + + } + + if(c.avgFuelEconomy) delete c.avgFuelEconomy; + c.avgFuelEconomy=0; + if(js.isMember("avgFuelEconomy")) + { + if(!js["avgFuelEconomy"].isNumeric()) return false; + c.avgFuelEconomy=new float(); + c.avgFuelEconomy[0]=js["avgFuelEconomy"].asDouble(); + if(c.avgFuelEconomy[0]<0 || c.avgFuelEconomy[0]>7000) return false; + + } + + if(c.batteryVoltage) delete c.batteryVoltage; + c.batteryVoltage=0; + if(js.isMember("batteryVoltage")) + { + if(!js["batteryVoltage"].isNumeric()) return false; + c.batteryVoltage=new float(); + c.batteryVoltage[0]=js["batteryVoltage"].asDouble(); + if(c.batteryVoltage[0]<0 || c.batteryVoltage[0]>26) return false; + + } + + if(c.externalTemperature) delete c.externalTemperature; + c.externalTemperature=0; + if(js.isMember("externalTemperature")) + { + if(!js["externalTemperature"].isNumeric()) return false; + c.externalTemperature=new float(); + c.externalTemperature[0]=js["externalTemperature"].asDouble(); + if(c.externalTemperature[0]<-40 || c.externalTemperature[0]>100) return false; + + } + + if(c.vin) delete c.vin; + c.vin=0; + if(js.isMember("vin")) + { + if(!js["vin"].isString()) return false; + c.vin=new std::string(); + c.vin[0]=js["vin"].asString(); + if(c.vin[0].length()>17) return false; + + } + + if(c.prndl) delete c.prndl; + c.prndl=0; + if(js.isMember("prndl")) + { + c.prndl=new NsSmartDeviceLinkRPCV2::PRNDL(); + if(!NsSmartDeviceLinkRPCV2::PRNDLMarshaller::fromJSON(js["prndl"],c.prndl[0])) return false; + } + + if(c.tirePressure) delete c.tirePressure; + c.tirePressure=0; + if(js.isMember("tirePressure")) + { + c.tirePressure=new NsSmartDeviceLinkRPCV2::TireStatus(); + if(!NsSmartDeviceLinkRPCV2::TireStatusMarshaller::fromJSON(js["tirePressure"],c.tirePressure[0])) return false; + } + + if(c.batteryPackVoltage) delete c.batteryPackVoltage; + c.batteryPackVoltage=0; + if(js.isMember("batteryPackVoltage")) + { + if(!js["batteryPackVoltage"].isNumeric()) return false; + c.batteryPackVoltage=new float(); + c.batteryPackVoltage[0]=js["batteryPackVoltage"].asDouble(); + if(c.batteryPackVoltage[0]<-1000 || c.batteryPackVoltage[0]>1000) return false; + + } + + if(c.batteryPackCurrent) delete c.batteryPackCurrent; + c.batteryPackCurrent=0; + if(js.isMember("batteryPackCurrent")) + { + if(!js["batteryPackCurrent"].isNumeric()) return false; + c.batteryPackCurrent=new float(); + c.batteryPackCurrent[0]=js["batteryPackCurrent"].asDouble(); + if(c.batteryPackCurrent[0]<-1000 || c.batteryPackCurrent[0]>1000) return false; + + } + + if(c.batteryPackTemperature) delete c.batteryPackTemperature; + c.batteryPackTemperature=0; + if(js.isMember("batteryPackTemperature")) + { + if(!js["batteryPackTemperature"].isInt()) return false; + c.batteryPackTemperature=new int(); + c.batteryPackTemperature[0]=js["batteryPackTemperature"].asInt(); + if(c.batteryPackTemperature[0]<-50 || c.batteryPackTemperature[0]>250) return false; + + } + + if(c.engineTorque) delete c.engineTorque; + c.engineTorque=0; + if(js.isMember("engineTorque")) + { + if(!js["engineTorque"].isInt()) return false; + c.engineTorque=new int(); + c.engineTorque[0]=js["engineTorque"].asInt(); + if(c.engineTorque[0]<-10000 || c.engineTorque[0]>55000) return false; + + } + + if(c.odometer) delete c.odometer; + c.odometer=0; + if(js.isMember("odometer")) + { + if(!js["odometer"].isInt()) return false; + c.odometer=new unsigned int(); + c.odometer[0]=js["odometer"].asInt(); + if(c.odometer[0]>2000000) return false; + + } + + if(c.tripOdometer) delete c.tripOdometer; + c.tripOdometer=0; + if(js.isMember("tripOdometer")) + { + if(!js["tripOdometer"].isInt()) return false; + c.tripOdometer=new unsigned int(); + c.tripOdometer[0]=js["tripOdometer"].asInt(); + if(c.tripOdometer[0]>2000000) return false; + + } + + if(c.satRadioESN) delete c.satRadioESN; + c.satRadioESN=0; + if(js.isMember("satRadioESN")) + { + if(!js["satRadioESN"].isString()) return false; + c.satRadioESN=new std::string(); + c.satRadioESN[0]=js["satRadioESN"].asString(); + if(c.satRadioESN[0].length()>500) return false; + + } + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.h new file mode 100644 index 000000000..becf1489a --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleDataResponseMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLEDATARESPONSEMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLEDATARESPONSEMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleDataResponse.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetVehicleDataResponseMarshaller + { + static bool checkIntegrity(GetVehicleDataResponse& e); + static bool checkIntegrityConst(const GetVehicleDataResponse& e); + + static bool fromString(const std::string& s,GetVehicleDataResponse& e); + static const std::string toString(const GetVehicleDataResponse& e); + + static bool fromJSON(const Json::Value& s,GetVehicleDataResponse& e); + static Json::Value toJSON(const GetVehicleDataResponse& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleType.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleType.cpp new file mode 100644 index 000000000..0530d3d7e --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleType.cpp @@ -0,0 +1,73 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleType.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetVehicleType& GetVehicleType::operator =(const GetVehicleType& c) +{ + return *this; +} + + +GetVehicleType::~GetVehicleType(void) +{ +} + + +GetVehicleType::GetVehicleType(void) : + RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLETYPE) +{ +} + + +GetVehicleType::GetVehicleType(const GetVehicleType& c) : RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLETYPE,c.getId()) +{ + *this=c; +} + + +bool GetVehicleType::checkIntegrity(void) +{ + return GetVehicleTypeMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.cpp new file mode 100644 index 000000000..86ed85b95 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.cpp @@ -0,0 +1,113 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleType.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetVehicleTypeMarshaller::checkIntegrity(GetVehicleType& s) +{ + return checkIntegrityConst(s); +} + + +bool GetVehicleTypeMarshaller::fromString(const std::string& s,GetVehicleType& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetVehicleTypeMarshaller::toString(const GetVehicleType& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetVehicleTypeMarshaller::checkIntegrityConst(const GetVehicleType& s) +{ + return true; +} + + +Json::Value GetVehicleTypeMarshaller::toJSON(const GetVehicleType& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["method"]=Json::Value("VehicleInfo.GetVehicleType"); + + json["id"]=Json::Value(e.getId()); + return json; +} + + +bool GetVehicleTypeMarshaller::fromJSON(const Json::Value& json,GetVehicleType& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("method") || !json["method"].isString() || json["method"].asString().compare("VehicleInfo.GetVehicleType")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.h new file mode 100644 index 000000000..f70919c4b --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLETYPEMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLETYPEMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleType.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetVehicleTypeMarshaller + { + static bool checkIntegrity(GetVehicleType& e); + static bool checkIntegrityConst(const GetVehicleType& e); + + static bool fromString(const std::string& s,GetVehicleType& e); + static const std::string toString(const GetVehicleType& e); + + static bool fromJSON(const Json::Value& s,GetVehicleType& e); + static Json::Value toJSON(const GetVehicleType& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.cpp new file mode 100644 index 000000000..edd196ab1 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.cpp @@ -0,0 +1,85 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +GetVehicleTypeResponse& GetVehicleTypeResponse::operator =(const GetVehicleTypeResponse& c) +{ + vehicleType=c.vehicleType; + return *this; +} + + +GetVehicleTypeResponse::~GetVehicleTypeResponse(void) +{ +} + + +GetVehicleTypeResponse::GetVehicleTypeResponse(void) : + RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLETYPERESPONSE) +{ +} + + +GetVehicleTypeResponse::GetVehicleTypeResponse(const GetVehicleTypeResponse& c) : RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__GETVEHICLETYPERESPONSE,c.getId(),c.getResult()) +{ + *this=c; +} + + +const NsSmartDeviceLinkRPCV2::VehicleType& GetVehicleTypeResponse::get_vehicleType(void) +{ + return vehicleType; +} + +bool GetVehicleTypeResponse::set_vehicleType(const NsSmartDeviceLinkRPCV2::VehicleType& vehicleType_) +{ + vehicleType=vehicleType_; + return true; +} + +bool GetVehicleTypeResponse::checkIntegrity(void) +{ + return GetVehicleTypeResponseMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.cpp new file mode 100644 index 000000000..aca11b6b4 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.cpp @@ -0,0 +1,133 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.h" +#include "../src/SDLRPCObjectsImpl/V2/VehicleTypeMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool GetVehicleTypeResponseMarshaller::checkIntegrity(GetVehicleTypeResponse& s) +{ + return checkIntegrityConst(s); +} + + +bool GetVehicleTypeResponseMarshaller::fromString(const std::string& s,GetVehicleTypeResponse& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string GetVehicleTypeResponseMarshaller::toString(const GetVehicleTypeResponse& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool GetVehicleTypeResponseMarshaller::checkIntegrityConst(const GetVehicleTypeResponse& s) +{ + if(!NsSmartDeviceLinkRPCV2::VehicleTypeMarshaller::checkIntegrityConst(s.vehicleType)) return false; + + return true; +} + + +Json::Value GetVehicleTypeResponseMarshaller::toJSON(const GetVehicleTypeResponse& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["id"]=Json::Value(e.getId()); + json["result"]=Json::Value(Json::objectValue); + NsSmartDeviceLinkRPCV2::Result r(static_cast<NsSmartDeviceLinkRPCV2::Result::ResultInternal>(e.getResult())); + json["result"]["resultCode"]=NsSmartDeviceLinkRPCV2::ResultMarshaller::toJSON(r); + json["result"]["method"]=Json::Value("VehicleInfo.GetVehicleTypeResponse"); + + json["result"]["vehicleType"]=NsSmartDeviceLinkRPCV2::VehicleTypeMarshaller::toJSON(e.vehicleType);; + return json; +} + + +bool GetVehicleTypeResponseMarshaller::fromJSON(const Json::Value& json,GetVehicleTypeResponse& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("result")) return false; + + Json::Value js=json["result"]; + if(!js.isObject()) return false; + + NsSmartDeviceLinkRPCV2::Result r; + if(!js.isMember("resultCode") || !js["resultCode"].isString()) return false; + if(!js.isMember("method") || !js["method"].isString()) return false; + if(js["method"].asString().compare("VehicleInfo.GetVehicleTypeResponse")) return false; + + if(!NsSmartDeviceLinkRPCV2::ResultMarshaller::fromJSON(js["resultCode"],r)) return false; + c.setResult(r.get()); + if(!js.isMember("vehicleType") || !NsSmartDeviceLinkRPCV2::VehicleTypeMarshaller::fromJSON(js["vehicleType"],c.vehicleType)) return false; + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.h new file mode 100644 index 000000000..5bf7d997e --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponseMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLETYPERESPONSEMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_GETVEHICLETYPERESPONSEMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/GetVehicleTypeResponse.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct GetVehicleTypeResponseMarshaller + { + static bool checkIntegrity(GetVehicleTypeResponse& e); + static bool checkIntegrityConst(const GetVehicleTypeResponse& e); + + static bool fromString(const std::string& s,GetVehicleTypeResponse& e); + static const std::string toString(const GetVehicleTypeResponse& e); + + static bool fromJSON(const Json::Value& s,GetVehicleTypeResponse& e); + static Json::Value toJSON(const GetVehicleTypeResponse& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleData.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleData.cpp new file mode 100644 index 000000000..966f64c20 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleData.cpp @@ -0,0 +1,447 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/OnVehicleData.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +OnVehicleData& OnVehicleData::operator =(const OnVehicleData& c) +{ + if(gps) delete gps; + gps= c.gps ? new NsSmartDeviceLinkRPCV2::GPSData(c.gps[0]) : 0; + if(speed) delete speed; + speed= c.speed ? new float(c.speed[0]) : 0; + if(rpm) delete rpm; + rpm= c.rpm ? new unsigned int(c.rpm[0]) : 0; + if(fuelLevel) delete fuelLevel; + fuelLevel= c.fuelLevel ? new float(c.fuelLevel[0]) : 0; + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy= c.avgFuelEconomy ? new float(c.avgFuelEconomy[0]) : 0; + if(batteryVoltage) delete batteryVoltage; + batteryVoltage= c.batteryVoltage ? new float(c.batteryVoltage[0]) : 0; + if(externalTemperature) delete externalTemperature; + externalTemperature= c.externalTemperature ? new float(c.externalTemperature[0]) : 0; + if(vin) delete vin; + vin= c.vin ? new std::string(c.vin[0]) : 0; + if(prndl) delete prndl; + prndl= c.prndl ? new NsSmartDeviceLinkRPCV2::PRNDL(c.prndl[0]) : 0; + if(tirePressure) delete tirePressure; + tirePressure= c.tirePressure ? new NsSmartDeviceLinkRPCV2::TireStatus(c.tirePressure[0]) : 0; + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage= c.batteryPackVoltage ? new float(c.batteryPackVoltage[0]) : 0; + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent= c.batteryPackCurrent ? new float(c.batteryPackCurrent[0]) : 0; + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature= c.batteryPackTemperature ? new int(c.batteryPackTemperature[0]) : 0; + if(engineTorque) delete engineTorque; + engineTorque= c.engineTorque ? new int(c.engineTorque[0]) : 0; + if(odometer) delete odometer; + odometer= c.odometer ? new unsigned int(c.odometer[0]) : 0; + if(tripOdometer) delete tripOdometer; + tripOdometer= c.tripOdometer ? new unsigned int(c.tripOdometer[0]) : 0; + if(genericbinary) delete genericbinary; + genericbinary= c.genericbinary ? new std::string(c.genericbinary[0]) : 0; + return *this; +} + + +OnVehicleData::~OnVehicleData(void) +{ + if(gps) delete gps; + if(speed) delete speed; + if(rpm) delete rpm; + if(fuelLevel) delete fuelLevel; + if(avgFuelEconomy) delete avgFuelEconomy; + if(batteryVoltage) delete batteryVoltage; + if(externalTemperature) delete externalTemperature; + if(vin) delete vin; + if(prndl) delete prndl; + if(tirePressure) delete tirePressure; + if(batteryPackVoltage) delete batteryPackVoltage; + if(batteryPackCurrent) delete batteryPackCurrent; + if(batteryPackTemperature) delete batteryPackTemperature; + if(engineTorque) delete engineTorque; + if(odometer) delete odometer; + if(tripOdometer) delete tripOdometer; + if(genericbinary) delete genericbinary; +} + + +OnVehicleData::OnVehicleData(void) : + RPC2Notification(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__ONVEHICLEDATA), + gps(0), + speed(0), + rpm(0), + fuelLevel(0), + avgFuelEconomy(0), + batteryVoltage(0), + externalTemperature(0), + vin(0), + prndl(0), + tirePressure(0), + batteryPackVoltage(0), + batteryPackCurrent(0), + batteryPackTemperature(0), + engineTorque(0), + odometer(0), + tripOdometer(0), + genericbinary(0) +{ +} + + +OnVehicleData::OnVehicleData(const OnVehicleData& c) : RPC2Notification(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__ONVEHICLEDATA) +{ + *this=c; +} + + +const NsSmartDeviceLinkRPCV2::GPSData* OnVehicleData::get_gps(void) +{ + return gps; +} + +bool OnVehicleData::set_gps(const NsSmartDeviceLinkRPCV2::GPSData& gps_) +{ + if(gps) delete gps; + gps=new NsSmartDeviceLinkRPCV2::GPSData(gps_); + return true; +} + +void OnVehicleData::reset_gps(void) +{ + if(gps) delete gps; + gps=0; +} + +const float* OnVehicleData::get_speed(void) +{ + return speed; +} + +bool OnVehicleData::set_speed(const float& speed_) +{ + if(speed) delete speed; + speed=new float(speed_); + return true; +} + +void OnVehicleData::reset_speed(void) +{ + if(speed) delete speed; + speed=0; +} + +const unsigned int* OnVehicleData::get_rpm(void) +{ + return rpm; +} + +bool OnVehicleData::set_rpm(const unsigned int& rpm_) +{ + if(rpm) delete rpm; + rpm=new unsigned int(rpm_); + return true; +} + +void OnVehicleData::reset_rpm(void) +{ + if(rpm) delete rpm; + rpm=0; +} + +const float* OnVehicleData::get_fuelLevel(void) +{ + return fuelLevel; +} + +bool OnVehicleData::set_fuelLevel(const float& fuelLevel_) +{ + if(fuelLevel) delete fuelLevel; + fuelLevel=new float(fuelLevel_); + return true; +} + +void OnVehicleData::reset_fuelLevel(void) +{ + if(fuelLevel) delete fuelLevel; + fuelLevel=0; +} + +const float* OnVehicleData::get_avgFuelEconomy(void) +{ + return avgFuelEconomy; +} + +bool OnVehicleData::set_avgFuelEconomy(const float& avgFuelEconomy_) +{ + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy=new float(avgFuelEconomy_); + return true; +} + +void OnVehicleData::reset_avgFuelEconomy(void) +{ + if(avgFuelEconomy) delete avgFuelEconomy; + avgFuelEconomy=0; +} + +const float* OnVehicleData::get_batteryVoltage(void) +{ + return batteryVoltage; +} + +bool OnVehicleData::set_batteryVoltage(const float& batteryVoltage_) +{ + if(batteryVoltage) delete batteryVoltage; + batteryVoltage=new float(batteryVoltage_); + return true; +} + +void OnVehicleData::reset_batteryVoltage(void) +{ + if(batteryVoltage) delete batteryVoltage; + batteryVoltage=0; +} + +const float* OnVehicleData::get_externalTemperature(void) +{ + return externalTemperature; +} + +bool OnVehicleData::set_externalTemperature(const float& externalTemperature_) +{ + if(externalTemperature) delete externalTemperature; + externalTemperature=new float(externalTemperature_); + return true; +} + +void OnVehicleData::reset_externalTemperature(void) +{ + if(externalTemperature) delete externalTemperature; + externalTemperature=0; +} + +const std::string* OnVehicleData::get_vin(void) +{ + return vin; +} + +bool OnVehicleData::set_vin(const std::string& vin_) +{ + if(vin) delete vin; + vin=new std::string(vin_); + return true; +} + +void OnVehicleData::reset_vin(void) +{ + if(vin) delete vin; + vin=0; +} + +const NsSmartDeviceLinkRPCV2::PRNDL* OnVehicleData::get_prndl(void) +{ + return prndl; +} + +bool OnVehicleData::set_prndl(const NsSmartDeviceLinkRPCV2::PRNDL& prndl_) +{ + if(prndl) delete prndl; + prndl=new NsSmartDeviceLinkRPCV2::PRNDL(prndl_); + return true; +} + +void OnVehicleData::reset_prndl(void) +{ + if(prndl) delete prndl; + prndl=0; +} + +const NsSmartDeviceLinkRPCV2::TireStatus* OnVehicleData::get_tirePressure(void) +{ + return tirePressure; +} + +bool OnVehicleData::set_tirePressure(const NsSmartDeviceLinkRPCV2::TireStatus& tirePressure_) +{ + if(tirePressure) delete tirePressure; + tirePressure=new NsSmartDeviceLinkRPCV2::TireStatus(tirePressure_); + return true; +} + +void OnVehicleData::reset_tirePressure(void) +{ + if(tirePressure) delete tirePressure; + tirePressure=0; +} + +const float* OnVehicleData::get_batteryPackVoltage(void) +{ + return batteryPackVoltage; +} + +bool OnVehicleData::set_batteryPackVoltage(const float& batteryPackVoltage_) +{ + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage=new float(batteryPackVoltage_); + return true; +} + +void OnVehicleData::reset_batteryPackVoltage(void) +{ + if(batteryPackVoltage) delete batteryPackVoltage; + batteryPackVoltage=0; +} + +const float* OnVehicleData::get_batteryPackCurrent(void) +{ + return batteryPackCurrent; +} + +bool OnVehicleData::set_batteryPackCurrent(const float& batteryPackCurrent_) +{ + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent=new float(batteryPackCurrent_); + return true; +} + +void OnVehicleData::reset_batteryPackCurrent(void) +{ + if(batteryPackCurrent) delete batteryPackCurrent; + batteryPackCurrent=0; +} + +const int* OnVehicleData::get_batteryPackTemperature(void) +{ + return batteryPackTemperature; +} + +bool OnVehicleData::set_batteryPackTemperature(const int& batteryPackTemperature_) +{ + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature=new int(batteryPackTemperature_); + return true; +} + +void OnVehicleData::reset_batteryPackTemperature(void) +{ + if(batteryPackTemperature) delete batteryPackTemperature; + batteryPackTemperature=0; +} + +const int* OnVehicleData::get_engineTorque(void) +{ + return engineTorque; +} + +bool OnVehicleData::set_engineTorque(const int& engineTorque_) +{ + if(engineTorque) delete engineTorque; + engineTorque=new int(engineTorque_); + return true; +} + +void OnVehicleData::reset_engineTorque(void) +{ + if(engineTorque) delete engineTorque; + engineTorque=0; +} + +const unsigned int* OnVehicleData::get_odometer(void) +{ + return odometer; +} + +bool OnVehicleData::set_odometer(const unsigned int& odometer_) +{ + if(odometer) delete odometer; + odometer=new unsigned int(odometer_); + return true; +} + +void OnVehicleData::reset_odometer(void) +{ + if(odometer) delete odometer; + odometer=0; +} + +const unsigned int* OnVehicleData::get_tripOdometer(void) +{ + return tripOdometer; +} + +bool OnVehicleData::set_tripOdometer(const unsigned int& tripOdometer_) +{ + if(tripOdometer) delete tripOdometer; + tripOdometer=new unsigned int(tripOdometer_); + return true; +} + +void OnVehicleData::reset_tripOdometer(void) +{ + if(tripOdometer) delete tripOdometer; + tripOdometer=0; +} + +const std::string* OnVehicleData::get_genericbinary(void) +{ + return genericbinary; +} + +bool OnVehicleData::set_genericbinary(const std::string& genericbinary_) +{ + if(genericbinary) delete genericbinary; + genericbinary=new std::string(genericbinary_); + return true; +} + +void OnVehicleData::reset_genericbinary(void) +{ + if(genericbinary) delete genericbinary; + genericbinary=0; +} + +bool OnVehicleData::checkIntegrity(void) +{ + return OnVehicleDataMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.cpp new file mode 100644 index 000000000..cf8a85b3a --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.cpp @@ -0,0 +1,364 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/OnVehicleData.h" +#include "../src/SDLRPCObjectsImpl/V2/GPSDataMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/PRNDLMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/TireStatusMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool OnVehicleDataMarshaller::checkIntegrity(OnVehicleData& s) +{ + return checkIntegrityConst(s); +} + + +bool OnVehicleDataMarshaller::fromString(const std::string& s,OnVehicleData& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string OnVehicleDataMarshaller::toString(const OnVehicleData& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool OnVehicleDataMarshaller::checkIntegrityConst(const OnVehicleData& s) +{ + if(s.gps && (!NsSmartDeviceLinkRPCV2::GPSDataMarshaller::checkIntegrityConst(s.gps[0]))) return false; + + if(s.speed && (s.speed[0]<-100 || s.speed[0]>500)) return false; + + if(s.rpm && (s.rpm[0]>20000)) return false; + + if(s.fuelLevel && (s.fuelLevel[0]<0 || s.fuelLevel[0]>100)) return false; + + if(s.avgFuelEconomy && (s.avgFuelEconomy[0]<0 || s.avgFuelEconomy[0]>7000)) return false; + + if(s.batteryVoltage && (s.batteryVoltage[0]<0 || s.batteryVoltage[0]>26)) return false; + + if(s.externalTemperature && (s.externalTemperature[0]<-40 || s.externalTemperature[0]>100)) return false; + + if(s.vin && (s.vin[0].length()>17)) return false; + + if(s.prndl && (!NsSmartDeviceLinkRPCV2::PRNDLMarshaller::checkIntegrityConst(s.prndl[0]))) return false; + + if(s.tirePressure && (!NsSmartDeviceLinkRPCV2::TireStatusMarshaller::checkIntegrityConst(s.tirePressure[0]))) return false; + + if(s.batteryPackVoltage && (s.batteryPackVoltage[0]<-1000 || s.batteryPackVoltage[0]>1000)) return false; + + if(s.batteryPackCurrent && (s.batteryPackCurrent[0]<-1000 || s.batteryPackCurrent[0]>1000)) return false; + + if(s.batteryPackTemperature && (s.batteryPackTemperature[0]<-50 || s.batteryPackTemperature[0]>250)) return false; + + if(s.engineTorque && (s.engineTorque[0]<-10000 || s.engineTorque[0]>55000)) return false; + + if(s.odometer && (s.odometer[0]>2000000)) return false; + + if(s.tripOdometer && (s.tripOdometer[0]>2000000)) return false; + + if(s.genericbinary && (s.genericbinary[0].length()>500)) return false; + + return true; +} + + +Json::Value OnVehicleDataMarshaller::toJSON(const OnVehicleData& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["method"]=Json::Value("VehicleInfo.OnVehicleData"); + json["params"]=Json::Value(Json::objectValue); + + if(e.gps) + json["params"]["gps"]=NsSmartDeviceLinkRPCV2::GPSDataMarshaller::toJSON(e.gps[0]);; + if(e.speed) + json["params"]["speed"]=Json::Value(e.speed[0]);; + if(e.rpm) + json["params"]["rpm"]=Json::Value(e.rpm[0]);; + if(e.fuelLevel) + json["params"]["fuelLevel"]=Json::Value(e.fuelLevel[0]);; + if(e.avgFuelEconomy) + json["params"]["avgFuelEconomy"]=Json::Value(e.avgFuelEconomy[0]);; + if(e.batteryVoltage) + json["params"]["batteryVoltage"]=Json::Value(e.batteryVoltage[0]);; + if(e.externalTemperature) + json["params"]["externalTemperature"]=Json::Value(e.externalTemperature[0]);; + if(e.vin) + json["params"]["vin"]=Json::Value(e.vin[0]);; + if(e.prndl) + json["params"]["prndl"]=NsSmartDeviceLinkRPCV2::PRNDLMarshaller::toJSON(e.prndl[0]);; + if(e.tirePressure) + json["params"]["tirePressure"]=NsSmartDeviceLinkRPCV2::TireStatusMarshaller::toJSON(e.tirePressure[0]);; + if(e.batteryPackVoltage) + json["params"]["batteryPackVoltage"]=Json::Value(e.batteryPackVoltage[0]);; + if(e.batteryPackCurrent) + json["params"]["batteryPackCurrent"]=Json::Value(e.batteryPackCurrent[0]);; + if(e.batteryPackTemperature) + json["params"]["batteryPackTemperature"]=Json::Value(e.batteryPackTemperature[0]);; + if(e.engineTorque) + json["params"]["engineTorque"]=Json::Value(e.engineTorque[0]);; + if(e.odometer) + json["params"]["odometer"]=Json::Value(e.odometer[0]);; + if(e.tripOdometer) + json["params"]["tripOdometer"]=Json::Value(e.tripOdometer[0]);; + if(e.genericbinary) + json["params"]["genericbinary"]=Json::Value(e.genericbinary[0]);; + return json; +} + + +bool OnVehicleDataMarshaller::fromJSON(const Json::Value& json,OnVehicleData& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("method") || !json["method"].isString() || json["method"].asString().compare("VehicleInfo.OnVehicleData")) return false; + if(!json.isMember("params")) return false; + + Json::Value js=json["params"]; + if(!js.isObject()) return false; + + if(c.gps) delete c.gps; + c.gps=0; + if(js.isMember("gps")) + { + c.gps=new NsSmartDeviceLinkRPCV2::GPSData(); + if(!NsSmartDeviceLinkRPCV2::GPSDataMarshaller::fromJSON(js["gps"],c.gps[0])) return false; + } + + if(c.speed) delete c.speed; + c.speed=0; + if(js.isMember("speed")) + { + if(!js["speed"].isNumeric()) return false; + c.speed=new float(); + c.speed[0]=js["speed"].asDouble(); + if(c.speed[0]<-100 || c.speed[0]>500) return false; + + } + + if(c.rpm) delete c.rpm; + c.rpm=0; + if(js.isMember("rpm")) + { + if(!js["rpm"].isInt()) return false; + c.rpm=new unsigned int(); + c.rpm[0]=js["rpm"].asInt(); + if(c.rpm[0]>20000) return false; + + } + + if(c.fuelLevel) delete c.fuelLevel; + c.fuelLevel=0; + if(js.isMember("fuelLevel")) + { + if(!js["fuelLevel"].isNumeric()) return false; + c.fuelLevel=new float(); + c.fuelLevel[0]=js["fuelLevel"].asDouble(); + if(c.fuelLevel[0]<0 || c.fuelLevel[0]>100) return false; + + } + + if(c.avgFuelEconomy) delete c.avgFuelEconomy; + c.avgFuelEconomy=0; + if(js.isMember("avgFuelEconomy")) + { + if(!js["avgFuelEconomy"].isNumeric()) return false; + c.avgFuelEconomy=new float(); + c.avgFuelEconomy[0]=js["avgFuelEconomy"].asDouble(); + if(c.avgFuelEconomy[0]<0 || c.avgFuelEconomy[0]>7000) return false; + + } + + if(c.batteryVoltage) delete c.batteryVoltage; + c.batteryVoltage=0; + if(js.isMember("batteryVoltage")) + { + if(!js["batteryVoltage"].isNumeric()) return false; + c.batteryVoltage=new float(); + c.batteryVoltage[0]=js["batteryVoltage"].asDouble(); + if(c.batteryVoltage[0]<0 || c.batteryVoltage[0]>26) return false; + + } + + if(c.externalTemperature) delete c.externalTemperature; + c.externalTemperature=0; + if(js.isMember("externalTemperature")) + { + if(!js["externalTemperature"].isNumeric()) return false; + c.externalTemperature=new float(); + c.externalTemperature[0]=js["externalTemperature"].asDouble(); + if(c.externalTemperature[0]<-40 || c.externalTemperature[0]>100) return false; + + } + + if(c.vin) delete c.vin; + c.vin=0; + if(js.isMember("vin")) + { + if(!js["vin"].isString()) return false; + c.vin=new std::string(); + c.vin[0]=js["vin"].asString(); + if(c.vin[0].length()>17) return false; + + } + + if(c.prndl) delete c.prndl; + c.prndl=0; + if(js.isMember("prndl")) + { + c.prndl=new NsSmartDeviceLinkRPCV2::PRNDL(); + if(!NsSmartDeviceLinkRPCV2::PRNDLMarshaller::fromJSON(js["prndl"],c.prndl[0])) return false; + } + + if(c.tirePressure) delete c.tirePressure; + c.tirePressure=0; + if(js.isMember("tirePressure")) + { + c.tirePressure=new NsSmartDeviceLinkRPCV2::TireStatus(); + if(!NsSmartDeviceLinkRPCV2::TireStatusMarshaller::fromJSON(js["tirePressure"],c.tirePressure[0])) return false; + } + + if(c.batteryPackVoltage) delete c.batteryPackVoltage; + c.batteryPackVoltage=0; + if(js.isMember("batteryPackVoltage")) + { + if(!js["batteryPackVoltage"].isNumeric()) return false; + c.batteryPackVoltage=new float(); + c.batteryPackVoltage[0]=js["batteryPackVoltage"].asDouble(); + if(c.batteryPackVoltage[0]<-1000 || c.batteryPackVoltage[0]>1000) return false; + + } + + if(c.batteryPackCurrent) delete c.batteryPackCurrent; + c.batteryPackCurrent=0; + if(js.isMember("batteryPackCurrent")) + { + if(!js["batteryPackCurrent"].isNumeric()) return false; + c.batteryPackCurrent=new float(); + c.batteryPackCurrent[0]=js["batteryPackCurrent"].asDouble(); + if(c.batteryPackCurrent[0]<-1000 || c.batteryPackCurrent[0]>1000) return false; + + } + + if(c.batteryPackTemperature) delete c.batteryPackTemperature; + c.batteryPackTemperature=0; + if(js.isMember("batteryPackTemperature")) + { + if(!js["batteryPackTemperature"].isInt()) return false; + c.batteryPackTemperature=new int(); + c.batteryPackTemperature[0]=js["batteryPackTemperature"].asInt(); + if(c.batteryPackTemperature[0]<-50 || c.batteryPackTemperature[0]>250) return false; + + } + + if(c.engineTorque) delete c.engineTorque; + c.engineTorque=0; + if(js.isMember("engineTorque")) + { + if(!js["engineTorque"].isInt()) return false; + c.engineTorque=new int(); + c.engineTorque[0]=js["engineTorque"].asInt(); + if(c.engineTorque[0]<-10000 || c.engineTorque[0]>55000) return false; + + } + + if(c.odometer) delete c.odometer; + c.odometer=0; + if(js.isMember("odometer")) + { + if(!js["odometer"].isInt()) return false; + c.odometer=new unsigned int(); + c.odometer[0]=js["odometer"].asInt(); + if(c.odometer[0]>2000000) return false; + + } + + if(c.tripOdometer) delete c.tripOdometer; + c.tripOdometer=0; + if(js.isMember("tripOdometer")) + { + if(!js["tripOdometer"].isInt()) return false; + c.tripOdometer=new unsigned int(); + c.tripOdometer[0]=js["tripOdometer"].asInt(); + if(c.tripOdometer[0]>2000000) return false; + + } + + if(c.genericbinary) delete c.genericbinary; + c.genericbinary=0; + if(js.isMember("genericbinary")) + { + if(!js["genericbinary"].isString()) return false; + c.genericbinary=new std::string(); + c.genericbinary[0]=js["genericbinary"].asString(); + if(c.genericbinary[0].length()>500) return false; + + } + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.h new file mode 100644 index 000000000..912f4c6a4 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/OnVehicleDataMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_ONVEHICLEDATAMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_ONVEHICLEDATAMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/OnVehicleData.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct OnVehicleDataMarshaller + { + static bool checkIntegrity(OnVehicleData& e); + static bool checkIntegrityConst(const OnVehicleData& e); + + static bool fromString(const std::string& s,OnVehicleData& e); + static const std::string toString(const OnVehicleData& e); + + static bool fromJSON(const Json::Value& s,OnVehicleData& e); + static Json::Value toJSON(const OnVehicleData& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDID.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDID.cpp new file mode 100644 index 000000000..a860aa8b9 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDID.cpp @@ -0,0 +1,131 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDID.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +ReadDID& ReadDID::operator =(const ReadDID& c) +{ + ecuName=c.ecuName; + didLocation=c.didLocation; + if(encrypted) delete encrypted; + encrypted= c.encrypted ? new bool(c.encrypted[0]) : 0; + appId=c.appId; + return *this; +} + + +ReadDID::~ReadDID(void) +{ + if(encrypted) delete encrypted; +} + + +ReadDID::ReadDID(void) : + RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__READDID), + encrypted(0) +{ +} + + +ReadDID::ReadDID(const ReadDID& c) : RPC2Request(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__READDID,c.getId()) +{ + *this=c; +} + + +unsigned int ReadDID::get_ecuName(void) +{ + return ecuName; +} + +bool ReadDID::set_ecuName(unsigned int ecuName_) +{ + ecuName=ecuName_; + return true; +} + +const std::vector< unsigned int>& ReadDID::get_didLocation(void) +{ + return didLocation; +} + +bool ReadDID::set_didLocation(const std::vector< unsigned int>& didLocation_) +{ + didLocation=didLocation_; + return true; +} + +const bool* ReadDID::get_encrypted(void) +{ + return encrypted; +} + +bool ReadDID::set_encrypted(const bool& encrypted_) +{ + if(encrypted) delete encrypted; + encrypted=new bool(encrypted_); + return true; +} + +void ReadDID::reset_encrypted(void) +{ + if(encrypted) delete encrypted; + encrypted=0; +} + +int ReadDID::get_appId(void) +{ + return appId; +} + +bool ReadDID::set_appId(int appId_) +{ + appId=appId_; + return true; +} + +bool ReadDID::checkIntegrity(void) +{ + return ReadDIDMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.cpp new file mode 100644 index 000000000..3d0eb43eb --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.cpp @@ -0,0 +1,179 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDID.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool ReadDIDMarshaller::checkIntegrity(ReadDID& s) +{ + return checkIntegrityConst(s); +} + + +bool ReadDIDMarshaller::fromString(const std::string& s,ReadDID& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string ReadDIDMarshaller::toString(const ReadDID& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool ReadDIDMarshaller::checkIntegrityConst(const ReadDID& s) +{ + if(s.ecuName>65535) return false; + + { + unsigned int i=s.didLocation.size(); + if(i<0) return false; + if(i>1000) return false; + while(i--) + { + if(s.didLocation[i]>65535) return false; + } + } + + return true; +} + + +Json::Value ReadDIDMarshaller::toJSON(const ReadDID& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["method"]=Json::Value("VehicleInfo.ReadDID"); + + json["id"]=Json::Value(e.getId()); + json["params"]=Json::Value(Json::objectValue); + json["params"]["ecuName"]=Json::Value(e.ecuName);; + { + unsigned int i=e.didLocation.size(); + Json::Value j=Json::Value(Json::arrayValue); + j.resize(i); + while(i--) + j[i]=Json::Value(e.didLocation[i]); + + json["params"]["didLocation"]=j; + } + if(e.encrypted) + json["params"]["encrypted"]=Json::Value(e.encrypted[0]);; + json["params"]["appId"]=Json::Value(e.appId);; + return json; +} + + +bool ReadDIDMarshaller::fromJSON(const Json::Value& json,ReadDID& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("method") || !json["method"].isString() || json["method"].asString().compare("VehicleInfo.ReadDID")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("params")) return false; + + Json::Value js=json["params"]; + if(!js.isObject()) return false; + if(!js.isMember("ecuName") || !js["ecuName"].isInt()) return false; + c.ecuName=js["ecuName"].asInt(); + if(c.ecuName>65535) return false; + + if(!js.isMember("didLocation") || !js["didLocation"].isArray()) + return false; + { + c.didLocation.clear(); + unsigned int i=js["didLocation"].size(); + if(i<0) return false; + if(i>1000) return false; + c.didLocation.resize(i); + while(i--) + { + if(!js["didLocation"][i].isInt()) + return false; + c.didLocation[i]=js["didLocation"][i].asInt(); + if(c.didLocation[i]>65535) return false; + + } + } + + + if(c.encrypted) delete c.encrypted; + c.encrypted=0; + if(js.isMember("encrypted")) + { + if(!js["encrypted"].isBool()) return false; + c.encrypted=new bool(); + c.encrypted[0]=js["encrypted"].asBool(); + + } + + if(!js.isMember("appId") || !js["appId"].isInt()) return false; + c.appId=js["appId"].asInt(); + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.h new file mode 100644 index 000000000..3d5b431ff --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_READDIDMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_READDIDMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDID.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct ReadDIDMarshaller + { + static bool checkIntegrity(ReadDID& e); + static bool checkIntegrityConst(const ReadDID& e); + + static bool fromString(const std::string& s,ReadDID& e); + static const std::string toString(const ReadDID& e); + + static bool fromJSON(const Json::Value& s,ReadDID& e); + static Json::Value toJSON(const ReadDID& e); + }; + } +} + +#endif diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponse.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponse.cpp new file mode 100644 index 000000000..010903695 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponse.cpp @@ -0,0 +1,117 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDIDResponse.h" +#include "../src/../include/JSONHandler/RPC2Objects/Marshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + + +ReadDIDResponse& ReadDIDResponse::operator =(const ReadDIDResponse& c) +{ + if(dataResult) delete dataResult; + dataResult= c.dataResult ? new std::vector<NsSmartDeviceLinkRPCV2::VehicleDataResultCode>(c.dataResult[0]) : 0; + if(data) delete data; + data= c.data ? new std::vector<std::string>(c.data[0]) : 0; + return *this; +} + + +ReadDIDResponse::~ReadDIDResponse(void) +{ + if(dataResult) delete dataResult; + if(data) delete data; +} + + +ReadDIDResponse::ReadDIDResponse(void) : + RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__READDIDRESPONSE), + dataResult(0), + data(0) +{ +} + + +ReadDIDResponse::ReadDIDResponse(const ReadDIDResponse& c) : RPC2Response(Marshaller::METHOD_NSRPC2COMMUNICATION_VEHICLEINFO__READDIDRESPONSE,c.getId(),c.getResult()) +{ + *this=c; +} + + +const std::vector< NsSmartDeviceLinkRPCV2::VehicleDataResultCode>* ReadDIDResponse::get_dataResult(void) +{ + return dataResult; +} + +bool ReadDIDResponse::set_dataResult(const std::vector< NsSmartDeviceLinkRPCV2::VehicleDataResultCode>& dataResult_) +{ + if(dataResult) delete dataResult; + dataResult=new std::vector< NsSmartDeviceLinkRPCV2::VehicleDataResultCode>(dataResult_); + return true; +} + +void ReadDIDResponse::reset_dataResult(void) +{ + if(dataResult) delete dataResult; + dataResult=0; +} + +const std::vector< std::string>* ReadDIDResponse::get_data(void) +{ + return data; +} + +bool ReadDIDResponse::set_data(const std::vector< std::string>& data_) +{ + if(data) delete data; + data=new std::vector< std::string>(data_); + return true; +} + +void ReadDIDResponse::reset_data(void) +{ + if(data) delete data; + data=0; +} + +bool ReadDIDResponse::checkIntegrity(void) +{ + return ReadDIDResponseMarshaller::checkIntegrity(*this); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.cpp b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.cpp new file mode 100644 index 000000000..618c98f11 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.cpp @@ -0,0 +1,206 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDIDResponse.h" +#include "../src/SDLRPCObjectsImpl/V2/VehicleDataResultCodeMarshaller.h" +#include "../src/SDLRPCObjectsImpl/V2/ResultMarshaller.h" +#include "../src/../src/RPC2ObjectsImpl//NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.h" + +/* + interface NsRPC2Communication::VehicleInfo + version 1.2 + generated at Thu Jan 24 06:41:15 2013 + source stamp Wed Jan 23 13:56:28 2013 + author RC +*/ + +using namespace NsRPC2Communication::VehicleInfo; + +bool ReadDIDResponseMarshaller::checkIntegrity(ReadDIDResponse& s) +{ + return checkIntegrityConst(s); +} + + +bool ReadDIDResponseMarshaller::fromString(const std::string& s,ReadDIDResponse& e) +{ + try + { + Json::Reader reader; + Json::Value json; + if(!reader.parse(s,json,false)) return false; + if(!fromJSON(json,e)) return false; + } + catch(...) + { + return false; + } + return true; +} + + +const std::string ReadDIDResponseMarshaller::toString(const ReadDIDResponse& e) +{ + Json::FastWriter writer; + return checkIntegrityConst(e) ? writer.write(toJSON(e)) : ""; +} + + +bool ReadDIDResponseMarshaller::checkIntegrityConst(const ReadDIDResponse& s) +{ + if(s.dataResult) + { + unsigned int i=s.dataResult[0].size(); + if(i<0) return false; + if(i>1000) return false; + } + + if(s.data) + { + unsigned int i=s.data[0].size(); + if(i<0) return false; + if(i>1000) return false; + while(i--) + { + if(s.data[0][i].length()>5000) return false; + } + } + + return true; +} + + +Json::Value ReadDIDResponseMarshaller::toJSON(const ReadDIDResponse& e) +{ + Json::Value json(Json::objectValue); + if(!checkIntegrityConst(e)) + return Json::Value(Json::nullValue); + + json["jsonrpc"]=Json::Value("2.0"); + json["id"]=Json::Value(e.getId()); + json["result"]=Json::Value(Json::objectValue); + NsSmartDeviceLinkRPCV2::Result r(static_cast<NsSmartDeviceLinkRPCV2::Result::ResultInternal>(e.getResult())); + json["result"]["resultCode"]=NsSmartDeviceLinkRPCV2::ResultMarshaller::toJSON(r); + json["result"]["method"]=Json::Value("VehicleInfo.ReadDIDResponse"); + + if(e.dataResult) + { + unsigned int i=e.dataResult[0].size(); + Json::Value j=Json::Value(Json::arrayValue); + j.resize(i); + while(i--) + j[i]=NsSmartDeviceLinkRPCV2::VehicleDataResultCodeMarshaller::toJSON(e.dataResult[0][i]); + + json["result"]["dataResult"]=j; + } + if(e.data) + { + unsigned int i=e.data[0].size(); + Json::Value j=Json::Value(Json::arrayValue); + j.resize(i); + while(i--) + j[i]=Json::Value(e.data[0][i]); + + json["result"]["data"]=j; + } + return json; +} + + +bool ReadDIDResponseMarshaller::fromJSON(const Json::Value& json,ReadDIDResponse& c) +{ + try + { + if(!json.isObject()) return false; + if(!json.isMember("jsonrpc") || !json["jsonrpc"].isString() || json["jsonrpc"].asString().compare("2.0")) return false; + if(!json.isMember("id") || !json["id"].isInt()) return false; + c.setId(json["id"].asInt()); + + if(!json.isMember("result")) return false; + + Json::Value js=json["result"]; + if(!js.isObject()) return false; + + NsSmartDeviceLinkRPCV2::Result r; + if(!js.isMember("resultCode") || !js["resultCode"].isString()) return false; + if(!js.isMember("method") || !js["method"].isString()) return false; + if(js["method"].asString().compare("VehicleInfo.ReadDIDResponse")) return false; + + if(!NsSmartDeviceLinkRPCV2::ResultMarshaller::fromJSON(js["resultCode"],r)) return false; + c.setResult(r.get()); + if(c.dataResult) delete c.dataResult; + c.dataResult=0; + if(js.isMember("dataResult")) + { + if(!js["dataResult"].isArray()) return false; + unsigned int i=js["dataResult"].size(); + if(i<0) return false; + if(i>1000) return false; + + c.dataResult=new std::vector<NsSmartDeviceLinkRPCV2::VehicleDataResultCode>(); + c.dataResult->resize(js["dataResult"].size()); + + while(i--) + if(!NsSmartDeviceLinkRPCV2::VehicleDataResultCodeMarshaller::fromJSON(js["dataResult"][i],c.dataResult[0][i])) return false; + } + + + if(c.data) delete c.data; + c.data=0; + if(js.isMember("data")) + { + if(!js["data"].isArray()) return false; + unsigned int i=js["data"].size(); + if(i<0) return false; + if(i>1000) return false; + + c.data=new std::vector<std::string>(); + c.data->resize(js["data"].size()); + + while(i--) + { + if(!js["data"][i].isString()) + return false; + + c.data[0][i]=js["data"][i].asString(); + if(c.data[0][i].length()>5000) return false; + } + } + + + } + catch(...) + { + return false; + } + return checkIntegrity(c); +} diff --git a/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.h b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.h new file mode 100644 index 000000000..597656970 --- /dev/null +++ b/SDL_Core/src/components/JSONHandler/src/RPC2ObjectsImpl/NsRPC2Communication/VehicleInfo/ReadDIDResponseMarshaller.h @@ -0,0 +1,60 @@ +// +// Copyright (c) 2013, Ford Motor Company +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. +// +// Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following +// disclaimer in the documentation and/or other materials provided with the +// distribution. +// +// Neither the name of the Ford Motor Company nor the names of its contributors +// may be used to endorse or promote products derived from this software +// without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// + +#ifndef NSRPC2COMMUNICATION_VEHICLEINFO_READDIDRESPONSEMARSHALLER_INCLUDE +#define NSRPC2COMMUNICATION_VEHICLEINFO_READDIDRESPONSEMARSHALLER_INCLUDE + +#include <string> +#include <json/json.h> + +#include "../src/../include/JSONHandler/RPC2Objects/NsRPC2Communication/VehicleInfo/ReadDIDResponse.h" + +namespace NsRPC2Communication +{ + namespace VehicleInfo + { + + struct ReadDIDResponseMarshaller + { + static bool checkIntegrity(ReadDIDResponse& e); + static bool checkIntegrityConst(const ReadDIDResponse& e); + + static bool fromString(const std::string& s,ReadDIDResponse& e); + static const std::string toString(const ReadDIDResponse& e); + + static bool fromJSON(const Json::Value& s,ReadDIDResponse& e); + static Json::Value toJSON(const ReadDIDResponse& e); + }; + } +} + +#endif |