#ifndef THREE_RATES_IMPL_H #define THREE_RATES_IMPL_H #include "db_api/CDBSingletonDefine.h" #include "struct_def.h" #include "three_rates.h" #include "worktime_rate.h" #include "tr_queue.h" #include "trm_drivingface_module.h" #include "vehicle_driver_alarm.h" #include "drivingface_alarm.h" #include #include #include #include #include using namespace std; class operating_rate; class regularcycle_rate; class common_data; class three_rates_impl : public three_rates { private: three_rates_impl() {}; three_rates_impl(const three_rates_impl &); three_rates_impl& operator = (const three_rates_impl &); protected: class proxy_creator { public: proxy_creator() { three_rates_impl::_instance(); } }; static proxy_creator m_proxy; public: static three_rates_impl* _instance(); protected: bool m_bstop; std::mutex m_thread_mutex; std::unique_ptr m_pthree_rates_thread; YADB::_DB_POOL_SETTING_ m_db_setting; std::shared_ptr m_poperating_rate; std::shared_ptr m_pregularcycle_rate; std::shared_ptr m_pvehicle_driver_alarm; std::shared_ptr m_drivingface_alarm; long long m_time; tr_queue *p_tr_queue ; boost::lockfree::queue> m_boost_queue; std::vector m_DB_Changed_list; std::mutex m_mutex; // 工作面数据 std::shared_ptr m_common_data; // 作为SO运行 bool m_runSo = true; public: std::shared_ptr &get_common_data() { return m_common_data; } void setRunSoFile(bool bRun) { m_runSo = bRun;} public: /* * Functon: Init the three_rates module * Parameters: * init_param& para - in&out, three_rates parameters * Returns: void * Throws: void */ virtual void init(const init_para& para, const db_para& dpara ); /* * Functon: Start the three_rates module * Parameters: void * Returns: void * Throws: void */ virtual void start(); /* * Functon: Stop the three_rates module * Parameters: void * Returns: void * Throws: void */ virtual void stop(); /* * Functon: Input the located datas * Parameters: * card_pos& pos - in, position informations * Returns: void * Throws: void */ virtual void put(const card_pos& pos); /* * Functon: Enter one area * Parameters: * card_pos& pos - in, the located datas * area_data& area - in, the area informations * Returns: void * Throws: void */ virtual void enter_area(std::shared_ptr &card_ptr, std::shared_ptr &area_ptr); /* * Functon: Leave one area * Parameters: * card_pos& pos - in, the located datas * area_data& area - in, the area informations * Returns: void * Throws: void */ virtual void leave_area(std::shared_ptr &card_ptr, std::shared_ptr &area_ptr); /* * 获取掘进机或者采煤机的开机状态 */ virtual bool GetVehicleState(int vehicleId); /* * Functon: thread function * Parameters: void * Returns: void * Throws: void */ void run(); /* * Functon: Init database settings * Parameters: void * Returns: int, returns 0 normally, otherwise it returns 1 * Throws: void */ int init_db(const db_para& dpara); /* * Functon: WEB通知数据有更新 * Parameters: * std::string webname, - in, 更新表名 * std::string param - in, 更新表内容(id) * edit_type_id,0 新增,1 修改,2 删除 * Returns: void * Throws: void */ virtual void update_db_data(const std::string& webname, const std::string& param,int edit_type_id); void deal_db_data_changed(const ChangedDBDate& Db); private: worktime m_worktime; trm_drivingface_module m_drivingface_module; public: //超时关机时间阈值 int m_shutdown_timeout_threshold; //卡同步的次数 std::map m_card_sync_num; //添加次数-id对应的消息处理次数 void add_cardsyncNum(int id); public: // 输入日志ID==log.ini中对应的日志属性(日志文件等) static int g_three_rates_log_id; // 更新数据的日志ID static int g_three_rates_sql_log_id; }; #define G_CommonData three_rates_impl::_instance()->get_common_data() #endif