added parking and environment properties
authorKevron Rees <tripzero.kev@gmail.com>
Mon, 11 Feb 2013 21:31:24 +0000 (13:31 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Fri, 15 Feb 2013 18:39:39 +0000 (10:39 -0800)
13 files changed:
TODO
docs/maintenance.txt
docs/parking.txt
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/dbus/CMakeLists.txt
plugins/dbus/dbusinterfacemanager.cpp
plugins/dbus/maintenance.cpp [new file with mode: 0644]
plugins/dbus/maintenance.h [new file with mode: 0644]
plugins/dbus/parking.cpp [moved from plugins/dbus/properties.cpp with 100% similarity]
plugins/dbus/parking.h [new file with mode: 0644]
plugins/dbus/runningstatus.cpp [new file with mode: 0644]
plugins/dbus/runningstatus.h [moved from plugins/dbus/properties.h with 86% similarity]

diff --git a/TODO b/TODO
index be88473..6520616 100644 (file)
--- 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)
index d306d2c..9e750d0 100644 (file)
@@ -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]
                        
index 056a365..90dbfd5 100644 (file)
@@ -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
index 7dbd30e..f91af1d 100644 (file)
@@ -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::Property> VehicleProperty::mCapabilities;
 std::list<VehicleProperty::Property> 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);
 
 
 }
index 5d6fab2..ad70529 100644 (file)
@@ -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<double> BatteryVoltageType;
 
+       static const Property BatteryCurrent;
+       typedef BasicPropertyType<double> BatteryCurrentType;
+
        /**< Interior Air Temperature in degrees celcius */
        static const Property InteriorTemperature;
        typedef BasicPropertyType<int> InteriorTemperatureType;
@@ -384,6 +395,50 @@ public:
        static const Property WheelTrack;
        typedef BasicPropertyType<uint> WheelTrackType;
 
+       static const Property Odometer;
+       typedef BasicPropertyType<uint> OdometerType;
+
+       /**< Transmission Fluid Level 0-100%.
+        **/
+       static const Property TransmissionFluidLevel;
+       typedef BasicPropertyType<uint16_t> TransmissionFluidLevelType;
+
+       /**< Brake Fluid Level 0-100%.
+        **/
+       static const Property BrakeFluidLevel;
+       typedef BasicPropertyType<uint16_t> BrakeFluidLevelType;
+
+       /**< Washer Fluid Level 0-100%.
+        **/
+       static const Property WasherFluidLevel;
+       typedef BasicPropertyType<uint16_t> WasherFluidLevelType;
+
+       /**< Securty Alert Status
+        * status of security alert
+        * @see Security::Status
+        */
+       static const Property SecurityAlertStatus;
+       typedef BasicPropertyType<Security::Status> SecurityAlertStatusType;
+
+       /**< Parking Brake Status
+        * status of parking break active (true) or inactive (false)
+        */
+       static const Property ParkingBrakeStatus;
+       typedef BasicPropertyType<bool> ParkingBrakeStatusType;
+
+       /**< Parking Light Status
+        * status of parking lights active (true) or inactive (false)
+        */
+       static const Property ParkingLightStatus;
+       typedef BasicPropertyType<bool> ParkingLightStatusType;
+
+       /**< Hazard Lights Status
+        * status of parking lights active (true) or inactive (false)
+        */
+       static const Property HazardLightStatus;
+       typedef BasicPropertyType<bool> HazardLightStatusType;
+
+
        /** END PROPERTIES **/
 
 
index d8c6432..548aa56 100644 (file)
@@ -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 "")
index e84182f..812df7b 100644 (file)
@@ -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 (file)
index 0000000..010bf9a
--- /dev/null
@@ -0,0 +1 @@
+#include "maintenance.h"
diff --git a/plugins/dbus/maintenance.h b/plugins/dbus/maintenance.h
new file mode 100644 (file)
index 0000000..80995af
--- /dev/null
@@ -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<string, string>())
+       {
+               wantProperty<uint>(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<string, string>())
+       {
+               wantProperty<double>(VehicleProperty::BatteryVoltage,"Voltage", "d", AbstractProperty::Read);
+               wantProperty<double>(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<string, string>())
+       {
+               wantProperty<double>(VehicleProperty::TirePressureLeftFront,"LeftFront", "d", AbstractProperty::Read);
+               wantProperty<double>(VehicleProperty::TirePressureRightFront,"RightFront", "d", AbstractProperty::Read);
+               wantProperty<double>(VehicleProperty::TirePressureLeftRear,"LeftRear", "d", AbstractProperty::Read);
+               wantProperty<double>(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<string, string>())
+       {
+               wantProperty<double>(VehicleProperty::TireTemperatureLeftFront,"LeftFront", "d", AbstractProperty::Read);
+               wantProperty<double>(VehicleProperty::TireTemperatureRightFront,"RightFront", "d", AbstractProperty::Read);
+               wantProperty<double>(VehicleProperty::TireTemperatureLeftRear,"LeftRear", "d", AbstractProperty::Read);
+               wantProperty<double>(VehicleProperty::TireTemperatureRightRear,"RightRear", "d", AbstractProperty::Read);
+               supportedChanged(re->supported());
+       }
+};
+
+#endif
diff --git a/plugins/dbus/parking.h b/plugins/dbus/parking.h
new file mode 100644 (file)
index 0000000..3ab2b1a
--- /dev/null
@@ -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<string, string>())
+       {
+               wantProperty<bool>(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<string, string>())
+       {
+               wantProperty<bool>(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<string, string>())
+       {
+               wantProperty<bool>(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<string, string>())
+       {
+               wantProperty<bool>(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 (file)
index 0000000..e69de29
similarity index 86%
rename from plugins/dbus/properties.h
rename to plugins/dbus/runningstatus.h
index 6ea677c..660b110 100644 (file)
@@ -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<string, string>())
-       {
-               wantProperty<double>(VehicleProperty::TirePressureLeftFront,"LeftFront", "d", AbstractProperty::Read);
-               wantProperty<double>(VehicleProperty::TirePressureRightFront,"RightFront", "d", AbstractProperty::Read);
-               wantProperty<double>(VehicleProperty::TirePressureLeftRear,"LeftRear", "d", AbstractProperty::Read);
-               wantProperty<double>(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<string, string>())
-       {
-               wantProperty<double>(VehicleProperty::TireTemperatureLeftFront,"LeftFront", "d", AbstractProperty::Read);
-               wantProperty<double>(VehicleProperty::TireTemperatureRightFront,"RightFront", "d", AbstractProperty::Read);
-               wantProperty<double>(VehicleProperty::TireTemperatureLeftRear,"LeftRear", "d", AbstractProperty::Read);
-               wantProperty<double>(VehicleProperty::TireTemperatureRightRear,"RightRear", "d", AbstractProperty::Read);
-               supportedChanged(re->supported());
-       }
-};
-
 
 class CruiseControlProperty: public DBusSink
 {