Retry to Websocket connection failure. 36/10036/1 accepted/tizen/20130917.011215 accepted/tizen/20130917.224135 submit/tizen/20130917.010841
authorHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
Mon, 16 Sep 2013 09:28:48 +0000 (18:28 +0900)
committerHayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
Mon, 16 Sep 2013 09:32:16 +0000 (18:32 +0900)
Change-Id: Id2fed6621489d6f2aa42d894d3d22fab7b857278
Signed-off-by: Hayato Nakamura <hayato.nakamura@mail.toyota-td.jp>
G25.conf
G27.conf
packaging/ico-vic-carsimulator.changes
packaging/ico-vic-carsimulator.spec
src/AmbpiComm.cpp
src/CConf.cpp
src/CGtCtrl.cpp
src/CGtCtrl.h
src/CJoyStick.h
src/CJoyStickEV.cpp
src/CJoyStickEV.h

index 6e6b854..f1fb17c 100644 (file)
--- a/G25.conf
+++ b/G25.conf
@@ -20,7 +20,7 @@ TYPE=1
 NUMBER=301
 [HEAD_LIGHT]
 TYPE=1
-NUMBER=2
+NUMBER=292
 [STEERING]
 TYPE=2
 NUMBER=0
@@ -35,4 +35,3 @@ NUMBER=2
 LAT=35.717931
 LNG=139.736518
 
-
index 9908c1c..823f481 100644 (file)
--- a/G27.conf
+++ b/G27.conf
@@ -35,7 +35,7 @@ TYPE=1
 NUMBER=710
 [HEAD_LIGHT]
 TYPE=1
-NUMBER=2
+NUMBER=292
 [STEERING]
 TYPE=2
 NUMBER=0
@@ -50,4 +50,3 @@ NUMBER=5
 LAT=35.717931
 LNG=139.736518
 
-
index adf8c6b..d257265 100644 (file)
@@ -1,3 +1,12 @@
+* Mon Sep 16 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/2.0alpha-wayland/20130612.174818@b57c2a9
+- 0.9.03 release.
+-- Retry to Websocket connection failure.
+
+- 0.9.02 release
+-- Corresponding to Tizen IVI 3.0 OS
+-- Create an event definition file of G25 and G27 steering wheel
+-- Set to head-light state operation to the right paddle shifter
+
 * Fri Aug 30 2013 Shibata Makoto <shibata@mac.tec.toyota.co.jp> accepted/2.0alpha-wayland/20130612.174818@cbaa0e0
 - release 0.9.01
 -- Support G27 Racing Wheel. (Current Support device G27 Racing Wheel and Driving Force GT)
index 5b2f967..7ab5900 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ico-vic-carsimulator
 Summary:    CarSimulator
-Version:    0.9.0
+Version:    0.9.03
 Release:    1.1
 Group:      System Environment/Daemons
 License:    Apache 2.0
@@ -13,10 +13,8 @@ Requires:       ico-uxf-utilities
 BuildRequires:  make
 BuildRequires:  automake
 BuildRequires:  boost-devel
-#BuildRequires:  libwebsockets-devel
 BuildRequires:  glib2-devel
 BuildRequires:  json-glib-devel
-#BuildRequires:  ico-uxf-utilities
 BuildRequires:  ico-uxf-utilities-devel
 
 %description 
@@ -39,7 +37,6 @@ rm -rf %{buildroot}
 %define carsim_conf /usr/bin/
 mkdir -p %{buildroot}/etc/carsim/
 mkdir -p %{buildroot}/usr/lib/systemd/system/
-#install -m 0644 src/CarSim_Daemon.conf %{buildroot}%{carsim_conf}
 install -m 0644 G25.conf %{buildroot}/etc/carsim/
 install -m 0644 G27.conf %{buildroot}/etc/carsim/
 install -m 0644 carsim.service %{buildroot}/usr/lib/systemd/system/
