This lesson is part of the Sequential Function Charts in Ignition course. You can browse the rest of the lessons below.


Autoplay Off


Learn how to design a chart that can interact with an operator at a client terminal and vice versa. You can use the system.sfc.StartChart function to start the SFC, and use Message Handlers to pass information back and forth.

Video recorded using: Ignition 7.8


(open in window)

[00:00] In this lesson, we're going to learn an important technique that allows sequential function charts to interact with vision clients. Now why would you need to do this? Imagine you have a chart that is controlling some process, and so an operator starts the process from a client and then sometime later, the chart needs to maybe confirm and have the operator confirm that something is in the correct position, or instruct the operator to manually add an ingredient. There's a number of reasons why a sequential function chart might need to communicate with the user interface. And of course, sequential function charts always run on the gateway. So it's not like they can just directly open up a vision window to do notifications or something like that. So we're going to learn how to achieve this using a combination of techniques. I've already got this all set up in this project and there's a number of parts that have to work together. So I'm going to walk you through them all, and then we'll see it in action. So let's start with our chart. So we have this chart called feedback. And the chart expects that a client ID is sent into it, that's going to be the ID of the client that this chart tries to communicate back with. If the chart starts and the client ID isn't there, we log an error message to the system console. Otherwise, we have a short two second delay. And then we send a message down to the client. And this is done using system.util.sendamessage, which invokes a message handler on the client. So we specify the name of the project, in this case, I'm in a project called ignition, the message handler name, feedback prompt, the ID of the client session to invoke the message handler on which is the parameter that was passed to this chart. And a payload, which is whatever message I'm trying to send, in this case, we're just sending the ID of the chart. So the chart is invoked with the ID of the client, and then it sends a message to that client with the ID of the chart. And then it waits for a chart scope variable name choice to become either A or B, at which point it just lights up these steps that do nothing for two seconds a piece. Okay, so, we have a window that simply starts the chart and feeds it, the client ID of this client. And then configures SFC monitor panel to show us the chart so that we can watch it run. We have a pop up window that gets the chart ID passed into it as a root container parameter and then has two buttons, each of which call system.sfc.setvariable so that sets a variable on a specific chart instance where we know the chart instance because we're past the chart instance ID. So in this case, we're setting the variable name choice to A. And this one set choice to B, and the piece that holds this whole thing together, is under client event scripts, the message handlers. So when the chart reaches that prompts step, and calls system.util.sendmessage. This is what it's invoking. It's invoking this client message handler named feedback prompt, which receives the payload which was a dictionary of parameters that just had the chart ID in it. And this message handlers simply opens the feedback pop up and passes the instance of the chart that it received from the message payload to the feedback pop up window. So let's go ahead and launch a plan. And we can see this in action. So we'll go ahead and start up our chart. And we didn't air out because we are successfully sent it our client ID, and now we're stuck here at the prompt step. So the prompts step executed, it invoked our client message handler, which opened our feedback window. And now it's awaiting. It's waiting for the choice to become either A or B, so we're going to go ahead and choose B. And you can see that B was chosen. And there was a new variable in chart scope called choice whose value is B, and if we do start this all over again you can see if you choose A, the A path will be followed. So that is how you can connect charts and client instances together so that you can interact with a client and send messages to operators or receive feedback from them.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.