Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-07-14 19:33:13

martijnperdaan
Member
Registered: 2016-06-24
Posts: 20

Database

i want to read a value from a database into a input field on the HMI  that works but de value that i read i want to change in the input field en write te nieuw value into the database hoe doe i do that ?

Offline

#2 2016-07-14 21:20:17

scoobsalamander
Member
From: Belgium - Hulshout
Registered: 2015-10-27
Posts: 217

Re: Database

Maybe you could use an input field and use a separate 'SET'-button to write this value to your database by using an additional auxiliary signals __Trigger (page 10 of DbDrv_ENG.pdf).

Offline

#3 2016-07-14 21:53:25

scoobsalamander
Member
From: Belgium - Hulshout
Registered: 2015-10-27
Posts: 217

Re: Database

I have no idea how to use this __Trigger but I guess it is something like this :

2016-07-14-22_49_22-REX.png

I can not test it myself at the moment so....

Offline

#4 2016-07-15 09:56:28

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Database

Hey martijnperdaan,

I think that this can be done only with some additional priorities. You would like to read a value from DB to Rex - that is possible. But you would also like to change the value according to HMI input and write it to the DB. These two requirements goes against each other.
You will probably have to add some additional logic which will determine if the value should be overwritten in DB or in HMI input.

Can you describe your application more into the deep so we can think of some other possible solution?

Regards, Tomas

Offline

#5 2016-07-15 11:33:35

martijnperdaan
Member
Registered: 2016-06-24
Posts: 20

Re: Database

On the HMI there is a input fields that show de streeftemp (target temp) of the room but i somtimes want to change te target temp in the input field

ds.jpgrex.jpg

Offline

#6 2016-07-15 12:03:52

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Database

Is there any reason for reading the target temperature from DB? (i.e. temperature is changing in DB from some other source, application, program, etc.?) Or do you want just to store the trend of target temperature values to DB?

Cheers, Tomas

Offline

#7 2016-07-15 13:19:19

martijnperdaan
Member
Registered: 2016-06-24
Posts: 20

Re: Database

i want to store it in a database because if there is some kind of blackout it starts up again read the database and it works again otherwise
i have to put the value in the input field again

ps sorry for my bad english

Offline

#8 2016-07-18 18:31:23

martijnperdaan
Member
Registered: 2016-06-24
Posts: 20

Re: Database

anyone ?

Offline

#9 2016-07-19 12:24:23

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Database

I see your point - you want to use it as some kind of persistent memory, right?

This can be done using database, but you need to be careful about handling with read / write commands from / to database as I already mentioned. Following picture shows how it can be done in REX. It uses triggered writing to database on signal change (change from HMI input) by auxiliary flag. You will need to reconfigure your HMI according to the picture - read target temperature from DB flag and write it to constant CNR_StreefTemp.
You also need to change your .rio configuration file to read and write to the same item in certain database table.
There is one drawback I'm able to think of now - the value in HMI will remain for a while unchanged after you edit it manually because it takes some time to process the value to and from database. This can be a bit confusing.

db_rw_2.png

Please, take it as a hint. It's not a working solution since I don't have any hardware available to test it on by now hmm

There are more options to satisfy your requirements - please see SILO Reading value from file example or REXLANG Reading value from file example.

Hope it will be useful for you.

Regards, Tomas

Offline

#10 2016-07-19 15:33:05

martijnperdaan
Member
Registered: 2016-06-24
Posts: 20

Re: Database

Is it maybe possible to execute a php schript from a rex function Blok ?

Offline

#11 2016-07-19 21:53:52

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Database

It is possible to call external scripts or commands - for more details see EPC Email notification example.

Note that in order to use EPC function block you need to have Advanced blocks installed on your target device and licenced.

Cheers, Tomas

Offline

#12 2016-07-28 10:19:37

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Database

I prepared a solution of this problem without the delay of value change in your HMI. Please, download the sample project.

In order to make it work you need to change HMI connection strings of the temperature to both read and write from / to "CNR_StreefTemp". If you will change the value manually (in HMI or directly in "CNR_StreefTemp") the value will be written to the database as well. If the database writing fails for some reason it will change the value of "CNR_StreefTemp" back to that one stored in the database. This means that after blackout is should automatically read the value from database and set it to "CNR_StreefTemp" as well.

Feel free to contact me if you will have any questions regarding this solution.

Cheers, Tomas

Offline

Board footer

Powered by FluxBB