Page 3 of 3

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

Posted: Wed Sep 28, 2011 8:36 am
by ECC
Probably not needed, but I've gotten used to doing it. It forces the variable to be a number. Since Javascript it a typeless language, sometimes it treats variables as text by default, so it concatenates variables instead of adding when you use +.

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

Posted: Wed Sep 28, 2011 8:40 am
by Baron Ken
ECC wrote: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.
So for Mike's example above where it would not update on the tab where he didn't change anything, with a real brewing situation the temperature fluctuations would cause a refresh of the HMI gui?

EDIT: I mean, the temperature fluctuations would NOT cause a refresh? So it won't update the HMI without a manual page refresh or a ultemp.dat change?

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

Posted: Wed Sep 28, 2011 9:48 am
by Baron Ken
var tempSetPt = ultemps[ULTMP_SETP + widgetObj.num/1]/10;
widgetObj.num is what is producing the NaN for me. I just changed it to:

Code: Select all

var tempnumber=0;  //set to whichever output you want
var tempSetPt = ultemps[ULTMP_SETP + tempnumber]/10;
tempSetPt  = (tempSetPt == -409.6)? "----" : tempSetPt ;
ctx.fillText(tempSetPt + "°F", widgetObj.xcoord,widgetObj.ycoord);
Verified that it updates the HMI (on a different tab) when the value is changed using either the Temperature Setpoint Adjust page or the Edit Processes page. :)

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

Posted: Wed Sep 28, 2011 10:23 am
by clearwaterbrewer
OK, this is working better and better!


stop all processes
start my P1 process 'MASH 60'
the HLT setpoint shows --- then goes to my 170 <---nice!

jump to S2 'MASH 154'
both setpoints show --- then go to correct value, no more HLT value in MLT space for a few seconds <--- VERY Nice!!!

open 'Edit Processes' in new tab in Firefox, select P1 and then S2, and change setpoint of OUT2 (Mash)

toggle to 1st tab, it shows new value fairly quickly... <--- PERFECT

BUT MASH TIMER STOPS!
(and not just the display, the actual timer!)

Code: Select all

	else if(widgetObj.typ==TYP_HLT_Out_Pump1_In)
	{
		ctx.beginPath();
		
		if(widgetObj.act)
		{
    	var tempSetPt = ultemps[ULTMP_SETP]/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(tempSetPt + "°F", 75, 90);
		}
		ctx.closePath();
	}

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

Posted: Wed Sep 28, 2011 10:53 am
by Baron Ken
clearwaterbrewer wrote:BUT MASH TIMER STOPS!
(and not just the display, the actual timer!)
I could not duplicate this. When I went to a process that had a timer, I changed the setpoint in Edit Processes and when I went back to the other tab, the setpoint updated and the timer kept going.

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

Posted: Wed Sep 28, 2011 10:56 am
by clearwaterbrewer
Current firmware version is
BCS-462 v3.4.4

Timer 0: 60 minute timer
Enable: yes
Count: Down
Continue from prev: no
Init value 1:00:00

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

Posted: Wed Sep 28, 2011 10:59 am
by Baron Ken
What are the exit conditions? Did changing the setpoint cause an exit to happen?

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

Posted: Wed Sep 28, 2011 11:28 am
by clearwaterbrewer
It did not exit the state, it has actually been in that same state since I verified the issue by carefully doing it a second time, probably 2 hours now, and the timer is stuck at 59:30

exit conditions, however are
WIN0 (manually go to next state, for testing and demo purposes)
60 minute timer <=0

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

Posted: Wed Sep 28, 2011 11:35 am
by clearwaterbrewer
Must have been a Firefox issue, I tried to open a new browser to check something and if I changed the SP there, it started working.,.. I closed all Firefox windows and problem is gone...

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

Posted: Fri Sep 30, 2011 7:54 am
by Baron Ken
JonW wrote:
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);
Here's how I implemented getting an Auto-change process displayed on the Main Control page (another topic). I have 3 processes I use for brewing, so in the external.js I added a variable and a couple new widgets:

Code: Select all

...
var previousultemp = 0;

var goto_process1 = 48;                                 // other one is goto_process2
newWidgetObj.desc = "goto Process1";
newWidgetObj.typ = goto_process1;
registerNewWidget(newWidgetObj);
...

//in the drawExtWidget section
...
else if(widgetObj.typ==goto_process1)
    {
        if (widgetObj.act)                              //does nothing unless widget activated.
                                                        //i.e the proper register turned on
        {
            if (gid("psel"))                            //checks to see if on Main Control page
            {
                if (ultemps[0]!=0)                      //meaning there is at least 1 process running
                {
                    if (ultemps[0]!=previousultemp)     //if the processes haven't changed, no need to do anything
                    {
                        gid("psel").selectedIndex = 1 ; //change the Process dropdown on the Main Control page
                        upd_cp() ;                      //cause an update
                        previousultemp = 2;             //2 indicates Process 1 (only) is running.
                                                        //use 4 for the goto_process2 widget
                    }
                }
                else
                {
                    previousultemp=0;                   //this 'resets' the widget if no processes are
                                                        //running, so if I start from the beginning again without
                                                        //refreshing the page, it still works fine
                }
            }
        }
    }
...
I set the first state used in Process 1 (state 0 for my setup) to enable a register and added the widget to the HMI using that register, so when that specific register is active, the widget checks to see if it is the first time it has caused a change of the display.

Note that I ONLY have 1 process running at a time, so the above works well for me. If you have multiple processes running at the same time, you could possibly modify the above to fit your setup (especially if the other processes were always on, for example). YMMV ;)

Seems to work great. When it finishes the last state of Process 0, it ends process0 and spawns Process 1. When Process 1 starts on state 0, the register is enabled and the widget causes the selected process on the Main Control page to display Process 1. I also have it set up to change the display when going to Process 2 as well. :D