NetTalk Central

Author Topic: Action on host value change  (Read 8098 times)

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Action on host value change
« on: July 07, 2020, 01:58:34 AM »
Nettalk 11.
I have form in where I watching host values.
The fields to show host values is already on the form. On changes in host values, how and where to put the code to do some another codes?
For example:
If p_web.GHV('Pressure1') > 150 and p_web.GHV('HeartBeat') > 100
 AlarmIt() ! calling another procedure
end
In theory this will work, but where in form to put that code?
Regards...

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Action on host value change
« Reply #1 on: July 07, 2020, 07:59:26 PM »
In WebServer procedure
SetHostValue method.

Bear in mind that you have no connection to any client, and hence no p_web, at this point.

cheers
Bruce

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #2 on: July 07, 2020, 11:19:19 PM »
Hm, understood.
Let me ask another question.
In web form, there is no timer event, from where I can send request to server side to check some values...
Or it is?

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Action on host value change
« Reply #3 on: July 08, 2020, 03:29:23 AM »
look the example web84 and Performance Form

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #4 on: July 08, 2020, 04:02:00 AM »
Thanks for answer.
But hehehe . I do already did that, my question is, when server "push" new value via websocket-host value, in the form where I am watching host value, how to start some new action, in my example AlarmIt procedure?
Regards,

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Action on host value change
« Reply #5 on: July 08, 2020, 04:28:34 AM »
So you're asking about how to write a JavaScript function that runs in the browser, see's the new value, and takes some sort of action other than just displaying the value?

How are your JavaScript skills?

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #6 on: July 08, 2020, 04:30:48 AM »
Hi Bruce,
my java skills is almost, be honest, none  :)


oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #7 on: July 08, 2020, 05:16:44 AM »
I must explain what I am going for.
On site 1, local hospital/ambulance, some medical instruments sends data to web server/SQL database. This is working part. I use Nettalk and simpleserver to get data from that instruments. So far, so good.
This is working without problems for almost a year now. Now, the users want to watch, see, actual data and on some condition to automatically do another task, for example, create PDF file, but on the client side, far from site 1.
There is 7 users, for now, that will be using that new function. Every user will log onto web site, already done with Nettalk, and after logging, if some new data is on site 1/ server side, I need to "push" that data to lets say channel-hosts and after receiving on remote sites, to create PDF document.... With hosts value I got it on remote sites, I can display that new data, but the part I do not know how to do it, is how to start AlarmIt procedure, where I will create PDF documents, and do some other tasks, when hosts values changes...

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Action on host value change
« Reply #8 on: July 09, 2020, 02:17:03 AM »
>>  Now, the users want to watch, see, actual data and on some condition to automatically do another task, for example, create PDF file, but on the client side, far from site 1.

You're gonna create PDF's _inside_ the browser? Not on the server?

>>  how to start AlarmIt procedure, where I will create PDF documents, and do some other tasks, when hosts values changes...

So AlarmIt is a JavaScript function?

>> My java skills is almost, be honest, none

Well first, the language is JavaScript and not Java. Second, you are hoping I can teach you enough JavaScript to do, um, creation of PDF files in the browser and "some other tasks"?

I feel like your goals here are pretty vague, and possibly outside your skill set?

cheers
Bruce



oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #9 on: July 09, 2020, 03:04:47 AM »
Ok, this new procedure alarmit, is on work now. I just say it will be used for example, PDF. Maybe it will be to send some email... For now, its only in development...
my main issue is how, if possible, and when, I can "read" host value and if the value is changed, or created, to start some code...

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #10 on: July 09, 2020, 03:39:11 AM »
I do not want to teach me how to "create pdf", i need some advise, if is possible or not...
In form I watching host values, for now I add group with couple of fields:
Watched         GROUP,PRE(ww)
heartbeat         STRING(255)
Pressure_1        STRING(255)
Pressure_2        STRING(255)
O_level           STRING(255)
N_level           STRING(255)
X_level_a         STRING(255)
X_level_b         STRING(255)
Y_level_a         STRING(255)
Y_level_b         STRING(255)
                END

In form, in generateform, after <form> embed:

p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:heartbeat') , 'ww:heartbeat')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:Pressure_1') , 'ww:Pressure_1')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:Pressure_2') , 'ww:Pressure_2')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:O_level') , 'ww:O_level')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:N_level') , 'ww:N_level')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:X_level_a') , 'ww:X_level_a')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:X_level_b') , 'ww:X_level_b')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:Y_level_a') , 'ww:Y_level_a')
p_web.ntWatch(loc:formname,'hostvalue', '#' & p_web.nocolon('ww:Y_level_b') , 'ww:Y_level_b')

Those host values is already populated on the form, all works well.
Now, when on server side, the value Heartbeat is changed, or any other values, I "pushed" it to all clients:

 s_Web.SHV('ww:heartbeat',Heartbeat,0)
 s_Web.SHV('ww:Pressure_1',Pressure_1,0)
 s_Web.SHV('ww:Pressure_2',Pressure_2,0).... and so on...
ok, the clients see the new values...

And now, when client(s) got the changed values... I need to start AlarmIt() procedure, for example, or simply on site do:
 loc:alert = 'The value of ....'&p_web.ghv('ww:heartbeat')&', is changed...!'
do SendMessage
This is the part I cannot accomplish, I need to "trap" host value changes...

« Last Edit: July 09, 2020, 03:47:47 AM by oggy »

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: Action on host value change
« Reply #11 on: July 09, 2020, 04:48:36 AM »
Adding code to the Clien-side of the Host Value does not work?
-----------
Regards
Alberto

oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #12 on: July 09, 2020, 04:53:21 AM »
I do not know, because I do not know where to put on client side.. .I try to put in every embed in the form, in all the host value embed, and everywhere, but no gain for now.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Action on host value change
« Reply #13 on: July 09, 2020, 07:37:43 PM »
Hi Oggy,

>> And now, when client(s) got the changed values...

the clients get the changed value via the WebSocket connection. there is no "page connection" to the browser.
If you want the browser to notice that the value changed then you would write a function, in JavaScript, and attach it to an event on the client side. From your description it sounds to me like that function would make a request to the server to tell the server to do something, and get a response.

I think key to you making this all work the way you want is to very clearly understand the exact flow of the data, and the request/response nature of the browser.

>> I need to start AlarmIt() procedure,

So, I'm interpreting this to mean that AlarmIt is a Clarion procedure in the Server app?
Not a JavaScript procedure written in JavaScript?

>> for example, or simply on site do:
 loc:alert = 'The value of ....'&p_web.ghv('ww:heartbeat')&', is changed...!'
do SendMessage

This looks like Clarion code, and so this is why I think you're making this a server-side procedure?

>> This is the part I cannot accomplish, I need to "trap" host value changes...

So yes, you need to trap the host value change - but I think you are thinking like this;

a) host value changes on server
b) execute some code on server
c) "send" something to browser to update the page. or send a PDF, or whatever.

Fundamentally this is wrong because servers do not "send" anything to browsers. Browsers _request_ something, which the server then provides.

So your question (I think) then becomes "when a host value changes on the client side, how do I execute some javascript code in the browser, which then requests something else from the server".

Do we agree on this?

cheers
Bruce



oggy

  • Full Member
  • ***
  • Posts: 219
    • View Profile
    • Email
Re: Action on host value change
« Reply #14 on: July 09, 2020, 11:14:58 PM »
Of course, we are on the same spot now ;)
I started to learn javascript some time ago, but because of lack of time, and undergoing projects, still on the "page one"...