@@ -52,4 +49,3 @@ install -m 0644 carsim.service %{buildroot}/usr/lib/systemd/system/
 %{_bindir}/*
 /etc/carsim/*
 /usr/lib/systemd/system/carsim.service
-#%{carsim_conf}/CarSim_Daemon.conf
index 8b3c043..b50f974 100644 (file)
@@ -19,6 +19,7 @@
 using namespace std;
 
 static vector<AmbpiCommIF*> _commList;
+const int RECONNECT_WS = 5;
 
 bool _addAmbCommIFList(AmbpiCommIF* comm);
 void _eraseAmbCommIFList(const AmbpiCommIF* comm);
@@ -225,11 +226,15 @@ bool AmbpiCommIF::init(const char* uri, const char* protocolName)
     }
     m_uri = uri;
     m_pNm = protocolName;
-    m_context = ico_uws_create_context(uri, protocolName);
-    if (NULL == m_context) {
+       int loopcount = 0;
+       do {
+               m_context = ico_uws_create_context(uri, protocolName);
+               if (NULL != m_context) {
+                       break;
+               }
         cerr << m_pNm << ":Failed to create context." << endl;
-        return false;
-    }
+               usleep (500 * 1000);
+       } while (m_context == NULL && ++loopcount < RECONNECT_WS);
     int r = ico_uws_set_event_cb(m_context, _icoUwsCallback, (void*)this);
     if (ICO_UWS_ERR_NONE != r) {
         cerr << m_pNm << ":Failed to callback entry(" << r << ")." << endl;
index 0cea4b5..904baa0 100644 (file)
@@ -52,6 +52,9 @@ void CConf::LoadConfig(const char*filePath)
     m_nAccel = CConf::GetConfig(m_strConfPath, "ACCEL", "NUMBER", 1);
     m_nBrake = CConf::GetConfig(m_strConfPath, "BRAKE", "NUMBER", 2);
 
+    m_nHeadLight =
+        CConf::GetConfig(m_strConfPath, "HEAD_LIGHT", "NUMBER", 292);
+
     m_fLat =
         CConf::GetConfig(m_strConfPath, "LASTPOSITION", "LAT", 35.717931);
     m_fLng =
index 75da1ca..f7fe957 100644 (file)
@@ -123,6 +123,7 @@ bool CGtCtrl::Initialize()
     m_stVehicleInfo.nDirection = 0;
     m_stVehicleInfo.dVelocity = 0.0;
     m_stVehicleInfo.nAccel = 0;
+    m_stVehicleInfo.bHeadLight = false; // HEAD LIGHT OFF(false)
 
     m_bFirstOpen = true;
 
@@ -237,7 +238,7 @@ void CGtCtrl::Run()
     int nAccPedalOpen = -1;
     int nSpeed = -1;
     CAvgCar pmCar(g_RPM_SAMPLE_SPACE_SIZE, g_SPEED_SAMPLE_SPACE_SIZE,
-                        g_BREAKE_SAMPLE_SPACE_SIZE);
+                  g_BREAKE_SAMPLE_SPACE_SIZE);
     pmCar.chgGear(CAvgGear::E_SHIFT_PARKING);
     /**
      * DIRECTION
@@ -268,33 +269,21 @@ void CGtCtrl::Run()
                                     vi, m_stVehicleInfo.nSteeringAngle);
                 }
             }
-
-            if (number == myConf.m_nAccel) {
-                //printf("Accel[%d]\n", value);
-                if (gbDevJs) {
-                    if (0 == value) {
-                        pmCar.chgThrottle(32767);
-                        pmCar.chgBrake(32767);
-                    }
-                    else if (0 < value) {
-                        pmCar.chgThrottle(32767);
-                        pmCar.chgBrake((value - 16384) * -2);
-                    }
-                    else {
-                        pmCar.chgThrottle((abs(value) - 16384) * -2);
-                        pmCar.chgBrake(32767);
-                    }
+            else if (number == myConf.m_nAccel) {
+                if (0 >= value) {
+                    pmCar.chgThrottle(32767);
                 }
                 else {
-                    pmCar.chgThrottle((65535 - value) / 1.1 + 32767);
-                    pmCar.chgBrake(32767);
+                    pmCar.chgThrottle((value - 16384) * -2);
                 }
             }
-
-            if (number == myConf.m_nBrake) {
-                //printf("Brake[%d]\n", value);
-                pmCar.chgThrottle(32767);
-                pmCar.chgBrake((65535 - value) / 64 + 32767);
+            else if (number == myConf.m_nBrake) {
+                if (0 >= value) {
+                    pmCar.chgBrake(32767);
+                }
+                else {
+                    pmCar.chgBrake((value - 16384) * -2);
+                }
             }
             break;
         case JS_EVENT_BUTTON:
@@ -425,7 +414,7 @@ void CGtCtrl::Run()
             /**
              * TURN SIGNAL(WINKER) & LIGHTSTATUS
              */
