#include "wheelCalcTask.h"

WheelCalcTask::WheelCalcTask(std::string termStr, nnxx::message_control *ctl, msgCallback func, void* p){
    // std::cout<<"task contructor start"<<std::endl;
    m_msg_callback_func = func;
    m_base_string = termStr;
    m_wind = p;
    // std::cout<<"task contructor 2"<<std::endl;
    m_ctl=ctl;
    // std::cout<<"task contructor end"<<std::endl;
}

WheelCalcTask::~WheelCalcTask(){
    if(m_msg_callback_func)
        m_msg_callback_func=NULL;
}

void WheelCalcTask::Main(){
    if(m_msg_callback_func){
        // std::cout<<"recv: "<<m_base_string<<std::endl;
        if(m_base_string.size()>8 && m_base_string.substr(0, 8) == "Terminal"){
            int termID = atoi(m_base_string.substr(8, m_base_string.length()-8).c_str());
            std::cout<<"terminal id: "<<termID<<std::endl;
            m_msg_callback_func(termID, m_ctl, m_wind);
        }
    }
}

void WheelCalcTask::Cancel(){

}
