DDE_Power.ccpage 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <fragment xmlns="http://www.holeschak.de/BmwDeepObd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.holeschak.de/BmwDeepObd BmwDeepObd.xsd">
  3. <page name="IBUS_App" display-mode="grid" fontsize="medium" gauges-portrait="2" gauges-landscape="4" logfile="DME_DDE.log">
  4. <strings lang="de">
  5. <string name="IBUS_App">LEISTUNG</string>
  6. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_AKTUELL_WERT"> Drehmoment [Nm]:</string>
  7. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORDREHZAHL_WERT"> Drehzahl [U/min]</string>
  8. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_WUNSCH_WERT"> Leistung [PS]</string>
  9. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_LUFTMASSE_PRO_HUB_WERT"> Leistung [kW]</string>
  10. </strings>
  11. <strings>
  12. <string name="IBUS_App">POWER</string>
  13. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_AKTUELL_WERT"> torque [Nm]:</string>
  14. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORDREHZAHL_WERT"> engine speed [U/min]</string>
  15. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_WUNSCH_WERT"> power [HP]</string>
  16. <string name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_LUFTMASSE_PRO_HUB_WERT"> power [kW]</string>
  17. </strings>
  18. <display name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_AKTUELL_WERT" result="STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_AKTUELL_WERT" grid-type="simple-gauge-round" min-value="0" max-value="600" log_tag="STAT_MOTORMOMENT_AKTUELL_WERT" />
  19. <display name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORDREHZAHL_WERT" result="STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORDREHZAHL_WERT" grid-type="simple-gauge-round" min-value="0" max-value="5000" log_tag="STAT_MOTORDREHZAHL_WERT" />
  20. <display name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_WUNSCH_WERT" result="STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_WUNSCH_WERT" grid-type="simple-gauge-round" min-value="0" max-value="600" log_tag="STAT_POWER_HP" />
  21. <display name="!JOB#STATUS_MESSWERTBLOCK_LESEN#STAT_LUFTMASSE_PRO_HUB_WERT" result="STATUS_MESSWERTBLOCK_LESEN#STAT_LUFTMASSE_PRO_HUB_WERT" grid-type="simple-gauge-round" min-value="0" max-value="1500" log_tag="STAT_POWER_KW" />
  22. <jobs />
  23. <code show_warnings="true">
  24. <![CDATA[
  25. class PageClass
  26. {
  27. private int mom_torque = 0;
  28. private int mom_N = 0;
  29. public void ExecuteJob(EdiabasNet ediabas, ref MultiMap<string, EdiabasNet.ResultData> resultDict, bool firstCall)
  30. {
  31. List<Dictionary<string, EdiabasNet.ResultData>> resultSets;
  32. // Job 1 - ständig zu aktualisierende Werte
  33. ediabas.ArgString = "JA;IMOAK;INMOT;IMWVO;ILMMG";
  34. ediabas.ArgBinaryStd = null;
  35. ediabas.ResultsRequests = string.Empty;
  36. ediabas.ExecuteJob("STATUS_MESSWERTBLOCK_LESEN");
  37. resultSets = ediabas.ResultSets;
  38. if (resultSets != null && resultSets.Count >= 2)
  39. {
  40. EdiabasThread.MergeResultDictionarys(ref resultDict, resultSets[1], "STATUS_MESSWERTBLOCK_LESEN#");
  41. }
  42. // extract values and save to global variables
  43. EdiabasNet.ResultData resultData;
  44. if (resultSets[1].TryGetValue("STAT_MOTORDREHZAHL_WERT", out resultData))
  45. {
  46. if (resultData.OpData is Double)
  47. {
  48. mom_N = (int)((Double)resultData.OpData);
  49. }
  50. }
  51. if (resultSets[1].TryGetValue("STAT_MOTORMOMENT_AKTUELL_WERT", out resultData))
  52. {
  53. if (resultData.OpData is Double)
  54. {
  55. mom_torque = (int)((Double)resultData.OpData);
  56. }
  57. }
  58. }
  59. public string FormatResult(JobReader.PageInfo pageInfo, MultiMap<string, EdiabasNet.ResultData> resultDict, string resultName, ref Android.Graphics.Color? textColor)
  60. {
  61. string result = string.Empty;
  62. double value;
  63. // bool found;
  64. // List of possible colors: https://docs.microsoft.com/en-us/dotnet/api/android.graphics.color?view=xamarin-android-sdk-9
  65. switch (resultName)
  66. {
  67. case "STATUS_MESSWERTBLOCK_LESEN#STAT_MOTORMOMENT_WUNSCH_WERT":
  68. // value = ActivityMain.GetResultDouble(resultDict, resultName, 0, out found);
  69. // this is the reading we overwrite with calculated horsepower
  70. value = mom_torque * mom_N / 7127;
  71. // result format: {0,[DIGITS TOTAL INCL COMMA],[0|0.0|0.00|0.000...]}
  72. result = string.Format(ActivityMain.Culture, "{0,1:0}", value);
  73. // if (found && value <= 4000) textColor = Android.Graphics.Color.White;
  74. // else if (found && value <= 4250) textColor = Android.Graphics.Color.Yellow;
  75. // else if (found && value <= 4500) textColor = Android.Graphics.Color.Orange;
  76. // else if (found && value > 4500) textColor = Android.Graphics.Color.Red;
  77. // else textColor = Android.Graphics.Color.Gray;
  78. break;
  79. case "STATUS_MESSWERTBLOCK_LESEN#STAT_LUFTMASSE_PRO_HUB_WERT":
  80. // value = ActivityMain.GetResultDouble(resultDict, resultName, 0, out found);
  81. // and this one we will overwrite with power in kW
  82. value = mom_torque * mom_N / 7127 / 1.36;
  83. // result format: {0,[DIGITS TOTAL INCL COMMA],[0|0.0|0.00|0.000...]}
  84. result = string.Format(ActivityMain.Culture, "{0,1:0}", value);
  85. // if (found && value <= 4000) textColor = Android.Graphics.Color.White;
  86. // else if (found && value <= 4250) textColor = Android.Graphics.Color.Yellow;
  87. // else if (found && value <= 4500) textColor = Android.Graphics.Color.Orange;
  88. // else if (found && value > 4500) textColor = Android.Graphics.Color.Red;
  89. // else textColor = Android.Graphics.Color.Gray;
  90. break;
  91. }
  92. return result;
  93. }
  94. }
  95. ]]>
  96. </code>
  97. </page>
  98. </fragment>