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:

Can we access a setpoint value for display in a widget

Post by clearwaterbrewer »

I would be really cool if I could write a widget that placed '170' on my HLT, and 154 and 168 on my mash tun for (mash and mash-out, respectively)...

I can do it manually, but that is a workaround, I hope!


This HMI is the future of cool brewing!
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 »

If you have a way of determining which Process is being displayed on the main page (or if you know exactly which process/state you want to display setpoints from), I would try this method (at work, so no BCS to test on).(see note below)

Have a textarea/label (whatever it is in JavaScript) and set the label's value to the value determined from:
http://<BSC address>/ulstate.dat?p=0&s=1&
where p = process and s = state, you would also need to parse out the proper value (divide by 10) from the returned csv file, e.g. position 4 for output0

see Ulstate.dat wiki page

I haven't looked up the js for parsing the value I want yet, but this may get you going.

Note: I'm still hoping for a way to set the main page process being displayed programmatically (vs. using the dropdown box). I would imagine if it were implemented to be possible to set the displayed process, then you would also be able to read which process was being displayed.
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 »

Awesome... now I just have to figure out how to parse the 170 and the 153 out of

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,

new pics(you can see my manual entries of 170 and 153):
state2.png
state2.png (26.06 KiB) Viewed 13344 times
state4.png
state4.png (28.8 KiB) Viewed 13344 times
state5.png
state5.png (30.25 KiB) Viewed 13344 times
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 »

OK, I have the parsing done and can get the setpoint to be displayed in the HMI, but as you can see, I am using a static array because I cannot figure out how to grab the ulstate.dat info

Current code added below the "drawExtWidget" function:

var dataP1S2 = "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,";
var xTokenList = dataP1S2.split(',');
var HLTsp = xTokenList[4] / 10;
var MLTsp = xTokenList[6] / 10;
~snip~
ctx.fillText(HLTsp, 75, 90);
~snip~
ctx.fillText(MLTsp, 245, 90);



In the header of external.js, there is the following:
// ulstates = ulstates.dat
(this should be "ulstate = ulstate.dat", correct?
What exactly does this mean? Does this mean I have to uncomment it, or that it 'ulstate.dat' already exists as variable 'ulstate' (or 'ulstates')

I tried replacing my current var dataP1S2 line with:

var dataP1S2 = ulstate; // does not work
var dataP1S2 = ulstate; // does not work
var dataP1S2 = ulstate?p=1&s=2&; // does not work
var dataP1S2 = ulstate.dat?p=1&s=2& // does not work
var dataP1S2 = ulstate[1][2]; // does not work
var dataP1S2 = ulstates[1][2]; // does not work
var dataP1S2 = ulstate.dat[1][2]; // does not work


any hints?
JonW
Site Admin
Posts: 1726
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

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

Post by JonW »

How about this:

For the current setpoint of an output (f), use: ulstates[ULST_PIDSET + f] / 10 ;

For the current temperature of a probe (c) use: ultemps[ULTMP_TMP + c] / 10 ;

These were gleaned from code in control.js. There's a lot of good sample code in there!
JonW
Site Admin
Posts: 1726
Joined: Sun Jul 18, 2010 7:51 am
Bot?: No
Location: Huntington Beach, CA
Contact:

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

Post by JonW »

Baron Ken wrote:Note: I'm still hoping for a way to set the main page process being displayed programmatically (vs. using the dropdown box). I would imagine if it were implemented to be possible to set the displayed process, then you would also be able to read which process was being displayed.
Here's a function I use for setting the active process. Call the function with the process # as the parameter.
function btn_cp(cp) {
// This allows direct selection of which process to display the details for.
// This forces the dropdown to the selected process and then calls the function to update the screen.
gid("psel").selectedIndex = cp ;
upd_cp() ;
};

You can get the current process from the dropdown object.
cp = parseInt(gid("psel").selectedIndex);
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 »

After going through all the hassle of learning XmlHttpRequest and coming up with this to pull the data:

Code: Select all

var jj=new Array;
var ee=null;
ee=new XMLHttpRequest();
ee.open("GET","ulstate.dat?p=0&s=0&",true);
ee.onreadystatechange= function ()
    {
         if ( ee.readyState == 4)
         {
             var hh=ee.responseText;
          jj=hh.split(",");
         }
    }
ee.send(null);
and using jj[4]/10 for the Output0 setpoint, I found in the external.js file the global structures section and you can just use the ulstates array, doh!

EDIT: I had all of this typed up and ready to submit when I had to run to a meeting. It's now obsolete as others posted already, hah.
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:...

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);
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 »

JonW wrote:How about this:

For the current setpoint of an output (f), use: ulstates[ULST_PIDSET + f] / 10 ;

For the current temperature of a probe (c) use: ultemps[ULTMP_TMP + c] / 10 ;

These were gleaned from code in control.js. There's a lot of good sample code in there!
Thanks Jon,
I had just started diving into the common and control files.
var MAXTIMERS=4;
var ULST_ITIME=0;
ULST_PIDSET=ULST_ITIME+MAXTIMERS;

means ULST_PIDSET = 4. I guess by using the ULST_PIDSET variable, you ensure future compatibility, thanks for leading me there. ;)
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 »

JonW wrote:Here's a function I use for setting the active process. Call the function with the process # as the parameter.
function btn_cp(cp) {
// This allows direct selection of which process to display the details for.
// This forces the dropdown to the selected process and then calls the function to update the screen.
gid("psel").selectedIndex = cp ;
upd_cp() ;
};

You can get the current process from the dropdown object.
cp = parseInt(gid("psel").selectedIndex);
Great, thanks!

System variables:
cp = current process
cs = current state

Nice!
Post Reply