23 - 05 - 2019

Text Formatting Conception

Text Formatting Conception:

Most of the blocks are designed to be universal and inputs with different types of signals can be added to them. Sometimes we need to format text with the values of the inputs. For example, if we are monitoring one temperature sensor and two PIR sensors (infrared sensors) and if there is an event as opened door, the diagram have to send an e-mail with values of the temperature and PIR sensors. We have to add a MailSender block to the diagram with three inputs:


- PIR1 (digital value);

- PIR2 (digital value);

- Temp (analog value);

The BODY of the sending e-mail can be:

Current temperature is 23.5 [C]
The bedroom door is: Closed
The living room door is: Open

This can be achieved by adding formatting tags to the text, which will change the contents of tags to the value of the inputs. For example:

Current temperature is <Temp;2> [C]
The bedroom door is: <PIR1;Open;Closed>
The living room door is: <PIR2;Open;Closed>

When the time comes to send an email, the following will happen:
- Tag <Temp;2> will be replaced with value of input Temp with two digits after the decimal separator;
- If the PIR1 or PIR2 inputs are at high level, their tag will be replaced with the Open string, if they are at a low level, they will be replaced with the Closed String;

Formats:
The formats for the different input types are described below. The basic rules are:
- tags always start with < and end with >
- the first parameter in the tag is always the name of the input, the parameters after the name are separated by ;
- all the parameters after the InputName are not required;

1. Digital values:
<InputName;OnValue;OffValue;WholeStringLen;LeftFillChar;RightFillChar>
- InputName - name of the input;
- OnValue - the value of the TAG if the input is in high level. If this parameter is not added, the TAG will be replaced with the default value On
- OffValue - the value of the TAG if the input is in low level. If this parameter is not added, the TAG will be replaced with the default value Off
- WholeStringLen - if this parameter is entered, the tag will be replaced by a string with the specified length;
- LeftFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added LeftFillChar on the left side, until the length WholeStringLen is reached;
- RightFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added RightFillChar on the right side, until the length WholeStringLen is reached;

2. Analog values:
<InputName;DigitsAfterDecimalSeparator;DecimalSeparator;WholeStringLen;LeftFillChar;RightFillChar>
- InputName - name of the input;
- DigitsAfterDecimalSeparator - digits after the decimal separator. Default value is 2;
- DecimalSeparator - this parameter can be only one character and is the decimal separator. The default value is a dot: .
- WholeStringLen - if this parameter is entered, the tag will be replaced by a string with the specified length;
- LeftFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added LeftFillChar on the left side, until the length WholeStringLen is reached;
- RightFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added RightFillChar on the right side, until the length WholeStringLen is reached;

3. Integer values:
<InputName;FormatType;WholeStringLen;LeftFillChar;RightFillChar>
- InputName - name of the input;
- FormatType, this parameter can be 0 - Decimal, 1 - Binary, 2 - Hex. It specifies whether the value of the input should be converted to decimal, binary or HEX string. Default value of the parameter is 0;
- WholeStringLen - if this parameter is entered, the tag will be replaced by a string with the specified length;
- LeftFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added LeftFillChar on the left side, until the length WholeStringLen is reached;
- RightFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added RightFillChar on the right side, until the length WholeStringLen is reached;

4. String values:
<InputName;WholeStringLen;LeftFillChar;RightFillChar>
- InputName - name of the input;
- WholeStringLen - if this parameter is entered, the tag will be replaced by a string with the specified length;
- LeftFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added LeftFillChar on the left side, until the length WholeStringLen is reached;
- RightFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added RightFillChar on the right side, until the length WholeStringLen is reached;

5. DateTime values:
<InputName;DateTimeFormat;WholeStringLen;LeftFillChar;RightFillChar>
- InputName - name of the input;
- DateTimeFormat - this ia a format of the DataTime input value and is described below, by default is: dd.MM.yyyy
- WholeStringLen - if this parameter is entered, the tag will be replaced by a string with the specified length;
- LeftFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added LeftFillChar on the left side, until the length WholeStringLen is reached;
- RightFillChar - only one character can be entered for this parameter. The TAG will be replaced with a string with added RightFillChar on the right side, until the length WholeStringLen is reached;

 

All the possible elements of the DateTimeFormat parameter are:

d - One-digit or two-digit day
dd - Two-digit day
ddd - Three-character day of the week abbreviation (for example, Mon or Tue)
dddd - Full day of the week name (for example, Monday or Tuesday)
h - One-digit or two-digit hour in 12-hour format
hh - Two-digit hour in 12-hour format
H - One-digit or two-digit hour in 24-hour format
HH - Two-digit hour in 24-hour format
m - One-digit or two-digit minute
mm - Two-digit minute
M - One-digit or two-digit month
MM - Two-digit month
MMM - Three-character month abbreviation (for example, Jan or Feb)
MMMM - Full month name (for example, January or February)
s - One-digit or two-digit second
ss - Two-digit second
y - One-digit year
yy - Two-digit year
yyyy Four-digit year

Examples for DateTimeFormat if the DateTime value is 27 July 2018 18:24:35
- dd.MM.yyyy will be replaced with 27.07.2018
- dd MMM yyyy hh:mm:ss will be replaced with 27 Jul 2018 18:24:35