-            bool bTurnSignal = false;
+            bool bLIGHTSTATUS = false;
             if (number == myConf.m_nWinkR) {
                 if (value != 0) {
 
@@ -440,7 +429,7 @@ void CGtCtrl::Run()
                     int wpos =
                         m_stVehicleInfo.nWinkerPos == WINKER_RIGHT ? 1 : 0;
                     SendVehicleInfo(dataport_def, vi, wpos);
-                    bTurnSignal = true;
+                    bLIGHTSTATUS = true;
                 }
             }
 
@@ -457,14 +446,37 @@ void CGtCtrl::Run()
                     int wpos =
                         m_stVehicleInfo.nWinkerPos == WINKER_LEFT ? 2 : 0;
                     SendVehicleInfo(dataport_def, vi, wpos);
-                    bTurnSignal = true;
+                    bLIGHTSTATUS = true;
                 }
             }
 
-            if (true == bTurnSignal) {
+            if (number == myConf.m_nHeadLight) {
+                if (0 != value) {
+                    if (false == m_stVehicleInfo.bHeadLight) { // HEAD LIGHT OFF(false) ?
+                        m_stVehicleInfo.bHeadLight = true; // HEAD LIGHT ON(true)
+                    }
+                    else {
+                        m_stVehicleInfo.bHeadLight = false; // HEAD LIGHT OFF(false)
+                    }
+                    bLIGHTSTATUS = true;
+                }
+            }
+
+            if (true == bLIGHTSTATUS) {
                 const size_t LSsz = 8;                                                              
-                char data[LSsz];                                                                    
+                char data[LSsz];
+                    // 0:LIGHT HEAD STATUS ON(1)/OFF(0)
+                    // 1:LEFT WINKER STATUS ON(1)/OFF(0)
+                    // 2:RIGHT WINKER STATUS ON(1)/OFF(0)
+                    // 3:PARKING
+                    // 4:FOG LAMP
+                    // 5:HAZARD
+                    // 6:BRAKE
+                    // 7:HIGHBEAM
                 memset(data, 0, sizeof(data));
+                if (true == m_stVehicleInfo.bHeadLight) { // HEAD LIGHT ON ?
+                    data[0] = 1;
+                }
                 if (WINKER_LEFT == m_stVehicleInfo.nWinkerPos) {
                     data[1] = 1;
                 }
index 3a627e8..cb57ac2 100644 (file)
@@ -214,6 +214,7 @@ struct VehicleInfo
     double dVelocity;
     int nAccel;
     int nBrake;
+    bool bHeadLight; // HEAD LIGHT ON(true)/OFF(false) status
 };
 
 enum SHIFT_POS
index ac1ef0b..1423c8d 100644 (file)
@@ -55,7 +55,6 @@ class CJoyStick
                     std::vector<std::string>& filesList) const;
     virtual bool getDeviceName(int fd, char* devNM, size_t sz);
 
-
 protected:
     char m_strJoyStick[64];
     int m_nJoyStickID;
index e45479d..9e19c97 100644 (file)
@@ -8,6 +8,17 @@
  */
 /**
  * @file    CJoyStickEV.h
+ *
+ * Note:
+ * processing in the value of the joystick-event in Tizen IVI 2.0
+ *  joystick-event
+ *    event-type is used JS_EVENT_BUTTON and JS_EVENT_AXIS 
+ *    axis/button number value is determine in configuration file
+ *      G27.conf G25.conf
+ *    event-value memo
+ *      Steering value: -32767(Right) <-> 32767(Left)
+ *      Accel value:0(full throttle) <-> 32767(free throttle)
+ *      Brake value:0(full throttle) <-> 32767(free throttle)
  */
 #include <unistd.h>
 #include <iostream>
@@ -23,6 +34,7 @@
 #include <linux/input.h>
 #include "CJoyStick.h"
 #include "CJoyStickEV.h"
+#include "CConf.h"
 using namespace std;
 
 CJoyStickEV::CJoyStickEV()
