ITK之RuleHandler(规则处理程序)开发流程

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

rule handler可以在流程节点不同的状态中判断规则。在流程中的节点有很多的状态,比如开始、执行、完成等。

  • 在这里使用rule 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 EPM_decision_t cust_rulehandler(EPM_rule_message_t msg);
#ifdef __cplusplus
}
#endif
  • handlerstudy.cpp文件内容如下
#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()
{
  printf("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_module111\n");
  int stat = ITK_ok;
  *decision = ALL_CUSTOMIZATIONS;
  // register rule  handlers
  EPM_register_rule_handler("cust_rulehandler", "Sample Rule Handler", (EPM_rule_handler_t)cust_rulehandler);
  return stat;
}
​
extern EPM_decision_t cust_rulehandler(EPM_rule_message_t msg) {
  printf("rule Handler!");
  //EPM_decision_t decision = EPM_go;//允许
  EPM_decision_t decision = EPM_nogo;//拒绝
  return decision;
}
  • 生成解决方案,将生成的handlerstudy.dll文件放到%TC_ROOT%\bin下

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

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

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

  • 返回值是EPM_nogo的时候,错误提示信息如下

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

叮当LIU

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

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

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

打赏作者

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

抵扣说明:

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

余额充值