IH100.c 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #include "IH100.h"
  2. #include "rtwtypes.h"
  3. #include "IH100_private.h"
  4. #include "look1_iu8lu16n16tu16_binlcase.h"
  5. #include "BCUDisp.h"
  6. MdlrefDW_IH100_T IH100_MdlrefDW;
  7. B_IH100_c_T IH100_B;
  8. DW_IH100_f_T IH100_DW;
  9. void IH100(uint16_T *rty_ihd_tm_parkTime)
  10. {
  11. ihd_tm_yearEo = rted_tm_year;
  12. ihd_tm_monthEo = rted_tm_month;
  13. ihd_tm_dayEo = rted_tm_day;
  14. ihd_tm_hourEo = rted_tm_hour;
  15. ihd_tm_minEo = rted_tm_min;
  16. ihd_tm_secEo = rted_tm_sec;
  17. if (IH100_DW.UnitDelay_DSTATE + 1.0 <= IH100_ConstB.Add) {
  18. IH100_DW.UnitDelay_DSTATE++;
  19. } else {
  20. IH100_DW.UnitDelay_DSTATE = IH100_ConstB.Add;
  21. }
  22. if (IH100_DW.UnitDelay_DSTATE == 1.0) {
  23. uint32_T rtb_Product3_f;
  24. uint16_T rtb_Add_j;
  25. uint8_T rtb_Divide1;
  26. uint8_T rtb_Divide_e;
  27. uint8_T rtb_Merge1;
  28. uint8_T rtb_Merge2;
  29. uint8_T rtb_Merge3;
  30. uint8_T rtb_Merge4;
  31. uint8_T rtb_Merge5;
  32. boolean_T rtb_LogicalOperator1;
  33. rtb_LogicalOperator1 = ((((uint16_T)(rted_tm_year % 4) == 0) && ((uint16_T)
  34. (rted_tm_year % 100) != 0)) || ((uint16_T)(rted_tm_year % 400) == 0));
  35. if (rtb_LogicalOperator1) {
  36. rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
  37. rtCP_uDLookupTable1_bp01Data, rtCP_uDLookupTable1_tableData, 11U);
  38. } else {
  39. rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rted_tm_month - 1),
  40. rtCP_uDLookupTable_bp01Data, rtCP_uDLookupTable_tableData, 11U);
  41. }
  42. IH100_B.Add1 = ((((((uint16_T)(((int32_T)((uint32_T)rted_tm_year >> 2) -
  43. (int32_T)(rted_tm_year / 100U)) - rtb_LogicalOperator1) + rted_tm_year *
  44. 365U) + rtb_Add_j) + (uint8_T)(rted_tm_day - 1)) *
  45. 86400U + rted_tm_hour * 3600U) + rted_tm_min * 60U) +
  46. rted_tm_sec;
  47. if (rtev_flg_EESt[0]) {
  48. rtb_Divide_e = ihd_tm_yearEi;
  49. rtb_Merge1 = ihd_tm_monthEi;
  50. rtb_Merge3 = ihd_tm_dayEi;
  51. rtb_Merge2 = ihd_tm_hourEi;
  52. rtb_Merge4 = ihd_tm_minEi;
  53. rtb_Merge5 = ihd_tm_secEi;
  54. } else {
  55. rtb_Divide_e = rted_tm_year;
  56. rtb_Merge1 = rted_tm_month;
  57. rtb_Merge3 = rted_tm_day;
  58. rtb_Merge2 = rted_tm_hour;
  59. rtb_Merge4 = rted_tm_min;
  60. rtb_Merge5 = rted_tm_sec;
  61. }
  62. rtb_Add_j = rtb_Divide_e;
  63. rtb_Product3_f = rtb_Divide_e * 365U;
  64. rtb_Divide_e = (uint8_T)((uint32_T)rtb_Divide_e >> 2);
  65. rtb_Divide1 = (uint8_T)(rtb_Add_j / 100U);
  66. rtb_LogicalOperator1 = ((((uint16_T)(rtb_Add_j % 4) == 0) && ((uint16_T)
  67. (rtb_Add_j % 100) != 0)) || ((uint16_T)(rtb_Add_j % 400) == 0));
  68. if (rtb_LogicalOperator1) {
  69. rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
  70. rtCP_uDLookupTable1_bp01Data_o, rtCP_uDLookupTable1_tableData_g, 11U);
  71. } else {
  72. rtb_Add_j = look1_iu8lu16n16tu16_binlcase((uint8_T)(rtb_Merge1 - 1),
  73. rtCP_uDLookupTable_bp01Data_b, rtCP_uDLookupTable_tableData_k, 11U);
  74. }
  75. *rty_ihd_tm_parkTime = (uint16_T)(((((int32_T)IH100_B.Add1 - (int32_T)
  76. (((((uint16_T)((rtb_Divide_e - rtb_Divide1) - rtb_LogicalOperator1) +
  77. rtb_Product3_f) + rtb_Add_j) + (uint8_T)(rtb_Merge3 - 1)) * 86400U)) -
  78. (int32_T)(rtb_Merge2 * 3600U)) - (int32_T)(rtb_Merge4 * 60U)) - rtb_Merge5);
  79. }
  80. IH100_DW.UnitDelay1_DSTATE++;
  81. ihd_tm_realTime = IH100_DW.UnitDelay1_DSTATE / 10U + IH100_B.Add1;
  82. ihv_flg_EESt[0] = rtev_flg_EESt[0];
  83. ihv_flg_EESt[1] = rtev_flg_EESt[1];
  84. ihv_flg_EESt[2] = rtev_flg_EESt[2];
  85. ihv_flg_EESt[3] = rtev_flg_EESt[3];
  86. }
  87. void IH100_initialize(const char_T **rt_errorStatus)
  88. {
  89. RT_MODEL_IH100_T *const IH100_M = &(IH100_MdlrefDW.rtm);
  90. rtmSetErrorStatusPointer(IH100_M, rt_errorStatus);
  91. }