From 099954b69268d325fa48a975eec95e2390765d25 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Mon, 11 Feb 2013 13:31:24 -0800 Subject: [PATCH] added parking and environment properties --- TODO | 3 +- docs/maintenance.txt | 75 +++++++++++++++++--------- docs/parking.txt | 47 ++++++++++------ lib/vehicleproperty.cpp | 20 ++++++- lib/vehicleproperty.h | 55 +++++++++++++++++++ plugins/dbus/CMakeLists.txt | 4 +- plugins/dbus/dbusinterfacemanager.cpp | 10 +++- plugins/dbus/maintenance.cpp | 1 + plugins/dbus/maintenance.h | 63 ++++++++++++++++++++++ plugins/dbus/{properties.cpp => parking.cpp} | 0 plugins/dbus/parking.h | 59 ++++++++++++++++++++ plugins/dbus/runningstatus.cpp | 0 plugins/dbus/{properties.h => runningstatus.h} | 28 ---------- 13 files changed, 291 insertions(+), 74 deletions(-) create mode 100644 plugins/dbus/maintenance.cpp create mode 100644 plugins/dbus/maintenance.h rename plugins/dbus/{properties.cpp => parking.cpp} (100%) create mode 100644 plugins/dbus/parking.h create mode 100644 plugins/dbus/runningstatus.cpp rename plugins/dbus/{properties.h => runningstatus.h} (86%) diff --git a/TODO b/TODO index be88473..6520616 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,5 @@ - websocket source may want to implement a timeout on Get/Set/GetRanged calls and reply with success=false (TEST) - enable ssl on websocket by default with option to turn it off - investigate and enable use of provisioning in ssl websockets -- support custom vendor properties in dbus sink +- add API to get number of sources per a given property +- DBus support for objects with multiple sources (ie battery(n)Voltage where 'n' is a battery source) diff --git a/docs/maintenance.txt b/docs/maintenance.txt index d306d2c..9e750d0 100644 --- a/docs/maintenance.txt +++ b/docs/maintenance.txt @@ -2,45 +2,68 @@ Maintenance hierarchy ================= Service org.automotive -Interface org.automotive.maintenance -Object path / -Properties uint32 Odometer [readonly] + +Interface org.automotive.odometer +Object path /org/automotive/maintenance/odometer +Properties: + + uint32 Odometer [readonly] Distance in km - - byte TransmissionFluid [readonly] + +Interface org.automotive.fluid +Object path /org/automotive/maintenance/fluid +Properties: + + + byte Transmission [readonly] Remaining percentage - byte BrakeFluid [readonly] + byte Brake [readonly] Remaining percentage - byte WasherFluid [readonly] + byte Washer [readonly] Remaining percentage + +Interface org.automotive.batteryStatus +Object path /org/automotive/maintenance/batteryStatus +Properties: - struct{ double, double } BatteryStatus [readonly] + double Voltage [readonly] - Voltage (double) - Current (double) + double Current [readonly] + + +Interface org.automotive.tirePressure +Object path /org/automotive/maintenance/tirePressure +Properties: - dict{ byte, double } TirePressure [readonly] + double LeftFront [readonly] - Tire (byte), Pressure (kPa) - Tire: - LeftFront = 0, - RightFront = 1, - LeftRear = 2, - RightRear = 3 - - dict( byte, double } TireTemperature [readonly] - - Tire (byte), Temperature (C) - Tire: - LeftFront = 0, - RightFront = 1, - LeftRear = 2, - RightRear = 3 + Pressure (kPa) + + double RightFront [readonly] + + double LeftRear [readonly] + + double RightRear [readonly] + + +Interface org.automotive.tireTemperature +Object path /org/automotive/maintenance/tireTemperature +Properties: + + double LeftFront [readonly] + + Temperature of tire in Celsius (C) + + double RightFront [readonly] + + double LeftRear [readonly] + + double RightRear [readonly] diff --git a/docs/parking.txt b/docs/parking.txt index 056a365..90dbfd5 100644 --- a/docs/parking.txt +++ b/docs/parking.txt @@ -2,27 +2,44 @@ Parking hierarchy ================= Service org.automotive -Interface org.automotive.parking -Object path / +Object path: /org/automotive/parking/* -Properties byte SecurityAlert [readonly] + + +Interface org.automotive.securityAlert +Object path /org/automotive/parking/securityAlert +Properties: + byte SecurityAlert [readonly] - returns status of security alert: + returns status of security alert: + + Idle = 0, + Armed = 1, + Alarm Detected = 2 - Idle = 0, - Armed = 1, - Alarm Detected = 2 +Interface org.automotive.parkingBrake +Object path /org/automotive/parking/parkingBrake +Properties: - bool ParkingBrake + bool ParkingBrake - returns whether the parking break is active (true)/inactive (false) + returns whether the parking break is active (true)/inactive (false) - bool ParkingLights + +Interface org.automotive.parkingLights +Object path /org/automotive/parking/parkingLights +Properties: + + bool ParkingLights - returns whether the parking lights are active (true) or inactive (false) - - bool HazardLights + returns whether the parking lights are active (true) or inactive (false) + +Interface org.automotive.hazardLights +Object path /org/automotive/parking/hazardLights +Properties: + + bool HazardLights - returns whether the hazard lights are active (true)/inactive (false) + returns whether the hazard lights are active (true) or inactive (false) + - \ No newline at end of file diff --git a/lib/vehicleproperty.cpp b/lib/vehicleproperty.cpp index 7dbd30e..f91af1d 100644 --- a/lib/vehicleproperty.cpp +++ b/lib/vehicleproperty.cpp @@ -56,6 +56,7 @@ const VehicleProperty::Property VehicleProperty::MassAirFlow = "MassAirFlow"; 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::InteriorTemperature = "InteriorTemperature"; const VehicleProperty::Property VehicleProperty::EngineOilTemperature = "EngineOilTemperature"; const VehicleProperty::Property VehicleProperty::VIN = "VIN"; @@ -109,6 +110,15 @@ const VehicleProperty::Property VehicleProperty::TransmissionGearType = "Transmi const VehicleProperty::Property VehicleProperty::FrontWheelRadius = "FrontWheelRadius"; const VehicleProperty::Property VehicleProperty::RearWheelRadius = "RearWheelRadius"; const VehicleProperty::Property VehicleProperty::WheelTrack = "WheelTrack"; +const VehicleProperty::Property VehicleProperty::Odometer = "Odometer"; +const VehicleProperty::Property VehicleProperty::TransmissionFluidLevel = "TransmissionFluidLevel"; +const VehicleProperty::Property VehicleProperty::BrakeFluidLevel = "BrakeFluidLevel"; +const VehicleProperty::Property VehicleProperty::WasherFluidLevel = "WasherFluidLevel"; +const VehicleProperty::Property VehicleProperty::SecurityAlertStatus = "SecurityAlertStatus"; +const VehicleProperty::Property VehicleProperty::ParkingBrakeStatus = "ParkingBrakeStatus"; +const VehicleProperty::Property VehicleProperty::ParkingLightStatus = "ParkingLightStatus"; +const VehicleProperty::Property VehicleProperty::HazardLightStatus = "HazardLightStatus"; + std::list VehicleProperty::mCapabilities; std::list VehicleProperty::mCustomProperties; @@ -138,6 +148,7 @@ VehicleProperty::VehicleProperty() registerPropertyPriv(ButtonEvent, [](){ return new ButtonEventType(ButtonEvents::NoButton); }); REGISTERPROPERTY(AirIntakeTemperature,0) registerPropertyPriv(BatteryVoltage, [](){ return new BatteryVoltageType(0); }); + REGISTERPROPERTY(BatteryCurrent,0); registerPropertyPriv(InteriorTemperature, [](){ return new InteriorTemperatureType(0); }); registerPropertyPriv(VIN, [](){ return new VINType(""); }); registerPropertyPriv(WMI, [](){ return new WMIType(""); }); @@ -189,7 +200,14 @@ VehicleProperty::VehicleProperty() REGISTERPROPERTYWITHTYPE(FrontWheelRadius, WheelRadiusType, 0); REGISTERPROPERTYWITHTYPE(RearWheelRadius, WheelRadiusType, 0); REGISTERPROPERTY(WheelTrack,0); - + REGISTERPROPERTY(Odometer,0); + REGISTERPROPERTY(TransmissionFluidLevel,0); + REGISTERPROPERTY(BrakeFluidLevel,0); + REGISTERPROPERTY(WasherFluidLevel,0); + REGISTERPROPERTY(SecurityAlertStatus,0); + REGISTERPROPERTY(ParkingBrakeStatus,false); + REGISTERPROPERTY(ParkingLightStatus,false); + REGISTERPROPERTY(HazardLightStatus,false); } diff --git a/lib/vehicleproperty.h b/lib/vehicleproperty.h index 5d6fab2..ad70529 100644 --- a/lib/vehicleproperty.h +++ b/lib/vehicleproperty.h @@ -145,6 +145,14 @@ enum Type }; } +namespace Security { +enum Status +{ + Idle = 0, + Armed, + AlarmDetected +}; +} class VehicleProperty @@ -257,6 +265,9 @@ public: static const Property BatteryVoltage; typedef BasicPropertyType BatteryVoltageType; + static const Property BatteryCurrent; + typedef BasicPropertyType BatteryCurrentType; + /**< Interior Air Temperature in degrees celcius */ static const Property InteriorTemperature; typedef BasicPropertyType InteriorTemperatureType; @@ -384,6 +395,50 @@ public: static const Property WheelTrack; typedef BasicPropertyType WheelTrackType; + static const Property Odometer; + typedef BasicPropertyType OdometerType; + + /**< Transmission Fluid Level 0-100%. + **/ + static const Property TransmissionFluidLevel; + typedef BasicPropertyType TransmissionFluidLevelType; + + /**< Brake Fluid Level 0-100%. + **/ + static const Property BrakeFluidLevel; + typedef BasicPropertyType BrakeFluidLevelType; + + /**< Washer Fluid Level 0-100%. + **/ + static const Property WasherFluidLevel; + typedef BasicPropertyType WasherFluidLevelType; + + /**< Securty Alert Status + * status of security alert + * @see Security::Status + */ + static const Property SecurityAlertStatus; + typedef BasicPropertyType SecurityAlertStatusType; + + /**< Parking Brake Status + * status of parking break active (true) or inactive (false) + */ + static const Property ParkingBrakeStatus; + typedef BasicPropertyType ParkingBrakeStatusType; + + /**< Parking Light Status + * status of parking lights active (true) or inactive (false) + */ + static const Property ParkingLightStatus; + typedef BasicPropertyType ParkingLightStatusType; + + /**< Hazard Lights Status + * status of parking lights active (true) or inactive (false) + */ + static const Property HazardLightStatus; + typedef BasicPropertyType HazardLightStatusType; + + /** END PROPERTIES **/ diff --git a/plugins/dbus/CMakeLists.txt b/plugins/dbus/CMakeLists.txt index d8c6432..548aa56 100644 --- a/plugins/dbus/CMakeLists.txt +++ b/plugins/dbus/CMakeLists.txt @@ -3,8 +3,8 @@ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs}) pkg_check_modules(gio REQUIRED gio-2.0) -set(dbussinkplugin_headers dbusplugin.h abstractproperty.h abstractdbusinterface.h dbusinterfacemanager.h basicproperty.h properties.h varianttype.h custompropertyinterface.h environmentproperties.h vehicleinfo.h) -set(dbussinkplugin_sources dbusplugin.cpp abstractproperty.cpp abstractdbusinterface.cpp dbusinterfacemanager.cpp basicproperty.cpp properties.cpp varianttype.cpp custompropertyinterface.cpp environmentproperties.cpp vehicleinfo.cpp) +set(dbussinkplugin_headers dbusplugin.h abstractproperty.h abstractdbusinterface.h dbusinterfacemanager.h basicproperty.h runningstatus.h varianttype.h custompropertyinterface.h environmentproperties.h vehicleinfo.h maintenance.h parking.h) +set(dbussinkplugin_sources dbusplugin.cpp abstractproperty.cpp abstractdbusinterface.cpp dbusinterfacemanager.cpp basicproperty.cpp runningstatus.cpp varianttype.cpp custompropertyinterface.cpp environmentproperties.cpp vehicleinfo.cpp maintenance.cpp parking.cpp) add_library(dbussinkplugin MODULE ${dbussinkplugin_sources}) set_target_properties(dbussinkplugin PROPERTIES PREFIX "") diff --git a/plugins/dbus/dbusinterfacemanager.cpp b/plugins/dbus/dbusinterfacemanager.cpp index e84182f..812df7b 100644 --- a/plugins/dbus/dbusinterfacemanager.cpp +++ b/plugins/dbus/dbusinterfacemanager.cpp @@ -24,10 +24,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ///properties: #include "accelerationproperty.h" -#include "properties.h" +#include "runningstatus.h" #include "custompropertyinterface.h" #include "environmentproperties.h" #include "vehicleinfo.h" +#include "maintenance.h" +#include "parking.h" #define ConstructProperty(property) \ new property(iface->re, connection); @@ -61,6 +63,12 @@ on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer user_d ConstructProperty(SizeProperty); ConstructProperty(DoorsProperty); ConstructProperty(WheelInformationProperty); + ConstructProperty(OdometerProperty); + ConstructProperty(BatteryProperty); + ConstructProperty(SecurityAlertProperty); + ConstructProperty(ParkingBrakeProperty); + ConstructProperty(ParkingLightProperty); + ConstructProperty(HazardLightProperty); PropertyList list = VehicleProperty::customProperties(); diff --git a/plugins/dbus/maintenance.cpp b/plugins/dbus/maintenance.cpp new file mode 100644 index 0000000..010bf9a --- /dev/null +++ b/plugins/dbus/maintenance.cpp @@ -0,0 +1 @@ +#include "maintenance.h" diff --git a/plugins/dbus/maintenance.h b/plugins/dbus/maintenance.h new file mode 100644 index 0000000..80995af --- /dev/null +++ b/plugins/dbus/maintenance.h @@ -0,0 +1,63 @@ +#ifndef _MAINTENANCE_H_ +#define _MAINTENANCE_H_ + + +#include "dbusplugin.h" +#include "abstractdbusinterface.h" +#include "abstractroutingengine.h" + + +class OdometerProperty: public DBusSink +{ +public: + OdometerProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.odometer","/org/automotive/maintenance/odometer", re, connection, map()) + { + wantProperty(VehicleProperty::Odometer,"Odometer", "i", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + +class BatteryProperty: public DBusSink +{ +public: + BatteryProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.battery","/org/automotive/maintenance/battery", re, connection, map()) + { + wantProperty(VehicleProperty::BatteryVoltage,"Voltage", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::BatteryCurrent,"Current", "d", AbstractProperty::Read); + supportedChanged(re->supported()); + } +}; + + +class TirePressureProperty: public DBusSink +{ +public: + TirePressureProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.tirePressure","/org/automotive/maintenance/tirePressure", re, connection, map()) + { + wantProperty(VehicleProperty::TirePressureLeftFront,"LeftFront", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureRightFront,"RightFront", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureLeftRear,"LeftRear", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TirePressureRightRear,"RightRear", "d", AbstractProperty::Read); + supportedChanged(re->supported()); + } +}; + +class TireTemperatureProperty: public DBusSink +{ +public: + TireTemperatureProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.tireTemperature","/org/automotive/maintenance/tireTemperature", re, connection, map()) + { + wantProperty(VehicleProperty::TireTemperatureLeftFront,"LeftFront", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TireTemperatureRightFront,"RightFront", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TireTemperatureLeftRear,"LeftRear", "d", AbstractProperty::Read); + wantProperty(VehicleProperty::TireTemperatureRightRear,"RightRear", "d", AbstractProperty::Read); + supportedChanged(re->supported()); + } +}; + +#endif diff --git a/plugins/dbus/properties.cpp b/plugins/dbus/parking.cpp similarity index 100% rename from plugins/dbus/properties.cpp rename to plugins/dbus/parking.cpp diff --git a/plugins/dbus/parking.h b/plugins/dbus/parking.h new file mode 100644 index 0000000..3ab2b1a --- /dev/null +++ b/plugins/dbus/parking.h @@ -0,0 +1,59 @@ +#ifndef _PARKING_H_ +#define _PARKING_H_ + + +#include "dbusplugin.h" +#include "abstractdbusinterface.h" +#include "abstractroutingengine.h" + +class SecurityAlertProperty: public DBusSink +{ +public: + SecurityAlertProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.securityAlert","/org/automotive/parking/securityAlert", re, connection, map()) + { + wantProperty(VehicleProperty::SecurityAlertStatus,"SecurityAlert", "b", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + + +class ParkingBrakeProperty: public DBusSink +{ +public: + ParkingBrakeProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.parkingBrake","/org/automotive/parking/parkingBrake", re, connection, map()) + { + wantProperty(VehicleProperty::ParkingBrakeStatus,"ParkingBrake", "b", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + +class ParkingLightProperty: public DBusSink +{ +public: + ParkingLightProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.parkingLight","/org/automotive/parking/parkingLight", re, connection, map()) + { + wantProperty(VehicleProperty::ParkingLightStatus,"ParkingLight", "b", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + + +class HazardLightProperty: public DBusSink +{ +public: + HazardLightProperty(AbstractRoutingEngine* re, GDBusConnection* connection) + :DBusSink("org.automotive.parkingLight","/org/automotive/parking/parkingLight", re, connection, map()) + { + wantProperty(VehicleProperty::HazardLightStatus,"HazardLight", "b", AbstractProperty::Read); + + supportedChanged(re->supported()); + } +}; + +#endif diff --git a/plugins/dbus/runningstatus.cpp b/plugins/dbus/runningstatus.cpp new file mode 100644 index 0000000..e69de29 diff --git a/plugins/dbus/properties.h b/plugins/dbus/runningstatus.h similarity index 86% rename from plugins/dbus/properties.h rename to plugins/dbus/runningstatus.h index 6ea677c..660b110 100644 --- a/plugins/dbus/properties.h +++ b/plugins/dbus/runningstatus.h @@ -49,20 +49,6 @@ public: }; -class TirePressureProperty: public DBusSink -{ -public: - TirePressureProperty(AbstractRoutingEngine* re, GDBusConnection* connection) - :DBusSink("org.automotive.tirePressure","/org/automotive/maintainance/tirePressure", re, connection, map()) - { - wantProperty(VehicleProperty::TirePressureLeftFront,"LeftFront", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureRightFront,"RightFront", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureLeftRear,"LeftRear", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TirePressureRightRear,"RightRear", "d", AbstractProperty::Read); - supportedChanged(re->supported()); - } -}; - class VehiclePowerModeProperty: public DBusSink { public: @@ -117,20 +103,6 @@ public: } }; -class TireTemperatureProperty: public DBusSink -{ -public: - TireTemperatureProperty(AbstractRoutingEngine* re, GDBusConnection* connection) - :DBusSink("org.automotive.tireTemperature","/org/automotive/maintainance/tireTemperature", re, connection, map()) - { - wantProperty(VehicleProperty::TireTemperatureLeftFront,"LeftFront", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TireTemperatureRightFront,"RightFront", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TireTemperatureLeftRear,"LeftRear", "d", AbstractProperty::Read); - wantProperty(VehicleProperty::TireTemperatureRightRear,"RightRear", "d", AbstractProperty::Read); - supportedChanged(re->supported()); - } -}; - class CruiseControlProperty: public DBusSink { -- 2.7.4