Skip to content

Commit

Permalink
Merge pull request #10 from CustomSDL/feature/REVSDL-967-moduleTypes
Browse files Browse the repository at this point in the history
Feature/revsdl 967 module types
  • Loading branch information
Konstantin Kolodii committed Jun 1, 2015
2 parents 9a63ddd + c2009e8 commit e1474a1
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 5 deletions.
39 changes: 35 additions & 4 deletions src/components/can_cooperation/reverse_sdl_pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,35 @@
"LIMITED"]
}
}
},
"RemoteControl": {
"rpcs": {
"ButtonPress": {
"hmi_levels": ["BACKGROUND",
"FULL",
"LIMITED"]
},
"GetInteriorVehicleDataCapabilities": {
"hmi_levels": ["BACKGROUND",
"FULL",
"LIMITED"]
},
"GetInteriorVehicleData": {
"hmi_levels": ["BACKGROUND",
"FULL",
"LIMITED"]
},
"SetInteriorVehicleData": {
"hmi_levels": ["BACKGROUND",
"FULL",
"LIMITED"]
},
"OnInteriorVehicleData": {
"hmi_levels": ["BACKGROUND",
"FULL",
"LIMITED"]
}
}
}
},
"consumer_friendly_messages": {
Expand Down Expand Up @@ -2356,18 +2385,20 @@
"steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
"moduleType": ["RADIO"],
"groups": ["Base-4"],
"groups_primaryRC": ["Base-4", "Base-RC", "Radio", "Climate"],
"groups_nonPrimaryRC": ["Base-RC", "Radio", "Climate", "Notifications-RC"]
"groups_primaryRC": ["Base-4", "Base-RC", "Radio", "Climate", "RemoteControl"],
"groups_nonPrimaryRC": ["Base-RC", "Radio", "Climate", "Notifications-RC", "RemoteControl"]
},
"8675311": {
"keep_context": false,
"steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
"moduleType": ["RADIO", "CLIMATE"],
"groups": ["Base-4"],
"groups_primaryRC": ["Base-4", "Base-RC", "Radio", "Climate"],
"groups_nonPrimaryRC": ["Base-RC", "Radio", "Climate", "Notifications-RC"],
"groups_primaryRC": ["Base-4", "Base-RC", "Radio", "Climate", "RemoteControl"],
"groups_nonPrimaryRC": ["Base-RC", "Radio", "Climate", "Notifications-RC", "RemoteControl"],
"AppHMIType": ["REMOTE_CONTROL"]
},
"device": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroupsPrimary;
extern const std::string kSelectAppGroupsNonPrimary;
extern const std::string kSelectNicknames;
extern const std::string kSelectAppTypes;
extern const std::string kSelectModuleTypes;
extern const std::string kSelectSecondsBetweenRetries;
extern const std::string kSelectIgnitionCycles;
extern const std::string kSelectKilometers;
Expand All @@ -79,6 +80,7 @@ extern const std::string kInsertAppGroupPrimary;
extern const std::string kInsertAppGroupNonPrimary;
extern const std::string kInsertNickname;
extern const std::string kInsertAppType;
extern const std::string kInsertModuleType;
extern const std::string kInsertMessageType;
extern const std::string kInsertLanguage;
extern const std::string kInsertMessageString;
Expand All @@ -105,12 +107,14 @@ extern const std::string kDeleteAllDevices;
extern const std::string kIncrementIgnitionCycles;
extern const std::string kResetIgnitionCycles;
extern const std::string kUpdateFlagUpdateRequired;
extern const std::string kUpdateRemoteControlDenied;
extern const std::string kSelectFlagUpdateRequired;
extern const std::string kUpdateCountersSuccessfulUpdate;
extern const std::string kSelectApplicationRevoked;
extern const std::string kUpdateApplicationCustomData;
extern const std::string kSelectApplicationRepresented;
extern const std::string kSelectApplicationIsDefault;
extern const std::string kSelectRemoteControlDenied;
extern const std::string kUpdateIsDefault;
extern const std::string kInsertInitData;
extern const std::string kDeleteAppGroupByApplicationId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,17 @@ class SQLPTRepresentation : public virtual PTRepresentation {
policy_table::Strings* app_groups) const;
bool GatherAppGroupNonPrimary(const std::string& app_id,
policy_table::Strings* app_groups) const;
bool GatherModuleType(const std::string& app_id,
policy_table::ModuleTypes* module_types) const;
bool GatherRemoteControlDenied(const std::string& app_id,
bool* denied) const;
bool SaveAppGroupPrimary(const std::string& app_id,
const policy_table::Strings& app_groups);
bool SaveAppGroupNonPrimary(const std::string& app_id,
const policy_table::Strings& app_groups);
bool SaveModuleType(const std::string& app_id,
const policy_table::ModuleTypes& types);
bool SaveRemoteControlDenied(const std::string& app_id, bool deny);
#endif // SDL_REMOTE_CONTROL

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,32 @@ bool EnumFromJsonString(const std::string& literal, Input* result) {
}
}

