Block Controller B

Q-SYS Control 101 Training : Block Controller

1 ) Introduction

8m 37s

3 ) Simple Communication

12m 49s

4 ) Feature License Activation

4m 12s

5 ) Block Controller

19m 7s

7 ) Flow Control

34m 20s

8 ) Control 101 Conclusion

1m 42s

Lesson Description

Block Controller B 9m 18s

Explore more sections of the Block Controller including control change, flow control, if statements, operators, boolean values, and converting blocks to Lua script.

Video Transcript

Block Controller B 9m 18s
0:08
Welcome back. Let’s dig a little deeper into the Block controller, and look at some of
0:12
the remaining types of blocks you have at your disposal.
0:15
Back inside the Block Controller edit screen, let’s look at another type of block. Look
0:19
under “Flow Control.” These blocks will only perform their action based on certain
0:25
parameters. It’s like a flow chart, where a decision point is made and a new path diverges
0:30
based on your answer. Let’s grab this one that says “if / do”. This block has a lot going on.
0:37
You’ll notice that it has a slot here at the top, which means it’s a command. It has
0:41
a slot here for a value or parameter, and it has an open mouth for what
0:46
we want it to do. It also has this cog icon, which we’ll talk about in just a bit. But for
0:52
now let’s integrate it with the rest of our program.
0:55
In the previous video we made a button that changes its label or Legend to “ON”
0:59
when it’s pressed. But in order to change that label to “OFF” when the button is
1:03
pressed again, we’re going to need the program to make an evaluation. If the state
1:08
of the button is ON, then we want the label to say on. If the state of the button is off,
1:14
then we want the label to say OFF. That’s flow control. So let’s undock our “set control”
1:20
block from the “control change” block, and add it to our “If” block instead. Now we can
1:27
drag the “If” block into the “control change block.” Essentially, when the button
1:31
is pressed, it’s only going to change the label if a certain requirement is met.
1:37
You can guess which part we need to complete now – if … what? We’ll need to add a
1:43
block here that equates to “if the control is on.” Next let’s look under the Operators
1:50
branch. Operators are things that, well, perform an operation. In this case, usually
1:56
mathematical operations such as basic arithmetic, or logical operations such as comparing
2:02
the equality of two different things. That’s what this Logic block does, that says
2:06
“blank equals blank.” This will work perfectly for us, so let’s snap this to our “If” block.
2:13
Now we see a new type of block connection. Rather than slots on the edge, this
2:18
block has holes. We’ve seen the type of block that fits in this hole before, with a triangular
2:24
tab on the side, right? These are values, or parameters. If we go back to our
2:29
“AMAZING” control branch, let’s grab this parameter: “AMAZING Boolean.” If you’re
2:34
not familiar with the word Boolean, it basically means a binary state, something that
2:38
only has two options, like our button. For our second hole, let’s look back in the Values
2:44
branch, and we’ll grab that “True/False” block. We can snap this into our Logic block’s second hole.
2:51
So let’s read our program so far – when the control changes, if the control’s state is
2:57
true, then we’ll change the label to “ON.” All that’s left is to define what happens
3:02
when the state is false. But where are we supposed to define this? There are no
3:06
more empty slots in this block! To fix this, we’ll have to use that cog icon we saw earlier.
3:12
Certain blocks like this one can have customizable configurations. This little window
3:17
that pops up is sort of a miniature version of the Block controller interface. On
3:22
the right is our block, and on the left is the library of possible things we can add to
3:27
that block – just like the main interface. Let’s drag a new option into our block – the
3:32
“Else” option. When we add the “Else” in this configuration window, we can see that
3:37
the block itself has changed in the main window. We now have a new area to add a second command.
3:43
Let’s close the configuration window by clicking the cog icon again. We need another
3:48
“set Legend” block for this new section, but we can simply copy and paste our first
3:52
one. Most Windows shortcut keys work in the Block Controller editor. I will Control+C
3:58
to copy and Control+V to paste, and add this as our “Else” command. All that’s
4:03
left is for me to change the Legend string from ON to OFF.
4:08
So let’s read our script one final time. When the control changes, if the control’s
4:13
state is true, we’ll change the label to “ON.” Otherwise, we’ll change the label to
4:18
“OFF.” Looks good! There are a few final things I want to show you before we’re
4:22
done. First, we have to press this yellow “Save changes” bar at the top in order for
4:27
this code to become active. This allows you to work on your program on a live system
4:32
without disrupting anything. Until you press “Save Changes” the old code is still running.
4:37
Once I press this, we can return to the Designer schematic to look at our button, and
4:42
make sure it works. When I turn the button off, the label says OFF. When I turn it on,
4:47
the label says ON. Excellent!
4:51
Okay, you’re right. It took us ten minutes to get a button to change labels, it’s not
4:55
that impressive. YET. We just did this as a tutorial on how the blocks connect to each
5:00
other. In reality, you’re going to do far more complicated things with the Block controller.
5:05
For instance – one important thing you should know is that you can stack commands
5:08
on top of each other. These blocks may look rigid, but they’ll adapt their size to whatever you need.
5:14
Let’s say I wanted to change the color of this button as well. I could add a “Set Color”
5:19
command into this block, and the block will adjust to accommodate it. You can add
5:24
as many commands as you want this way – which means that when the button is
5:27
pressed it can change its label and change its color, and reset another control, and
5:33
start a timer, and activate a third-party lighting device, and change the layer that’s
5:38
visible on the UCI, and launch the pyrotechnics, etc., all at the same time. Now we’ve
5:44
got a button that’s doing a lot more than changing its label. That’s the point. That’s
5:52
where we’re headed. But for now, I’m going to keep mine simple, and add commands
5:57
that simply make the button green when the button is on, and red when the button is off.
6:04
Once again I can save my changes, and then back in the Schematic I’ve
6:09
got a button that changes its color and its label as you interact with it.
6:14
Another very important thing in the Block Controller – if you right click on a block,
6:19
there are a couple of options for you. You could select “Show Comment” which gives
6:23
you a comment section at the top of the block. This lets you type in whatever you
6:27
like, which has absolutely no effect on the functionality of the block. So if you want
6:32
to remind yourself what this block does, you can give it a title. You could also choose
6:38
“Collapse Block” which will truncate the block down to a single visual line, without
6:43
changing the code. This can be very convenient if you have a lot of blocks in your
6:47
program and need to focus on one at a time. The jagged scale line indicates that
6:53
there is more to see, and you can always Expand the block again to reconfigure it.
6:58
Alright, one final thing. I saved the best for last! We mentioned earlier that the Block
7:02
controller is a great bridge between people who don’t write code – like me – and the
7:07
ability to accomplish things that require scripting. Well these visual blocks are literally
7:12
writing the code for you, and you can read that code by navigating to the “Lua” tab.
7:18
This is the Lua script of what we’ve done so far. This stuff at the top is just housekeeping,
7:23
while the block we built is represented down here. You can even kind of read it,
7:29
now that you understand how the language is structured. If you knew how to
7:32
write script before this, you could have written all this out rather than use the Block
7:36
Controller at all. But if you typed anything wrong, if you missed a capital letter, or if
7:42
you weren’t exactly sure how to format it, then the script wouldn’t work. The Block
7:46
Controller takes all that worry away by letting you build your program with easy to
7:50
manage puzzle pieces, and the code is written in the background – free of any syntax errors.
7:57
If you’re interested in learning scripting, reading this Lua tab might help you on your
8:00
way. In fact, if you want to further edit this script yourself now, you could select this
8:06
icon at the top and choose “Convert to Script.” However, a warning will pop up now,
8:12
and with good reason. You can convert blocks to script, which allows you to continue
8:18
editing in Lua, but you cannot convert those edits back into blocks. Once you select
8:24
OK, the interface changes to an editable text scripting screen. You do have the option
8:30
to “Revert to Blocks” but doing so will revert it back to its original blocks, so you
8:36
would lose any changes you made in Lua.
8:39
So, that’s the Block Controller component. We obviously only skimmed the surface
8:44
of what it can do, and what each of the different blocks in each category are. Mostly
8:49
we wanted to show you how the blocks connect to each other, demonstrate how
8:53
some are customizable, and hope you feel comfortable navigating the edit window
8:57
now that you know what options are available to you. In upcoming videos, we’ll go a
9:02
little slower and talk about the concepts of a programming language, and see how
9:06
each idea is implemented both in Lua and in the Block Controller. Thanks for watching.