Read, write Tag values

Hello all,

I have this view:

I would like to tap/click on one of the labels on the left (which are bound to individual tags), display that value, the chosen label value in the 'CZ' label, and another value from the tag.

The value displayed on the left would populate the top two labels (currently showing 0.0), and the lower labels would display an additional value retrieved from said tag.

The plus/minus buttons would increase the lower value and write to the PLC, while the upper value is a result of that change.

The columns on the left are three separate embedded views.

So far, I have been able to pass a hard coded value to from the embedded view to the display label using a message handler, but I'm not sure if I can pass a Tag path this way or if I should. Somehow it's going to have a write feature so a bi-directional tag?

Or, would sending those values via params work better? Read and write?


I don't understand your logic, but it's possible to pass parameters to components to achieve indirect writable bindings, or use scripts to read parameters and write tags.

This is not clear.
Let's take CZ09. There's a value on its left, 79.6, and another one on the right, 80.2.
What do you want to display where ? What's "another value from the tag" ?

What additional value ? How do you retrieve it ? How is it different than the tag's value ?

I don't get this either. If modifying the value in the bottom label writes that value to the PLC, what is that result you want to display in the top label ? What's the difference between the two ?

To wrap up: when asking for help, make the problem as simple as possible, give examples, and name things in a manner that can be easily understood. As it is, I have no idea what you're asking for.

I hear ya. I wasn't the best description.

I click on CZ09, the values in the list, left and right side, will be 'mirrored' in the Con and Bay boxes. I tried to indicate that as val. 1.

Value 2 (val.2) is the voltage value from the tag, which will be displayed as well.

The plus/minus buttons will adjust val. 2, which, when written back to the PLC, will affect a change in val. 1.

I began tinkering with indirect bindings yesterday, but I am not sure how to send data via an On Click event from the components displayed on the left side of the screen.

In the past I have sent data to a popup (not a tag, just a value from a table). Here, I would need to send the CZ number, for example CZ01, CZ02, etc.

Then, send a write request back if any changes are made.

This is the tag binding for the value 1 Con box.

Hope this makes more sense!

To clarify, the question is:

How do I change the view param when I click on one of the CZ boxes on the left?

The tree would look like this:

  1. Main view
    a. embedded view
    1. CZ01 label in the embedded view - click here to get data
      b. flex container
    2. flex container
      a. flex container
      1. Value 1 display label - display selected CZ data, via view param.
        2. Value 2 display label - display selected CZ data, via view param.

so, from CZ01 label, in the embedded view: returns "view", actual name is "tm_right".
self.view does not seem to reference the actual view that it resides in or the main view for the whole screen.

self.parent.anything errors out
self.view does not seem to yield anything useful
self.parent.parent.anything does not seem to work.

if your params is on Main view, you need to pass it to embedded view. self.view means the designer page(the embedded one), not web/vision page.

Bottom line:

Since I am (was) working with an embedded view, most likely the only option would be to pass that data via a session prop, aka something in the URL, and from there into the View's parameters... Yet to be tested.

So, I have decided against using the embedded views in this case, thereby allowing the components to be able to "see" each other in the script configuration screen via the props drop down button.

Much simpler, for now at least.

Thanks for all input folks!

In the View you're embedding, presumably this:

You would have View params, one for a tag path. This tag path would be the path to your base tag, e.g. [default]Coater Process/Transmission Monitors/CZ01_TM1

Then inside your View, you would use that tag path param to indirectly bind to your tags. e.g. {1}/Percentage
where {1} is bound to {view.params.tagPath}

Then, when you click on your buttons, just update the tagPath param that you're passing to your embedded View. If the buttons themselves are within their own independent Views and are embedded, then you can use any of:

  • system.perspective.sendMessage to send a message to the page, and then you can listen for your message on the main View and handle it by writing to the Embedded View's tagPath prop
  • use a session custom prop to store the tagPath to show, then write to this from your buttons, and bind this to your EV tagPath param. This would allow the tagPath to be maintained for the session e.g. across page changes
