Skip to content

Commit

Permalink
Detect Y SR MIC / MIG / BYD / CATL / SR+
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Feb 7, 2024
1 parent c82d787 commit f445f52
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 1 deletion.
21 changes: 20 additions & 1 deletion TeslaLogger/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ public void UpdateEfficiency()
}
else if (car.CarType == "modely" && car.CarSpecialType == "base")
{
Tools.VINDecoder(car.Vin, out int year, out _, out bool _, out bool MIC, out string _, out string _, out bool MIG);
Tools.VINDecoder(car.Vin, out int year, out string ct, out bool AWD, out bool MIC, out string battery, out string motor, out bool MIG);
if (car.TrimBadging == "74d")
{
if (MIC)
Expand Down Expand Up @@ -2913,6 +2913,25 @@ public void UpdateEfficiency()
}
else if (car.TrimBadging == "50")
{
if (MIG)
{
if (!AWD && car.Vin[6] == 'E' && (car.Vin[7] == 'S' || car.Vin[7] == 'J'))
{
WriteCarSettings("0.142", "Y SR (MIG BYD)");
return;
}
else if (battery == "LFP")
{
WriteCarSettings("0.142", "Y SR (MIG CATL)");
return;
}
}
else if (MIC)
{
WriteCarSettings("0.142", "Y SR (MIC)");
return;
}

WriteCarSettings("0.142", "Y SR+");
return;
}
Expand Down
84 changes: 84 additions & 0 deletions UnitTestsTeslalogger/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Web;

using Newtonsoft.Json;
using System.Data;

namespace UnitTestsTeslalogger
{
Expand Down Expand Up @@ -580,6 +581,89 @@ public void Car_Y_LR_AWD_MIC_2022()
Assert.AreEqual("Y LR AWD (MIC 2022)", wh.car.ModelName);
Assert.AreEqual(0.148, wh.car.WhTR);
}
[TestMethod]
public void Car_Y_SR_MIG_BYD()
{
string[] VINSs = {
"XP7YGCEJ1PB",
"XP7YGCEJ2PB",
"XP7YGCEJ3PB",
"XP7YGCEJ6PB",
"XP7YGCEJ7PB",
"XP7YGCEJ8PB",
"XP7YGCEJ9PB",
"XP7YGCES0RB",
"XP7YGCES1RB",
"XP7YGCES4RB",
"XP7YGCES8PB",
"XP7YGCES9RB" };

foreach (string vin in VINSs)
{
Car c = new Car(0, "", "", 0, "", DateTime.Now, "", "", "", "", "", "", "", null, false);
WebHelper wh = c.webhelper;

MemoryCache.Default.Remove("GetAvgMaxRage_0");
MemoryCache.Default.Add("GetAvgMaxRage_0", 520, DateTime.Now.AddMinutes(1));
wh.car.Vin = vin + "XXXXXX";
wh.car.CarType = "modely";
wh.car.CarSpecialType = "base";
wh.car.DBWhTR = 0.142;
wh.car.TrimBadging = "50";
wh.UpdateEfficiency();

Assert.AreEqual("Y SR (MIG BYD)", wh.car.ModelName);
Assert.AreEqual(0.142, wh.car.WhTR);
}
}

[TestMethod]
public void Car_Y_SR_MIG_CATL()
{
string[] VINSs = { "XP7YGCFS2RB", "XP7YGCFSXRB"};

foreach (string vin in VINSs)
{
Car c = new Car(0, "", "", 0, "", DateTime.Now, "", "", "", "", "", "", "", null, false);
WebHelper wh = c.webhelper;

MemoryCache.Default.Remove("GetAvgMaxRage_0");
MemoryCache.Default.Add("GetAvgMaxRage_0", 520, DateTime.Now.AddMinutes(1));
wh.car.Vin = vin + "XXXXXX";
wh.car.CarType = "modely";
wh.car.CarSpecialType = "base";
wh.car.DBWhTR = 0.142;
wh.car.TrimBadging = "50";
wh.UpdateEfficiency();

Assert.AreEqual("Y SR (MIG CATL)", wh.car.ModelName);
Assert.AreEqual(0.142, wh.car.WhTR);
}
}

[TestMethod]
public void Car_Y_SR_MIC()
{
string[] VINSs = { "LRWYGCFSXPC" };

foreach (string vin in VINSs)
{
Car c = new Car(0, "", "", 0, "", DateTime.Now, "", "", "", "", "", "", "", null, false);
WebHelper wh = c.webhelper;

MemoryCache.Default.Remove("GetAvgMaxRage_0");
MemoryCache.Default.Add("GetAvgMaxRage_0", 520, DateTime.Now.AddMinutes(1));
wh.car.Vin = vin + "XXXXXX";
wh.car.CarType = "modely";
wh.car.CarSpecialType = "base";
wh.car.DBWhTR = 0.142;
wh.car.TrimBadging = "50";
wh.UpdateEfficiency();

Assert.AreEqual("Y SR (MIC)", wh.car.ModelName);
Assert.AreEqual(0.142, wh.car.WhTR);
}
}

[TestMethod]
public void Car_YP_MIG_First30()
Expand Down

0 comments on commit f445f52

Please sign in to comment.