Table of Contents |
---|
Date, Time,
...
Time Add and Subtract,
...
and
...
Time Conversion Blocks
These are the various date and time related blocks available in the Time group of the block library:
date:
grabsextracts just the date
partportion of a date time
point value- time: grabs the time part of a date time point value
- dayToNumber
value
dateTimeAdd: adds a duration (hrs, mins, or secs) to a dateTime
dateTimeSub: subtracts a duration (hrs, mins, or secs) from a dateTime
dateToNumber: converts the date into a number
- dayToString
dateToString: converts a part of date into a string
siteDateTime: get the current data dtToDtAdd: adds one dateTime to another dateTime; results in a duration of minutes or seconds
dtToDtSub: subtracts one dateTime from another dateTime; results in a duration of minutes or seconds
now: gets the current dateTime for the host
siteDateTime: gets the current date and time for the site associated with the target Ref of the bline program
These are the main blocks, but there are 2 other blocks that provide specific operations for the time:
- dateTimeAdd: add a duration from a dateTime. (minutes are the assumed unit)
- dateTimeSub: substract a duration from a dateTime (minutes are the assumed unit
time: extracts just the time portion of a date time value
timeToMinutes: converts a time value to a number of minutes
timeToTimeAdd: adds one time to another time; results in a duration of minutes
timeToTimeSub: subtracts one time from another time; results in a duration of minutes
Some blocks have inputs or results in dateTime format, while others in simple time format. Blocks that require a time format input might not work if a dateTime value is used as the input.
dateTime example: 2019-07-04 14:39:15:149 (date and time with milliseconds)
time example: 14:39:15 (just hours:minutes:seconds)
The Blocks can be found in the Block Library in the B-Line app, after creating a new programTime group.
Date
...
All the date & time blocks accept only one parameter, but some have an extra option hidden inside them. The user can reach that by clicking on the block.
How To Create Date/Time Block
(Click to enlarge)
Once you have created or opened a new or existing program, you will see a "+" button at the very top right of the B-Line app in the " - Routines - " section.
Click on this "+" button to get a drop down list of possible routines that can be created. Select "Alarm Routine" to create an alarm routine.
When an Alarm Routine is added, the Alarm Block will automatically be created in its own section below.
How to Use Alarm Block
Once you've made an Alarm Routine, and filled out the Alarm Block properties(Shown Above), a boolean point will automatically be created and placed in your available variables panel.
If your variable panel isn't opened, click on the "VARS" option found in the top main menu. (highlighted in blue in the picture below)
The name of the point will be taken from what is typed into the alarm block's "Alarm Name" slot
(Click to enlarge)
When that Boolean point's value is set to "On" or "True", an alarm will be thrown against everything that matches up with the tags that the bLine program was set to target.
When the Boolean is set to "Off" or "False" no alarm will be thrown until the point reads on/true again.
Example Alarm Setup
The above screenshot represents a very basic setup on how to use and apply the alarm block to get an alarm result.
So based off of the setup shown in the above screenshot, we have it set up so that if the value of the roomTemp point is ">=" (greater than or equal to) "85" for at least 5 Seconds , then the "overHeatedZone" alarm point gets set to "On" which will throw an alarm.
We also added an "else do.." block so that if the value is not greater than or equal to "85" for at least 1 minute, then the "overHeatedZone" alarm point will be set to off
Click on the link below to watch a video demonstration on how the above example was set up!
Date &Time(DayToNumber, DayToString, SiteDateTime) blocks
How to set up the Alarm email notification
The above screenshot represents a very basic setup on how to use and apply the email block to get an alarm result.
So based off of the setup shown in the above screenshot, we have it set up so that if the value of the EF point is "TRUE" , then the "alarm" point will be set to "On" which will throw an alarm and also an email will be send out with the set subject and message.
Warning |
---|
The EMAIL BLOCK needs to be used only in ON EVENT routines!!! Using the above set up for the email, the user will only receive a notification when the alarm is triggered and not constantly thru the hole alarm period. Also in order for this set up to work the user need to set the email settings before, and enable the 2 pod extensions in Settings App. |
and Time Blocks
These four blocks provide or extract a value of time or dateTime, depending on your usage and need.
date: extracts just the date portion of a date time value
time: extracts just the time portion of a date time value
now: gets the current date and time from the host PC where the program is running
siteDateTime: gets the current date and time for the site associated with the target Ref of the bline program
Time Add and Subtract Blocks
dateTimeAdd: adds a duration (days, hrs, mins, or secs) to a dateTime
dateTimeSub: subtracts a duration (days, hrs, mins, or secs) from a dateTime
dtToDtAdd: adds one dateTime to another dateTime; results in a duration of minutes or seconds. Note: This is not to be considered a traditional add function. Rather, the result is in fact an invert of a subtraction of the two inputs. Meaning, if the difference is 30 minutes, then the result is written as -30 min. So it is actually subtracting the two inputs and then inverting the math sign of the result.
dtToDtSub: subtracts one dateTime from another dateTime; results in a duration of minutes or seconds
timeToTimeAdd: adds one time to another time; results in a duration of minutes or seconds. Note: This is not to be considered a traditional add function. Rather, the result is in fact an invert of a subtraction of the two inputs. Meaning, if the difference is 30 minutes, then the result is written as -30 min. So it is actually subtracting the two inputs and then inverting the math sign of the result.
timeToTimeSub: subracts one time from another time; results in a duration of minutes or seconds
Time Conversion Blocks
dateToNumber: converts the date into a number. This block extracts a selected portion of the date and converts it to a number that represents that Year, Month, Day, etc.
As you can see in the example below, we show how to use the block to extract those three entities from the date. You could also get Hour, Minute, or Second if desired.
dateToString: converts a part of date into a string. This block extracts a selected portion of the date and converts it to the actual Month or Day of the week.
In the example below, we show how to use the block to extract those two entities from the date.
timeToMinutes: converts a time value to a number of minutes. In the example below, we have converted current time of 19:20 to 1160 minutes. Also, you will see that we took minutes and divided it by 60 to get the current hour of the day. That result is 19.33 hours, or 7:20pm (.33 hours is approximately 20 minutes).
Usage Examples
Parking Lot Lights
In the example below, we are using the time block to extract just current time from the now block. Then we are using time subtract blocks to determine if the current time is either 15 minutes before sunset (or less) or 15 minutes after sunrise (or less). If either of these conditions are true, then we set the Parking Lot Lights to on. In our example below, current time is 20:17 and sunset time is 20:29. Because the difference is less than 15 minutes, the lights are set on.
Another thing we could do with this application is to set the Sunrise, Sunset, and Current Time as Project variables (or global variables), so we wouldn't have to use the weather blocks in every program. We could also package up this lighting application as a Macro in order to use it elsewhere in this project, as well as export it for use in other projects.