From 0ed1b9c0a88063c9ed826b9d8291f8dbedadf381 Mon Sep 17 00:00:00 2001 From: yoh-there Date: Sun, 1 Nov 2015 16:36:53 +0100 Subject: [PATCH] Vastly improved braking. Some doubts about factors used, but ready for release. --- .../canze/activities/DrivingActivity.java | 25 +++++++++++++------ .../java/lu/fisch/canze/actors/Fields.java | 6 ++--- app/src/main/res/layout/activity_braking.xml | 2 +- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/lu/fisch/canze/activities/DrivingActivity.java b/app/src/main/java/lu/fisch/canze/activities/DrivingActivity.java index 70eb809b..775c19ca 100644 --- a/app/src/main/java/lu/fisch/canze/activities/DrivingActivity.java +++ b/app/src/main/java/lu/fisch/canze/activities/DrivingActivity.java @@ -30,10 +30,11 @@ public class DrivingActivity extends CanzeActivity implements FieldListener { // free data public static final String SID_Pedal = "186.40"; public static final String SID_MeanEffectiveTorque = "18a.16"; - public static final String SID_BrakePressure = "352.24"; public static final String SID_RealSpeed = "5d7.0"; public static final String SID_SoC = "654.24"; public static final String SID_RangeEstimate = "654.42"; + public static final String SID_DriverBrakeWheel_Torque_Request = "130.44"; // braking wheel torque the driver wants + public static final String SID_ElecBrakeWheelsTorqueApplied = "1f8.28"; //10ms // ISO-TP data // public static final String SID_EVC_SoC = "7ec.622002.24"; // (EVC) @@ -43,10 +44,12 @@ public class DrivingActivity extends CanzeActivity implements FieldListener { public static final String SID_EVC_TractionBatteryVoltage = "7ec.623203.24"; // (EVC) public static final String SID_EVC_TractionBatteryCurrent = "7ec.623204.24"; // (EVC) - private double dcVolt = 0; // holds the DC voltage, so we can calculate the power when the amps come in - private int odo = 0; - private int destOdo = 0; // have to init from save file - private double realSpeed = 0; + private double dcVolt = 0; // holds the DC voltage, so we can calculate the power when the amps come in + private int odo = 0; + private int destOdo = 0; // have to init from save file + private double realSpeed = 0; + private double driverBrakeWheel_Torque_Request = 0; + private ArrayList subscribedFields; @Override @@ -210,7 +213,8 @@ private void initListeners() { addListener(SID_Pedal); addListener(SID_MeanEffectiveTorque); - addListener(SID_BrakePressure); + addListener(SID_DriverBrakeWheel_Torque_Request); + addListener(SID_ElecBrakeWheelsTorqueApplied); addListener(SID_RealSpeed); addListener(SID_SoC); addListener(SID_RangeEstimate); @@ -298,9 +302,14 @@ public void run() { } tv = null; break; - case SID_BrakePressure: + case SID_DriverBrakeWheel_Torque_Request: + driverBrakeWheel_Torque_Request = field.getValue(); + tv = null; + break; + case SID_ElecBrakeWheelsTorqueApplied: + double frictionBrakeTorque = driverBrakeWheel_Torque_Request - field.getValue(); pb = (ProgressBar) findViewById(R.id.FrictionBreaking); - pb.setProgress((int) (field.getValue() * realSpeed)); + pb.setProgress((int) (frictionBrakeTorque * realSpeed)); break; } // set regular new content, all exeptions handled above diff --git a/app/src/main/java/lu/fisch/canze/actors/Fields.java b/app/src/main/java/lu/fisch/canze/actors/Fields.java index 98ead5a8..2caa7e31 100644 --- a/app/src/main/java/lu/fisch/canze/actors/Fields.java +++ b/app/src/main/java/lu/fisch/canze/actors/Fields.java @@ -342,11 +342,11 @@ private void fillStatic() +"0x130, 11, 12, 1, 1, 0, 0, HBB_Malfunction %1ld, , , , HBB_Malfunction, 0, 0, 10\n" +"0x130, 16, 17, 1, 1, 0, 0, EB_Malfunction %ld, , , , EB_Malfunction, 0, 0, 10\n" +"0x130, 18, 19, 1, 1, 0, 0, EB_inProgress %1ld, , , , EB_inProgress, 0, 0, 10\n" - +"0x130, 20, 31, 1, -1, 4049, 0, ElBrkWhTqReq %4d , Nm, , , ElecBrakeWheelsTorqueRequest, 0, 0, 10\n" + +"0x130, 20, 31, 1, -1, 4094, 0, ElBrkWhTqReq %4d , Nm, , , ElecBrakeWheelsTorqueRequest, 0, 0, 10\n" +"0x130, 32, 38, 1, 1, 0, 0, BrakePedalDriverWill %3ld, %, , , BrakePedalDriverWill, 0, 0, 10\n" +"0x130, 40, 41, 1, 1, 0, 0, HBA_ActivationRequest %1ld, , , , HBA_ActivationRequest, 0, 0, 10\n" +"0x130, 42, 43, 1, 1, 0, 0, PressureBuildUp %1ld, , , , PressureBuildUp, 0, 0, 10\n" - +"0x130, 44, 55, 1, -3, 4049, 0, DriverBrakeWheelTq_Req %4ld, Nm, , , DriverBrakeWheelTq_Req , 0, 0, 10\n" + +"0x130, 44, 55, 1, -3, 4094, 0, DriverBrakeWheelTq_Req %4ld, Nm, , , DriverBrakeWheelTq_Req , 0, 0, 10\n" +"0x130, 56, 63, 1, 1, 0, 0, CheckSum_UBP %3ld, , , , CheckSum_UBP, 0, 0, 10\n" +"0x130, 8, 10, 1, 1, 0, 0, UBP_Clock %1ld, , , , UBP_Clock, 0, 0, 10\n" +"0x17e, 40, 41, 1, 1, 0, 0, , , , , CrankingAuthorisation_AT, 0, 0, 10\n" @@ -363,7 +363,7 @@ private void fillStatic() +"0x18a, 27, 38, 1, 5, 800, 10, FrictionTorque: %4ld, Nm, , , , 0, 0, 10\n" +"0x1f6, 20, 20, 1, 5, 0, 10, Break pedal: %4ld, , , , Break Pedal, 0, 0, 10\n" - +"0x1f8, 16, 27, 1, -1, 4096, 0, TotalPotentialResistiveWheelsTorque: %4ld, Nm, , , TotalPotentialResistiveWheelsTorque, 0, 0, 10\n" + +"0x1f8, 16, 27, 1, 1, 2048, 0, TotalPotentialResistiveWheelsTorque: %4ld, Nm, , , TotalPotentialResistiveWheelsTorque, 0, 0, 10\n" +"0x1f8, 28, 39, 1, -1, 4096, 0, ElecBrakeWheelsTorqueApplied: %4ld, Nm, , , ElecBrakeWheelsTorqueApplied, 0, 0, 10\n" +"0x1fd, 0, 7, 1, 5, 0, 10, Amp 12V: %2ld.%01ld, A, , , 12V Battery Current, 0, 0, 100\n" diff --git a/app/src/main/res/layout/activity_braking.xml b/app/src/main/res/layout/activity_braking.xml index 0558e711..ba768504 100644 --- a/app/src/main/res/layout/activity_braking.xml +++ b/app/src/main/res/layout/activity_braking.xml @@ -68,7 +68,7 @@ android:layout_height="wrap_content" android:minHeight="25dp" android:max="4096" - android:progressDrawable="@drawable/progressbar_canze" + android:progressDrawable="@drawable/progressbar_canze_red" />