Last modified by Hera Guo on 2024/11/11 16:48

From version 5.1
edited by Hera Guo
on 2024/11/07 16:03
Change comment: There is no comment for this version
To version 6.1
edited by Hera Guo
on 2024/11/07 17:21
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -477,14 +477,221 @@
477 477  
478 478  === 6.4.1 math function ===
479 479  
480 +
481 +
482 +This rule node can perform mathematical calculations and save the results to messages or databases. The configurable contents of this node include:
483 +
484 +**Name: **required field, indicating the name of the node;
485 +
486 +**Functions: **Mathematical functions, the system provides many commonly used mathematical functions for users to use (see table below). In addition, users can choose Custom Function to customize the function;
487 +
488 +**Arguments: **Set the mapping relationship between the parameters in the function formula and the actual physical quantity. Multiple mapping relationships can be added here. Type is a mapping relationship type, and the system provides 5 mapping relationship types to choose from, namely:
489 +
490 +* **Attribute:** Select from the attributes, where the Key in the configuration is the attribute name, the Attribute scope is the scope of the attribute (shared attribute, client attribute, server attribute), and the Default value is the missing default value;
491 +* **Time series: **Select from the time series data, where the Key in the configuration is the attribute name of the time series data, and the Default value is the missing default value;
492 +* **Constant:** The Constant value in its configuration is the value of the constant;
493 +* **Message body: **Select from the message body, where the Key in its configuration is the property name in the message body, and the Default value is the missing default value;
494 +* **Message metadata: **Select from the message metadata, where the Key in the configuration is the attribute name in the message metadata, and the Default value is the missing default value;
495 +
496 +**Mathematical Expression: **When selecting a custom function, this option needs to be configured to set the calculation rules for the function. The parameters in the formula need to be represented using mappings such as x, y, z in Arguments.
497 +
498 +**Result:** Used to configure how to use the results of function calculations. The system provides four options for selection, namely:
499 +
500 +* **Attribute: **configured into an attribute and can be stored as an attribute in the database. The Attribute scope in its configuration is used to set the scope of the attribute, which can be selected from shared attributes and server attributes. The Key is used to configure the name of the attribute, the Number of digits after floating point is used to configure the reserved decimal places of the calculation result, and the Add to message body and Add to message metadata are optional options. After checking, the data will be synchronously stored in the message body and metadata;
501 +* **Time series: **configured into time series data and can be stored as time series data in the database. Key is used to configure the name of the attribute, Number of digits after floating point is used to configure the reserved decimal places of the calculation result, and Add to message body and Add to message metadata are optional options. After checking, the data will be synchronously stored in the message body and metadata;
502 +* **Message body:** configured into the message body and can be passed as message content to downstream rule nodes. Key is used to configure the name of the attribute, and Number of digits after floating point is used to configure the reserved decimal places of the calculation result;
503 +* **Message metadata: **configured into the message metadata and can be passed as message metadata to downstream rule nodes. Key is used to configure the name of the attribute, and Number of digits after floating point is used to configure the reserved decimal places of the calculation result;
504 +
505 +**Explanation:** Non mandatory field, additional explanation;
506 +
507 +The built-in functions of the system are shown in the following table:
508 +
509 +(% dir="ltr" style="width:2514.5px" %)
510 +|**function**|**Number of parameters**|(% style="width:1639px" %)**refer to**
511 +|ADD|2|(% style="width:1639px" %)x + y|(% style="width:82px" %)
512 +|SUB|2|(% style="width:1639px" %)x - y|(% style="width:82px" %)
513 +|(((
514 +MULT
515 +)))|2|(% style="width:1639px" %)x * y|(% style="width:82px" %)
516 +|DIV|2|(% style="width:1639px" %)x / y|(% style="width:82px" %)
517 +|SIN|1|(% style="width:1639px" %)Returns Triangular Sine|(% style="width:82px" %)
518 +|SINH|1|(% style="width:1639px" %)Returns hyperbolic sine (ex-e-x)/2|(% style="width:82px" %)
519 +|COS|1|(% style="width:1639px" %)Returns Triangular Cosine|(% style="width:82px" %)
520 +|COSH|1|(% style="width:1639px" %)Returns Triangular Cosine (ex+e-x)/2|(% style="width:82px" %)
521 +|TAN|1|(% style="width:1639px" %)Returns Triangular Tangent|(% style="width:82px" %)
522 +|TANH|1|(% style="width:1639px" %)Returns hyperbolic tangent|(% style="width:82px" %)
523 +|ACOS|1|(% style="width:1639px" %)Returns within the inverse cosine range of 0.0 to pi|(% style="width:82px" %)
524 +|ASIN|1|(% style="width:1639px" %)Returns within the sine arc range of * pi/2 to pi/2*|(% style="width:82px" %)
525 +|ATAN|1|(% style="width:1639px" %)Returns are cut within the range of pi/2 to pi/2|(% style="width:82px" %)
526 +|ATAN2|2|(% style="width:1639px" %)Returns rectangular coordinates|(% style="width:82px" %)
527 +|EXP|1|(% style="width:1639px" %)Returns ex|(% style="width:82px" %)
528 +|EXPM1|1|(% style="width:1639px" %)Returns ex-1|(% style="width:82px" %)
529 +|SQRT|1|(% style="width:1639px" %)Returns positive square root|(% style="width:82px" %)
530 +|CBRT|1|(% style="width:1639px" %)Returns multidimensional dataset root|(% style="width:82px" %)
531 +|GET_EXP|1|(% style="width:1639px" %)Returns unbiased index|(% style="width:82px" %)
532 +|HYPOT|2|(% style="width:1639px" %)Returns unbiased index sqrt (x2+y2)|(% style="width:82px" %)
533 +|LOG|1|(% style="width:1639px" %)Returns Natural Logarithms|(% style="width:82px" %)
534 +|LOG10|1|(% style="width:1639px" %)Returns 10 logarithms|(% style="width:82px" %)
535 +|LOG1P|1|(% style="width:1639px" %)The natural logarithm of the sum of the Returns parameter and 1|(% style="width:82px" %)
536 +|GEIL|1|(% style="width:1639px" %)Returns minimum integer|(% style="width:82px" %)
537 +|FLOOR|1|(% style="width:1639px" %)Returns maximum integer|(% style="width:82px" %)
538 +|FLOOR_DIV|2|(% style="width:1639px" %)Maximum quotient of Returns|(% style="width:82px" %)
539 +|FLOOR_MOD|2|(% style="width:1639px" %)Returns base modulus|(% style="width:82px" %)
540 +|ABS|1|(% style="width:1639px" %)Returns Absolute Value|(% style="width:82px" %)
541 +|MIN|2|(% style="width:1639px" %)Minimum Returns|(% style="width:82px" %)
542 +|MAX|2|(% style="width:1639px" %)Maximum Returns|(% style="width:82px" %)
543 +|POW|2|(% style="width:1639px" %)Returns power|(% style="width:82px" %)
544 +|SIGNUM|1|(% style="width:1639px" %)Returns symbol function|(% style="width:82px" %)
545 +|RAD|1|(% style="width:1639px" %)Convert angles measured in degrees to approximately equivalent angles measured in radians|(% style="width:82px" %)
546 +|DEG|1|(% style="width:1639px" %)Convert the angle measured in radians to an approximate equivalent angle measured in degrees|(% style="width:82px" %)
547 +|CUSTOM|1-16|(% style="width:1639px" %)Custom functions such as (x-32)/1.8 use this function to specify complex mathematical expressions|(% style="width:82px" %)
548 +
549 +
550 +According to the running results, there are two types of exits for this rule node: Success and Failure.
551 +
552 +A simple usage example is as follows:
553 +
554 +[[image:1730968732576-495.png]]
555 +
480 480  === 6.4.2 create alarm && clear alarm ===
481 481  
558 +
559 +
560 +Two rule nodes are used to create and clear alerts, respectively. As long as there is data flowing into the node that creates or clears alerts, an alert will definitely be created or cleared. Nodes can customize the detailed content of alerts through encoding. In this system, there can be at most one alarm message of the same type for the same device, and subsequent alarms will be presented in an updated manner. When existing alarms are cleared, subsequent alarm information will be created.
561 +
562 +The contents that need to be configured for the create alarm rule node are:
563 +
564 +**Name:** required field, indicating the name of the node;
565 +
566 +**Function Details:** Define the detailed content of the alert. The function parameters include msg (message), metadata (metadata), and msgType (message type pushed by the previous node). The previous alert details can be accessed through metadata. prvAlarmDetails. The return value should be the details object, which is the detailed information of the alarm;
567 +
568 +**Alarm type: **required field, customizable alarm type;
569 +
570 +**Alarm severity: **required option, configure the degree of danger of the alarm, the system provides five levels of danger, important, secondary, warning, and uncertain for selection;
571 +
572 +**Explanation:** Non mandatory field, additional explanation;
573 +
574 +According to the running results, the exits of this rule node include Created, Updated, False, and Failure. Newly created alerts will be passed through the Created exit, while updated alerts will be passed through the Updated exit.
575 +
576 +The clear alarm rule node needs to configure the following contents:
577 +
578 +**Name: **required field, indicating the name of the node;
579 +
580 +**Function Details: **Define the detailed content of the alert. The function parameters include msg (message), metadata (metadata), and msgType (message type pushed by the previous node). The previous alert details can be accessed through metadata. prvAlarmDetails. The return value should be the details object, which is the detailed information of the alarm;
581 +
582 +**Alarm type:** required field, customizable alarm type;
583 +
584 +**Explanation:** Non mandatory field, additional explanation;
585 +
586 +According to the running results, the exits of this rule node are Cleared, False, and Failure. Cleared alerts will be passed through the Cleared exit, and alerts that do not need to be cleared will be passed through the False exit.
587 +
588 +A simple usage example is as follows. In this example, it is defined that a high temperature alarm is triggered when the temperature is 28 degrees Celsius or above. The alarm content records the current temperature and the number of messages that continuously trigger the high temperature alarm; If the temperature reported by the device is below 29 degrees Celsius, clear the alarm.
589 +
590 +Create alarm rule node code:
591 +
592 +{{code language="none"}}
593 +var details = {temperature: msg.temperature, count: 1};
594 +if (metadata.prevAlarmDetails) {
595 + var prevDetails = JSON.parse(metadata.prevAlarmDetails);
596 + if(prevDetails.count) {
597 + details.count = prevDetails.count + 1;
598 + }
599 +}
600 +
601 +return details;
602 +
603 +{{/code}}
604 +
605 +Clear alarm rule node code:
606 +
607 +{{code language="none"}}
608 +var details = {};
609 +if (metadata.prevAlarmDetails) {
610 + details = JSON.parse(metadata.prevAlarmDetails);
611 + //remove prevAlarmDetails from metadata
612 + delete metadata.prevAlarmDetails;
613 + //now metadata is the same as it comes IN this rule node
614 +}
615 +
616 +
617 +return details;
618 +
619 +{{/code}}
620 +
621 +(% class="wikigeneratedid" %)
622 +Rule chain configuration:
623 +
624 +(% class="wikigeneratedid" %)
625 +[[image:1730969772885-609.png]]
626 +
482 482  === 6.4.3 delay ===
483 483  
629 +
630 +
631 +
632 +
633 +This rule node is used to delay the data flowing into the node for a certain period of time before sending it out to downstream nodes. Its configuration includes:
634 +
635 +**Name:** required field, indicating the name of the node;
636 +
637 +**Use period in seconds pattern:** optional, when checked, you can use the value of certain attributes in the message body or metadata as the delay time for the message, which is not checked by default;
638 +
639 +**Period in seconds:** required field, used to configure delay time;
640 +
641 +**Period in seconds pattern: **Required field, used to specify which attribute value to use as the delay time when 'Use period in seconds pattern' is checked. Use ${metadataKey} to retrieve the numerical values in the metadata, and use $[messageKey] to retrieve the numerical values in the message body;
642 +
643 +**Maximum pending messages:** Used to specify the length of the node queue. Data flowing into the node will be placed in a pending queue, and after a delay time, the data will be sent downstream and deleted from the queue;
644 +
645 +**Explanation: **Non mandatory field, additional explanation;
646 +
647 +According to the queue size, this rule node has two exits, Success and Failure. The data that is suspended in the queue and reaches the delay time will flow out from the Success exit, and the data that reaches the node after the queue is full will flow out from the Failure exit.
648 +
649 +A simple usage example is as follows:
650 +
651 +
652 +
653 +[[image:1730971057205-484.png]]
654 +
655 +
656 +
484 484  === 6.4.4 generator ===
485 485  
659 +
660 +
661 +
662 +
663 +This node is used to generate messages and is typically used for testing rule chains during development. Its configuration includes:
664 +
665 +Name: required field, indicating the name of the node;
666 +
667 +**Message count: **required field, configure the number of messages produced;
668 +
669 +**Period in seconds:** required field, configure the time interval for message sending;
670 +
671 +**Type: **Non mandatory field, can specify the initiating entity of the message;
672 +
673 +**Queue:** Non mandatory field, can specify the sending strategy of the message;
674 +
675 +**Function Generate: **The generated message content and format can be defined through encoding. The input parameters of the function include pre message body (previous message body), pre message metadata (previous message metadata), and pre message type (previous message type). The return value of the function should be in the format of {msg: msg, metadata: metadata, msgType: msgType}, where the values msg, metadata, and msgType are all objects;
676 +
677 +**Explanation:** Non mandatory field, additional explanation;
678 +
679 +According to the execution status, the rule node has two exits, Success and Failure.
680 +
681 +A simple usage example is as follows:
682 +
683 +
684 +
685 +[[image:1730971261632-402.png]]
686 +
687 +
688 +
486 486  === 6.4.5 log ===
487 487  
691 +
692 +
693 +
694 +
488 488  == 6.5 external ==
489 489  
490 490  === 6.5.1 kafka ===
1730968732576-495.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +195.7 KB
Content
1730969772885-609.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +222.2 KB
Content
1730971057205-484.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +199.7 KB
Content
1730971261632-402.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.hera
Size
... ... @@ -1,0 +1,1 @@
1 +188.7 KB
Content