ITK之Action Handler(操作处理程序)开发流程

Handler是用于控制流程的系统行为,分为rule handler(规则处理程序)与action handler(操作处理程序)。

action handler可以在流程节点不同的状态中做需要的操作。在流程中的节点有很多的状态,比如开始、执行、完成等。

  • 在这里使用action handler实现一个修改目标对象名称的小例子,如何创建一个项目并引用tc的头文件和链接库配置可以参考下面这一篇文章。
  • VS2015搭建ITK开发环境
  • 创建完后的项目结构如下图:

  • handlerstudy.h文件内容如下,声明需要使用的方法
#pragma once
#include <ict/ict_userservice.h>
#include <tc/iman.h>
#include <tccore/custom.h>
#include <epm/epm_toolkit_tc_utils.h>
#ifdef __cplusplus
extern "C"
{
#endif
  extern DLLAPI int CUST_init_module(int *, va_list);
  extern DLLAPI int handlerstudy_register_callbacks();
  extern DLLAPI int cust_actionhandler(EPM_action_message_t msg);
#ifdef __cplusplus
}
#endif
  • handlerstudy.cpp文件内容如下,在cust_actionhandler方法中修改目标对象的名称
#include <pie/sample_err.h>
#include <ict/ict_userservice.h>
#include<tc/tc.h>
#include <bom/bom.h>
#include <tccore/aom_prop.h>
#include <tccore/custom.h>
#include "handlerstudy_cust.h"
extern DLLAPI int handlerstudy_register_callbacks()
{
  int stat = ITK_ok;
  CUSTOM_register_exit("handlerstudy", "USER_gs_shell_init_module", (CUSTOM_EXIT_ftn_t)CUST_init_module);
  return stat;
}
extern DLLAPI int CUST_init_module(int *decision, va_list args)
{
  printf("CUST_init_module\n");
  int stat = ITK_ok;
  *decision = ALL_CUSTOMIZATIONS;
  // register action  handlers
  //使用EPM_register_action_handler() 注册action handler
  EPM_register_action_handler("cust_actionhandler", "Sample Action Handler", (EPM_action_handler_t)cust_actionhandler);
  return stat;
}
int cust_actionhandler(EPM_action_message_t msg) {
  tag_t
      obj = NULLTAG,
      *attachments = NULL;
    int
      att_count = 0;
      
    EPM_ask_root_task(msg.task, &obj);
    EPM_ask_attachments(obj, EPM_target_attachment, &att_count, &attachments);
    char *str_object_name = NULL;
    char *object_name = "修改的名称";
    for (int i = 0; i < att_count; i++) {
      //获取对象的属性值
      AOM_ask_value_string(attachments[i], "object_name", &str_object_name);
      printf(str_object_name);//修改前名称
​
      AOM_set_value_string(attachments[i], "object_name", object_name);
      printf(object_name);//需要修改成的名称
​
      AOM_ask_value_string(attachments[i], "object_name", &str_object_name);
      printf(str_object_name);//修改后的名称
    }
  return ITK_ok;
}
  • 生成解决方案,将生成的handlerstudy.dll文件放到%TC_ROOT%\bin下

  • 在首选项TC_customization_libraries中添加生成的dll文件名称

  • 启动TC胖客户端查看TAO窗口,可以看到注册的handler信息

  • 在流程中的完成节点中添加注册的cust_actionhandler

到这里一个简单的actionhandler的开发流程就完成了

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叮当LIU

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值