diff options
author | Kevron Rees <tripzero.kev@gmail.com> | 2014-09-02 09:59:42 -0700 |
---|---|---|
committer | Kevron Rees <tripzero.kev@gmail.com> | 2014-09-02 09:59:42 -0700 |
commit | 6dcc2d6cfe5428bfe659bbbdbd1067532c66685e (patch) | |
tree | 1c4985e4cc490b096f15e850e7a5d4b196db22cd | |
parent | 0cb6735cab8943e5d1242cc105b8511dcee43bc9 (diff) | |
parent | 713f6cc4dd059774630345e68025e86911c6420f (diff) | |
download | automotive-message-broker-6dcc2d6cfe5428bfe659bbbdbd1067532c66685e.tar.gz |
Merge pull request #20 from tripzero/master0.11.900
0.11.900
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | RELEASE | 5 | ||||
-rw-r--r-- | ambd/core.cpp | 7 | ||||
-rw-r--r-- | ambd/core.h | 2 | ||||
-rw-r--r-- | docs/amb.idl | 343 | ||||
-rw-r--r-- | lib/abstractpropertytype.h | 41 | ||||
-rw-r--r-- | lib/abstractroutingengine.h | 28 | ||||
-rw-r--r-- | lib/vehicleproperty.cpp | 106 | ||||
-rw-r--r-- | lib/vehicleproperty.h | 109 | ||||
-rw-r--r-- | plugins/database/databasesink.cpp | 51 | ||||
-rw-r--r-- | plugins/database/databasesink.h | 14 | ||||
-rw-r--r-- | plugins/dbus/custompropertyinterface.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/dbusinterfacemanager.cpp | 9 | ||||
-rw-r--r-- | plugins/dbus/dbusplugin.h | 12 | ||||
-rw-r--r-- | plugins/dbus/drivingsafety.h | 18 | ||||
-rw-r--r-- | plugins/dbus/environmentproperties.h | 59 | ||||
-rw-r--r-- | plugins/dbus/maintenance.h | 61 | ||||
-rw-r--r-- | plugins/dbus/runningstatus.h | 81 | ||||
-rw-r--r-- | plugins/dbus/uncategorizedproperty.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/varianttype.cpp | 2 | ||||
-rw-r--r-- | plugins/dbus/varianttype.h | 2 | ||||
-rw-r--r-- | plugins/exampleplugin.cpp | 10 | ||||
-rw-r--r-- | plugins/testplugin/testplugin.cpp | 15 | ||||
-rw-r--r-- | plugins/testplugin/testplugin.h | 4 | ||||
-rw-r--r-- | plugins/wheel/wheelplugin.cpp | 220 | ||||
-rwxr-xr-x | tests/amb-set | 2 |
26 files changed, 881 insertions, 328 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 77213034..89f211ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,9 @@ set(CMAKE_BUILD_TYPE, Debug) include(FindPkgConfig) set(PROJECT_NAME "automotive-message-broker") -set(PROJECT_VERSION "0.11.812") +set(PROJECT_VERSION "0.11.900") set(PROJECT_CODENAME "veyron") -set(PROJECT_QUALITY "alpha") +set(PROJECT_QUALITY "beta") add_definitions(-DPROJECT_VERSION="${PROJECT_VERSION}") add_definitions(-DPROJECT_NAME="${PROJECT_NAME}") @@ -14,7 +14,10 @@ Changes: the last pid that called FindObject* disconnects from DBus (or closes). - Many internal stl containers have been changed to use more efficient ones. - Some internal methods changed to const & references to avoid copies. -- DBus plugin will no cache unsubscribed values. Improves performance. +- DBus plugin will not cache unsubscribed values. Improves performance. +- Many DBus API changes. See new docs/amb.idl. Several interfaces are deprecated and replaced with + more w3c compliant interfaces. +-- Fuel interface units changed Fixes: - database plugin updated to use zones diff --git a/ambd/core.cpp b/ambd/core.cpp index cdbb862d..9911cc10 100644 --- a/ambd/core.cpp +++ b/ambd/core.cpp @@ -147,7 +147,7 @@ PropertyList Core::supported() return supportedProperties; } -void Core::updateProperty(AbstractPropertyType *value, const string &uuid) +void Core::updateProperty(AbstractPropertyType *value, const string & uuid) { if(value->sourceUuid != uuid) { @@ -448,7 +448,7 @@ PropertyInfo Core::getPropertyInfo(const VehicleProperty::Property &property, co return (*theSource)->getPropertyInfo(property); } -std::list<string> Core::sourcesForProperty(VehicleProperty::Property property) +std::list<string> Core::sourcesForProperty(const VehicleProperty::Property & property) { std::list<std::string> list; @@ -465,9 +465,6 @@ std::list<string> Core::sourcesForProperty(VehicleProperty::Property property) } } - //DebugOut(1)<<__FUNCTION__<<"sources list: " << endl; - //for_each(list.begin(), list.end(), [](const std::string& str){ DebugOut(1)<<__FUNCTION__<< str << endl; }); - return list; } diff --git a/ambd/core.h b/ambd/core.h index f98d6616..4ff68ef7 100644 --- a/ambd/core.h +++ b/ambd/core.h @@ -78,7 +78,7 @@ public: PropertyList supported(); PropertyInfo getPropertyInfo(const VehicleProperty::Property &,const std::string &sourceUuid); - std::list<std::string> sourcesForProperty(VehicleProperty::Property property); + std::list<std::string> sourcesForProperty(const VehicleProperty::Property & property); struct Performance { Performance(): propertiesPerSecond(0), firedPropertiesPerSecond(0) {} diff --git a/docs/amb.idl b/docs/amb.idl index cbf7bd85..40e5b04c 100644 --- a/docs/amb.idl +++ b/docs/amb.idl @@ -241,47 +241,66 @@ interface org.automotive.Acceleration extends VehiclePropertyType { attribute UInt16 Z readonly } +enumeration TransmissionMode { + park = "park", + reverse = "reverse", + neutral = "neutral", + low = "low", + drive = "drive", + overdrive = "overdrive" +} -interface org.automotive.Transmission extends VehiclePropertyType { - const UInt16 TRANSMISSIONPOSITION_NEUTRAL = 0; - const UInt16 TRANSMISSIONPOSITION_FIRST = 1; - const UInt16 TRANSMISSIONPOSITION_SECOND = 2; - const UInt16 TRANSMISSIONPOSITION_THIRD = 3; - const UInt16 TRANSMISSIONPOSITION_FORTH = 4; - const UInt16 TRANSMISSIONPOSITION_FIFTH = 5; - const UInt16 TRANSMISSIONPOSITION_SIXTH = 6; - const UInt16 TRANSMISSIONPOSITION_SEVENTH = 7; - const UInt16 TRANSMISSIONPOSITION_EIGHTH = 8; - const UInt16 TRANSMISSIONPOSITION_NINTH = 9; - const UInt16 TRANSMISSIONPOSITION_TENTH = 10; - const UInt16 TRANSMISSIONPOSITION_CVT = 64; - const UInt16 TRANSMISSIONPOSITION_REVERSE = 128; - const UInt16 TRANSMISSIONPOSITION_PARK = 255; - const UInt16 TRANSMISSIONMODE_NORMAL = 0; - const UInt16 TRANSMISSIONMODE_SPORT = 1; - const UInt16 TRANSMISSIONMODE_ECONOMY = 2; - const UInt16 TRANSMISSIONMODE_OEMCUSTOM1 = 3; - const UInt16 TRANSMISSIONMODE_OEMCUSTOM2 = 4; +/*! TransmissionPosition + * \brief Describes Transmission Pistion. Deprecated. Will disappear in 0.13 + */ +enumeration TransmissionPosition { + Neutral = 0, + First = 1, + Second = 2, + Third = 3, + Fourth = 4, + Fifth = 5, + Sixth = 6, + Seventh = 7, + Eighth = 8, + Ninth = 9, + Tenth = 10, + Cvt = 64, + Reverse = 128, + Park = 255 +} + +/*! TransmissionGearType + * \brief Describes the transmission gearbox type +*/ +enumeration TransmissionGearType +{ + Auto = 0, + Manual = 1, + CVT = 2 +} +interface org.automotive.Transmission extends VehiclePropertyType { /*! GearPosition - * \brief Must return transmission gear position (see TRANSMISSIONPOSITION) + * \brief Must return transmission gear position (see TRANSMISSIONPOSITION) Deprecated. Replaced with Gear */ - attribute UInt8 GearPosition readonly - - const UInt16 TRANSMISSIONGEARTYPE_AUTO=0; - const UInt16 TRANSMISSIONGEARTYPE_MANUAL=1; - const UInt16 TRANSMISSIONGEARTYPE_CV=2; + attribute TransmissionPosition GearPosition readonly /*! TransmissionGearType * \brief MUST return transmission gear type of either Automatic, Manual or Constant Variable (CV). * See TRANSMISSIONGEARTYPE */ - attribute UInt8 Type; + attribute TransmissionGearType Type; + + /*! Gear + * \brief Must return transmission gear position 1-10 + */ + attribute UInt8 Gear readonly /*! Mode - * \brief Must return transmission Mode (see + * \brief Must return transmission Mode */ - attribute UInt8 Mode readonly + attribute TransmissionMode Mode readonly } @@ -298,7 +317,9 @@ interface org.automotive.CruiseControlStatus extends VehiclePropertyType { attribute UInt16 Speed readonly } - +/*! + * Deprecated. Use BrakeOperation. Remove in 0.13 + */ interface org.automotive.WheelBrake extends VehiclePropertyType { /*! Engaged @@ -307,6 +328,13 @@ interface org.automotive.WheelBrake extends VehiclePropertyType { attribute Boolean Engaged readonly } +interface org.automotive.BrakeOperation extends VehiclePropertyType { + + /*! BrakePedalDepressed + * \brief must return whether brake pedal is depressed or not. true: brake pedal is depressed, false: brake pedal is not depressed + */ + attribute Boolean BrakePedalDepressed readonly +} interface org.automotive.LightStatus extends VehiclePropertyType { @@ -349,6 +377,16 @@ interface org.automotive.LightStatus extends VehiclePropertyType { * \brief Must return high beam status: on = true, off = false. */ attribute Boolean HighBeam readonly + + /*! AutomaticHeadlights + * \brief Must return automatic headlight status: on = true, off = false. + */ + attribute Boolean AutomaticHeadlights readonly + + /*! DynamicHighBeam + * \brief Must return dynamic high beam status: on = true, off = false. + */ + attribute Boolean DynamicHighBeam readonly } @@ -388,14 +426,14 @@ interface org.automotive.Fuel extends VehiclePropertyType { attribute UInt16 Level readonly /*! Range - * \brief Must return estimated fuel range in kilometers. + * \brief Must return estimated fuel range in meters. */ - attribute UInt16 Range readonly + attribute UInt32 Range readonly /*! InstantConsumption - * \brief Must return instant fuel consumption in microiliters of fuel per second. + * \brief Must return instant fuel consumption in per distance travelled (Unit: milliliters per 100 kilometers). */ - attribute UInt16 InstantConsumption readonly + attribute UInt32 InstantConsumption readonly /*! InstantEconomy * \brief Must return instant fuel 'economy' in kilometers per liter of fuel. @@ -406,6 +444,21 @@ interface org.automotive.Fuel extends VehiclePropertyType { * \brief Must return average fuel 'economy' in kilometers per liter of fuel since last reset. Setting this to any value should reset the counter to '0' */ attribute UInt16 AverageEconomy; + + /*! AverageConsumption + * \brief Must return average fuel consumption in per distance travelled (Unit: milliliters per 100 kilometers). Setting this to any value should reset the counter to '0' + */ + attribute UInt32 AverageConsumption; + + /*! FuelConsumedSinceRestart + * \brief must return fuel consumed since engine start; (Unit: milliliters per 100 kilometers) resets to 0 each restart + */ + attribute UInt32 FuelConsumedSinceRestart readonly; + + /*! FuelConsumedSinceRestart + * \brief must return fuel consumed since engine start; (Unit: milliliters per 100 kilometers) resets to 0 each restart + */ + attribute UInt32 FuelConsumedSinceRestart readonly; } @@ -466,12 +519,24 @@ interface org.automotive.Temperature extends VehiclePropertyType { /*! Interior * \brief Must return the temperature of the interior of the vehicle in celcius. */ + /// Deprecated. Use InteriorTemperature. Remove in 0.13 attribute signed short Interior readonly /*! Exterior * \brief Must return the temperature of the exterior of the vehicle in celcius. */ + /// Deprecated. Use ExteriorTemperature. Remove in 0.13 attribute signed short Exterior readonly + + /*! Interior + * \brief Must return the temperature of the interior of the vehicle in celcius. + */ + attribute signed short InteriorTemperature readonly + + /*! Exterior + * \brief Must return the temperature of the exterior of the vehicle in celcius. + */ + attribute signed short ExteriorTemperature readonly } @@ -496,7 +561,8 @@ interface org.automotive.WindshieldWiper extends VehiclePropertyType { attribute UInt16 WindshieldWiper readonly } - +/*! Deprecated. Use ClimateControl interface. Remove in 0.13 +*/ interface org.automotive.HVAC extends VehiclePropertyType { const UInt16 AIRFLOWDIRECTION_FRONTPANEL = 0; const UInt16 AIRFLOWDIRECTION_FLOORDUCT= 1; @@ -549,6 +615,60 @@ interface org.automotive.HVAC extends VehiclePropertyType { attribute Boolean SeatCooler; } +enumeration AirflowDirectionType +{ + frontpanel = "frontpanel", + floorduct = "floorduct", + bilevel = "bilevel", + defrostfloor = "defrostfloor" +} + +interface org.automotive.ClimateControl extends VehiclePropertyType { + /*! AirflowDirection + * \brief Must return current status of the direction of the air flow through the ventilation system + */ + attribute AirflowDirectionType AirflowDirection; + + /*! FanSpeedLevel + * \brief Must return seat heater status: on (true) / off (false). + */ + attribute UInt8 FanSpeedLevel; + + /*! TargetTemperature + * \brief Must return current setting of the desired temperature (Unit: celsius) + */ + attribute Int8 TargetTemperature; + + /*! AirConditioning + * \brief Must return current status of the air conditioning system: on (true) or off (false) + */ + attribute Boolean AirConditioning; + + /*! Heater + * \brief Must return current status of the heating system: on (true) or off (false) + */ + attribute Boolean Heater; + + /*! SeatHeater + * \brief Must return current status of the seat warmer ( 0: off, 1: least warm, 10: warmest ) + */ + attribute UInt8 SeatHeater; + + /*! SeatCooler + * \brief Must return current status of the seat ventilation ( 0: off, 1: least warm, 10: warmest ) + */ + attribute UInt8 SeatCooler; + + /*! AirRecirculation + * \brief Must return current setting of air recirculation: on (true) or pulling in outside air (false). + */ + attribute Boolean AirRecirculation; + + /*! SteeringWheelHeater + * \brief Must return current status of steering wheel heater ( 0: off, 1: least warm, 10: warmest ). + */ + attribute UInt8 SteeringWheelHeater; +} interface org.automotive.WindowStatus extends VehiclePropertyType { @@ -560,10 +680,25 @@ interface org.automotive.WindowStatus extends VehiclePropertyType { /*! Defrost * \brief Must return the defroster status of the window. On = true, Off = false. + * Deprecated. Use Defrost interface. Remove in 0.13. */ attribute Boolean Defrost; } +interface org.automotive.Defrost extends VehiclePropertyType { + + /*! DefrostWindow + * \brief Must return current status of the defrost switch for mirrors. It can be + * used to send user's request for changing setting. + */ + attribute Boolean DefrostWindow; + + /*! DefrostMirrors + * \brief Must return current status of the defrost switch for window. It can be + * used to send user's request for changing setting. + */ + attribute Boolean DefrostMirrors; +} interface org.automotive.Sunroof extends VehiclePropertyType { @@ -701,7 +836,19 @@ interface org.automotive.Odometer extends VehiclePropertyType { /*! Odometer * \brief MUST return Distance traveled in km */ - attribute UInt16 Odometer readonly + /// Deprecated. Use DistanceTotal. Remove in 0.13 + attribute UInt32 Odometer readonly + + /*! DistnaceTotal + * \brief MUST return Distance traveled in m + */ + attribute UInt32 DistanceTotal readonly + + /*! DistanceSinceStart + * \brief MUST return Distance traveled since start in m + */ + attribute UInt32 DistanceSinceStart readonly + } @@ -723,7 +870,7 @@ interface org.automotive.Fluid extends VehiclePropertyType { attribute UInt16 Washer readonly } - +/// Deprecated. Use BatteryStatus. Remove in 0.13 interface org.automotive.Battery extends VehiclePropertyType { /*! Voltage @@ -737,18 +884,41 @@ interface org.automotive.Battery extends VehiclePropertyType { attribute Double Current readonly } +interface org.automotive.BatteryStatus extends VehiclePropertyType { + + /*! Voltage + * \brief MUST return battery voltage. + */ + attribute UInt8 Voltage readonly + + /*! Current + * \brief MUST return battery current in Amperes + */ + attribute UInt8 Current readonly + + /*! ChargeLevel + * \brief MUST return battery charge level (Unit: percentage, 0%: empty, 100%: full). + */ + attribute UInt8 ChargeLevel readonly +} + interface org.automotive.Tire extends VehiclePropertyType { /*! Pressure * \brief MUST return tire pressure in kPa. */ - attribute Double Pressure readonly + attribute UInt16 Pressure readonly /*! Temperature * \brief MUST return left front tire temperature in Celcius. */ - attribute Double Temperature readonly + attribute Int16 Temperature readonly + + /*! Temperature + * \brief MUST return true if any tire pressure is low: pressure low (true), pressure not low (false). + */ + attribute Boolean PressureLow readonly } @@ -760,7 +930,7 @@ interface org.automotive.SecurityAlert extends VehiclePropertyType { attribute Boolean SecurityAlert readonly } - +/// Deprecated. Use LightStatus. remove in 0.13 interface org.automotive.ParkingBrake extends VehiclePropertyType { /*! ParkingBrake @@ -769,7 +939,7 @@ interface org.automotive.ParkingBrake extends VehiclePropertyType { attribute Boolean ParkingBrake readonly } - +/// Deprecated. Use LightStatus. remove in 0.13 interface org.automotive.ParkingLight extends VehiclePropertyType { /*! ParkingLight @@ -778,7 +948,7 @@ interface org.automotive.ParkingLight extends VehiclePropertyType { attribute Boolean ParkingLight readonly } - +/// Deprecated. Use LightStatus. remove in 0.13 interface org.automotive.HazardLight extends VehiclePropertyType { /*! HazardLight @@ -827,15 +997,20 @@ interface org.automotive.AirbagStatus extends VehiclePropertyType { attribute UInt16 AirbagStatus readonly } +enumeration +/*! + * Deprecated. Use "Door". Remove in 0.13 + */ interface org.automotive.DoorStatus extends VehiclePropertyType { - const UInt16 DOORSTATUS_CLOSED = 0; - const UInt16 DOORSTATUS_OPEN = 1; - const UInt16 DOORSTATUS_AJAR = 2; + /*! DoorStatus - * \brief MUST returns Door status (byte). See DOORSTATUS_* + * \brief MUST returns Door status (byte). + * CLOSED = 0 + * OPEN = 1 + * AJAR = 2 */ attribute UInt16 DoorStatus readonly @@ -852,6 +1027,32 @@ interface org.automotive.DoorStatus extends VehiclePropertyType { attribute Boolean ChildLockStatus; } +enumeration DoorStatus { + open = "open", + ajar = "ajar", + closed = "closed" +} + +interface org.automotive.Door extends VehiclePropertyType { + + /*! Status + * \brief MUST returns Door status (byte). See DOORSTATUS_* + */ + attribute DoorStatus Status readonly + + /*! Lock + * \brief MUST returns Door status (bool locked = true, unlocked = false). + */ + attribute Boolean Lock; + + /*! ChildLock + * \brief MUST returns Child lock status of rear doors. active = true, inactive = false. + * Setting this to 'true' will prevent the rear doors from being opened + * from the inside. + */ + attribute Boolean ChildLock; +} + interface org.automotive.SeatBelt extends VehiclePropertyType { @@ -884,8 +1085,14 @@ interface org.automotive.NightMode extends VehiclePropertyType { /*! * \brief MUST return whether or not the system is in NightMode or not. True = Night time, False = Day time + * Deprecated. Will be removed in 0.13. Use "Mode" */ attribute Boolean NightMode readonly + + /*! + * \brief MUST return whether or not the system is in NightMode or not. True = Night time, False = Day time + */ + attribute Boolean Mode readonly } @@ -895,6 +1102,11 @@ interface org.automotive.DrivingMode extends VehiclePropertyType { * \brief MUST return whether or not the system is in DrivingMode or not. 1 = Driving, 0 = Not Driving */ attribute UInt16 DrivingMode readonly + + /*! + * \brief must return true if vehicle is in driving mode + */ + attribute Boolean Mode readonly } @@ -1000,7 +1212,11 @@ interface org.automotive.GeneratedVehicleSoundMode extends VehiclePropertyType { } -interface org.automotive.SteeringWheelAngleextends VehiclePropertyType { +/*! SteeringWheelAngle + *\brief + * Deprecated. Use SteeringWheel + */ +interface org.automotive.SteeringWheelAngle extends VehiclePropertyType { /*! * \brief MUST return angle of the steering wheel. 0-359 degrees. @@ -1008,8 +1224,16 @@ interface org.automotive.SteeringWheelAngleextends VehiclePropertyType { attribute UInt16 SteeringWheelAngle readonly } +interface org.automotive.SteeringWheel extends VehiclePropertyType { + + /*! + * \brief MUST return angle of steering wheel off centerline (Unit: degrees -:degrees to the left, +:degrees to the right) + */ + attribute Int16 Angle readonly +} -interface org.automotive.ButtoneEventextends VehiclePropertyType { + +interface org.automotive.ButtoneEvent extends VehiclePropertyType { /*! * \brief MUST return button event: @@ -1032,7 +1256,7 @@ interface org.automotive.ButtoneEventextends VehiclePropertyType { } -interface org.automotive.DriverIdextends VehiclePropertyType { +interface org.automotive.DriverId extends VehiclePropertyType { /*! * \brief MUST return driver ID. Driver Id is an abstract and can be determined @@ -1041,5 +1265,26 @@ interface org.automotive.DriverIdextends VehiclePropertyType { attribute String DriverId readonly } +interface org.automotive.ThrottlePosition extends VehiclePropertyType { + + /*! + * \brief MUST return throttle position as a percentage (Unit: percentage, 0%: closed, 100%: fully open) + */ + attribute Uint8 Value readonly +} + +interface org.automotive.EngineCoolant extends VehiclePropertyType { + + /*! + * \brief MUST return engine coolant level (Unit: percentage 0%: empty, 100%: full) + */ + attribute Uint8 Level readonly + + /*! + * \brief MUST return engine coolant temperature (Unit: celcius) + */ + attribute Uint8 Temperature readonly +} + } diff --git a/lib/abstractpropertytype.h b/lib/abstractpropertytype.h index 98e2b114..f68bfca5 100644 --- a/lib/abstractpropertytype.h +++ b/lib/abstractpropertytype.h @@ -352,6 +352,36 @@ public: return *this; } + BasicPropertyType & operator = (T const & other) + { + setValue(other); + return *this; + } + + BasicPropertyType & operator ++ () + { + setValue(basicValue() + 1); + } + + BasicPropertyType & operator -- () + { + setValue(basicValue() - 1); + } + + BasicPropertyType operator ++ (int) + { + BasicPropertyType<T> temp = *this; + temp.setValue(basicValue() + 1); + return temp; + } + + BasicPropertyType operator -- (int) + { + BasicPropertyType<T> temp = *this; + temp.setValue(basicValue() - 1); + return temp; + } + bool operator < (const BasicPropertyType<T>& other) const { return value<T>() < other.value<T>(); @@ -432,6 +462,11 @@ public: setValue(deserializeVariant<T>(v)); } + T basicValue() + { + return value<T>(); + } + private: //GVariant* mVariant; @@ -526,6 +561,12 @@ public: return *this; } + StringPropertyType & operator = (std::string const & other) + { + setValue(std::string(other)); + return *this; + } + void fromString(std::string val) { setValue(val); diff --git a/lib/abstractroutingengine.h b/lib/abstractroutingengine.h index 2ed798fe..ccc717f4 100644 --- a/lib/abstractroutingengine.h +++ b/lib/abstractroutingengine.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Intel Corporation + Copyright (C) 2012 Intel Corporation - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -351,7 +351,7 @@ public: * /param property * /return list of source uuid's that support the "property" */ - virtual std::list<std::string> sourcesForProperty(VehicleProperty::Property property) = 0; + virtual std::list<std::string> sourcesForProperty(const VehicleProperty::Property & property) = 0; /** * /brief getPropertyAsync requests a property value from a source. This call has a timeout and the callback specified in the request will always be called. @@ -407,7 +407,7 @@ public: * \see AsyncPropertyReply * \param request the request containing the property and the value to set * \return a pointer to the reply which is owned by the caller of this method - * \example + * \example */ virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0; diff --git a/lib/vehicleproperty.cpp b/lib/vehicleproperty.cpp index ad7feec4..3573ce28 100644 --- a/lib/vehicleproperty.cpp +++ b/lib/vehicleproperty.cpp @@ -43,6 +43,15 @@ const char* Transmission::W3C::Low = "low"; const char* Transmission::W3C::Drive = "drive"; const char* Transmission::W3C::Overdrive = "overdrive"; +const char* Door::W3C::Closed = "closed"; +const char* Door::W3C::Open = "open"; +const char* Door::W3C::Ajar = "ajar"; + +const char* HVAC::W3C::FloorPanel = "floorpanel"; +const char* HVAC::W3C::FloorDuct = "floorduct"; +const char* HVAC::W3C::Bilevel = "bilevel"; +const char* HVAC::W3C::DefrostFloor = "defrostfloor"; + const VehicleProperty::Property VehicleProperty::NoValue = "NoValue"; const VehicleProperty::Property VehicleProperty::VehicleSpeed = "VehicleSpeed"; const VehicleProperty::Property VehicleProperty::EngineSpeed = "EngineSpeed"; @@ -54,10 +63,12 @@ const VehicleProperty::Property VehicleProperty::ThrottlePosition = "ThrottlePos const VehicleProperty::Property VehicleProperty::WheelBrake = "WheelBrake"; const VehicleProperty::Property VehicleProperty::WheelBrakePressure = "WheelBrakePressure"; const VehicleProperty::Property VehicleProperty::SteeringWheelAngle = "SteeringWheelAngle"; +const VehicleProperty::Property VehicleProperty::SteeringWheelAngleW3C = "SteeringWheelAngleW3C"; const VehicleProperty::Property VehicleProperty::TurnSignal = "TurnSignal"; const VehicleProperty::Property VehicleProperty::ClutchStatus = "ClutchStatus"; const VehicleProperty::Property VehicleProperty::EngineOilPressure = "EngineOilPressure"; const VehicleProperty::Property VehicleProperty::EngineCoolantTemperature = "EngineCoolantTemperature"; +const VehicleProperty::Property VehicleProperty::EngineCoolantLevel = "EngineCoolantLevel"; const VehicleProperty::Property VehicleProperty::MachineGunTurretStatus = "MachineGunTurretStatus"; const VehicleProperty::Property VehicleProperty::AccelerationX = "AccelerationX"; const VehicleProperty::Property VehicleProperty::AccelerationY = "AccelerationY"; @@ -67,12 +78,14 @@ const VehicleProperty::Property VehicleProperty::ButtonEvent = "ButtonEvent"; const VehicleProperty::Property VehicleProperty::AirIntakeTemperature = "AirIntakeTemperature"; const VehicleProperty::Property VehicleProperty::BatteryVoltage = "BatteryVoltage"; const VehicleProperty::Property VehicleProperty::BatteryCurrent = "BatteryCurrent"; +const VehicleProperty::Property VehicleProperty::BatteryChargeLevel = "BatteryChargeLevel"; const VehicleProperty::Property VehicleProperty::InteriorTemperature = "InteriorTemperature"; const VehicleProperty::Property VehicleProperty::ExteriorTemperature = "ExteriorTemperature"; const VehicleProperty::Property VehicleProperty::EngineOilTemperature = "EngineOilTemperature"; const VehicleProperty::Property VehicleProperty::VIN = "VIN"; const VehicleProperty::Property VehicleProperty::WMI = "WMI"; const VehicleProperty::Property VehicleProperty::TirePressure = "TirePressure"; +const VehicleProperty::Property VehicleProperty::TirePressureLow = "TirePressureLow"; const VehicleProperty::Property VehicleProperty::TireTemperature = "TireTemperature"; const VehicleProperty::Property VehicleProperty::VehiclePowerMode = "VehiclePowerMode"; const VehicleProperty::Property VehicleProperty::TripMeters = "TripMeters"; @@ -86,6 +99,8 @@ const VehicleProperty::Property VehicleProperty::LightFog = "LightFog"; const VehicleProperty::Property VehicleProperty::LightHazard= "LightHazard"; const VehicleProperty::Property VehicleProperty::LightHighBeam = "LightHighBeam"; const VehicleProperty::Property VehicleProperty::LightBrake= "LightBrake"; +const VehicleProperty::Property VehicleProperty::LightAutomatic= "LightAutomatic"; +const VehicleProperty::Property VehicleProperty::LightDynamicHighBeam= "LightDynamicHighBeam"; const VehicleProperty::Property VehicleProperty::InteriorLightDriver = "InteriorLightDriver"; const VehicleProperty::Property VehicleProperty::InteriorLightCenter = "InteriorLightCenter"; const VehicleProperty::Property VehicleProperty::InteriorLightPassenger = "InteriorLightPassenger"; @@ -96,6 +111,9 @@ const VehicleProperty::Property VehicleProperty::FuelConsumption = "FuelConsumpt const VehicleProperty::Property VehicleProperty::FuelRange = "FuelRange"; const VehicleProperty::Property VehicleProperty::FuelEconomy = "FuelEconomy"; const VehicleProperty::Property VehicleProperty::FuelAverageEconomy = "FuelAverageEconomy"; +const VehicleProperty::Property VehicleProperty::FuelAverageConsumption = "FuelAverageConsumption"; +const VehicleProperty::Property VehicleProperty::FuelConsumptionSinceRestart = "FuelConsumptionSinceRestart"; +const VehicleProperty::Property VehicleProperty::FuelTimeSinceRestart = "FuelTimeSinceRestart"; const VehicleProperty::Property VehicleProperty::FuelType = "FuelType"; const VehicleProperty::Property VehicleProperty::FuelPositionSide = "FuelPositionSide"; const VehicleProperty::Property VehicleProperty::EngineOilRemaining = "EngineOilRemaining"; @@ -115,6 +133,8 @@ const VehicleProperty::Property VehicleProperty::RearWheelRadius = "RearWheelRad const VehicleProperty::Property VehicleProperty::WheelTrack = "WheelTrack"; const VehicleProperty::Property VehicleProperty::BrakePressure = "BrakePressure"; const VehicleProperty::Property VehicleProperty::Odometer = "Odometer"; +const VehicleProperty::Property VehicleProperty::DistanceTotal = "DistanceTotal"; +const VehicleProperty::Property VehicleProperty::DistanceSinceStart = "DistanceSinceStart"; const VehicleProperty::Property VehicleProperty::TransmissionFluidLevel = "TransmissionFluidLevel"; const VehicleProperty::Property VehicleProperty::BrakeFluidLevel = "BrakeFluidLevel"; const VehicleProperty::Property VehicleProperty::WasherFluidLevel = "WasherFluidLevel"; @@ -127,6 +147,7 @@ const VehicleProperty::Property VehicleProperty::AntilockBrakingSystem = "Antilo const VehicleProperty::Property VehicleProperty::TractionControlSystem = "TractionControlSystem"; const VehicleProperty::Property VehicleProperty::VehicleTopSpeedLimit = "VehicleTopSpeedLimit"; const VehicleProperty::Property VehicleProperty::DoorStatus = "DoorStatus"; +const VehicleProperty::Property VehicleProperty::DoorStatusW3C = "DoorStatusW3C"; const VehicleProperty::Property VehicleProperty::DoorLockStatus = "DoorLockStatus"; const VehicleProperty::Property VehicleProperty::ChildLockStatus = "ChildLockStatus"; const VehicleProperty::Property VehicleProperty::SeatBeltStatus = "SeatBeltStatus"; @@ -136,12 +157,15 @@ const VehicleProperty::Property VehicleProperty::ObstacleDistance = "ObstacleDis const VehicleProperty::Property VehicleProperty::RainSensor = "RainSensor"; const VehicleProperty::Property VehicleProperty::WindshieldWiper = "WindshieldWiper"; const VehicleProperty::Property VehicleProperty::AirflowDirection = "AirflowDirection"; +const VehicleProperty::Property VehicleProperty::AirflowDirectionW3C = "AirflowDirectionW3C"; const VehicleProperty::Property VehicleProperty::FanSpeed = "FanSpeed"; const VehicleProperty::Property VehicleProperty::TargetTemperature = "TargetTemperature"; const VehicleProperty::Property VehicleProperty::AirConditioning = "AirConditioning"; const VehicleProperty::Property VehicleProperty::AirRecirculation = "AirRecirculation"; const VehicleProperty::Property VehicleProperty::Heater = "Heater"; const VehicleProperty::Property VehicleProperty::Defrost = "Defrost"; +const VehicleProperty::Property VehicleProperty::DefrostWindow = "DefrostWindow"; +const VehicleProperty::Property VehicleProperty::DefrostMirror = "DefrostMirror"; const VehicleProperty::Property VehicleProperty::SteeringWheelHeater = "SteeringWheelHeater"; const VehicleProperty::Property VehicleProperty::SeatHeater = "SeatHeater"; const VehicleProperty::Property VehicleProperty::SeatCooler = "SeatCooler"; @@ -151,6 +175,7 @@ const VehicleProperty::Property VehicleProperty::SunroofTilt = "SunroofTilt"; const VehicleProperty::Property VehicleProperty::ConvertibleRoof = "ConvertibleRoof"; const VehicleProperty::Property VehicleProperty::NightMode = "NightMode"; const VehicleProperty::Property VehicleProperty::DrivingMode = "DrivingMode"; +const VehicleProperty::Property VehicleProperty::DrivingModeW3C = "DrivingModeW3C"; const VehicleProperty::Property VehicleProperty::KeyId = "KeyId"; const VehicleProperty::Property VehicleProperty::Language = "Language"; const VehicleProperty::Property VehicleProperty::MeasurementSystem = "MeasurementSystem"; @@ -183,12 +208,14 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTY(WheelBrake, false); REGISTERPROPERTY(WheelBrakePressure,0); REGISTERPROPERTY(SteeringWheelAngle,0); + REGISTERPROPERTY(SteeringWheelAngleW3C,0); REGISTERPROPERTY(TurnSignal, TurnSignals::Off); REGISTERPROPERTY(ClutchStatus, false); REGISTERPROPERTY(EngineOilPressure, 0); REGISTERPROPERTY(EngineOilTemperature, 0); REGISTERPROPERTY(EngineOilRemaining,0); REGISTERPROPERTY(EngineCoolantTemperature, 0); + REGISTERPROPERTY(EngineCoolantLevel, 0); REGISTERPROPERTY(MachineGunTurretStatus, false); REGISTERPROPERTY(AccelerationX,0); REGISTERPROPERTY(AccelerationY,0); @@ -198,11 +225,13 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTY(AirIntakeTemperature,0) REGISTERPROPERTY(BatteryVoltage, 0); REGISTERPROPERTY(BatteryCurrent,0); + REGISTERPROPERTY(BatteryChargeLevel,0); REGISTERPROPERTY(InteriorTemperature, 0); REGISTERPROPERTY(ExteriorTemperature,0); REGISTERPROPERTY(VIN, ""); REGISTERPROPERTY(WMI, ""); REGISTERPROPERTY(TirePressure, 0); + REGISTERPROPERTY(TirePressureLow, false); REGISTERPROPERTY(TireTemperature,0); REGISTERPROPERTY( VehiclePowerMode,Power::Off); registerPropertyPriv(TripMeters,[](){ @@ -222,49 +251,56 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTY(LightHazard, false); REGISTERPROPERTY(LightHighBeam, false); REGISTERPROPERTY(LightBrake, false); + REGISTERPROPERTY(LightAutomatic, false); + REGISTERPROPERTY(LightDynamicHighBeam, false); REGISTERPROPERTY(InteriorLightDriver, false); REGISTERPROPERTY(InteriorLightPassenger, false); REGISTERPROPERTY(InteriorLightCenter, false); - REGISTERPROPERTY(EngineLoad,0); + REGISTERPROPERTY(EngineLoad, 0); REGISTERPROPERTY(Horn, false); REGISTERPROPERTY(FuelLevel, 0); REGISTERPROPERTY(FuelRange, 0); REGISTERPROPERTY(FuelConsumption, 0); REGISTERPROPERTY(FuelEconomy, 0); REGISTERPROPERTY(FuelAverageEconomy, 0); + REGISTERPROPERTY(FuelAverageConsumption, 0); + REGISTERPROPERTY(FuelConsumptionSinceRestart, 0); + REGISTERPROPERTY(FuelTimeSinceRestart, 0); REGISTERPROPERTY(FuelType, Fuel::Unknown); REGISTERPROPERTY(FuelPositionSide, Fuel::UnknownPosition); REGISTERPROPERTY(ExteriorBrightness, 0); - REGISTERPROPERTY(VehicleWidth,0); - REGISTERPROPERTY(VehicleHeight,0); - REGISTERPROPERTY(VehicleLength,0); - REGISTERPROPERTY(Latitude,0); - REGISTERPROPERTY(Longitude,0); + REGISTERPROPERTY(VehicleWidth, 0); + REGISTERPROPERTY(VehicleHeight, 0); + REGISTERPROPERTY(VehicleLength, 0); + REGISTERPROPERTY(Latitude, 0); + REGISTERPROPERTY(Longitude, 0); REGISTERPROPERTY(Altitude,0); - REGISTERPROPERTY(Direction,0); - REGISTERPROPERTY(VehicleType,Vehicle::Unknown); - registerPropertyPriv(DoorsPerRow,[]() { BasicPropertyType<uint16_t> d(0); return new DoorsPerRowType(&d); }); - REGISTERPROPERTY(TransmissionGearType,Transmission::Unknown); + REGISTERPROPERTY(Direction, 0); + REGISTERPROPERTY(VehicleType, Vehicle::Unknown); + registerPropertyPriv(DoorsPerRow, []() { BasicPropertyType<uint16_t> d(0); return new DoorsPerRowType(&d); }); + REGISTERPROPERTY(TransmissionGearType, Transmission::Unknown); REGISTERPROPERTY(FrontWheelRadius, 0); REGISTERPROPERTY(RearWheelRadius, 0); - REGISTERPROPERTY(WheelTrack,0); - REGISTERPROPERTY(BrakePressure,0); - REGISTERPROPERTY(Odometer,0); + REGISTERPROPERTY(WheelTrack, 0); + REGISTERPROPERTY(BrakePressure, 0); + REGISTERPROPERTY(Odometer, 0); + REGISTERPROPERTY(DistanceTotal, 0); + REGISTERPROPERTY(DistanceSinceStart, 0); REGISTERPROPERTY(TransmissionFluidLevel,0); REGISTERPROPERTY(BrakeFluidLevel,0); REGISTERPROPERTY(WasherFluidLevel,0); REGISTERPROPERTY(SecurityAlertStatus,Security::Idle); - REGISTERPROPERTY(ParkingBrakeStatus,false); - REGISTERPROPERTY(ParkingLightStatus,false); - REGISTERPROPERTY(HazardLightStatus,false); + REGISTERPROPERTY(ParkingBrakeStatus, false); + REGISTERPROPERTY(ParkingLightStatus, false); + REGISTERPROPERTY(HazardLightStatus, false); REGISTERPROPERTY(AirbagStatus, Airbag::Inactive); - REGISTERPROPERTY(AntilockBrakingSystem,false); - REGISTERPROPERTY(TractionControlSystem,false); - REGISTERPROPERTY(VehicleTopSpeedLimit,0); - + REGISTERPROPERTY(AntilockBrakingSystem, false); + REGISTERPROPERTY(TractionControlSystem, false); + REGISTERPROPERTY(VehicleTopSpeedLimit, 0); REGISTERPROPERTY(DoorStatus, Door::Closed); + REGISTERPROPERTY(DoorStatusW3C, Door::W3C::Closed); REGISTERPROPERTY(DoorLockStatus, false); REGISTERPROPERTY(ChildLockStatus, false); REGISTERPROPERTY(SeatBeltStatus, false); @@ -272,26 +308,30 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTY(WindowLockStatus, false); REGISTERPROPERTY(ObstacleDistance, 0); - REGISTERPROPERTY(RainSensor,0); - REGISTERPROPERTY(WindshieldWiper,Window::Off); - REGISTERPROPERTY(AirflowDirection,HVAC::Front); - REGISTERPROPERTY(FanSpeed,0); - REGISTERPROPERTY(TargetTemperature,0); - REGISTERPROPERTY(AirConditioning,false); - REGISTERPROPERTY(AirRecirculation,false); - REGISTERPROPERTY(Heater,false); + REGISTERPROPERTY(RainSensor, 0); + REGISTERPROPERTY(WindshieldWiper, Window::Off); + REGISTERPROPERTY(AirflowDirection, HVAC::Front); + REGISTERPROPERTY(AirflowDirectionW3C, HVAC::W3C::FloorPanel); + REGISTERPROPERTY(FanSpeed, 0); + REGISTERPROPERTY(TargetTemperature, 0); + REGISTERPROPERTY(AirConditioning, false); + REGISTERPROPERTY(AirRecirculation, false); + REGISTERPROPERTY(Heater, false); REGISTERPROPERTY(Defrost,false); + REGISTERPROPERTY(DefrostWindow,false); + REGISTERPROPERTY(DefrostMirror,false); REGISTERPROPERTY(SteeringWheelHeater,false); REGISTERPROPERTY(SeatHeater, 0); REGISTERPROPERTY(SeatCooler, false); REGISTERPROPERTY(WindowStatus, 100); - REGISTERPROPERTY(Sunroof,0); - REGISTERPROPERTY(SunroofTilt,0); - REGISTERPROPERTY(ConvertibleRoof,false); - REGISTERPROPERTY(NightMode,false); - REGISTERPROPERTY(DrivingMode,Driving::None); + REGISTERPROPERTY(Sunroof, 0); + REGISTERPROPERTY(SunroofTilt, 0); + REGISTERPROPERTY(ConvertibleRoof, false); + REGISTERPROPERTY(NightMode, false); + REGISTERPROPERTY(DrivingMode, Driving::None); + REGISTERPROPERTY(DrivingModeW3C, false); REGISTERPROPERTY(KeyId,""); REGISTERPROPERTY(Language,""); REGISTERPROPERTY(MeasurementSystem,Measurement::Metric); diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 4f4611ae..b2cfa81b 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -190,6 +190,12 @@ enum Status Open, Ajar }; +namespace W3C +{ +extern const char * Closed; +extern const char * Open; +extern const char * Ajar; +} } namespace Seat @@ -238,6 +244,14 @@ enum AirflowDirection Defroster = 1 << 2 }; + +namespace W3C +{ +extern const char * FloorPanel; +extern const char * FloorDuct; +extern const char * Bilevel; +extern const char * DefrostFloor; +} } namespace Driving @@ -276,6 +290,7 @@ enum Type class propertyType : public baseClass { \ public: propertyType(): baseClass(property) {} \ propertyType(valueType val) : baseClass(property, val) {} \ + using baseClass::operator=; \ }; #define PROPERTYTYPE1(property, propertyType, baseClass, valueType) \ @@ -288,6 +303,7 @@ enum Type class property ## Type : public BasicPropertyType<valueType> { \ public: property ## Type(): BasicPropertyType(property) {} \ property ## Type(valueType val) : BasicPropertyType(property, val) {} \ + using BasicPropertyType<valueType>::operator=; \ }; #define PROPERTYTYPEBASIC1(property, valueType) \ @@ -399,14 +415,20 @@ public: PROPERTYTYPE(WheelBrakePressure, WheelBrakePressureType, BasicPropertyType<uint16_t>, uint16_t) //typedef BasicPropertyType<uint16_t> WheelBrakePressureType; - /**< Steering wheel angle (0-359) */ + /**< Steering wheel angle (0-359) + * TODO: Deprecate in 0.13. Replace with SteeringWheelAngleW3C + */ static const Property SteeringWheelAngle; PROPERTYTYPE(SteeringWheelAngle, SteeringWheelAngleType, BasicPropertyType<uint16_t>, uint16_t) //typedef BasicPropertyType<uint16_t> SteeringWheelAngleType; + /// TODO: Rename to "SteeringWheel" in 0.13 + static const Property SteeringWheelAngleW3C; + PROPERTYTYPEBASIC(SteeringWheelAngleW3C, int16_t) + /**< 0=off, 1=right, 2=left, 3=hazard */ static const Property TurnSignal; - PROPERTYTYPE(TurnSignal, TurnSignalType, BasicPropertyType<TurnSignals::TurnSignalType> ,TurnSignals::TurnSignalType) + PROPERTYTYPEBASIC(TurnSignal, TurnSignals::TurnSignalType) //typedef BasicPropertyType<TurnSignals::TurnSignalType> TurnSignalType; /**< Clutch pedal status 0=off, 1=on */ @@ -424,9 +446,12 @@ public: PROPERTYTYPE(EngineCoolantTemperature, EngineCoolantTemperatureType, BasicPropertyType<int>, int) //typedef BasicPropertyType<int> EngineCoolantTemperatureType; + static const Property EngineCoolantLevel; + PROPERTYTYPE(EngineCoolantLevel, EngineCoolantLevelType, BasicPropertyType<uint>, uint) + /**< 0=off, 1=on */ static const Property MachineGunTurretStatus; - PROPERTYTYPE(MachineGunTurretStatus, MachineGunTurretStatusType, BasicPropertyType<bool>, bool) + PROPERTYTYPEBASIC(MachineGunTurretStatus, bool) //typedef BasicPropertyType<bool> MachineGunTurretStatusType; /**< Acceleration on the 'x' axis in 1/1000 gravitational acceleration "g-force" */ @@ -466,6 +491,9 @@ public: PROPERTYTYPE(BatteryCurrent, BatteryCurrentType, BasicPropertyType<double>, double) //typedef BasicPropertyType<double> BatteryCurrentType; + static const Property BatteryChargeLevel; + PROPERTYTYPEBASIC(BatteryChargeLevel, uint16_t) + /**< Interior Air Temperature in degrees celcius */ static const Property InteriorTemperature; PROPERTYTYPE(InteriorTemperature, InteriorTemperatureType, BasicPropertyType<int>, int) @@ -496,11 +524,15 @@ public: /**< Tire pressure in kPa */ static const Property TirePressure; - PROPERTYTYPEBASIC(TirePressure, double) + PROPERTYTYPEBASIC(TirePressure, uint16_t) + + /**< Tire pressure low */ + static const Property TirePressureLow; + PROPERTYTYPEBASIC(TirePressureLow, bool) /**< Tire temperature in degrees C */ static const Property TireTemperature; - PROPERTYTYPEBASIC(TireTemperature, double) + PROPERTYTYPEBASIC(TireTemperature, int16_t) /**< Vehicle Power Mode. *@see Power::PowerModes @@ -537,7 +569,11 @@ public: PROPERTYTYPE(LightParking, LightParkingType, BasicPropertyType<bool>, bool) static const Property LightHighBeam; PROPERTYTYPE(LightHighBeam, LightHighBeamType, BasicPropertyType<bool>, bool) - //typedef BasicPropertyType<bool> LightStatusType; + static const Property LightAutomatic; + PROPERTYTYPEBASIC(LightAutomatic, bool) + static const Property LightDynamicHighBeam; + PROPERTYTYPEBASIC(LightDynamicHighBeam, bool) + static const Property InteriorLightDriver; PROPERTYTYPE(InteriorLightDriver, InteriorLightDriverType, BasicPropertyType<bool>, bool) @@ -548,59 +584,54 @@ public: static const Property EngineLoad; PROPERTYTYPE(EngineLoad, EngineLoadType, BasicPropertyType<uint16_t>, uint16_t) - //typedef BasicPropertyType<uint16_t> EngineLoadType; static const Property Horn; PROPERTYTYPE(Horn, HornType, BasicPropertyType<bool>, bool) - //typedef BasicPropertyType<bool> HornType; static const Property FuelLevel; PROPERTYTYPE(FuelLevel, FuelLevelType, BasicPropertyType<uint16_t>, uint16_t) - //typedef BasicPropertyType<uint16_t> FuelLevelType; static const Property FuelRange; PROPERTYTYPE(FuelRange, FuelRangeType, BasicPropertyType<uint16_t> , uint16_t) - //typedef BasicPropertyType<uint16_t> FuelRangeType; static const Property FuelConsumption; - PROPERTYTYPE(FuelConsumption, FuelConsumptionType, BasicPropertyType<uint16_t>, uint16_t) - //typedef BasicPropertyType<uint16_t> FuelConsumptionType; + PROPERTYTYPE(FuelConsumption, FuelConsumptionType, BasicPropertyType<uint>, uint) static const Property FuelEconomy; PROPERTYTYPE(FuelEconomy, FuelEconomyType, BasicPropertyType<uint16_t>, uint16_t) -// /typedef BasicPropertyType<uint16_t> FuelEconomyType; static const Property FuelAverageEconomy; PROPERTYTYPE(FuelAverageEconomy, FuelAverageEconomyType, BasicPropertyType<uint16_t> , uint16_t) - //typedef BasicPropertyType<uint16_t> FuelAverageEconomyType; + + static const Property FuelAverageConsumption; + PROPERTYTYPEBASIC(FuelAverageConsumption, uint) + + static const Property FuelTimeSinceRestart; + PROPERTYTYPEBASIC(FuelTimeSinceRestart, uint) + + static const Property FuelConsumptionSinceRestart; + PROPERTYTYPEBASIC(FuelConsumptionSinceRestart, uint) static const Property FuelType; PROPERTYTYPE(FuelType, FuelTypeType, BasicPropertyType<Fuel::Type>, Fuel::Type) - //typedef BasicPropertyType<Fuel::Type> FuelTypeType; static const Property FuelPositionSide; PROPERTYTYPE(FuelPositionSide, FuelPositionSideType, BasicPropertyType<Fuel::RefuelPosition>, Fuel::RefuelPosition) -// /typedef BasicPropertyType<Fuel::RefuelPosition> FuelPositionSideType; static const Property ExteriorBrightness; PROPERTYTYPE(ExteriorBrightness, ExteriorBrightnessType, BasicPropertyType<uint16_t>, uint16_t) - //typedef BasicPropertyType<uint16_t> ExteriorBrightnessType; static const Property Latitude; PROPERTYTYPE(Latitude, LatitudeType, BasicPropertyType<double>, double) - //typedef BasicPropertyType<double> LatitudeType; static const Property Longitude; PROPERTYTYPE(Longitude, LongitudeType, BasicPropertyType<double>, double) - //typedef BasicPropertyType<double> LongitudeType; static const Property Altitude; PROPERTYTYPE(Altitude, AltitudeType, BasicPropertyType<double> , double) - //typedef BasicPropertyType<double> AltitudeType; static const Property Direction; PROPERTYTYPE(Direction, DirectionType, BasicPropertyType<uint16_t>, uint16_t) - //typedef BasicPropertyType<uint16_t> DirectionType; static const Property VehicleWidth; PROPERTYTYPE(VehicleWidth, VehicleWidthType, BasicPropertyType<uint>, uint) @@ -636,9 +667,15 @@ public: PROPERTYTYPEBASIC(BrakePressure, uint16_t) //typedef BasicPropertyType<uint16_t> BrakePressureType; + /// TODO: deprecated. remove in 0.13. Use DistanceTotal static const Property Odometer; PROPERTYTYPEBASIC(Odometer, uint) - //typedef BasicPropertyType<uint> OdometerType; + + static const Property DistanceTotal; + PROPERTYTYPEBASIC(DistanceTotal, uint) + + static const Property DistanceSinceStart; + PROPERTYTYPEBASIC(DistanceSinceStart, uint) /**< Transmission Fluid Level 0-100%. **/ @@ -702,9 +739,15 @@ public: static const Property AirbagStatus; PROPERTYTYPEBASIC(AirbagStatus, Airbag::Status) + /// TODO: deprecate in 0.13. Use DoorStatusW3C static const Property DoorStatus; PROPERTYTYPEBASIC(DoorStatus, Door::Status) + /** use with Door::W3C::* + */ + static const Property DoorStatusW3C; + PROPERTYTYPE(DoorStatusW3C, DoorStatusW3CType, StringPropertyType, std::string) + static const Property DoorLockStatus; PROPERTYTYPEBASIC(DoorLockStatus, bool) @@ -715,7 +758,7 @@ public: PROPERTYTYPEBASIC(SeatBeltStatus, bool) static const Property WindowLockStatus; - PROPERTYTYPEBASIC(WindowLockStatus, bool ) + PROPERTYTYPEBASIC(WindowLockStatus, bool) static const Property OccupantStatus; PROPERTYTYPEBASIC(OccupantStatus, Seat::Occupant) @@ -731,33 +774,38 @@ public: PROPERTYTYPEBASIC(WindshieldWiper,Window::WiperSpeed) //typedef BasicPropertyType<Window::WiperSpeed> WindshieldWiperType; + /// TODO: Deprecated. Remove in 0.13 static const Property AirflowDirection; PROPERTYTYPEBASIC(AirflowDirection,HVAC::AirflowDirection) - //typedef BasicPropertyType<HVAC::AirflowDirection> AirflowDirectionType; + + static const Property AirflowDirectionW3C; + PROPERTYTYPE(AirflowDirectionW3C, AirflowDirectionW3CType, StringPropertyType, std::string) static const Property FanSpeed; PROPERTYTYPEBASIC(FanSpeed, uint16_t) - //typedef BasicPropertyType<uint16_t> FanSpeedType; static const Property TargetTemperature; PROPERTYTYPEBASIC(TargetTemperature, int) - //typedef BasicPropertyType<int> TargetTemperatureType; static const Property AirConditioning; PROPERTYTYPEBASIC(AirConditioning,bool) - //typedef BasicPropertyType<bool> AirConditioningType; static const Property AirRecirculation; PROPERTYTYPEBASIC(AirRecirculation,bool) - //typedef BasicPropertyType<bool> AirRecirculationType; static const Property Heater; PROPERTYTYPEBASIC(Heater, bool) - //typedef BasicPropertyType<bool> HeaterType; + /// TODO: deprecated. remove in 0.13 static const Property Defrost; PROPERTYTYPEBASIC(Defrost, bool ) + static const Property DefrostWindow; + PROPERTYTYPEBASIC(DefrostWindow, bool ) + + static const Property DefrostMirror; + PROPERTYTYPEBASIC(DefrostMirror, bool ) + static const Property SteeringWheelHeater; PROPERTYTYPEBASIC(SteeringWheelHeater,bool) //typedef BasicPropertyType<bool> SteeringWheelHeaterType; @@ -791,6 +839,9 @@ public: static const Property DrivingMode; PROPERTYTYPEBASIC(DrivingMode, Driving::Mode) + static const Property DrivingModeW3C; + PROPERTYTYPEBASIC(DrivingModeW3C, bool) + static const Property KeyId; PROPERTYTYPE(KeyId, KeyIdType, StringPropertyType, std::string) diff --git a/plugins/database/databasesink.cpp b/plugins/database/databasesink.cpp index 6313fd52..dbc141e4 100644 --- a/plugins/database/databasesink.cpp +++ b/plugins/database/databasesink.cpp @@ -1,6 +1,7 @@ #include "databasesink.h" #include "abstractroutingengine.h" #include "listplusplus.h" +#include "superptr.hpp" int bufferLength = 100; int timeout=1000; @@ -96,15 +97,16 @@ int getNextEvent(gpointer data) DBObject obj = *itr; - AbstractPropertyType* value = VehicleProperty::getPropertyTypeForPropertyNameValue(obj.key,obj.value); + auto value = amb::make_unique(VehicleProperty::getPropertyTypeForPropertyNameValue(obj.key, obj.value)); if(value) { - pbshared->routingEngine->updateProperty(value, pbshared->uuid); + value->priority = AbstractPropertyType::Instant; value->timestamp = obj.time; value->sequence = obj.sequence; value->sourceUuid = obj.source; value->zone = obj.zone; + pbshared->routingEngine->updateProperty(value.get(), pbshared->uuid); } if(++itr != pbshared->playbackQueue.end()) @@ -237,14 +239,14 @@ void DatabaseSink::parseConfig() { //Should handle the extra data here sometime... } - + json_object *propobject = json_object_object_get(rootobject,"properties"); - + g_assert(json_object_get_type(propobject) == json_type_array); array_list *proplist = json_object_get_array(propobject); - - for(int i=0; i < array_list_length(proplist); i++) + + for(int i=0; i < array_list_length(proplist); i++) { json_object *idxobj = (json_object*)array_list_get_idx(proplist,i); std::string prop = json_object_get_string(idxobj); @@ -274,7 +276,7 @@ void DatabaseSink::stopDb() void DatabaseSink::startDb() { - if(playback) + if(playback.basicValue()) { DebugOut(0)<<"ERROR: tried to start logging during playback. Only logging or playback can be used at one time"<<endl; return; @@ -293,7 +295,7 @@ void DatabaseSink::startDb() void DatabaseSink::startPlayback() { - if(playback) + if(playback.basicValue()) return; playback = true; @@ -344,7 +346,7 @@ void DatabaseSink::initDb() if(shared) delete shared; shared = new Shared; - shared->db->init(databaseName, tablename, tablecreate); + shared->db->init(databaseName.value<std::string>(), tablename, tablecreate); } void DatabaseSink::setPlayback(bool v) @@ -358,13 +360,12 @@ void DatabaseSink::setPlayback(bool v) void DatabaseSink::setLogging(bool b) { + databaseLogging = b; AsyncSetPropertyRequest request; request.property = DatabaseLogging; - request.value = new DatabaseLoggingType(b); + request.value = &databaseLogging; setProperty(request); - - delete request.value; } void DatabaseSink::setDatabaseFileName(string filename) @@ -433,9 +434,9 @@ void DatabaseSink::getPropertyAsync(AsyncPropertyReply *reply) } else if(reply->property == DatabaseLogging) { - DatabaseLoggingType temp = shared; + databaseLogging = shared != nullptr; - reply->value = &temp; + reply->value = &databaseLogging; reply->success = true; reply->completed(reply); @@ -458,7 +459,7 @@ void DatabaseSink::getPropertyAsync(AsyncPropertyReply *reply) void DatabaseSink::getRangePropertyAsync(AsyncRangePropertyReply *reply) { BaseDB * db = new BaseDB(); - db->init(databaseName, tablename, tablecreate); + db->init(databaseName.value<std::string>(), tablename, tablecreate); ostringstream query; query.precision(15); @@ -535,15 +536,15 @@ AsyncPropertyReply *DatabaseSink::setProperty(AsyncSetPropertyRequest request) setPlayback(false); startDb(); reply->success = true; - DatabaseLoggingType temp(true); - routingEngine->updateProperty(&temp,uuid()); + databaseLogging = true; + routingEngine->updateProperty(&databaseLogging,uuid()); } else { stopDb(); reply->success = true; - DatabaseLoggingType temp(false); - routingEngine->updateProperty(&temp,uuid()); + databaseLogging = false; + routingEngine->updateProperty(&databaseLogging,uuid()); } } @@ -553,9 +554,7 @@ AsyncPropertyReply *DatabaseSink::setProperty(AsyncSetPropertyRequest request) databaseName = fname; - DatabaseFileType temp(databaseName); - - routingEngine->updateProperty(&temp,uuid()); + routingEngine->updateProperty(&databaseName,uuid()); reply->success = true; } @@ -566,9 +565,7 @@ AsyncPropertyReply *DatabaseSink::setProperty(AsyncSetPropertyRequest request) setLogging(false); startPlayback(); - DatabasePlaybackType temp(playback); - - routingEngine->updateProperty(&temp,uuid()); + routingEngine->updateProperty(&playback,uuid()); } else { @@ -577,9 +574,7 @@ AsyncPropertyReply *DatabaseSink::setProperty(AsyncSetPropertyRequest request) playback = false; - DatabasePlaybackType temp(playback); - - routingEngine->updateProperty(&temp,uuid()); + routingEngine->updateProperty(&playback,uuid()); } reply->success = true; diff --git a/plugins/database/databasesink.h b/plugins/database/databasesink.h index 6311f457..2ec319f1 100644 --- a/plugins/database/databasesink.h +++ b/plugins/database/databasesink.h @@ -219,6 +219,10 @@ public: bool stop; }; +PROPERTYTYPEBASIC(DatabaseLogging, bool) +PROPERTYTYPEBASIC(DatabasePlayback, bool) +PROPERTYTYPE(DatabaseFile, DatabaseFileType, StringPropertyType, std::string) + class DatabaseSink : public AbstractSource { @@ -255,20 +259,18 @@ private: PropertyList mSubscriptions; Shared *shared; GThread* thread; - std::string databaseName; + //std::string databaseName; std::string tablename; std::string tablecreate; std::list<VehicleProperty::Property> propertiesToSubscribeTo; PropertyList mSupported; - bool playback; PlaybackShared* playbackShared; uint playbackMultiplier; + DatabasePlaybackType playback; + DatabaseFileType databaseName; + DatabaseLoggingType databaseLogging; }; -PROPERTYTYPEBASIC(DatabaseLogging, bool) -PROPERTYTYPEBASIC(DatabasePlayback, bool) -PROPERTYTYPE(DatabaseFile, DatabaseFileType, StringPropertyType, std::string) - class DatabaseSinkManager: public AbstractSinkManager { diff --git a/plugins/dbus/custompropertyinterface.cpp b/plugins/dbus/custompropertyinterface.cpp index de688a5f..3c93db3f 100644 --- a/plugins/dbus/custompropertyinterface.cpp +++ b/plugins/dbus/custompropertyinterface.cpp @@ -21,7 +21,7 @@ CustomPropertyInterface::CustomPropertyInterface(VehicleProperty::Property prop, std::string signature = g_variant_get_type_string(var); g_variant_unref(var); - propertyDBusMap.push_back( new VariantType(re, signature, prop, prop, VariantType::ReadWrite)); + propertyDBusMap.push_back( new VariantType(re, prop, prop, VariantType::ReadWrite)); delete temp; } diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp index 434afef3..3ca7f279 100644 --- a/plugins/dbus/dbusinterfacemanager.cpp +++ b/plugins/dbus/dbusinterfacemanager.cpp @@ -172,6 +172,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d exportProperty<TransmissionProperty>(iface->re, connection); exportProperty<CruiseControlProperty>(iface->re, connection); exportProperty<WheelBrakeProperty>(iface->re, connection); + exportProperty<BrakeOperation>(iface->re, connection); exportProperty<LightStatusProperty>(iface->re, connection); exportProperty<HornProperty>(iface->re, connection); exportProperty<FuelProperty>(iface->re, connection); @@ -181,7 +182,9 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d exportProperty<RainSensor>(iface->re, connection); exportProperty<WindshieldWiper>(iface->re, connection); exportProperty<HVACProperty>(iface->re, connection); + exportProperty<ClimateControlProperty>(iface->re, connection); exportProperty<WindowStatusProperty>(iface->re, connection); + exportProperty<DefrostProperty>(iface->re, connection); exportProperty<Sunroof>(iface->re, connection); exportProperty<ConvertibleRoof>(iface->re, connection); exportProperty<VehicleId>(iface->re, connection); @@ -193,6 +196,7 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d exportProperty<OdometerProperty>(iface->re, connection); exportProperty<FluidProperty>(iface->re, connection); exportProperty<BatteryProperty>(iface->re, connection); + exportProperty<BatteryStatusProperty>(iface->re, connection); exportProperty<SecurityAlertProperty>(iface->re, connection); exportProperty<ParkingBrakeProperty>(iface->re, connection); exportProperty<ParkingLightProperty>(iface->re, connection); @@ -208,7 +212,12 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d exportProperty<ObstacleDistanceProperty>(iface->re, connection); exportProperty<SeatPostionProperty>(iface->re, connection); exportProperty<SteeringWheelPositionProperty>(iface->re, connection); + exportProperty<SteeringWheel>(iface->re, connection); exportProperty<MirrorSettingProperty>(iface->re, connection); + exportProperty<ThrottlePosition>(iface->re, connection); + exportProperty<EngineCoolant>(iface->re, connection); + exportProperty<NightMode>(iface->re, connection); + exportProperty<DrivingMode>(iface->re, connection); iface->registerCustomTypes(); } diff --git a/plugins/dbus/dbusplugin.h b/plugins/dbus/dbusplugin.h index 290a1612..9ea38d24 100644 --- a/plugins/dbus/dbusplugin.h +++ b/plugins/dbus/dbusplugin.h @@ -74,20 +74,26 @@ protected: void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access) { //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access); - propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access)); + propertyDBusMap.push_back( new VariantType(routingEngine, property, propertyName, access)); } void wantPropertyString(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access) { //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access); - propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access)); + propertyDBusMap.push_back( new VariantType(routingEngine, property, propertyName, access)); } void wantPropertyVariant(VehicleProperty::Property ambProperty, std::string propertyName, std::string signature, AbstractProperty::Access access) { //propertyDBusMap[ambProperty] = new VariantType(routingEngine, signature, ambProperty, propertyName, access); - propertyDBusMap.push_back(new VariantType(routingEngine, signature, ambProperty, propertyName, access)); + propertyDBusMap.push_back(new VariantType(routingEngine, ambProperty, propertyName, access)); + } + + void wantPropertyVariant(VehicleProperty::Property ambProperty, std::string propertyName, AbstractProperty::Access access) + { + //propertyDBusMap[ambProperty] = new VariantType(routingEngine, signature, ambProperty, propertyName, access); + propertyDBusMap.push_back(new VariantType(routingEngine, ambProperty, propertyName, access)); } PropertyDBusMap propertyDBusMap; diff --git a/plugins/dbus/drivingsafety.h b/plugins/dbus/drivingsafety.h index ab91df23..80806386 100644 --- a/plugins/dbus/drivingsafety.h +++ b/plugins/dbus/drivingsafety.h @@ -46,6 +46,7 @@ public: } }; +/// TODO: deprecated. remove in 0.13 class DoorStatusProperty: public DBusSink { public: @@ -57,7 +58,22 @@ public: wantPropertyVariant(VehicleProperty::DoorLockStatus, "DoorLockStatus", "b", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::ChildLockStatus, "ChildLockStatus", "b", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::ChildLockStatus, "ChildLockStatus", "b", AbstractProperty::Read); + } +}; + +class DoorProperty: public DBusSink +{ +public: + DoorProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("Door", re, connection, map<string, string>()) + { + + wantPropertyVariant(VehicleProperty::DoorStatusW3C, "Status", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::DoorLockStatus, "Lock", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::ChildLockStatus, "ChildLock", AbstractProperty::Read); } }; diff --git a/plugins/dbus/environmentproperties.h b/plugins/dbus/environmentproperties.h index ce52af82..40655a15 100644 --- a/plugins/dbus/environmentproperties.h +++ b/plugins/dbus/environmentproperties.h @@ -19,7 +19,7 @@ public: * @attributeComment \brief Must return the brightness outside the vehicle in lux. */ wantPropertyVariant(VehicleProperty::ExteriorBrightness,"ExteriorBrightness", "q", AbstractProperty::Read); - + } }; @@ -36,7 +36,9 @@ public: * @access readonly * @attributeComment \brief Must return the temperature of the interior of the vehicle in celcius. */ - wantPropertyVariant(VehicleProperty::InteriorTemperature, "Interior", "i", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::InteriorTemperature, "Interior", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::InteriorTemperature, "InteriorTemperature", AbstractProperty::Read); /** * @attributeName Exterior @@ -44,9 +46,11 @@ public: * @access readonly * @attributeComment \brief Must return the temperature of the exterior of the vehicle in celcius. */ - wantPropertyVariant(VehicleProperty::ExteriorTemperature, "Exterior", "i", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::ExteriorTemperature, "Exterior", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::ExteriorTemperature, "ExteriorTemperature", AbstractProperty::Read); + - } }; @@ -64,7 +68,7 @@ public: * @attributeComment \brief Must return level of rain intensity 0: No Rain - 10: Heaviest Rain. */ wantPropertyVariant(VehicleProperty::RainSensor, "RainSensor", "q", AbstractProperty::Read); - + } }; @@ -89,7 +93,7 @@ public: * @attributeComment \brief Must return Level of windshield whiper speed (see WIPERSPEED_) */ wantPropertyVariant(VehicleProperty::RainSensor, "WindshieldWiper", "y", AbstractProperty::ReadWrite); - + } }; @@ -113,6 +117,7 @@ public: * @access readwrite * @attributeComment \brief Must return airflow direction. See AIRFLOWDIRECTION_*. */ + /// TODO: Deprecated. Remove in 0.13 wantPropertyVariant(VehicleProperty::AirflowDirection, "AirflowDirection", "y", AbstractProperty::ReadWrite); /** @@ -179,7 +184,33 @@ public: */ wantPropertyVariant(VehicleProperty::SeatCooler, "SeatCooler", "b", AbstractProperty::ReadWrite); - + + } +}; + +class ClimateControlProperty: public DBusSink +{ +public: + ClimateControlProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("ClimateControl", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::AirflowDirectionW3C, "AirflowDirection", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::FanSpeed, "FanSpeed", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::TargetTemperature, "TargetTemperature", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::AirConditioning, "AirConditioning", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::AirRecirculation, "AirRecirculation", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::Heater, "Heater", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::SteeringWheelHeater, "SteeringWheelHeater", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::SeatHeater, "SeatHeater", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::SeatCooler, "SeatCooler", AbstractProperty::ReadWrite); } }; @@ -190,9 +221,19 @@ public: WindowStatusProperty(AbstractRoutingEngine* re, GDBusConnection* connection) :DBusSink("WindowStatus", re, connection, map<string, string>()) { - wantPropertyVariant(VehicleProperty::WindowStatus,"Openness", "q", AbstractProperty::ReadWrite); + wantPropertyVariant(VehicleProperty::WindowStatus,"Openness", AbstractProperty::ReadWrite); + wantPropertyVariant(VehicleProperty::Defrost, "Defrost", AbstractProperty::ReadWrite); + } +}; - wantPropertyVariant(VehicleProperty::Defrost, "Defrost", "b", AbstractProperty::ReadWrite); +class DefrostProperty: public DBusSink +{ +public: + DefrostProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("Defrost", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::DefrostWindow,"DefrostWindow", AbstractProperty::ReadWrite); + wantPropertyVariant(VehicleProperty::DefrostMirror, "DefrostMirror", AbstractProperty::ReadWrite); } }; diff --git a/plugins/dbus/maintenance.h b/plugins/dbus/maintenance.h index f8a32997..97bc187f 100644 --- a/plugins/dbus/maintenance.h +++ b/plugins/dbus/maintenance.h @@ -18,9 +18,10 @@ public: * @access readonly * @attributeComment \brief MUST return Distance traveled in km **/ - wantProperty<uint>(VehicleProperty::Odometer, "Odometer", "i", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::Odometer, "Odometer", AbstractProperty::Read); - + wantPropertyVariant(VehicleProperty::DistanceTotal, "DistanceTotal", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::DistanceSinceStart, "DistanceSinceStart", AbstractProperty::Read); } }; @@ -36,25 +37,26 @@ public: * @access readonly * @attributeComment \brief MUST return Transmission fluid level percentage. 0-100. **/ - wantProperty<uint16_t>(VehicleProperty::TransmissionFluidLevel, "Transmission", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::TransmissionFluidLevel, "Transmission", AbstractProperty::Read); /** @attributeName Brake * @type unsigned short * @access readonly * @attributeComment \brief MUST return Brake fluid level percentage. 0-100. **/ - wantProperty<uint16_t>(VehicleProperty::BrakeFluidLevel, "Brake", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::BrakeFluidLevel, "Brake", AbstractProperty::Read); /** @attributeName Washer * @type unsigned short * @access readonly * @attributeComment \brief MUST return Washer fluid level percentage. 0-100. **/ - wantProperty<uint16_t>(VehicleProperty::WasherFluidLevel, "Washer", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::WasherFluidLevel, "Washer", AbstractProperty::Read); } }; /** @interface Battery : VehiclePropertyType **/ +/// TODO: deprecated. remove in 0.13 class BatteryProperty: public DBusSink { public: @@ -66,15 +68,41 @@ public: * @access readonly * @attributeComment \brief MUST return battery voltage. **/ - wantProperty<double>(VehicleProperty::BatteryVoltage, "Voltage", "d", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::BatteryVoltage, "Voltage", "d", AbstractProperty::Read); /** @attributeName Current * @type double * @access readonly * @attributeComment \brief MUST return battery current in Amperes **/ - wantProperty<double>(VehicleProperty::BatteryCurrent, "Current", "d", AbstractProperty::Read); - + wantPropertyVariant(VehicleProperty::BatteryCurrent, "Current", "d", AbstractProperty::Read); + + } +}; + +/** @interface Battery : VehiclePropertyType **/ +class BatteryStatusProperty: public DBusSink +{ +public: + BatteryStatusProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("BatteryStatus", re, connection, map<string, string>()) + { + /** @attributeName Voltage + * @type double + * @access readonly + * @attributeComment \brief MUST return battery voltage. + **/ + wantPropertyVariant(VehicleProperty::BatteryVoltage, "Voltage", AbstractProperty::Read); + + /** @attributeName Current + * @type double + * @access readonly + * @attributeComment \brief MUST return battery current in Amperes + **/ + wantPropertyVariant(VehicleProperty::BatteryCurrent, "Current", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::BatteryCurrent, "ChargeLevel", AbstractProperty::Read); + } }; @@ -85,8 +113,21 @@ public: TireProperty(AbstractRoutingEngine* re, GDBusConnection* connection) :DBusSink("Tire", re, connection, map<string, string>()) { - wantProperty<double>(VehicleProperty::TirePressure, "Pressure", "d", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::TireTemperature, "Temperature", "d", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::TirePressure, "Pressure", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::TirePressureLow, "PressureLow", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::TireTemperature, "Temperature", AbstractProperty::Read); + } +}; + + +class EngineCoolant: public DBusSink +{ +public: + EngineCoolant(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("EngineCoolant", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::EngineCoolantLevel, "Level", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::EngineCoolantTemperature, "Temperature", AbstractProperty::Read); } }; diff --git a/plugins/dbus/runningstatus.h b/plugins/dbus/runningstatus.h index 2ad2bd2c..38f0b873 100644 --- a/plugins/dbus/runningstatus.h +++ b/plugins/dbus/runningstatus.h @@ -157,7 +157,7 @@ public: wantPropertyVariant(VehicleProperty::TransmissionGearPosition, "Gear", "y", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::TransmissionMode, + wantPropertyVariant(VehicleProperty::TransmissionModeW3C, "Mode", "y", AbstractProperty::Read); wantPropertyVariant(VehicleProperty::TransmissionGearType, "Type", "q", AbstractProperty::Read); @@ -189,6 +189,7 @@ public: }; /** @interface WheelBrake : VehiclePropertyType **/ +/// TODO: deprecated remove in 0.13 class WheelBrakeProperty: public DBusSink { public: @@ -205,6 +206,23 @@ public: } }; +/** @interface WheelBrake : VehiclePropertyType **/ +class BrakeOperation: public DBusSink +{ +public: + BrakeOperation(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("BrakeOperation", re, connection, map<string, string>()) + { + /** @attributeName Engaged + * @type boolean + * @access readonly + * @attributeComment \brief Must return Wheel Brake status: Engaged = true, disengaged = false + **/ + wantPropertyVariant(VehicleProperty::WheelBrake, "brakePedalDepressed", "b", AbstractProperty::Read); + + } +}; + /** @interface LightStatus : VehiclePropertyType **/ class LightStatusProperty: public DBusSink { @@ -268,6 +286,9 @@ public: **/ wantPropertyVariant(VehicleProperty::LightHighBeam, "HighBeam", "b", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::LightAutomatic, "automaticHeadlights", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::LightDynamicHighBeam, "dynamicHighBeam", AbstractProperty::Read); + } }; @@ -326,15 +347,21 @@ public: FuelProperty(AbstractRoutingEngine *re, GDBusConnection *connection) :DBusSink("Fuel", re, connection, map<string, string>()) { - wantPropertyVariant(VehicleProperty::FuelLevel,"Level", "y", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::FuelLevel,"Level", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::FuelRange,"Range", AbstractProperty::Read); + + wantPropertyVariant(VehicleProperty::FuelConsumption,"InstantConsumption", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::FuelRange,"Range", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::FuelEconomy,"InstantEconomy", AbstractProperty::Read); - wantPropertyVariant(VehicleProperty::FuelConsumption,"InstantConsumption", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::FuelAverageEconomy,"AverageEconomy", AbstractProperty::ReadWrite); - wantPropertyVariant(VehicleProperty::FuelEconomy,"InstantEconomy", "q", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::FuelAverageConsumption,"AverageConsumption", AbstractProperty::ReadWrite); - wantPropertyVariant(VehicleProperty::FuelAverageEconomy,"AverageEconomy", "q", AbstractProperty::ReadWrite); + wantPropertyVariant(VehicleProperty::FuelConsumptionSinceRestart,"FuelConsumedSinceRestart", AbstractProperty::ReadWrite); + + wantPropertyVariant(VehicleProperty::FuelTimeSinceRestart,"TimeSinceRestart", AbstractProperty::ReadWrite); } }; @@ -408,4 +435,46 @@ public: } }; +class SteeringWheel: public DBusSink +{ +public: + SteeringWheel(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("SteeringWheel", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::SteeringWheelAngleW3C, "Angle", AbstractProperty::Read); + } +}; + +class ThrottlePosition: public DBusSink +{ +public: + ThrottlePosition(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("ThrottlePosition", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::ThrottlePosition, "Value", "i", AbstractProperty::Read); + } +}; + +class NightMode: public DBusSink +{ +public: + NightMode(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("NightMode", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::NightMode, "NightMode", "b", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::NightMode, "Mode", "b", AbstractProperty::Read); + } +}; + +class DrivingMode: public DBusSink +{ +public: + DrivingMode(AbstractRoutingEngine *re, GDBusConnection *connection) + :DBusSink("DrivingMode", re, connection, map<string, string>()) + { + wantPropertyVariant(VehicleProperty::DrivingMode, "DrivingMode", "i", AbstractProperty::Read); + wantPropertyVariant(VehicleProperty::DrivingModeW3C, "Mode", "b", AbstractProperty::Read); + } +}; + #endif diff --git a/plugins/dbus/uncategorizedproperty.cpp b/plugins/dbus/uncategorizedproperty.cpp index 6351c230..1ac34aba 100644 --- a/plugins/dbus/uncategorizedproperty.cpp +++ b/plugins/dbus/uncategorizedproperty.cpp @@ -17,7 +17,7 @@ UncategorizedPropertyInterface::UncategorizedPropertyInterface(VehicleProperty:: std::string signature = g_variant_get_type_string(var); g_variant_unref(var); - propertyDBusMap.push_back( new VariantType(re, signature, prop, prop, VariantType::ReadWrite)); + propertyDBusMap.push_back( new VariantType(re, prop, prop, VariantType::ReadWrite)); delete temp; diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp index abf31be9..730ed59c 100644 --- a/plugins/dbus/varianttype.cpp +++ b/plugins/dbus/varianttype.cpp @@ -3,7 +3,7 @@ #include "debugout.h" #include "listplusplus.h" -VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, VehicleProperty::Property ambPropertyName, std::string propertyName, Access access) +VariantType::VariantType(AbstractRoutingEngine* re, VehicleProperty::Property ambPropertyName, std::string propertyName, Access access) :AbstractProperty(propertyName, access), mInitialized(false) { mAmbPropertyName = ambPropertyName; diff --git a/plugins/dbus/varianttype.h b/plugins/dbus/varianttype.h index 6db5915d..09f550aa 100644 --- a/plugins/dbus/varianttype.h +++ b/plugins/dbus/varianttype.h @@ -8,7 +8,7 @@ class VariantType: public AbstractProperty { public: - VariantType(AbstractRoutingEngine* re, string signature, VehicleProperty::Property ambPropertyName, string propertyName, Access access); + VariantType(AbstractRoutingEngine* re, VehicleProperty::Property ambPropertyName, string propertyName, Access access); void initialize(); diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index c7bf2655..2e59d295 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -41,9 +41,9 @@ const char* id = "6dd4268a-c605-4a06-9034-59c1e8344c8e"; static gboolean timeoutCallback(gpointer data) { ExampleSourcePlugin* src = (ExampleSourcePlugin*)data; - + src->randomizeProperties(); - + return true; } @@ -110,7 +110,7 @@ ExampleSourcePlugin::ExampleSourcePlugin(AbstractRoutingEngine* re, map<string, extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config) { return new ExampleSourcePlugin(routingengine, config); - + } const string ExampleSourcePlugin::uuid() @@ -361,10 +361,10 @@ void ExampleSourcePlugin::randomizeProperties() steeringWheelAngle = 1 + (359.00 * (rand() / (RAND_MAX + 1.0))); throttlePos = 1 + (100.00 * (rand() / (RAND_MAX + 1.0))); engineCoolant = 1 + (40.00 * (rand() / (RAND_MAX + 140.0))); - + DebugOut()<<"setting velocity to: "<<velocity<<endl; DebugOut()<<"setting enginespeed to: "<<engineSpeed<<endl; - + vel.setValue(velocity); vel.priority = AbstractPropertyType::High; es.setValue(engineSpeed); diff --git a/plugins/testplugin/testplugin.cpp b/plugins/testplugin/testplugin.cpp index 47a0f3fb..476660cb 100644 --- a/plugins/testplugin/testplugin.cpp +++ b/plugins/testplugin/testplugin.cpp @@ -52,10 +52,6 @@ bool beginsWith(std::string a, std::string b) { return (a.compare(0, b.length(), b) == 0); } -void TestPlugin::updateProperty(VehicleProperty::Property property,AbstractPropertyType* value) -{ - -} /** * Tests Core's methods: @@ -148,6 +144,7 @@ bool TestPlugin::testSubscription() int oldPropertyChanges = propertyChanges; AbstractPropertyType* value = new BasicPropertyType<int>(TestProptertyName1, 22); + value->priority = AbstractPropertyType::Instant; routingEngine->updateProperty(value, ""); TEST(oldSupportedPropertyChanges == supportedPropertyChanges); TEST(oldPropertyChanges == propertyChanges); @@ -157,6 +154,7 @@ bool TestPlugin::testSubscription() delete value; value = new BasicPropertyType<short>(TestProptertyName2, 255); + value->priority = AbstractPropertyType::Instant; routingEngine->updateProperty(value, ""); TEST(oldSupportedPropertyChanges == supportedPropertyChanges); TEST(oldPropertyChanges == propertyChanges); @@ -166,6 +164,7 @@ bool TestPlugin::testSubscription() delete value; value = new BasicPropertyType<bool>(VehicleProperty::ClutchStatus, true); + value->priority = AbstractPropertyType::Instant; routingEngine->updateSupported({VehicleProperty::ClutchStatus},PropertyList(), this); class TestSink : public AbstractSink @@ -209,6 +208,8 @@ bool TestPlugin::testSubscription() routingEngine->updateSupported(s, PropertyList(), this); VehicleProperty::VehicleSpeedType speed(10); + speed.priority = AbstractPropertyType::Instant; + routingEngine->updateProperty(&speed,uuid()); routingEngine->updateSupported(PropertyList(), s, this); @@ -379,7 +380,7 @@ int TestPlugin::supportedOperations() extern "C" AbstractSource * create(AbstractRoutingEngine* routingengine, map<string, string> config) { return new TestPlugin(routingengine, config); - + } const string TestPlugin::uuid() { @@ -405,7 +406,7 @@ void TestPlugin::unsubscribeToPropertyChanges(VehicleProperty::Property property void TestPlugin::getPropertyAsync(AsyncPropertyReply *reply) { - + } AsyncPropertyReply *TestPlugin::setProperty(AsyncSetPropertyRequest request ) @@ -418,7 +419,7 @@ AsyncPropertyReply *TestPlugin::setProperty(AsyncSetPropertyRequest request ) return reply; } -PropertyInfo TestPlugin::getPropertyInfo(VehicleProperty::Property property) +PropertyInfo TestPlugin::getPropertyInfo(const VehicleProperty::Property &property) { if(!contains(m_supportedProperties, property)) return PropertyInfo::invalid(); diff --git a/plugins/testplugin/testplugin.h b/plugins/testplugin/testplugin.h index f01d4753..1b91efae 100644 --- a/plugins/testplugin/testplugin.h +++ b/plugins/testplugin/testplugin.h @@ -55,9 +55,9 @@ public: void supportedChanged(const PropertyList &) {} void setConfiguration(map<string, string> config); //void randomizeProperties(); - void updateProperty(VehicleProperty::Property property,AbstractPropertyType *value); + void updateProperty(VehicleProperty::Property property, AbstractPropertyType *value); - PropertyInfo getPropertyInfo(VehicleProperty::Property property); + PropertyInfo getPropertyInfo(const VehicleProperty::Property & property); void propertyChanged(AbstractPropertyType *value); private: diff --git a/plugins/wheel/wheelplugin.cpp b/plugins/wheel/wheelplugin.cpp index 6115ce49..e8cb142c 100644 --- a/plugins/wheel/wheelplugin.cpp +++ b/plugins/wheel/wheelplugin.cpp @@ -49,7 +49,7 @@ double gearRatio[8] = { 1.0/0.69, //Sixth 1.0/3.21 //Reverse }; - + class WheelPrivate { @@ -90,20 +90,22 @@ private: int *axis; char *button; - uint16_t machineGuns; - TurnSignals::TurnSignalType turnSignal; - Transmission::TransmissionPositions currentGear; - uint16_t oilPSI; - uint16_t coolantTemp; - uint16_t steeringAngle; - uint16_t throttle; - bool clutch; - bool oldClutch; - bool brake; - bool oldBrake; + VehicleProperty::MachineGunTurretStatusType* machineGuns; + VehicleProperty::VehicleSpeedType *vehicleSpeed; + VehicleProperty::EngineSpeedType *engineSpeed; + VehicleProperty::TurnSignalType *turnSignal; + VehicleProperty::TransmissionShiftPositionType *shiftPosition; + VehicleProperty::TransmissionGearPositionType *gearPosition; + VehicleProperty::EngineOilPressureType *oilPSI; + VehicleProperty::EngineCoolantTemperatureType *coolantTemp; + VehicleProperty::SteeringWheelAngleType *steeringAngle; + VehicleProperty::ThrottlePositionType *throttle; + VehicleProperty::ClutchStatusType *clutch; + VehicleProperty::WheelBrakeType *brake; + AbstractSource* mParent; - VehicleProperty::ButtonEventType tempButton; + VehicleProperty::ButtonEventType *tempButton; }; @@ -132,16 +134,12 @@ const string WheelSourcePlugin::uuid() void WheelSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) { - - reply->value = this->mWheel->getProperty(reply->property); if(reply->value) reply->success = true; reply->completed(reply); - - delete reply->value; } AsyncPropertyReply *WheelSourcePlugin::setProperty(AsyncSetPropertyRequest request ) @@ -161,7 +159,6 @@ PropertyList WheelSourcePlugin::supported() props.push_back(VehicleProperty::VehicleSpeed); props.push_back(VehicleProperty::TransmissionShiftPosition); props.push_back(VehicleProperty::TransmissionGearPosition); - props.push_back(VehicleProperty::TransmissionMode); props.push_back(VehicleProperty::ThrottlePosition); props.push_back(VehicleProperty::WheelBrake); props.push_back(VehicleProperty::SteeringWheelAngle); @@ -200,10 +197,21 @@ void readCallback(GObject *srcObj, GAsyncResult *res, gpointer userData) } WheelPrivate::WheelPrivate(WheelSourcePlugin *parent, AbstractRoutingEngine *route) -:re(route), gis(nullptr), axis(nullptr), button(nullptr), -oilPSI(10), coolantTemp(100), turnSignal(TurnSignals::Off), throttle(0), -machineGuns(false), currentGear(Transmission::Neutral), steeringAngle(0), - clutch(false), oldClutch(false), brake(false), oldBrake(false), mParent(parent) + :re(route), gis(nullptr), axis(nullptr), button(nullptr), + oilPSI(new VehicleProperty::EngineOilPressureType(10)), + coolantTemp(new VehicleProperty::EngineCoolantTemperatureType(100)), + turnSignal(new VehicleProperty::TurnSignalType(TurnSignals::Off)), + throttle(new VehicleProperty::ThrottlePositionType(0)), + machineGuns(new VehicleProperty::MachineGunTurretStatusType(false)), + gearPosition(new VehicleProperty::TransmissionGearPositionType(Transmission::Neutral)), + shiftPosition(new VehicleProperty::TransmissionShiftPositionType(Transmission::Neutral)), + engineSpeed(new VehicleProperty::EngineSpeedType(0)), + vehicleSpeed(new VehicleProperty::VehicleSpeedType(0)), + steeringAngle(new VehicleProperty::SteeringWheelAngleType(0)), + clutch(new VehicleProperty::ClutchStatusType(false)), + brake(new VehicleProperty::WheelBrakeType(false)), + tempButton(new VehicleProperty::ButtonEventType(ButtonEvents::NoButton)), + mParent(parent) { unsigned char numAxes = 0; @@ -222,7 +230,7 @@ machineGuns(false), currentGear(Transmission::Neutral), steeringAngle(0), 1, 0, 0, 0, 536854528, 536854528, 1, 0, 0, 0, 536854528, 536854528 }; - + //FIXME: Support config file with joystick device mapping, button/axis mappings, etc. std::string jsdev = parent->getConfiguration()["device"]; @@ -245,30 +253,30 @@ machineGuns(false), currentGear(Transmission::Neutral), steeringAngle(0), for (i = 0; i < 6; i++) { int k = 0; - cal[i].type = calData[(i*6)+k]; + cal[i].type = calData[(i*6)+k]; k++; - cal[i].prec = calData[(i*6)+k]; + cal[i].prec = calData[(i*6)+k]; k++; - for(j = 0; j < 4; j++) { + for(j = 0; j < 4; j++) { cal[i].coef[j] = calData[(i*6)+k]; k++; - } - } + } + } if (ioctl(fd, JSIOCSCORR, &cal) < 0) { throw std::runtime_error("Could not set calibration data!"); return; } - cout << "Driver version: " << (version >> 16) << "." << ((version >> 8) & 0xFF) << "." << (version & 0xFF) << endl; - cout << "JS Name: " << name << endl; - cout << "JS Axes/Buttons: " << (int)numAxes << "/" << (int)numButtons << endl; - cout << "Converting FD to GIO Input Stream..." << endl; + DebugOut() << "Driver version: " << (version >> 16) << "." << ((version >> 8) & 0xFF) << "." << (version & 0xFF) << endl; + DebugOut() << "JS Name: " << name << endl; + DebugOut() << "JS Axes/Buttons: " << (int)numAxes << "/" << (int)numButtons << endl; + DebugOut() << "Converting FD to GIO Input Stream..." << endl; this->axis = (int *)calloc(numAxes, sizeof(int)); this->button = (char *)calloc(numButtons, sizeof(char)); this->gis = g_unix_input_stream_new(fd, TRUE); g_input_stream_read_async(this->gis, &this->jsEvent, sizeof(struct js_event), G_PRIORITY_DEFAULT, nullptr, &readCallback, this); - + } WheelPrivate::~WheelPrivate() @@ -281,33 +289,37 @@ WheelPrivate::~WheelPrivate() AbstractPropertyType *WheelPrivate::getProperty(VehicleProperty::Property propType) { if (propType == VehicleProperty::VehicleSpeed) - return new VehicleProperty::VehicleSpeedType(this->calcCarSpeed()); + { + vehicleSpeed->setValue(this->calcCarSpeed()); + return vehicleSpeed; + } else if (propType == VehicleProperty::EngineSpeed) - return new VehicleProperty::EngineSpeedType(this->calcRPM()); + { + engineSpeed->setValue(this->calcRPM()); + return engineSpeed; + } else if (propType == VehicleProperty::TransmissionShiftPosition) - return new VehicleProperty::TransmissionShiftPositionType(this->currentGear); + return this->shiftPosition; else if (propType == VehicleProperty::TransmissionGearPosition) - return new VehicleProperty::TransmissionGearPositionType(this->currentGear); - else if (propType == VehicleProperty::TransmissionMode) - return new VehicleProperty::TransmissionModeType(Transmission::Sports); + return this->gearPosition; else if (propType == VehicleProperty::ThrottlePosition) - return new VehicleProperty::ThrottlePositionType(this->throttle); + return this->throttle; else if (propType == VehicleProperty::WheelBrake) - return new VehicleProperty::WheelBrakeType(this->brake); + return this->brake; else if (propType == VehicleProperty::SteeringWheelAngle) - return new VehicleProperty::SteeringWheelAngleType(this->steeringAngle); + return this->steeringAngle; else if (propType == VehicleProperty::TurnSignal) - return new VehicleProperty::TurnSignalType(this->turnSignal); + return this->turnSignal; else if (propType == VehicleProperty::ClutchStatus) - return new VehicleProperty::ClutchStatusType(this->clutch); + return this->clutch; else if (propType == VehicleProperty::EngineOilPressure) - return new VehicleProperty::EngineOilPressureType(this->oilPSI); + return this->oilPSI; else if (propType == VehicleProperty::EngineCoolantTemperature) - return new VehicleProperty::EngineCoolantTemperatureType(this->coolantTemp); + return this->coolantTemp; else if (propType == VehicleProperty::MachineGunTurretStatus) - return new VehicleProperty::MachineGunTurretStatusType(this->machineGuns); + return this->machineGuns; else if (propType == VehicleProperty::ButtonEvent) - return new VehicleProperty::ButtonEventType(tempButton); + return tempButton; else cout << "Unhandled getProperty type: " << propType << endl; @@ -342,15 +354,15 @@ void WheelPrivate::newButtonValue(char number, bool val) checkButtonEvents(); break; case 4: //Right paddle shifter - if(val && this->currentGear < MAX_GEARS) + if(val && this->gearPosition->basicValue() < MAX_GEARS) { - this->changeGear(Transmission::TransmissionPositions(this->currentGear+1)); + this->changeGear(Transmission::TransmissionPositions(this->gearPosition->basicValue()+1)); changeMachineGuns(val); } break; case 5: //Left paddle shifter - if(val && this->currentGear > 0) - this->changeGear(Transmission::TransmissionPositions(this->currentGear-1)); + if(val && this->gearPosition->basicValue() > 0) + this->changeGear(Transmission::TransmissionPositions(this->gearPosition->basicValue()-1)); break; case 6: //Right upper wheel button this->changeTurnSignal(TurnSignals::Right, val); @@ -376,7 +388,7 @@ void WheelPrivate::newButtonValue(char number, bool val) case 21://Left lower wheel button //Coolant temperature down if (val) - this->changeCoolantTemp(false); + this->changeCoolantTemp(false); break; case 12://1st gear this->changeGear((val ? 1 : 0)); @@ -474,10 +486,8 @@ void WheelPrivate::gotData(GAsyncResult *res) void WheelPrivate::changeMachineGuns(bool val) { - this->machineGuns = val; - VehicleProperty::MachineGunTurretStatusType temp(this->machineGuns); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); + *(this->machineGuns) = val; + this->re->updateProperty(this->machineGuns, mParent->uuid()); } void WheelPrivate::changeTurnSignal(TurnSignals::TurnSignalType dir, bool val) @@ -489,129 +499,113 @@ void WheelPrivate::changeTurnSignal(TurnSignals::TurnSignalType dir, bool val) else tsVal = TurnSignals::Right; } - this->turnSignal = tsVal; - VehicleProperty::TurnSignalType temp(this->turnSignal); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); + *(this->turnSignal) = tsVal; + this->re->updateProperty(this->turnSignal, mParent->uuid()); } void WheelPrivate::changeGear(int gear) { - this->currentGear = (Transmission::TransmissionPositions)gear; - VehicleProperty::TransmissionShiftPositionType tempTrans(this->currentGear); - VehicleProperty::TransmissionGearPositionType tempTransGear(this->currentGear); - VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed()); - - this->re->updateProperty(&tempTrans, mParent->uuid()); - this->re->updateProperty(&tempTransGear, mParent->uuid()); - this->re->updateProperty(&tempSpeed, mParent->uuid()); + gearPosition->setValue((Transmission::TransmissionPositions)gear); + shiftPosition->setValue((Transmission::TransmissionPositions)gear); + + vehicleSpeed->setValue(this->calcCarSpeed()); + + this->re->updateProperty(gearPosition, mParent->uuid()); + this->re->updateProperty(shiftPosition, mParent->uuid()); + this->re->updateProperty(vehicleSpeed, mParent->uuid()); } void WheelPrivate::changeOilPressure(bool increase) { - VehicleProperty::EngineOilPressureType temp(increase ? ++this->oilPSI : --this->oilPSI); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); + (increase ? *(oilPSI)++ : *(oilPSI)--); + this->re->updateProperty(oilPSI, mParent->uuid()); } void WheelPrivate::changeCoolantTemp(bool increase) { - VehicleProperty::EngineCoolantTemperatureType temp(increase ? ++this->coolantTemp : --this->coolantTemp); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); + (increase ? ++(*coolantTemp) : --(*coolantTemp)); + + this->re->updateProperty(coolantTemp, mParent->uuid()); } void WheelPrivate::changeSteeringAngle(int val) { - this->steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; - VehicleProperty::SteeringWheelAngleType temp(this->steeringAngle); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); + *steeringAngle = (((double)val/(double)32767.0) + (double)1.0) * (double)180.0; + this->re->updateProperty(steeringAngle, mParent->uuid()); } void WheelPrivate::changeClutch(int val) { - this->oldClutch = this->clutch; - this->clutch = (val < 20000); - if (this->oldClutch != this->clutch) - { - VehicleProperty::ClutchStatusType temp(this->clutch); - temp.timestamp = amb::currentTime(); - this->re->updateProperty(&temp, mParent->uuid()); - } + + *clutch = (val < 20000); + this->re->updateProperty(clutch, mParent->uuid()); + } void WheelPrivate::changeThrottle(int val) { - this->throttle = ((double)(val - 32767)/(double)-65534.0)*(double)100.0; - - VehicleProperty::ThrottlePositionType tempThrottle(this->throttle); - VehicleProperty::EngineSpeedType tempRpm(this->calcRPM()); - VehicleProperty::VehicleSpeedType tempSpeed(this->calcCarSpeed()); + *throttle = ((double)(val - 32767)/(double)-65534.0)*(double)100.0; + *vehicleSpeed = calcCarSpeed(); + *engineSpeed = calcRPM(); - this->re->updateProperty(&tempThrottle, mParent->uuid()); - this->re->updateProperty(&tempRpm, mParent->uuid()); - this->re->updateProperty(&tempSpeed, mParent->uuid()); + this->re->updateProperty(throttle, mParent->uuid()); + this->re->updateProperty(engineSpeed, mParent->uuid()); + this->re->updateProperty(vehicleSpeed, mParent->uuid()); } void WheelPrivate::changeBrake(int val) { - this->oldBrake = this->brake; - this->brake = (val < 20000); - if (this->oldBrake != this->brake) - { - VehicleProperty::WheelBrakeType temp(this->brake); - this->re->updateProperty(&temp, mParent->uuid()); - } + *brake = (val < 20000); + this->re->updateProperty(brake, mParent->uuid()); } uint16_t WheelPrivate::calcCarSpeed() { // cout << "Calc Car Speed, rpm: " << this->calcRPM() << ", gearRatio: " << gearRatio[this->currentGear == 128 ? 7 : this->currentGear] << " current gear: " << this->currentGear << endl; - return (this->calcRPM() * gearRatio[this->currentGear == 128 ? 7 : this->currentGear])/100; + return (this->calcRPM() * gearRatio[this->gearPosition->basicValue() == 128 ? 7 : this->gearPosition->basicValue()])/100; } uint16_t WheelPrivate::calcRPM() { // cout << "Calc rpm, throttle: " << this->throttle << endl; - return this->throttle * 100; + return throttle->basicValue() * 100; } void WheelPrivate::checkButtonEvents() { if (this->button[0]) { // cout << "Inside button 11!" << endl; - tempButton = ButtonEvents::StopButton; + *tempButton = ButtonEvents::StopButton; } if (this->button[1]) { // cout << "Inside button 11!" << endl; - tempButton = (ButtonEvents::PrevButton); + *tempButton = (ButtonEvents::PrevButton); } if (this->button[2]) { - tempButton = (ButtonEvents::SkipButton); + *tempButton = (ButtonEvents::SkipButton); } if (this->button[3]) { - tempButton = ButtonEvents::PlayButton; + *tempButton = ButtonEvents::PlayButton; } if (this->button[11]) { - tempButton = (ButtonEvents::Preset1Button); + *tempButton = (ButtonEvents::Preset1Button); } if (this->button[8]) { - tempButton = (ButtonEvents::Preset2Button); + *tempButton = (ButtonEvents::Preset2Button); } if (this->button[9]) { - tempButton = (ButtonEvents::Preset3Button); + *tempButton = (ButtonEvents::Preset3Button); } if (this->button[10]) { - tempButton = (ButtonEvents::Preset4Button); + *tempButton = (ButtonEvents::Preset4Button); } - this->re->updateProperty(&tempButton, mParent->uuid()); + this->re->updateProperty(tempButton, mParent->uuid()); } diff --git a/tests/amb-set b/tests/amb-set index d6a972d7..19e25cf1 100755 --- a/tests/amb-set +++ b/tests/amb-set @@ -28,6 +28,8 @@ elif valueType == "string": realValue = value elif valueType == "double": realValue = double(value) +elif valueType == "UInt16": + realValue = dbus.UInt16(int(value)) bus = dbus.SystemBus() managerObject = bus.get_object("org.automotive.message.broker", "/"); |