realvalue.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "realvalue.h"
  2. #include "yt_unit_shm.h"
  3. #include <stdio.h>
  4. extern YT_UNIT_SHM *ytShm;
  5. void set_realtime_io_value(quint8 commid, quint8 busadd, quint8 value, uint timestamp)
  6. {
  7. }
  8. void set_realtime_real_value(quint8 commid, quint8 busadd, float value, uint timestamp)
  9. {
  10. ytShm->spStatusList.spStatus[commid][busadd].REALTIME_VALUE = value*1.0;
  11. ytShm->spStatusList.spStatus[commid][busadd].REALTIME_TIMESTAMP = timestamp;
  12. }
  13. void set_realtime_value(quint8 commid, quint8 busadd, float value, uint timestamp)
  14. {
  15. // printf("%d) %d %f\n",commid,busadd,value);
  16. if(commid<4)
  17. {
  18. if(ytShm->commList.comm[commid].ENABLED==0x01)
  19. {
  20. if(ytShm->sPointList.sPoint[commid][busadd].ENABLED==0x01)
  21. {
  22. // printf("pno_type:%d\n",ytShm->sPointList.sPoint[commid][busadd].PNO_TYPE);
  23. switch(ytShm->sPointList.sPoint[commid][busadd].PNO_TYPE)
  24. {
  25. case 0x01://开关量输入
  26. set_realtime_io_value(commid, busadd, (value==0)?0x00:0x01, timestamp);
  27. break;
  28. case 0x02://模拟量输入
  29. set_realtime_real_value(commid, busadd, value, timestamp);
  30. break;
  31. default:
  32. break;
  33. }
  34. }
  35. }
  36. }
  37. }