You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61850gui/dialog_rcb.cpp

725 lines
26 KiB
C++

2 years ago
/*
* 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: dialog_rcb.cpp
* Author: shjd
*
* Created on 20171226, 4:53
*/
#include "dialog_rcb.h"
#include "gui_srv.h"
#include "ac_read.h"
#include "ac_write.h"
#include <stdlib.h>
#include <QMessageBox>
#include <QDebug>
#include "mem_chk.h"
#include "ac_rptEna.h"
extern gui_srv * w;
dialog_rcb *dlg_rcb;
//#ifdef DEBUG_SISCO
//SD_CONST static ST_CHAR *SD_CONST thisFileName = __FILE__;
//#endif
typedef ST_RET(*ai_get_obj_dir_type)(AI_IED_CTRL*, AI_OBJ_ID, ST_BOOLEAN, AI_OBJ_ID **, ST_INT*);
typedef AI_IED_CTRL * (*ac_get_srvm_ied_type)(ST_INT);
typedef ST_RET(*ai_obj_id_to_ref_type)(AI_IED_CTRL *, AI_OBJ_ID, ST_CHAR *);
typedef ST_RET(*ai_read_obj_primVals_type) (AI_OBJ_ID, AI_IED_CTRL*, AI_OBJ_VAL*);
typedef ST_RET(*ai_prim_value_to_str_type)(AI_VAL_TYPE, ST_VOID *, ST_CHAR *);
typedef ST_VOID(*ai_cleanup_objVals_type) (AI_OBJ_VAL *);
typedef AI_OBJ_ID(*ai_obj_ref_to_id_type)(AI_IED_CTRL*, ST_CHAR *);
typedef ST_RET(*ac_read_obj_value_chnl_type)(ST_INT, AC_READ_REQ_INFO*, ST_INT, AC_REQ_CTRL **, AC_CHANNEL);
typedef ST_RET(*ac_read_obj_value_type)(ST_INT, AC_READ_REQ_INFO*, ST_INT, AC_REQ_CTRL **);
typedef ST_RET(*ac_write_obj_value_type)(ST_INT srv_id, AC_WRITE_REQ_INFO* ac_reqInfo,
ST_INT time_out, AC_REQ_CTRL **ac_reqCtrl_out);
typedef ST_RET(*ai_prim_str_to_value_type)(AI_VAL_TYPE type, ST_CHAR *str, ST_VOID *val);
typedef ST_RET(*ac_rpt_enable_type)(ST_INT srv_id, AC_ENAREPORT_INFO* enarpt_info, ST_INT time_out, AC_REQ_CTRL **ac_req_ctrl_out);
extern ai_get_obj_dir_type ai_get_obj_dir_ad;
extern ac_get_srvm_ied_type ac_get_srvm_ied_ad;
extern ai_obj_id_to_ref_type ai_obj_id_to_ref_ad;
extern ai_read_obj_primVals_type ai_read_obj_primVals_ad;
extern ai_prim_value_to_str_type ai_prim_value_to_str_ad;
extern ai_cleanup_objVals_type ai_cleanup_objVals_ad;
extern ai_obj_ref_to_id_type ai_obj_ref_to_id_ad;
extern ac_read_obj_value_chnl_type ac_read_obj_value_chnl_ad;
extern ac_read_obj_value_type ac_read_obj_value_ad;
extern ac_write_obj_value_type ac_write_obj_value_ad;
extern ai_prim_str_to_value_type ai_prim_str_to_value_ad;
extern ac_rpt_enable_type ac_rpt_enable_ad;
static void setcbv(QComboBox *combobox, char *ch) {
if (0 == strcmp(ch, "true") || 0 == strcmp(ch, "TRUE")) {
combobox->setCurrentIndex(1);
} else if (0 == strcmp(ch, "false") || 0 == strcmp(ch, "FALSE")) {
combobox->setCurrentIndex(0);
}
}
static ST_BOOLEAN _is_fco_fc_ubrrpt(ST_CHAR *ref) {
ST_INT len = strlen(ref);
if (NULL == ref) {
return SD_FALSE;
}
if (0 == strncmp((ref + len - 2), "RP", 2)) {
return SD_TRUE;
}
return SD_FALSE;
}
static ST_BOOLEAN _is_fco_fc_brrpt(ST_CHAR *ref) {
ST_INT len = strlen(ref);
if (NULL == ref) {
return SD_FALSE;
}
if (0 == strncmp((ref + len - 2), "BR", 2)) {
return SD_TRUE;
}
return SD_FALSE;
}
/************************************************************************/
/* 需要用户编写回调函数 */
/************************************************************************/
static void demo_c_setRptAttri_req_done(AC_REQ_CTRL *req_ctrl) {
if ((SD_SUCCESS == req_ctrl->result)) {
w->out_put("ac_write_obj_value success!!!");
} else {
w->out_put("ac_write_obj_value failure!!!");
}
}
/************************************************************************/
/* 需要用户编写回调函数 */
/************************************************************************/
static void demo_c_getbrcbv_req_done(AC_REQ_CTRL *req_ctrl) {
ST_INT *id = (ST_INT *) malloc(sizeof (ST_INT));
*id = *req_ctrl->u.rdCtrl.obj_ids;
if ((SD_SUCCESS == req_ctrl->result)) {
w->out_put("a_ai_get_brcb_values success!!!");
//PostMessage(rcb_dlg.m_hWnd, WM_RCB, 0,(LPARAM)id);
dlg_rcb->ShowBRcbValues(id, SD_TRUE);
} else
w->out_put("a_ai_get_brcb_values failure!!!");
}
/************************************************************************/
/* 需要用户编写回调函数 */
/************************************************************************/
static void demo_c_setbrcbv_req_done(AC_REQ_CTRL *req_ctrl) {
if ((SD_SUCCESS != req_ctrl->result)) {
w->out_put("a_ai_set_brcb_values failure!!!");
return;
}
w->out_put("a_ai_set_brcb_values success!!!");
}
/************************************************************************/
/* 需要用户编写回调函数 */
/************************************************************************/
static void demo_c_geturcbv_req_done(AC_REQ_CTRL *req_ctrl) {
ST_INT *id = (ST_INT *) malloc(sizeof (ST_INT));
*id = *req_ctrl->u.rdCtrl.obj_ids;
if ((SD_SUCCESS != req_ctrl->result)) {
w->out_put("a_ai_get_urcb_values failure!!!");
return;
}
w->out_put("a_ai_get_urcb_values success!!!");
dlg_rcb->ShowBRcbValues(id, SD_FALSE);
}
/************************************************************************/
/* 需要用户编写回调函数 */
/************************************************************************/
static void demo_c_seturcbv_req_done(AC_REQ_CTRL *req_ctrl) {
if ((SD_SUCCESS != req_ctrl->result)) {
w->out_put("a_ai_set_urcb_values failure!!!");
} else {
w->out_put("a_ai_set_urcb_values success!!!");
}
}
static ST_VOID _demo_parse_enaRpt_done(AC_REQ_CTRL *ac_reqCtrl) {
if (ac_reqCtrl) {
if ((SD_SUCCESS != ac_reqCtrl->result)) {
w->out_put("报告使能失败!!!");
} else {
w->out_put("报告使能成功!!!");
}
}
}
dialog_rcb::dialog_rcb() {
qRegisterMetaType<ST_INT>("ST_INT");
qRegisterMetaType<AC_CHANNEL>("ST_BOOLEAN");
widget.setupUi(this);
widget.rB_BR->setChecked(true);
tbmodel = new QStandardItemModel;
widget.tV_RCB->setModel(tbmodel);
QStandardItem *item1 = new QStandardItem(tr("RCB Name"));
tbmodel-> setHorizontalHeaderItem(0, item1);
widget.tV_RCB->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
widget.tV_RCB->verticalHeader()->setVisible(false); //设置行表头不显示
widget.tV_RCB->setEditTriggers(QAbstractItemView::NoEditTriggers); //设置表格只读属性
widget.cB_GI->addItem("false");
widget.cB_GI->addItem("true");
widget.cB_PurgeBuf->addItem("false");
widget.cB_PurgeBuf->addItem("true");
widget.cB_Resv->addItem("false");
widget.cB_Resv->addItem("true");
widget.cB_RptEna->addItem("false");
widget.cB_RptEna->addItem("true");
srv_id=-1;
obj_id=-1;
connect(this, SIGNAL(s_ShowBRcbValues(ST_INT*, ST_BOOLEAN)), this, SLOT(t_ShowBRcbValues(ST_INT*, ST_BOOLEAN)), Qt::QueuedConnection);
}
void dialog_rcb::SetIds(ST_INT srvid, AI_OBJ_ID objid) {
srv_id = srvid;
obj_id = objid;
}
void dialog_rcb::on_rB_BR_clicked() {
InitBRCBShowInfo(NULL, true);
}
void dialog_rcb::on_rB_RP_clicked() {
InitBRCBShowInfo(NULL, false);
}
void dialog_rcb::on_pB_RptID_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$RptID");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_RptID->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set RptID value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set RptID value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_DataSetRef_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$DatSet");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_DataSetRef->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set DataSet value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set DataSet value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_OptFlds_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$OptFlds");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_OptFlds->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set OptFlds value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set OptFlds value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_TrgOps_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$TrgOps");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_TrgOps->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set TrgOps value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set TrgOps value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_EntryID_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$EntryID");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_EntryID->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set EntryID value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set EntryID value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_EntryTm_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$EntryTm");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_EntryTm->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set EntryTm value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set EntryTm value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_RptEna_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$RptEna");
if (SD_FAILURE == fullObjWriteInfo(name, widget.cB_RptEna->currentText().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set RptEna value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set RptEna value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_ConfRev_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$ConfRev");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_ConfRev->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set ConfRev value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set ConfRev value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_SqNum_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$SqNum");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_SqNum->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set SqNum value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set SqNum value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_GI_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$GI");
if (SD_FAILURE == fullObjWriteInfo(name, widget.cB_GI->currentText().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set GI value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set GI value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_BufTm_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$BufTm");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_BufTm->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set BufTm value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set BufTm value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_IntgPd_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$IntgPd");
if (SD_FAILURE == fullObjWriteInfo(name, widget.lE_IntgPd->text().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set IntgPd value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set IntgPd value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_PurgeBuf_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$PurgeBuf");
if (SD_FAILURE == fullObjWriteInfo(name, widget.cB_PurgeBuf->currentText().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set PurgeBuf value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set PurgeBuf value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_Resv_clicked() {
char name[MAX_REFERENCE_LENGTH] = {0};
strcpy(name, "$Resv");
if (SD_FAILURE == fullObjWriteInfo(name, widget.cB_Resv->currentText().toLatin1().data())) {
QMessageBox::warning(NULL, "warning", "set Resv value failure!", QMessageBox::Yes);
return;
} else {
QMessageBox::warning(NULL, "warning", "set Resv value success!", QMessageBox::Yes);
return;
}
}
void dialog_rcb::on_pB_GetRcbValues_clicked() {
int row = widget.tV_RCB->currentIndex().row();
if (row < 0) {
QMessageBox::warning(NULL, "warning", "未选择RCB名称,请重新选择!", QMessageBox::Yes);
return;
}
QString str = tbmodel->data(tbmodel->index(row, 0)).toString(); //第n行第1列的内容
getRcbValues(str.toLatin1().data());
}
void dialog_rcb::on_pB_SetRcbValues_clicked() {
OnSetrcbvaluebut();
}
void dialog_rcb::on_pB_EnableRpt_clicked() {
OnEnablerpt();
}
/************************************************************************/
/* RCB服务get urcb values/get brcb values */
/************************************************************************/
void dialog_rcb::getRcbValues(ST_CHAR *ref) {
ST_INT objid = -1;
AC_READ_REQ_INFO reqinfo;
AI_IED_CTRL *ied = NULL;
ied = ac_get_srvm_ied_ad(srv_id);
objid = ai_obj_ref_to_id_ad(ied, ref);
if (-1 == objid) {
return;
}
reqinfo.num_obj = 1;
reqinfo.obj_ids = &objid;
if (widget.rB_BR->isChecked())
reqinfo.u_read_done = demo_c_getbrcbv_req_done;
else
reqinfo.u_read_done = demo_c_geturcbv_req_done;
ac_read_obj_value_ad(srv_id, &reqinfo, 15, NULL);
}
void dialog_rcb::InitBRCBShowInfo(char *str, bool brptflag) {
ST_INT index = 0, i;
ST_CHAR ref[MAX_REFERENCE_LENGTH + 1] = {0};
ST_BOOLEAN addsuccess = FALSE;
ST_CHAR objRef[MAX_REFERENCE_LENGTH + 1] = {0};
AI_IED_CTRL *ied = NULL;
ST_INT *ids = NULL;
ST_INT idnum = 0;
ied = ac_get_srvm_ied_ad(srv_id);
if (NULL == ied) {
return;
}
tbmodel->removeRows(0, tbmodel->rowCount());
ai_obj_id_to_ref_ad(ied, obj_id, objRef);
if (NULL == str) {
ai_get_obj_dir_ad(ied, obj_id, SD_FALSE, &ids, &idnum);
for (i = 0; i < idnum; i++) {
ai_obj_id_to_ref_ad(ied, ids[i], ref);
if (true == brptflag) {
if (_is_fco_fc_ubrrpt(objRef)) {
continue;
}
} else {
if (_is_fco_fc_brrpt(objRef)) {
continue;
}
}
tbmodel->setItem(index, 0, new QStandardItem(ref));
index++;
addsuccess = TRUE;
}
}
}
/************************************************************************/
/* SetRcbValues()服务 */
/************************************************************************/
void dialog_rcb::OnSetrcbvaluebut() {
ST_RET ret = SD_FAILURE;
ST_INT objid;
AC_WRITE_REQ_INFO reqinfo;
AI_OBJ_VAL objval;
AI_IED_CTRL *ied = NULL;
int index=0;
int row = widget.tV_RCB->currentIndex().row();
if (row < 0) {
QMessageBox::warning(NULL, "warning", "未选择RCB名称,请重新选择!", QMessageBox::Yes);
return;
}
QString str = tbmodel->data(tbmodel->index(row, 0)).toString(); //第n行第1列的内容
ied = ac_get_srvm_ied_ad(srv_id);
objid = ai_obj_ref_to_id_ad(ied, str.toLatin1().data());
reqinfo.num_obj = 1;
if (widget.rB_BR->isChecked()) {
reqinfo.u_write_done = demo_c_setbrcbv_req_done;
} else {
reqinfo.u_write_done = demo_c_seturcbv_req_done;
}
// objval.obj_id = objid; //报告的ID
if (SD_FAILURE == ai_read_obj_primVals_ad(objid, ied, &objval))
return;
if (widget.rB_BR->isChecked()) {
GetBRcbValuesFormEdit(&objval, SD_TRUE);
} else {
GetBRcbValuesFormEdit(&objval, SD_FALSE);
}
char ch[513] = {0};
AI_PRIM_VAL* primval = objval.prim_vals;
ai_prim_value_to_str_ad(primval[0].type, primval[0].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[1].type, primval[1].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[2 + index].type, primval[2 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[3 + index].type, primval[3 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[4 + index].type, primval[4 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[5 + index].type, primval[5 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[6 + index].type, primval[6 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[7 + index].type, primval[7 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[8 + index].type, primval[8 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[9 + index].type, primval[9 + index].data, ch);
w->out_put(ch);
memset(ch, 0, 513);
reqinfo.obj_vals = &objval;
ret = ac_write_obj_value_ad(srv_id, &reqinfo, 30, NULL);
if (ret) {
w->out_put("入发送队列失败!!!");
}
ai_cleanup_objVals_ad(&objval);
}
void dialog_rcb::GetBRcbValuesFormEdit(AI_OBJ_VAL *objval, ST_BOOLEAN brflag) {
int i = 0;
ST_INT index = 0;
ai_prim_str_to_value_ad(objval->prim_vals[0].type, widget.lE_RptID->text().toLatin1().data(), objval->prim_vals[0].data);
ai_prim_str_to_value_ad(objval->prim_vals[1].type, widget.cB_RptEna->currentText().toLatin1().data(), objval->prim_vals[1].data);
if (SD_FALSE == brflag) {
ai_prim_str_to_value_ad(objval->prim_vals[2].type, widget.cB_Resv->currentText().toLatin1().data(), objval->prim_vals[2].data);
index = 1;
}
ai_prim_str_to_value_ad(objval->prim_vals[2 + index].type, widget.lE_DataSetRef->text().toLatin1().data(), objval->prim_vals[2 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[4 + index].type, widget.lE_OptFlds->text().toLatin1().data(), objval->prim_vals[4 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[5 + index].type, widget.lE_BufTm->text().toLatin1().data(), objval->prim_vals[5 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[7 + index].type, widget.lE_TrgOps->text().toLatin1().data(), objval->prim_vals[7 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[8 + index].type, widget.lE_IntgPd->text().toLatin1().data(), objval->prim_vals[8 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[9 + index].type, widget.cB_GI->currentText().toLatin1().data(), objval->prim_vals[9 + index].data);
if (SD_TRUE == brflag) {
ai_prim_str_to_value_ad(objval->prim_vals[10 + index].type, widget.cB_PurgeBuf->currentText().toLatin1().data(), objval->prim_vals[10 + index].data);
ai_prim_str_to_value_ad(objval->prim_vals[11 + index].type, widget.lE_EntryID->text().toLatin1().data(), objval->prim_vals[11 + index].data);
}
}
/************************************************************************/
/* 显示BRCB属性值 */
/************************************************************************/
void dialog_rcb::ShowBRcbValues(ST_INT *id, ST_BOOLEAN flag) {
emit s_ShowBRcbValues(id, flag);
}
void dialog_rcb::t_ShowBRcbValues(ST_INT *id, ST_BOOLEAN flag) {
char ch[513] = {0};
int i = 0;
AI_IED_CTRL *ied = NULL;
AI_OBJ_VAL objval;
int index = 0;
ied = ac_get_srvm_ied_ad(srv_id);
if (NULL == ied)
return;
ai_read_obj_primVals_ad(*id, ied, &objval);
AI_PRIM_VAL* primval = objval.prim_vals;
ai_prim_value_to_str_ad(primval[0].type, primval[0].data, ch);
widget.lE_RptID->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[1].type, primval[1].data, ch);
setcbv(widget.cB_RptEna, ch);
memset(ch, 0, 513);
if (SD_FALSE == flag) {
ai_prim_value_to_str_ad(primval[2].type, primval[2].data, ch);
setcbv(widget.cB_Resv, ch);
memset(ch, 0, 513);
index = 1;
}
ai_prim_value_to_str_ad(primval[2 + index].type, primval[2 + index].data, ch);
widget.lE_DataSetRef->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[3 + index].type, primval[3 + index].data, ch);
widget.lE_ConfRev->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[4 + index].type, primval[4 + index].data, ch);
widget.lE_OptFlds->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[5 + index].type, primval[5 + index].data, ch);
widget.lE_BufTm->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[6 + index].type, primval[6 + index].data, ch);
widget.lE_SqNum->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[7 + index].type, primval[7 + index].data, ch);
widget.lE_TrgOps->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[8 + index].type, primval[8 + index].data, ch);
widget.lE_IntgPd->setText(ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[9 + index].type, primval[9 + index].data, ch);
setcbv(widget.cB_GI, ch);
memset(ch, 0, 513);
if (SD_TRUE == flag) {
ai_prim_value_to_str_ad(primval[10+ index].type, primval[10+ index].data, ch);
setcbv(widget.cB_PurgeBuf, ch);
memset(ch, 0, 513);
ai_prim_value_to_str_ad(primval[11+ index].type, primval[11+ index].data, ch);
widget.lE_EntryID->setText(ch);
memset(ch, 0, 513);
}
ai_cleanup_objVals_ad(&objval);
}
ST_BOOLEAN dialog_rcb::OnWriteObjVal(int objid, ST_CHAR *str) {
AI_OBJ_VAL *objval = NULL;
AC_WRITE_REQ_INFO reqinfo;
ST_RET ret = SD_SUCCESS;
ST_VOID *data = NULL;
AI_IED_CTRL *ied = ac_get_srvm_ied_ad(srv_id);
if (NULL == ied)
return ret;
objval = (AI_OBJ_VAL *) malloc(sizeof (AI_OBJ_VAL));
ret = ai_read_obj_primVals_ad(objid, ied, objval);
if (SD_FAILURE == ret) {
return ret;
}
data = malloc(objval->prim_vals->size);
ret = ai_prim_str_to_value_ad(objval->prim_vals->type, str, data);
if (SD_FAILURE == ret) {
return ret;
}
memcpy(objval->prim_vals->data, data, objval->prim_vals->size); //重新复制
reqinfo.num_obj = 1;
reqinfo.obj_vals = objval;
reqinfo.u_write_done = demo_c_setRptAttri_req_done;
ret = ac_write_obj_value_ad(srv_id, &reqinfo, 15, NULL);
ai_cleanup_objVals_ad(objval);
return ret;
}
ST_RET dialog_rcb::fullObjWriteInfo(ST_CHAR *name, ST_CHAR *str) {
ST_INT objid = -1;
AI_IED_CTRL *ied = ac_get_srvm_ied_ad(srv_id);
ST_CHAR RcbName[MAX_IDENT_LEN + 1];
ST_CHAR ref[MAX_IDENT_LEN + 1];
if (NULL == ied)
return SD_FAILURE;
int row = widget.tV_RCB->currentIndex().row();
if (row < 0) {
QMessageBox::warning(NULL, "warning", "未选择RCB名称,请重新选择!", QMessageBox::Yes);
return SD_FAILURE;
}
QString rcbinfo = tbmodel->data(tbmodel->index(row, 0)).toString(); //第n行第1列的内容
strcpy(RcbName, rcbinfo.toLatin1().data());
strcpy(ref, RcbName); //RPTREF
strcat(RcbName, name);
objid = ai_obj_ref_to_id_ad(ied, RcbName);
if (-1 == objid)
return SD_FAILURE;
return OnWriteObjVal(objid, str);
}
void dialog_rcb::OnEnablerpt() {
AC_ENAREPORT_INFO info;
ST_INT objid = -1;
AC_REQ_CTRL *ac_reqCtrl = NULL;
AI_IED_CTRL *ied = NULL;
ST_OPTFLDS optval;
ST_TRGOP trgval;
int row = widget.tV_RCB->currentIndex().row();
if (row < 0) {
QMessageBox::warning(NULL, "warning", "未选择RCB名称,请重新选择!", QMessageBox::Yes);
return;
}
QString rcbinfo = tbmodel->data(tbmodel->index(row, 0)).toString(); //第n行第1列的内容
ied = ac_get_srvm_ied_ad(srv_id);
objid = ai_obj_ref_to_id_ad(ied, rcbinfo.toLatin1().data());
info.rcb_id = objid;
info.IntgPd = -1; //初始化成小于0的无效值库里就不会写这个属性
info.OptFlds = OPT_UNKNOWN;
info.TrgOps = TRG_UNKNOWN;
info.rptEna = SD_FALSE;
info.u_rpt_done = _demo_parse_enaRpt_done;
QString rptenastr = widget.cB_RptEna->currentText();
if (rptenastr == "true" || rptenastr == "TRUE") {
info.rptEna = SD_TRUE;
info.IntgPd = widget.lE_IntgPd->text().toInt();
ai_prim_str_to_value_ad(VAL_TYPE_OPTFLDS, widget.lE_OptFlds->text().toLatin1().data(), &optval);
info.OptFlds = *(ST_UINT16 *) optval.data_1;
ai_prim_str_to_value_ad(VAL_TYPE_TRGC, widget.lE_TrgOps->text().toLatin1().data(), &trgval);
info.TrgOps = *(ST_INT8 *) trgval.data_1;
}
ac_rpt_enable_ad(srv_id, &info, 30, &ac_reqCtrl);
}
dialog_rcb::~dialog_rcb() {
}