NUMBER=301
[HEAD_LIGHT]
TYPE=1
-NUMBER=2
+NUMBER=292
[STEERING]
TYPE=2
NUMBER=0
LAT=35.717931
LNG=139.736518
-
NUMBER=710
[HEAD_LIGHT]
TYPE=1
-NUMBER=2
+NUMBER=292
[STEERING]
TYPE=2
NUMBER=0
LAT=35.717931
LNG=139.736518
-
+* 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)
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
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
%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/
%{_bindir}/*
/etc/carsim/*
/usr/lib/systemd/system/carsim.service
-#%{carsim_conf}/CarSim_Daemon.conf
using namespace std;
static vector<AmbpiCommIF*> _commList;
+const int RECONNECT_WS = 5;
bool _addAmbCommIFList(AmbpiCommIF* comm);
void _eraseAmbCommIFList(const AmbpiCommIF* comm);
}
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;
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 =
m_stVehicleInfo.nDirection = 0;
m_stVehicleInfo.dVelocity = 0.0;
m_stVehicleInfo.nAccel = 0;
+ m_stVehicleInfo.bHeadLight = false; // HEAD LIGHT OFF(false)
m_bFirstOpen = true;
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
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:
/**
* TURN SIGNAL(WINKER) & LIGHTSTATUS
*/
- bool bTurnSignal = false;
+ bool bLIGHTSTATUS = false;
if (number == myConf.m_nWinkR) {
if (value != 0) {
int wpos =
m_stVehicleInfo.nWinkerPos == WINKER_RIGHT ? 1 : 0;
SendVehicleInfo(dataport_def, vi, wpos);
- bTurnSignal = true;
+ bLIGHTSTATUS = true;
}
}
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;
}
double dVelocity;
int nAccel;
int nBrake;
+ bool bHeadLight; // HEAD LIGHT ON(true)/OFF(false) status
};
enum SHIFT_POS
std::vector<std::string>& filesList) const;
virtual bool getDeviceName(int fd, char* devNM, size_t sz);
-
protected:
char m_strJoyStick[64];
int m_nJoyStickID;
*/
/**
* @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>
#include <linux/input.h>
#include "CJoyStick.h"
#include "CJoyStickEV.h"
+#include "CConf.h"
using namespace std;
CJoyStickEV::CJoyStickEV()
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:
}
/**
* @brief calc value case 1
+ * change to -32767 <-> 32767
*/
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
*/
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 */