Since you said you are trying to learn, I thought I would point out a few things.
- I would try to get in the habit of reading all or as many tags as you need once at the beginning of the script and then writing all or as many as possible at the end of the script.
- Avoid unnecessary nesting and branches
- Treat boolean values like booleans
- Know what functions have been deprecated. While legacy functions may be supported there is a reason they have been deprecated. Also, support for those functions may be removed in future versions and then your code will break.
So, I assume you are using some version of 8.0 since you tagged this with perspective. If that is the case then you should replace system.tag.read and write with the appropriate functions, readBlocking, readAsync, writeBlocking, writeAsync. The legacy functions read and write are supported for backwards compatibility but they should not be used, particularly in new scripts.
The new functions accept a list of Tag Paths and will facilitate reading multiple tags at once. This is far more efficient than calling the functions multiple times.
The new write functions also accept a list of values. If you are writing multiple times then the index of the tag path should match the index of the intended value.
Taking all of that into consideration your script could look something like this:
tagPaths = ['[default]CM_Merker/cas_prostoj','[default]CM21/Machine/Data/ModeAutomat','[default]CM21/Machine/Data/DoorClose','[default]CM21/Machine/Data/StartTl','[default]CM21/Machine/Data/ModeHeating']
tagValues = system.tag.readBlocking(tagPaths)
#the values returned will be in a list with the same index as the associated tag path.
#remember that the read functions return Qualified Values
time = tagValues.value
autmat = tagValues.value
door = tagValues.value
buttStart = tagValues.value
heating = tagValues.value
#you do not define value anywhere in the provided script so technically it will never be 1
#unless you intend to take a different action based on value, there is no need for a nested if statement
if not door and automat and value:
time += 1
#no need to nest an if statement here, just use and elif (else if) instead
time = 0
One last thing, when trying to figure out how to best use these functions the manual is your friend.
Hope this helps!