Can we access a setpoint value for display in a widget

Using the HMI Builder and creating custom interfaces for the BCS.
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

Baron Ken wrote:
clearwaterbrewer wrote:...

any hints?
To display the setpoint for output0 for process 0/state0, you can do something like this in the drawExtWidget appropriate section:

ctx.fillText(ulstates[4]/10 + "°F",widgetObj.xcoord,widgetObj.ycoord+25);
where do i change it to use P1 S2?
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Can we access a setpoint value for display in a widget

Post by Baron Ken »

Baron Ken wrote:
clearwaterbrewer wrote:...

any hints?
To display the setpoint for output0 for process 0/state0, you can do something like this in the drawExtWidget appropriate section:

ctx.fillText(ulstates[4]/10 + "°F",widgetObj.xcoord,widgetObj.ycoord+25);
Actually, this will display the value for whatever the current process/state is being displayed. It seems the ulstates array is populated for us depending on which process/state is being displayed.

So a better version is:

Code: Select all

var outputnumber=0;  //set to whichever output you want
ctx.fillText(ulstates[ULST_PIDSET + outputnumber]/10,widgetObj.xcoord,widgetObj.ycoord+25);
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Can we access a setpoint value for display in a widget

Post by Baron Ken »

clearwaterbrewer wrote:where do i change it to use P1 S2?
The ulstates array uses the currently displayed process and state (note that a process must actually be running to display a state other than 0). See the post right before this one.
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

I am not sure about inside the system, but looking at ulstate from outside does not look at current process...

my current process is Process 1, and my current state is state 2 *EDIT* and it is running */EDIT*

http://192.168.15.200/ulstate.dat
0,0,0,0,750,750,750,750,750,750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

http://192.168.15.200/ulstate.dat?p=1&s=2&
36000,0,0,0,1700,750,1530,750,750,750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,768,768,5,0,0,0,0,

changing my previous
ctx.fillText(HLTsp, 75, 90);
the following:
ctx.fillText(ulstates[ULST_PIDSET + '0']/10 + "°F", 75, 90);

results in the displaying of NaN°F

*edit2* OK, the below works, why does the above not?
var outputnumber=0;
~
ctx.fillText(ulstates[ULST_PIDSET + outputnumber]/10 + "°F", 75, 90);
*/edit2*
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Can we access a setpoint value for display in a widget

Post by Baron Ken »

clearwaterbrewer wrote:I am not sure about inside the system, but looking at ulstate from outside does not look at current process...

my current process is Process 1, and my current state is state 2 *EDIT* and it is running */EDIT*

http://192.168.15.200/ulstate.dat
0,0,0,0,750,750,750,750,750,750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,

http://192.168.15.200/ulstate.dat?p=1&s=2&
36000,0,0,0,1700,750,1530,750,750,750,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,768,768,5,0,0,0,0,

changing my previous
ctx.fillText(HLTsp, 75, 90);
the following:
ctx.fillText(ulstates[ULST_PIDSET + '0']/10 + "°F", 75, 90);

results in the displaying of NaN°F
There is an array created called ulstates that is based on the current process/state. You are correct in that the http statements you used above, you have to specify the process/state.

This exact line in my external:
ctx.fillText(ulstates[ULST_PIDSET + outputnumber]/10 + "°F",widgetObj.xcoord,widgetObj.ycoord);
produces a NaN when viewed from the HMI Builder, but when I go to the Main Control page it shows the value (initally process 0/state 0 when nothing is running, and it DOES show a correct value there).

It looks like you are adding '0' to the ULST_PIDSET. That means you are adding a string to a number....change it to 0 (without the quotes) and you should be good to go. ;)
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

ahhh, I thought it was an argument of some sorts, simple addition to index the correct PID setpoint, I understand...

One nitpick... when the page loads, both the HLT and MLT values go to the temp setpoint of OUT0 (the HLT), then a few seconds later the MLT one corrects itself...


ok, 2nd nit... can this be updated with the refreshes, in case another browser window, or some other entity changes the setpoint?