bool IsValidEnum(ModuleType val) {
switch (val) {
case MT_CLIMATE: return true;
case MT_RADIO: return true;
default: return false;
}
}
const char* EnumToJsonString(ModuleType val) {
switch (val) {
case MT_CLIMATE: return "CLIMATE";
case MT_RADIO: return "RADIO";
default: return "";
}
}
bool EnumFromJsonString(const std::string& literal, ModuleType* result) {
if ("CLIMATE" == literal) {
*result = MT_CLIMATE;
return true;
} else if ("RADIO" == literal) {
*result = MT_RADIO;
return true;
} else {
return false;
}
}

const std::string kDefaultApp = "default";
const std::string kPreDataConsentApp = "pre_DataConsent";
const std::string kDeviceApp = "device";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ bool IsValidEnum(Input val);
const char* EnumToJsonString(Input val);
bool EnumFromJsonString(const std::string& literal, Input* result);

enum ModuleType {
MT_CLIMATE,
MT_RADIO,
};
bool IsValidEnum(ModuleType val);
const char* EnumToJsonString(ModuleType val);
bool EnumFromJsonString(const std::string& literal, ModuleType* result);

extern const std::string kDefaultApp;
extern const std::string kPreDataConsentApp;
extern const std::string kDeviceApp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__)
groups_primaryRC(impl::ValueMember(value__, "groups_primaryRC")),
groups_nonPrimaryRC(impl::ValueMember(value__, "groups_nonPrimaryRC")),
nicknames(impl::ValueMember(value__, "nicknames")),
moduleType(impl::ValueMember(value__, "moduleType")),
AppHMIType(impl::ValueMember(value__, "AppHMIType")),
priority(impl::ValueMember(value__, "priority")),
memory_kb(impl::ValueMember(value__, "memory_kb")),
Expand All @@ -50,6 +51,7 @@ Json::Value ApplicationParams::ToJsonValue() const {
impl::WriteJsonField("groups_primaryRC", groups_primaryRC, &result__);
impl::WriteJsonField("groups_nonPrimaryRC", groups_nonPrimaryRC, &result__);
impl::WriteJsonField("nicknames", nicknames, &result__);
impl::WriteJsonField("moduleType", moduleType, &result__);
impl::WriteJsonField("AppHMIType", AppHMIType, &result__);
impl::WriteJsonField("priority", priority, &result__);
impl::WriteJsonField("memory_kb", memory_kb, &result__);
Expand Down Expand Up @@ -103,6 +105,9 @@ bool ApplicationParams::struct_empty() const {
if (nicknames.is_initialized()) {
return false;
}
if (moduleType.is_initialized()) {
return false;
}

if (AppHMIType.is_initialized()) {
return false;
Expand Down Expand Up @@ -139,6 +144,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const {
if (!nicknames.is_valid()) {
nicknames.ReportErrors(&report__->ReportSubobject("nicknames"));
}
if (!moduleType.is_valid()) {
moduleType.ReportErrors(&report__->ReportSubobject("moduleType"));
}
if (!AppHMIType.is_valid()) {
AppHMIType.ReportErrors(&report__->ReportSubobject("AppHMIType"));
}
Expand All @@ -162,6 +170,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) {
groups.SetPolicyTableType(pt_type);
groups_primaryRC.SetPolicyTableType(pt_type);
groups_nonPrimaryRC.SetPolicyTableType(pt_type);
moduleType.SetPolicyTableType(pt_type);
priority.SetPolicyTableType(pt_type);
memory_kb.SetPolicyTableType(pt_type);
heart_beat_timeout_ms.SetPolicyTableType(pt_type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ typedef Array< String<1, 255>, 0, 255 > Strings;

typedef Array< Enum<AppHMIType>, 0, 255 > AppHMITypes;

typedef Array< Enum<ModuleType>, 0, 255 > ModuleTypes;

typedef Array< Enum<HmiLevel>, 0, 4 > HmiLevels;

typedef Array< Enum<Parameter>, 0, 24 > Parameters;
Expand Down Expand Up @@ -63,6 +65,7 @@ struct ApplicationParams : CompositeType {
Optional< Strings > groups_primaryRC;
Optional< Strings > groups_nonPrimaryRC;
Optional< Strings > nicknames;
mutable Optional< ModuleTypes > moduleType;
Optional< AppHMITypes > AppHMIType;
Enum<Priority> priority;
Optional< Integer<uint16_t, 0, 65225> > memory_kb;
Expand All @@ -81,6 +84,7 @@ struct ApplicationParams : CompositeType {
virtual void SetPolicyTableType(PolicyTableType pt_type);
private:
bool Validate() const;
bool ValidateModuleTypes() const;
};

struct RpcParameters : CompositeType {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
// This file is generated, do not edit
#include <algorithm>
#include "./types.h"

namespace rpc {
namespace policy_table_interface_base {
bool ApplicationParams::Validate() const {
return ValidateModuleTypes();
}
bool ApplicationParams::ValidateModuleTypes() const {
// moduleType is optional so see Optional<T>::is_valid()
bool is_initialized = moduleType->is_initialized();
if (!is_initialized) {
// valid if not initialized
return true;
}
bool is_valid = moduleType->is_valid();
if (is_valid) {
return true;
}

struct IsInvalid {
bool operator()(Enum<ModuleType> item) const {
return !item.is_valid();
}
};
// cut invalid items
moduleType->erase(std::remove_if(moduleType->begin(), moduleType->end(),
IsInvalid()),
moduleType->end());
bool empty = moduleType->empty();
if (empty) {
// set non initialized value
ModuleTypes non_initialized;
moduleType = Optional<ModuleTypes>(non_initialized);
}
return true;
}

bool RpcParameters::Validate() const {
return true;
}
Expand Down
29 changes: 29 additions & 0 deletions src/components/policy/src/policy/src/sql_pt_queries.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const std::string kCreateSchema =
" `memory_kb` INTEGER NOT NULL, "
" `heart_beat_timeout_ms` INTEGER NOT NULL, "
" `certificate` VARCHAR(45), "
" `remote_control_denied` BOOLEAN NOT NULL DEFAULT 0, "
" CONSTRAINT `fk_application_hmi_level1` "
" FOREIGN KEY(`default_hmi`) "
" REFERENCES `hmi_level`(`value`), "
Expand Down Expand Up @@ -305,6 +306,19 @@ const std::string kCreateSchema =
"); "
"CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` "
" ON `app_type`(`application_id`); "

/* module type */
"CREATE TABLE IF NOT EXISTS `module_type`( "
" `name` VARCHAR(50) NOT NULL, "
" `application_id` VARCHAR(45) NOT NULL, "
" PRIMARY KEY(`name`,`application_id`), "
" CONSTRAINT `fk_module_type_application1` "
" FOREIGN KEY(`application_id`) "
" REFERENCES `application`(`id`) "
"); "
"CREATE INDEX IF NOT EXISTS `module_type.fk_module_type_application1_idx` "
" ON `module_type`(`application_id`); "

"CREATE TABLE IF NOT EXISTS `consent_group`( "
" `device_id` VARCHAR(100) NOT NULL, "
" `application_id` VARCHAR(45) NOT NULL, "
Expand Down Expand Up @@ -397,6 +411,8 @@ const std::string kDropSchema =
"DROP TABLE IF EXISTS `consent_group`; "
"DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; "
"DROP TABLE IF EXISTS `app_type`; "
"DROP INDEX IF EXISTS `module_type.fk_module_type_application1_idx`; "
"DROP TABLE IF EXISTS `module_type`; "
"DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; "
"DROP TABLE IF EXISTS `nickname`; "
"DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; "
Expand Down Expand Up @@ -447,6 +463,7 @@ const std::string kDeleteData =
"DELETE FROM `endpoint`; "
"DELETE FROM `consent_group`; "
"DELETE FROM `app_type`; "
"DELETE FROM `module_type`; "
"DELETE FROM `nickname`; "
"DELETE FROM `app_level`; "
"DELETE FROM `device_consent_group`; "
Expand Down Expand Up @@ -531,6 +548,9 @@ const std::string kInsertNickname =
const std::string kInsertAppType =
"INSERT OR IGNORE INTO `app_type` (`application_id`, `name`) VALUES (?, ?)";

const std::string kInsertModuleType =
"INSERT OR IGNORE INTO `module_type` (`application_id`, `name`) VALUES (?, ?)";

const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?";

const std::string kInsertMessageType =
Expand Down Expand Up @@ -660,6 +680,9 @@ const std::string kSelectNicknames = "SELECT DISTINCT `name` FROM `nickname` "
const std::string kSelectAppTypes = "SELECT DISTINCT `name` FROM `app_type` "
"WHERE `application_id` = ?";

const std::string kSelectModuleTypes =
"SELECT DISTINCT `name` FROM `module_type` WHERE `application_id` = ?";

const std::string kSelectSecondsBetweenRetries =
"SELECT `value` FROM `seconds_between_retry` ORDER BY `index`";

Expand Down Expand Up @@ -693,9 +716,15 @@ const std::string kSelectTimeoutResponse =
const std::string kUpdateFlagUpdateRequired =
"UPDATE `module_meta` SET `flag_update_required` = ?";

const std::string kUpdateRemoteControlDenied =
"UPDATE `application` SET `remote_control_denied` = ? WHERE `id` = ?";

const std::string kSelectFlagUpdateRequired =
"SELECT `flag_update_required` FROM `module_meta` LIMIT 1";

const std::string kSelectRemoteControlDenied =
"SELECT `remote_control_denied` FROM `application` WHERE `id` = ? LIMIT 1";

const std::string kUpdateCountersSuccessfulUpdate =
"UPDATE `module_meta` SET `pt_exchanged_at_odometer_x` = ?,"
"`pt_exchanged_x_days_after_epoch` = ?";
Expand Down
Loading

0 comments on commit e1474a1

Please sign in to comment.