123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- #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 <mutex>
- #include <memory>
- #include <thread>
- #include <iostream>
- #include <boost/lockfree/queue.hpp>
- 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<std::thread> m_pthree_rates_thread;
- YADB::_DB_POOL_SETTING_ m_db_setting;
- std::shared_ptr<operating_rate> m_poperating_rate;
- std::shared_ptr<regularcycle_rate> m_pregularcycle_rate;
- std::shared_ptr<vehicle_driver_alarm> m_pvehicle_driver_alarm;
- std::shared_ptr<DrivingFaceAlarm> m_drivingface_alarm;
- long long m_time;
- tr_queue *p_tr_queue ;
- boost::lockfree::queue<card_pos,boost::lockfree::capacity<40000>> m_boost_queue;
- std::vector<ChangedDBDate> m_DB_Changed_list;
- std::mutex m_mutex;
- // 工作面数据
- std::shared_ptr<common_data> m_common_data;
- // 作为SO运行
- bool m_runSo = true;
- public:
- std::shared_ptr<common_data> &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_pos> &card_ptr, std::shared_ptr<area_data> &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_pos> &card_ptr, std::shared_ptr<area_data> &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<int,int> 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
|