008 VANTIQRulesandProcedures V30Vantiq资源_第1页
008 VANTIQRulesandProcedures V30Vantiq资源_第2页
008 VANTIQRulesandProcedures V30Vantiq资源_第3页
008 VANTIQRulesandProcedures V30Vantiq资源_第4页
008 VANTIQRulesandProcedures V30Vantiq资源_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论