版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 贵州省黔南州都匀市2023-2024学年八年级上学期期末考试数学试卷(答案不全)
- 养老院老人生活照顾人员激励制度
- 养老院老人健康监测人员社会保险制度
- 《开场白的艺术》课件
- 挽回婚姻协议书(2篇)
- 拆架子免责协议书(2篇)
- 《生化课件生物氧化》课件
- 2025年甘肃货运资格证考题
- 2025年黑龙江货运从业资格考试题目及答案大全解析
- 2025年拉萨货运从业资格证结业考试答案
- 【肿瘤标志物不同检验方式的临床研究进展综述报告5000字(论文)】
- 基于多元智能理论的学生评价与发展研究
- 游戏综合YY频道设计模板
- 2023-2024学年天津市部分地区六年级数学第一学期期末综合测试试题含答案
- 2023年阻碍中国芯片产业发展的主要因素分析
- 城市亮化高空作业及安全措施施工方案
- 实验心理学文献阅读报告
- Rexroth (博世力士乐)VFC 3610系列变频器使用说明书
- 黑龙江龙江森工集团招聘笔试题
- 大班美术教案:拉手小人教案及教学反思
- 外墙外保温监理实施细则
评论
0/150
提交评论