1 Like

You can use output parameters. There's a little arrow next to each params, click them and they'll turn around, indicating the parameter is now an output instead of input. Click again and they'll be bi-directional.
In this case, you want an output.
Here's an analogy: If your view was a function, input parameters would be the functions parameters, and the output parameter would be the return value.
When you're outputting something from a view, you can easily use it from another component on the same scope.

If these are all individual components, you can make a custom view property and use an on-click event on the CZ label to change the property accordingly. Then, use this property in an indirect bi-directional binding as needed for the other components.

If these are embedded views you can add parameters to the view "template." The parameter can then be used in your indirect bi-directional bindings.

You can also right-click and use the Parameter Direction dropdown to explicitly select which one you want.

Actually, the embedded views are the three vertical 'lists' on the left of the pic.

Regarding messages: I've read that can take up valuable resources, is slower, and can (potentially) overload. Something about the number of threads.

Regarding session props, that's kinda where I thought I would have to go if passing data to/from an embedded view.

That is where I was struggling. Apparently, coming from an embedded view, the main view is not visible. That is why I was thinking session props would work.

Passing data to/from an embedded view is as simple as using the input/output parameters of the view. Let's assume you want to use an embedded view because of your concerns about how messaging would effect performance on your gateway.

In this example above, I adapted a confirmation dialog to work as both a popup and an embedded view.

Parameters to the view:

The payload_id and popup inputs would not have to be included if you don't intend to use the view as a popup. Also, note that output is in/out.

Yes button script:

def runAction(self, event):
	if self.view.params.popup:
		system.perspective.sendMessage("Confirm", payload = {"payloadID":self.view.params.payload_id, "confirm":True})
		self.view.params.output = True

No button script:

def runAction(self, event):
	if self.view.params.popup:
		system.perspective.sendMessage("Confirm", payload = {"payloadID":self.view.params.payload_id, "confirm":False})
		self.view.params.output = False

Other bindings are pretty self-explanatory.

Now you can add the view as an embedded view to your tank barcode view. (make sure you un-check the popup input if you're using it).

On your submit button, just set the Confirm embedded view's output to null:

def runAction(self, event):
	self.getSibling("Confirm").props.params.output = None

Clicking yes/no on the embedded view will update the output value accordingly.

Bind the embedded view's visible property to the output property:


Add a change script to the output property to do your action when the output is true:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	if currentValue:
		#do stuff

With this setup you end up with this functionality:

When the Submit button is pressed, the Confirm embedded view output property is set to null (None), which triggers the visibility of the embedded view via the binding on the visible meta property. Once visible, the embedded view is able to write to it’s output property when yes or no is pressed. Any time the output property changes value, the value change script runs to determine if action needs to be taken.


I got to this point, but the output value does not change with Confirm/Cancel.

Embedded view, manually set output to true

Label to the right is linked to the output param

clicking Submit sets output param to null

def runAction(self, event):
	if self.view.params.popup:
		system.perspective.sendMessage("Confirm", payload = {"payloadID":self.view.params.payload_id, "confirm":True})
		self.view.params.output = True

but this does not change the output param to true.

If I preview the Confirm View not as embedded, then the output parameter changes.


This does not make the embedded view hidden.

What I did not know, was that the embedded view's parameters are available in the props.params section!
I like that!

Then I suppose this means that this.props.params.output is not null.

Do you have a script on the submit button to set the output to null?

The output parameter needs to be InputOutput, otherwise you won't be able to write to it from the outside

Submit button:

self.getSibling("EmbeddedView").props.params.output = None

If I change "EmbeddedView" to "confirm_test" (which is the name of the view), I get an error:

AttributeError: 'NoneType' object has no attribute 'props'

That's because you changed the name of the embedded view, which is used in your script.

self.getSibling("confirm_test").props.params.output = None