




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、VANTIQ Rules and ProceduresVANTIQ Training Module 008MODULE OBJECTIVESBy the end of this module, you should be able to:Understand VAIL RulesUnderstand VAIL ProceduresUnderstand how to define VAIL rules/procedures2PROCEDURESyntax:PROCEDURE.()WITH properties = Example:PROCEDURE changeSalary(empName, n
2、ewSalary DEFAULT 1000)your code herereturn “success” 3RETURN?RETURN may be used to explicitly specify the returned value?Procedures return a value when their execution completes.?If not RETURN statement is defined then the value of the last statement in the procedure is returned?RETURN statement MUS
3、T be the last statement in the procedure body ?Example?RETURN This string will be the return value for the procedure4CALLING A PROCEDURE?In VAIL (Rule or Procedure)?changeSalary(David)?or?EXECUTE changeSalary(“David”)?Or use the UI:5PROCEDURE PARAMETERS?You can optionally declare the parameter types
4、.?Allowable types: String, Integer, Real, DateType, Decimal, Currency, GeoJSON, ResourceReference, Object (plus ARRAYs of the above)?Example:?PROCEDURE changeSalary(empName String, newSalary Currency)? your code here?return “success”6PARAMETERS DESCRIPTIONS?You can also add descriptions to your para
5、meters?Used by UI only?Example:?PROCEDURE changeSalary(empName String description Full name (first last),?newSalary Currency description annual salary)7PARAMETERS UI EXAMPLEProcedure Parameter Description8RULE STATEMENTThe rule statement is the first statement in a rule definition and it gives its n
6、ame. Full Syntax:RULE : WHERE ACTIVATIONCONSTRAINT Basic Syntax:RULE Examples:RULE onInsertOrder WHEN INSERT OCCURS ON Order9ACTIVATION CONSTRAINTThe activation contraint determines when the rule should fire. The activation contraint starts with WHEN or BEFORE. WHEN Syntax:WHEN INSERT | UPDATE | DEL
7、ETE OCCURS ON AS WHERE WHEN MESSAGE ARRIVES FROM AS WHERE WHEN PUBLISH OCCURS ON AS WHERE 10ACTIVATION CONSTRAINT EXAMPLESWHEN INSERT OCCURS ON SensorWHEN INSERT OCCURS ON Sensor WHERE Sensor.reading 100WHEN INSERT OCCURS ON Sensor AS tempSensorWHERE tempSensor 100AND tempSensor.sensorType=“temp”WHE
8、N UPDATE OCCURS ON Patient AS pWHERE patient.location = “Hospital”11MORE ACTIVATION CONSTRAINTS EXAMPLESWHEN MESSAGE ARRIVES FROM ”MQTT_topic AS msgWHEN PUBLISH OCCURS ON /sensorData AS sensor12RULE BODY (DATA RULES)In the case of rules that trigger of data, rules can use the data referenced directl
9、y in the body of the rule.RULE onInsert_simpleWHEN INSERT OCCURS ON Simple as sIF (s.msg = “test”)13RULE BODY (MESSAGE/PUBLISH RULES)In the case of rules that trigger off a topics, the message contains the data in a ”newValue” attribute e.g. topic: /VoltageReading/new, newValue: sensorId: SampleIden
10、tifier, reading: 12.35 RULE onPublish_testWHEN PUBLISH OCCURS ON “/test” AS mIF (m.newValue.msg = “test)14RULES COMPLETE EXAMPLERULE myFirstRule WHEN INSERT OCCURS ON Order AS order FOR mgr IN SELECT ONE * FROM Employee WHERE name = order.salesPersonManager Search for manager for sales person PUBLIS
11、H message: There is an order for your review: + order.orderId TO SOURCE corporateEmail USING recipients: mgr.emailAddress IF (order.customerName = myFavoriteCustomer) applyDiscount(10%, order) Email manager to review orderExecute “applyDiscount” if “myFavoriteCustomer”15RULE ACTIVATION VERSUS RULE B
12、ODYWhat is the difference between the following rules?RULE onInsert_withActivationWHEN INSERT OCCURS on Sensor WHERE Sensor.temp100doSomething(Sensor.sensorId)ANDRULE onInsert_withIfWHEN INSERT OCCURS on SensorIF (Sensor.temp100) doSomething(Sensor.sensorId)16FURTHER THOUGHT ON ACTIVATIONRULE onInse
13、rt_tempWHEN INSERT OCCURS on Sensor WHERE Sensor.type=“temp”doSomething(Sensor.sensorId)RULE onInsert_vibrationWHEN INSERT OCCURS on Sensor WHERE Sensor.type=“vibration”doSomethingElse(Sensor.sensorId)RULE onInsert_withIfWHEN INSERT OCCURS on SensorIF (Sensor.type=“temp” doSomething(Sensor.sensorId) ELSE IF (
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 广场花砖施工方案
- 2025-2030中国睡袋行业市场深度调研及发展策略研究报告
- 2025项目部治理人员安全培训考试试题(ab卷)
- 2025年新版车间安全培训考试试题(典型题)
- 2025-2030中国直接数字控制器行业市场发展趋势与前景展望战略研究报告
- 2025年翡翠长寿壶项目可行性研究报告
- 2025公司厂级员工安全培训考试试题完整
- 25年公司安全管理人员安全培训考试试题附答案(培优)
- 2025-2030中国电话电缆行业市场现状供需分析及重点企业投资评估规划分析研究报告
- 2024-2025企业安全培训考试试题及答案
- 2025年中考道德与法治专题复习:非选择题答题指导与答题模板 课件67张
- 患者隐私保护培训课件
- 四川凉山州人民政府办公室考调所属事业单位工作人员2人高频重点提升(共500题)附带答案详解
- 分包单位负责人岗位责任制度模版(3篇)
- 2023年高考化学试卷(河北)(解析卷)
- 2025年国家信息中心招聘15人高频重点提升(共500题)附带答案详解
- 基于STM32单片机的人体感应灯设计
- 教学课件英语人教版2024版七年级初一上册Unit 1 You and Me Section A1a1d2
- 学前儿童语言教育与活动指导-期末试卷(二)
- 畜牧业边境管理办法
- 基于单片机的步进电机控制系统的设计【毕业论文】
评论
0/150
提交评论