Thanks guys, this working really great!
User avatar
Baron Ken
Posts: 99
Joined: Fri Jan 15, 2010 2:50 pm
Bot?: No

Re: Can we access a setpoint value for display in a widget

Post by Baron Ken »

One nitpick... when the page loads, both the HLT and MLT values go to the temp setpoint of OUT0 (the HLT), then a few seconds later the MLT one corrects itself...
I only tested with one. Will look later.
ok, 2nd nit... can this be updated with the refreshes, in case another browser window, or some other entity changes the setpoint?
Have you verified it does not? If you add it to the drawExtWidget function, I believe that gets called every refresh cycle, i.e. 1sec?
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

Verified.


My items are in the drawExtWidget function, here are my verification notes

unit powered down all night, power up.
start my P1 process 'MASH 60'
jump to S2 'MASH 154'
HLT and MLT read current setpoints (OUT2 is a little delayed and reads OUT1's value for a second or three)
open 'Edit Processes' in new tab in Firefox, select P1 and then S2, and change setpoint of OUT2 (mash)
open 'Main Control' in new tab, it displays the new OUT setpoint.
toggle to 1st tab, it still shows old value until you navigate away and back or hit refresh.

-mike
User avatar
ECC
Posts: 676
Joined: Fri Sep 12, 2008 12:29 pm
Bot?: No
Contact:

Re: Can we access a setpoint value for display in a widget

Post by ECC »

I would recommend using the ultemps[ULTMP_SETP] to get the current setpoint. This is per temperature, not per output. So if more than one output is associated with the same temp, the latest active one wins.

When ultemps[ULTMP_SETP] == -409.6, that means that no running process is using the temp. So I recommend using something like this.

Code: Select all

var tempSetPt = ultemps[ULTMP_SETP + widgetObj.num/1]/10;
tempSetPt  = (tempSetPt == -409.6)? "----" : tempSetPt ;
ctx.fillText(tempSetPt + "°F", widgetObj.xcoord,widgetObj.ycoord);
The interface is setup to reduce network traffic, it attempts to only load files when it needs to.

ultemp.dat = This is the control file that is always read every refresh, on every BCS interface page.

If anything in ultemp.dat changes from one refresh to the next like state changes, process start/stop, (but not temp value or timer values), all of the following files are refreshed.

ulstate.dat = Per Process, These two are read based on the Select Process pulldown, and current state of that process. Not read in the HMI Builder page
ucstate.dat = same

ulsysio.dat = These two files contain system configuration
ucsysio.dat = same

FYI, this is a very useful widget, so I'll include it in the next firmware release! Maybe I'll update the default external.js file to include this so people can use it immediately. I love how it looks over your HLT/MLT. Great work!
clearwaterbrewer
Posts: 383
Joined: Wed Feb 09, 2011 3:43 pm
Bot?: No
Location: Clearwater, FL
Contact:

Re: Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

what does the divide by 1 do? ( widgetObj.num/1 )

Here is my code snippet, the temp shows NaN
(I have it activated along with a stationary line, so the position is hard-coded)

Code: Select all

	else if(widgetObj.typ==TYP_HLT_Out_Pump1_In)
	{
		ctx.beginPath();
		
		if(widgetObj.act)
		{
    	var tempSetPt = ultemps[ULTMP_SETP + widgetObj.num/1]/10;
    	tempSetPt  = (tempSetPt == -409.6)? "----" : tempSetPt ;
			ctx.lineWidth=6;
			ctx.strokeStyle='#4080FF';
			ctx.lineCap='round';
			ctx.moveTo(75,175);
			ctx.lineTo(75,205);
			ctx.lineTo(105,205);
			ctx.stroke();
			ctx.font = 'italic 18px sans-serif';
		 	ctx.fillStyle = '#00f';
//			ctx.fillText(ulstates[ULST_PIDSET + 0]/10 + "°F", 75, 90);
			ctx.fillText(tempSetPt + "°F", 75, 90);
		}
		ctx.closePath();
	}
Last edited by clearwaterbrewer on Wed Sep 28, 2011 9:07 am, edited 1 time in total.
Post Reply