mdl.c 948 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "plt.h"
  2. #include "mdl.h"
  3. void mdl_sim()
  4. {
  5. }
  6. void mdl_prepare()
  7. {
  8. MDL.smoke_alarm = 0;
  9. MDL.switch_statu = 0;
  10. MDL.temperature_alarm = 0;
  11. MDL.press_low_alarm = 0;
  12. }
  13. void from_modbus_to_dev()
  14. {
  15. //usHoldingRegisters[0x6020] = uab;
  16. return 0;
  17. }
  18. int from_dev_to_modbus()
  19. {
  20. // uab = usHoldingRegisters[0x6020];
  21. return 0;
  22. }
  23. void update_states()
  24. {
  25. }
  26. static void *mdl_thrd_main(void *param)
  27. {
  28. mdl_prepare();
  29. from_dev_to_modbus();
  30. while (1)
  31. {
  32. from_modbus_to_dev();
  33. mdl_sim();
  34. from_dev_to_modbus();
  35. usleep(10000); /* 10ms */
  36. }
  37. return NULL;
  38. }
  39. int mdl_init()
  40. {
  41. log_dbg("%s, ++", __func__);
  42. int ret = 0;
  43. pthread_t xthrd;
  44. if (pthread_create(&xthrd, NULL, mdl_thrd_main, NULL) != 0)
  45. {
  46. log_dbg("%s, pthread_create fail", __func__);
  47. ret = -1;
  48. }
  49. log_dbg("%s, --, ret: %d", __func__, ret);
  50. return ret;
  51. }