scan_common.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #pragma once
  2. #include <opencv\cv.h>
  3. #include <opencv\cxcore.h>
  4. #include <opencv2\opencv.hpp>
  5. using namespace cv;
  6. enum SCAN_TASK_TYPE{
  7. SCAN_TASK_TYPE_NORMAL,
  8. SCAN_TASK_TYPE_ADJUST_BATCH,
  9. SCAN_TASK_TYPE_ADJUST_EXAMINNE,
  10. };
  11. enum DATABASE_STATE{
  12. //创建
  13. DATABASE_STATE_CREATE,
  14. //扫描中
  15. DATABASE_STATE_SCANNING,
  16. //扫描完成
  17. DATABASE_STATE_SCAN_OVER,
  18. //放弃
  19. DATABASE_STATE_GIVEUP,
  20. //成绩上传中
  21. DATABASE_STATE_RESULT_UPLOADING,
  22. //成绩上传完成
  23. DATABASE_STATE_RESULT_UPLOADED,
  24. //图片上传中
  25. DATABASE_STATE_IMG_UPLOADING,
  26. //图片上传暂停
  27. DATABASE_STATE_IMG_PAUSED,
  28. //图片上传完成
  29. DATABASE_STATE_IMG_UPLOADED,
  30. //正在删除数据库
  31. DATABASE_STATE_DELETING,
  32. //数据库已经删除
  33. DATABASE_STATE_DELETED,
  34. //无效状态
  35. DATABASE_STATE_CREATE_INVALID=9999,
  36. };
  37. enum ServiceState{
  38. stoped,
  39. starting,
  40. running,
  41. pausing,
  42. paused,
  43. resuming,
  44. stoping
  45. };
  46. class IService{
  47. public:
  48. IService(void);
  49. ~IService(void);
  50. // 启动服务
  51. virtual BOOL Start(void);
  52. // 停止服务
  53. virtual BOOL Stop(void);
  54. // 暂停服务
  55. virtual BOOL Pause(void);
  56. // 恢复服务
  57. virtual BOOL Resume(void);
  58. // 是否支持暂停
  59. virtual BOOL SupportPause(void);
  60. //获取服务当前状态
  61. ServiceState GetServiceSate(void);
  62. //运行函数
  63. UINT Run0();
  64. protected:
  65. enum command{
  66. command_none,
  67. command_start,
  68. command_pause,
  69. command_resume,
  70. command_stop
  71. };
  72. command m_command;
  73. //服务状态
  74. ServiceState m_serviceState;
  75. //状态同步锁
  76. RTL_CRITICAL_SECTION m_state_lock;
  77. //在服务状态为oldState时,设置服务状态
  78. inline BOOL SetServiceSate(ServiceState newState,ServiceState oldState);
  79. // 服务执行方法
  80. virtual int Run(void);
  81. virtual ServiceState OnStarting(void);
  82. virtual ServiceState OnRunning(void);
  83. virtual ServiceState OnPausing(void);
  84. virtual ServiceState OnPaused(void);
  85. virtual ServiceState OnResuming(void);
  86. virtual ServiceState OnStoping(void);
  87. private:
  88. //服务线程
  89. CWinThread * m_serviceThread;
  90. };