Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. using CAN_BUS_IO;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace OBD_API {
  9.  
  10. static class EOBD {
  11.  
  12. public static readonly Dictionary<BaseParser.PacketInfo, IParser> ParameterTable = new Dictionary<BaseParser.PacketInfo, IParser> {
  13.  
  14. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x0C }), new EOBD_EngineSpeed()},
  15. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x0D }), new EOBD_VehicleSpeed()},
  16. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x05 }), new EOBD_EngineTemp()},
  17. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x46 }), new EOBD_AmbientAirTemp()},
  18. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0xA6 }), new EOBD_Odometer()},
  19. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x2F }), new EOBD_FuelTankLevelInput()},
  20. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x51 }), new EOBD_TypeofFuel()},
  21. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x5E }), new EOBD_FuelRate()},
  22. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x04 }), new EOBD_EngineLoad()},
  23. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x64 }), new EOBD_EngineTorque()},
  24. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x21 }), new EOBD_DistanceMIL()},
  25. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x5A }), new EOBD_AcceleratorPos()},
  26. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x10 }), new EOBD_MAFAirFlow()},
  27. {new BaseParser.PacketInfo(0x7DF, 0x01, new byte[]{ 0x1F }), new EOBD_TimeSinceEngineStart()}
  28.  
  29. };
  30.  
  31. }
  32.  
  33. public class EOBD_EngineSpeed : IParser {
  34. public void ParsePacket(BaseParser.PacketInfo input) {
  35. uint ID = 0x7E8;
  36. byte SID = (byte)(input.SID + 0x40);
  37. byte[] PID = input.PID;
  38. byte[] data = new byte[2] { 0x1F, 0x40 };
  39.  
  40. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  41. }
  42. }
  43.  
  44. public class EOBD_VehicleSpeed : IParser {
  45. public void ParsePacket(BaseParser.PacketInfo input) {
  46. uint ID = 0x7E8;
  47. byte SID = (byte)(input.SID + 0x40);
  48. byte[] PID = input.PID;
  49. byte[] data = new byte[1] { 0x64 };
  50.  
  51. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  52. }
  53. }
  54.  
  55. public class EOBD_EngineTemp : IParser {
  56. public void ParsePacket(BaseParser.PacketInfo input) {
  57. uint ID = 0x7E8;
  58. byte SID = (byte)(input.SID + 0x40);
  59. byte[] PID = input.PID;
  60. byte[] data = new byte[1] { 0x3C };
  61.  
  62. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  63. }
  64. }
  65.  
  66. public class EOBD_AmbientAirTemp : IParser {
  67. public void ParsePacket(BaseParser.PacketInfo input) {
  68. uint ID = 0x7E8;
  69. byte SID = (byte)(input.SID + 0x40);
  70. byte[] PID = input.PID;
  71. byte[] data = new byte[1] { 0x3C };
  72.  
  73. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  74. }
  75. }
  76.  
  77. public class EOBD_Odometer : IParser {
  78. public void ParsePacket(BaseParser.PacketInfo input) {
  79. uint ID = 0x7E8;
  80. byte SID = (byte)(input.SID + 0x40);
  81. byte[] PID = input.PID;
  82. byte[] data = new byte[4] { 0x01, 0x86, 0xA0, 0x00 };
  83.  
  84. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  85. }
  86. }
  87.  
  88. public class EOBD_FuelTankLevelInput : IParser {
  89. public void ParsePacket(BaseParser.PacketInfo input) {
  90. uint ID = 0x7E8;
  91. byte SID = (byte)(input.SID + 0x40);
  92. byte[] PID = input.PID;
  93. byte[] data = new byte[1] { 0x32};
  94.  
  95. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  96. }
  97. }
  98.  
  99. public class EOBD_TypeofFuel : IParser {
  100. public void ParsePacket(BaseParser.PacketInfo input) {
  101. uint ID = 0x7E8;
  102. byte SID = (byte)(input.SID + 0x40);
  103. byte[] PID = input.PID;
  104. byte[] data = new byte[1] { 0x01 };
  105.  
  106. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  107. }
  108. }
  109.  
  110. public class EOBD_FuelRate : IParser {
  111. public void ParsePacket(BaseParser.PacketInfo input) {
  112. uint ID = 0x7E8;
  113. byte SID = (byte)(input.SID + 0x40);
  114. byte[] PID = input.PID;
  115. byte[] data = new byte[2] { 0x01, 0x20 };
  116.  
  117. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  118. }
  119. }
  120.  
  121. public class EOBD_EngineLoad : IParser {
  122. public void ParsePacket(BaseParser.PacketInfo input) {
  123. uint ID = 0x7E8;
  124. byte SID = (byte)(input.SID + 0x40);
  125. byte[] PID = input.PID;
  126. byte[] data = new byte[1] { 0x32 };
  127.  
  128. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  129. }
  130. }
  131.  
  132. public class EOBD_EngineTorque : IParser {
  133. public void ParsePacket(BaseParser.PacketInfo input) {
  134. uint ID = 0x7E8;
  135. byte SID = (byte)(input.SID + 0x40);
  136. byte[] PID = input.PID;
  137. byte[] data = new byte[5] { 0x01, 0x02, 0x03, 0x04, 0x05 };
  138.  
  139. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  140. }
  141. }
  142.  
  143. public class EOBD_DistanceMIL : IParser {
  144. public void ParsePacket(BaseParser.PacketInfo input) {
  145. uint ID = 0x7E8;
  146. byte SID = (byte)(input.SID + 0x40);
  147. byte[] PID = input.PID;
  148. byte[] data = new byte[2] { 0x64, 0x01 };
  149.  
  150. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  151. }
  152. }
  153.  
  154. public class EOBD_AcceleratorPos : IParser {
  155. public void ParsePacket(BaseParser.PacketInfo input) {
  156. uint ID = 0x7E8;
  157. byte SID = (byte)(input.SID + 0x40);
  158. byte[] PID = input.PID;
  159. byte[] data = new byte[1] { 0x32 };
  160.  
  161. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  162. }
  163. }
  164.  
  165. public class EOBD_MAFAirFlow : IParser {
  166. public void ParsePacket(BaseParser.PacketInfo input) {
  167. uint ID = 0x7E8;
  168. byte SID = (byte)(input.SID + 0x40);
  169. byte[] PID = input.PID;
  170. byte[] data = new byte[2] { 0x32, 0x01 };
  171.  
  172. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  173. }
  174. }
  175.  
  176. public class EOBD_TimeSinceEngineStart : IParser {
  177. public void ParsePacket(BaseParser.PacketInfo input) {
  178. uint ID = 0x7E8;
  179. byte SID = (byte)(input.SID + 0x40);
  180. byte[] PID = input.PID;
  181. byte[] data = new byte[2] { 0x32, 0x01 };
  182.  
  183. Sender.AddToQueue(BaseParser.FormResponse(ID, SID, PID, data, MessageFormat.Standard));
  184. }
  185. }
  186.  
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement