I tried using the search feature but it either doesn’t seem to work well at all, or I’m trying to do something that no one has asked. I feel like I’m missing something.
Question 1) I have a screen for changing the auto start up and auto shut down times for a machine. I’d like the user to change all the necessary fields and then hit a save button. After clicking that button, then and only then will the values from all those fields actually be written to the PLC. I don’t want one to be written, then the next, then the next, as they’re filling out the screen. I want them all written at the same time.
Question 2) When the user makes those changes, I want to log his/her username, along with all the values from the fields on the screen, to a table on the SQL server so we have a history of the changes made and who made them.
The simplest way I’ve found to do this sort of pending save is to use a extra (custom) property for the actual tag binding (bidirectional) and a one-way binding on the editable field’s normal value property to that custom property. Then your edits stay in the form, but the form still populates from the PLC’s current values.
In the actionPerformed script on your save button, you iterate through the form’s components, assigning the current field value back to the custom property. As for the logging, I would turn on tag history for the values, and have just the operator/workstation identification inserted to a log table. (Again in the actionPerformed script.)
Some notes for this design pattern:
[ul][li]When open on multiple clients, changes saved by one user will show up in all of the other clients[/li]
[li]In a propertyChange event script for the editable property, you can check if the new value is different from the custom property. When different, it must be a human entry. Use this to enable the “Save” button, so it is obvious that changes have been made to the form.[/li]
[li]Bind the background color of the field to highlight it when the editable property differs from the custom property[/li][/ul]