@@ -191,33 +203,35 @@ int CJoyStickEV::getJS_EVENT_AXIS(int& num, int& val,
     int r = -1;
     switch (s.code) {
     case ABS_X:
+        // Convert value Steering
+        //    0 to 16353 -> -32766 to 32767
         r = JS_EVENT_AXIS;
-        num = 0;
-        val = calc2pm32767((int)s.value, m_absInf[E_ABSX]);
+        num = (int)s.code;
+        val = calc1pm32767((int)s.value, m_absInf[E_ABSX]);
         break;
     case ABS_Y:
         r = JS_EVENT_AXIS;
-        num = 1;
-        val = calc2pm32767((int)s.value, m_absInf[E_ABSY]);
+        num = (int)s.code;
+        val = calc1pm32767((int)s.value, m_absInf[E_ABSY]);
         break;
     case ABS_Z:
         r = JS_EVENT_AXIS;
-        num = 2;
-        val = calc2pm32767((int)s.value, m_absInf[E_ABSZ]);
+        num = (int)s.code;
+        val = calc3p32767Reverse((int)s.value, m_absInf[E_ABSZ]);
         break;
     case ABS_RZ:
         r = JS_EVENT_AXIS;
-        num = 5;
-        val = calc2pm32767((int)s.value, m_absInf[E_ABSRZ]);
+        num = (int)s.code;
+        val = calc3p32767Reverse((int)s.value, m_absInf[E_ABSRZ]);
         break;
     case ABS_HAT0X:
         r = JS_EVENT_AXIS;
-        num = 16;
+        num = (int)s.code;
         val = (int)s.value;
         break;
     case ABS_HAT0Y:
         r = JS_EVENT_AXIS;
-        num = 17;
+        num = (int)s.code;
         val = (int)s.value;
         break;
     defaulr:
@@ -227,6 +241,7 @@ int CJoyStickEV::getJS_EVENT_AXIS(int& num, int& val,
 }
 /**
  * @brief calc value case 1
+ *        change to -32767 <-> 32767
  */
 int CJoyStickEV::calc1pm32767(int val, const struct input_absinfo& ai)
 {
@@ -235,16 +250,43 @@ int CJoyStickEV::calc1pm32767(int val, const struct input_absinfo& ai)
     int c = ((int) (b * 65534)) - 32767;
     return c;
 }
+
 /**
  * @brief calc value case 2
+ *        change to 0 <-> 65534
  */
-int CJoyStickEV::calc2pm32767(int val, const struct input_absinfo& ai)
+int CJoyStickEV::calc2p65535(int val, const struct input_absinfo& ai)
 {
     int a = ai.maximum - ai.minimum;
     double b = (double)val / (double)a;
     int c = (int) (b * 65534);
     return c;
 }
+
+/**
+ * @brief calc value case 3
+ *        change to 0 <-> 32767
+ */
+int CJoyStickEV::calc3p32767(int val, const struct input_absinfo& ai)
+{
+    int a = ai.maximum - ai.minimum;
+    double b = (double)val / (double)a;
+    int c = (int) (b * 32767);
+    return c;
+}
+
+/**
+ * @brief calc value case 3
+ *        change to 32767 <-> 0
+ */
+int CJoyStickEV::calc3p32767Reverse(int val, const struct input_absinfo& ai)
+{
+    int a = ai.maximum - ai.minimum;
+    double b = (double)val / (double)a;
+    int c = abs(((int) (b * 32767)) - 32767);
+    return c;
+}
+
 /**
  * get device name
  */
index 4688545..802ce71 100644 (file)
@@ -41,7 +41,9 @@ class CJoyStickEV : public CJoyStick
     int getJS_EVENT_BUTTON(int& num, int& val, const struct input_event& s);
     int getJS_EVENT_AXIS(int& num, int& val, const struct input_event& s);
     int calc1pm32767(int val, const struct input_absinfo& ai);
-    int calc2pm32767(int val, const struct input_absinfo& ai);
+    int calc2p65535(int val, const struct input_absinfo& ai);
+    int calc3p32767(int val, const struct input_absinfo& ai);
+    int calc3p32767Reverse(int val, const struct input_absinfo& ai);
     enum {
         E_ABSX = 0, /* ABS_X */
         E_ABSY,     /* ABS_Y */