mirror of
https://github.com/DarthAffe/OBD.NET.git
synced 2025-12-12 16:58:30 +00:00
Merge pull request #9 from StefanKraai/master
Added abstract pids supported and changed the way to get the supported PIDs. This fixes #8
This commit is contained in:
commit
be454452d7
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupported01_20 : AbstractOBDData
|
||||
public class PidsSupported01_20 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupported01_20()
|
||||
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupported21_40 : AbstractOBDData
|
||||
public class PidsSupported21_40 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupported21_40()
|
||||
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupported41_60 : AbstractOBDData
|
||||
public class PidsSupported41_60 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupported41_60()
|
||||
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupported61_80 : AbstractOBDData
|
||||
public class PidsSupported61_80 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupported61_80()
|
||||
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupported81_A0 : AbstractOBDData
|
||||
public class PidsSupported81_A0 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupported81_A0()
|
||||
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupportedA1_C0 : AbstractOBDData
|
||||
public class PidsSupportedA1_C0 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupportedA1_C0()
|
||||
|
||||
34
OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs
Normal file
34
OBD.NET/OBD.NET.Common/OBDData/AbstractPidsSupported.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public abstract class AbstractPidsSupported : AbstractOBDData
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
BitArray bitArray = new BitArray(new[] { D, C, B, A });
|
||||
|
||||
for (int i = 0x01; i <= 0x20; i++)
|
||||
if (bitArray.Get(bitArray.Length - i))
|
||||
supportedPids.Add(PID + i);
|
||||
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public AbstractPidsSupported(byte pid, int length) : base(pid, length)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -1,42 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OBD.NET.Common.OBDData
|
||||
namespace OBD.NET.Common.OBDData
|
||||
{
|
||||
public class PidsSupportedC1_E0 : AbstractOBDData
|
||||
public class PidsSupportedC1_E0 : AbstractPidsSupported
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
public int[] SupportedPids
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> supportedPids = new List<int>();
|
||||
for (int i = 0x01; i < 0x20; i++)
|
||||
switch ((int)(i / 8.0))
|
||||
{
|
||||
case 0:
|
||||
if ((A << (7 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 1:
|
||||
if ((B << (15 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 2:
|
||||
if ((C << (23 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
case 3:
|
||||
if ((D << (31 - i)) != 0)
|
||||
supportedPids.Add(PID + i);
|
||||
break;
|
||||
}
|
||||
return supportedPids.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public PidsSupportedC1_E0()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user