/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: treeMenu.cpp * Author: shjd * * Created on 2017年12月22日, 下午5:06 */ #include "treeMenu.h" #include "gui_srv.h" #include "ac_read.h" #include "dialog_rcb.h" #include "dialog_sg.h" extern gui_srv * w; extern dialog_rcb *dlg_rcb; extern dialog_sg *dlg_sg; typedef ST_RET(*ac_read_obj_value_type)(ST_INT, AC_READ_REQ_INFO*, ST_INT, AC_REQ_CTRL **); typedef ST_BOOLEAN (*ac_get_srvm_chnlKeepCon_type)(ST_INT, AC_CHANNEL); typedef ST_BOOLEAN(*ac_set_srvm_chnlKeepCon_type)(ST_INT, ST_BOOLEAN, AC_CHANNEL); extern ac_read_obj_value_type ac_read_obj_value_ad; extern ac_set_srvm_chnlKeepCon_type ac_set_srvm_chnlKeepCon_ad; extern ac_get_srvm_chnlKeepCon_type ac_get_srvm_chnlKeepCon_ad; treeMenu::treeMenu(QWidget *parent) { setWindowFlags(Qt::CustomizeWindowHint); widget.setupUi(this); dlg_rcb=new dialog_rcb(); dlg_sg=new dialog_sg(); } static ST_VOID gui_on_read_req(AC_REQ_CTRL *req_ctrl) { w->_on_read_req(req_ctrl); } void treeMenu::SetIds(ST_INT srvid, AI_OBJ_ID objid) { srv_id=srvid; obj_id=objid; dlg_rcb->SetIds(srv_id, obj_id); } void treeMenu::SetControlState(QStringList controllst) { widget.tBtn_connA->setEnabled(false); widget.tBtn_connB->setEnabled(false); widget.tBtn_control->setEnabled(false); widget.tBtn_directory->setEnabled(false); widget.tBtn_fixedValue->setEnabled(false); widget.tBtn_log->setEnabled(false); widget.tBtn_read->setEnabled(false); widget.tBtn_write->setEnabled(false); widget.tBtn_report->setEnabled(false); for(int i=0;isetEnabled(true); } else if(controllst[i].toStdString()=="conn") { widget.tBtn_connA->setEnabled(true); widget.tBtn_connB->setEnabled(true); } else if(controllst[i].toStdString()=="control") { widget.tBtn_control->setEnabled(true); } else if(controllst[i].toStdString()=="directory") { widget.tBtn_directory->setEnabled(true); } else if(controllst[i].toStdString()=="log") { widget.tBtn_log->setEnabled(true); } else if(controllst[i].toStdString()=="read") { widget.tBtn_read->setEnabled(true); } else if(controllst[i].toStdString()=="write") { widget.tBtn_write->setEnabled(true); } else if(controllst[i].toStdString()=="fixedValue") { widget.tBtn_fixedValue->setEnabled(true); } } } void treeMenu::setconnA(bool conn) { if(conn) { widget.tBtn_connA->setPalette(QPalette(Qt::green)); widget.tBtn_connA->setAutoFillBackground(true); widget.tBtn_connA->setText("断开A网"); } else { widget.tBtn_connA->setPalette(QPalette(Qt::red)); widget.tBtn_connA->setAutoFillBackground(true); widget.tBtn_connA->setText("连接A网"); } } void treeMenu::setconnB(bool conn) { if(conn) { widget.tBtn_connB->setPalette(QPalette(Qt::green)); widget.tBtn_connB->setAutoFillBackground(true); widget.tBtn_connB->setText("断开B网"); } else { widget.tBtn_connB->setPalette(QPalette(Qt::red)); widget.tBtn_connB->setAutoFillBackground(true); widget.tBtn_connB->setText("连接B网"); } } treeMenu::~treeMenu() { dlg_rcb->~dialog_rcb(); } void treeMenu::on_tBtn_read_clicked(){ AI_OBJ_ID obj_ids[1]; ST_RET ret; char str[MAX_REFERENCE_LENGTH + 1] = {0}; AC_READ_REQ_INFO ac_reqInfo; obj_ids[0]=obj_id; ac_reqInfo.num_obj = 1; ac_reqInfo.obj_ids = obj_ids; ac_reqInfo.u_read_done = gui_on_read_req; ret = ac_read_obj_value_ad(srv_id, &ac_reqInfo,15,NULL); if(SD_SUCCESS == ret) { sprintf(str,"读服务加入队列成功"); w->out_put(str); } this->close(); } void treeMenu::on_tBtn_write_clicked() { this->close(); w->out_put("tBtn_read"); } void treeMenu::on_tBtn_directory_clicked() { // ST_INT srv_id; // ST_INT obj_id; // ST_RET ret; // int img_type; // // char ser_name[MAX_IDENT_LEN + 1] = {0}; // char dom_name[MAX_IDENT_LEN + 1] = {0}; // char str[MAX_REFERENCE_LENGTH + 1] = {0}; // char obj_ref[MAX_REFERENCE_LENGTH + 1] = {0}; // OBJECT_NAME objname; // // HTREEITEM hItem; // ULONG para; // AI_OBJ_IDCTRL *id_ctrl; // AI_IED_CTRL *vmd; // AC_GETLDD_REQ_INFO getldd_ln; // AC_GETLDD_REQ_INFO getldd_ds; // AC_GETDSD_REQ_INFO getdsd; // AC_GETOBJDEF_REQ_INFO objdef; // // memset(&objname, 0, sizeof(OBJECT_NAME)); // get_server_name(ser_name); // srv_id = ac_get_srvm_srvId(ser_name); // vmd = ac_get_srvm_ied(srv_id); // // hItem = GetSelectedItem(); // if(!hItem) // return; // para = GetItemData(hItem); // id_ctrl = (AI_OBJ_IDCTRL*)para; // obj_id = ai_obj_id_ctrl_to_id(id_ctrl); // img_type = get_img_type(); // switch(img_type) // { // case IMG_LINKSERVER_N: // ret = ac_get_ied_dir(srv_id,u_dir_callback_done,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"VMD目录服务入队列成功OBJ_ID=%d",srv_id); // user_log_put(str); // } // break; // case IMG_LD_N: // ai_obj_id_to_objName(vmd,obj_id,&objname); // getldd_ln.ld_name = objname.obj_name.vmd_spec; // getldd_ln.type = OBJECT_TYPE_LN; // getldd_ln.u_getldd_done = u_dir_callback_done; // ret = ac_get_ld_dir(srv_id,&getldd_ln,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"DOM(VAR)目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // // getldd_ds.ld_name = objname.obj_name.vmd_spec; // getldd_ds.type = OBJECT_TYPE_DS; // getldd_ds.u_getldd_done = u_dir_callback_done; // ret = ac_get_ld_dir(srv_id,&getldd_ds,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"DOM(NVL)目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // break; // case IMG_DS_N: // //ai_obj_id_to_objName(vmd,obj_id,&objname); // ai_obj_id_to_ref(vmd,obj_id,obj_ref); // strcpy(getdsd.ds_ref, obj_ref); // getdsd.u_getdsd_done = u_dir_callback_done; // ret = ac_get_ds_dir(srv_id,&getdsd,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"NVL目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // // break; // case IMG_LN_N: // //ai_obj_id_to_objName(vmd,obj_id,&objname); // ai_obj_id_to_ref(vmd,obj_id,obj_ref); // strcpy(objdef.obj_ref, obj_ref); // objdef.u_getobjdef_done = u_dir_callback_done; // ret = ac_get_obj_definition(srv_id,&objdef,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"VAR(LN)目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // break; // case IMG_FC_N: // //ai_obj_id_to_objName(vmd,obj_id,&objname); // ai_obj_id_to_ref(vmd,obj_id,obj_ref); // strcpy(objdef.obj_ref, obj_ref); // objdef.u_getobjdef_done = u_dir_callback_done; // ret = ac_get_obj_definition(srv_id,&objdef,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"VAR(FC)目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // break; // case IMG_VA_N: // //ai_obj_id_to_objName(vmd,obj_id,&objname); // ai_obj_id_to_ref(vmd,obj_id,obj_ref); // strcpy(objdef.obj_ref, obj_ref); // objdef.u_getobjdef_done = u_dir_callback_done; // ret = ac_get_obj_definition(srv_id,&objdef,10,NULL); // if(SD_SUCCESS == ret) // { // sprintf(str,"VAR(VA)目录服务入队列成功OBJ_ID=%d",obj_id); // user_log_put(str); // } // break; // default: // break; // } // ai_cleanup_objName(&objname); this->close(); } void treeMenu::on_tBtn_report_clicked() { dlg_rcb->setWindowModality(Qt::ApplicationModal); dlg_rcb->show(); this->close(); w->out_put("tBtn_read"); } void treeMenu::on_tBtn_log_clicked() { this->close(); w->out_put("tBtn_read"); } void treeMenu::on_tBtn_control_clicked() { this->close(); w->out_put("tBtn_read"); } void treeMenu::on_tBtn_fixedValue_clicked() { dlg_sg->setWindowModality(Qt::ApplicationModal); dlg_sg->show(); } void treeMenu::on_tBtn_connA_clicked() { if(ac_get_srvm_chnlKeepCon_ad(srv_id,AC_CHANNEL_A)) { ac_set_srvm_chnlKeepCon_ad(srv_id,FALSE,AC_CHANNEL_A); } else { ac_set_srvm_chnlKeepCon_ad(srv_id,TRUE,AC_CHANNEL_A); } this->close(); } void treeMenu::on_tBtn_connB_clicked() { if(ac_get_srvm_chnlKeepCon_ad(srv_id,AC_CHANNEL_B)) { ac_set_srvm_chnlKeepCon_ad(srv_id,FALSE,AC_CHANNEL_B); } else { ac_set_srvm_chnlKeepCon_ad(srv_id,TRUE,AC_CHANNEL_B); } this->close(); }